feat: add total order of product to report
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 8s

This commit is contained in:
Methapon2001 2025-03-04 14:15:26 +07:00
parent 3b29f56100
commit e92870602d

View file

@ -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,
}));