feat: filter date
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s

This commit is contained in:
Methapon2001 2025-03-06 11:47:51 +07:00
parent a979c60143
commit 2beaf6d26c

View file

@ -168,13 +168,21 @@ const permissionCond = createPermCondition(globalAllow);
export class QuotationController extends Controller { export class QuotationController extends Controller {
@Get("stats") @Get("stats")
@Security("keycloak") @Security("keycloak")
async getProductStats(@Request() req: RequestWithUser) { async getQuotationStats(
@Request() req: RequestWithUser,
@Query() startDate?: Date,
@Query() endDate?: Date,
) {
const result = await prisma.quotation.groupBy({ const result = await prisma.quotation.groupBy({
_count: true, _count: true,
by: "quotationStatus", by: "quotationStatus",
where: { where: {
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) }, registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
isDebitNote: false, isDebitNote: false,
createdAt: {
gte: startDate,
lte: endDate,
},
}, },
}); });