Browse Source

Refactor query to filter activities of excluded accounts

pull/3016/head
Thomas Kaul 2 years ago
parent
commit
7ddee62246
  1. 16
      apps/api/src/app/order/order.service.ts

16
apps/api/src/app/order/order.service.ts

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

Loading…
Cancel
Save