feat: add total order of product to report
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 8s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 8s
This commit is contained in:
parent
3b29f56100
commit
e92870602d
1 changed files with 13 additions and 0 deletions
|
|
@ -201,12 +201,25 @@ export class StatsController extends Controller {
|
|||
},
|
||||
});
|
||||
|
||||
const order = await prisma.quotationProductServiceList.groupBy({
|
||||
_count: true,
|
||||
by: "productId",
|
||||
where: {
|
||||
quotation: {
|
||||
createdAt: { gte: startDate, lte: endDate },
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
productId: { in: record.map((v) => v.id) },
|
||||
},
|
||||
});
|
||||
|
||||
return record.map((v) => ({
|
||||
document: "product",
|
||||
code: v.code,
|
||||
name: v.name,
|
||||
sale: v._count.quotationProductServiceList,
|
||||
did: doing.find((item) => item.productId === v.id)?._count || 0,
|
||||
order: order.find((item) => item.productId === v.id)?._count || 0,
|
||||
createdAt: v.createdAt,
|
||||
updatedAt: v.updatedAt,
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue