Feature/refactor query to filter activities of excluded accounts (#3016)

* Refactor query to filter activities of excluded accounts

* Update changelog
pull/3019/head
Thomas Kaul 4 months ago committed by GitHub
parent e1371a8d2b
commit a3cdb23776
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the usability of the holdings table - Improved the usability of the holdings table
- Refactored the query to filter activities of excluded accounts
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
- Upgraded `ng-extract-i18n-merge` from version `2.9.1` to `2.10.0` - Upgraded `ng-extract-i18n-merge` from version `2.9.1` to `2.10.0`

@ -301,6 +301,12 @@ export class OrderService {
}); });
} }
if (withExcludedAccounts === false) {
where.Account = {
NOT: { isExcluded: true }
};
}
const [orders, count] = await Promise.all([ const [orders, count] = await Promise.all([
this.orders({ this.orders({
orderBy, orderBy,
@ -322,32 +328,24 @@ export class OrderService {
this.prismaService.order.count({ where }) this.prismaService.order.count({ where })
]); ]);
const activities = orders const activities = orders.map((order) => {
.filter((order) => { const value = new Big(order.quantity).mul(order.unitPrice).toNumber();
return (
withExcludedAccounts || return {
!order.Account || ...order,
order.Account?.isExcluded === false value,
); feeInBaseCurrency: this.exchangeRateDataService.toCurrency(
}) order.fee,
.map((order) => { order.SymbolProfile.currency,
const value = new Big(order.quantity).mul(order.unitPrice).toNumber(); userCurrency
),
return { valueInBaseCurrency: this.exchangeRateDataService.toCurrency(
...order,
value, value,
feeInBaseCurrency: this.exchangeRateDataService.toCurrency( order.SymbolProfile.currency,
order.fee, userCurrency
order.SymbolProfile.currency, )
userCurrency };
), });
valueInBaseCurrency: this.exchangeRateDataService.toCurrency(
value,
order.SymbolProfile.currency,
userCurrency
)
};
});
return { activities, count }; return { activities, count };
} }

Loading…
Cancel
Save