From 2beaf6d26c1ff137d59fa193062f76cbf94e2771 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 6 Mar 2025 11:47:51 +0700 Subject: [PATCH] feat: filter date --- src/controllers/05-quotation-controller.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index bf0f0e5..d60d6a5 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -168,13 +168,21 @@ const permissionCond = createPermCondition(globalAllow); export class QuotationController extends Controller { @Get("stats") @Security("keycloak") - async getProductStats(@Request() req: RequestWithUser) { + async getQuotationStats( + @Request() req: RequestWithUser, + @Query() startDate?: Date, + @Query() endDate?: Date, + ) { const result = await prisma.quotation.groupBy({ _count: true, by: "quotationStatus", where: { registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) }, isDebitNote: false, + createdAt: { + gte: startDate, + lte: endDate, + }, }, });