fix: stats now group by status
This commit is contained in:
parent
5fa6e4d2f9
commit
4d2dadbc05
1 changed files with 2 additions and 2 deletions
|
|
@ -170,14 +170,14 @@ export class QuotationController extends Controller {
|
||||||
async getProductStats(@Request() req: RequestWithUser) {
|
async getProductStats(@Request() req: RequestWithUser) {
|
||||||
const result = await prisma.quotation.groupBy({
|
const result = await prisma.quotation.groupBy({
|
||||||
_count: true,
|
_count: true,
|
||||||
by: "payCondition",
|
by: "quotationStatus",
|
||||||
where: {
|
where: {
|
||||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.reduce<Record<string, number>>((a, c) => {
|
return result.reduce<Record<string, number>>((a, c) => {
|
||||||
a[c.payCondition.charAt(0).toLowerCase() + c.payCondition.slice(1)] = c._count;
|
a[c.quotationStatus.charAt(0).toLowerCase() + c.quotationStatus.slice(1)] = c._count;
|
||||||
return a;
|
return a;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue