feat: add quotation stats by group
This commit is contained in:
parent
474ac86f46
commit
bbdf47205b
1 changed files with 20 additions and 0 deletions
|
|
@ -158,6 +158,26 @@ const permissionCond = createPermCondition(globalAllow);
|
|||
@Route("/api/v1/quotation")
|
||||
@Tags("Quotation")
|
||||
export class QuotationController extends Controller {
|
||||
@Get("stats")
|
||||
@Security("keycloak")
|
||||
async getProductStats(@Request() req: RequestWithUser) {
|
||||
const result = await prisma.quotation.groupBy({
|
||||
_count: true,
|
||||
by: "payCondition",
|
||||
where: {
|
||||
customerBranch: {
|
||||
customer: {
|
||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return result.reduce<Record<string, number>>((a, c) => {
|
||||
a[c.payCondition] = c._count;
|
||||
return a;
|
||||
}, {});
|
||||
}
|
||||
@Get()
|
||||
@Security("keycloak")
|
||||
async getQuotationList(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue