diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 2b91d87..dc5c925 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -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>((a, c) => { + a[c.payCondition] = c._count; + return a; + }, {}); + } @Get() @Security("keycloak") async getQuotationList(