Browse Source

Bugfix/fix export functionality for accounts without activities (#5116)

* Fix export functionality for accounts without activities

* Update changelog
pull/5129/head
Attila Cseh 2 weeks ago
committed by GitHub
parent
commit
0addf645b0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 22
      apps/api/src/app/export/export.service.ts

5
CHANGELOG.md

@ -14,9 +14,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Respected the filter by account for accounts when exporting activities on the portfolio activities page
- Improved the label for asset profiles with `MANUAL` data source in the chart of the holdings tab on the home page
- Improved the language localization for Catalan (`ca`)
### Fixed
- Fixed the export functionality for accounts without activities
## 2.179.0 - 2025-07-07
### Added

22
apps/api/src/app/export/export.service.ts

@ -5,7 +5,8 @@ import { TagService } from '@ghostfolio/api/services/tag/tag.service';
import { Filter, Export } from '@ghostfolio/common/interfaces';
import { Injectable } from '@nestjs/common';
import { Platform } from '@prisma/client';
import { Platform, Prisma } from '@prisma/client';
import { groupBy } from 'lodash';
@Injectable()
export class ExportService {
@ -26,6 +27,9 @@ export class ExportService {
userCurrency: string;
userId: string;
}): Promise<Export> {
const { ACCOUNT: filtersByAccount } = groupBy(filters, ({ type }) => {
return type;
});
const platformsMap: { [platformId: string]: Platform } = {};
let { activities } = await this.orderService.getOrders({
@ -44,20 +48,30 @@ export class ExportService {
});
}
const where: Prisma.AccountWhereInput = { userId };
if (filtersByAccount?.length > 0) {
where.id = {
in: filtersByAccount.map(({ id }) => {
return id;
})
};
}
const accounts = (
await this.accountService.accounts({
where,
include: {
balances: true,
platform: true
},
orderBy: {
name: 'asc'
},
where: { userId }
}
})
)
.filter(({ id }) => {
return activities.length > 0
return activityIds?.length > 0
? activities.some(({ accountId }) => {
return accountId === id;
})

Loading…
Cancel
Save