From c399cd26df3d0002fa0786740d4ebd9d3cc2149c Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:15:30 +0700 Subject: [PATCH] fix: make it check for status --- src/controllers/04-invoice-controller.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/controllers/04-invoice-controller.ts b/src/controllers/04-invoice-controller.ts index 2338a97..2dc80bb 100644 --- a/src/controllers/04-invoice-controller.ts +++ b/src/controllers/04-invoice-controller.ts @@ -20,6 +20,7 @@ import { createPermCheck, createPermCondition, } from "../services/permission"; +import { PaymentStatus } from "../generated/kysely/types"; type InvoicePayload = { quotationId: string; @@ -54,8 +55,18 @@ export class InvoiceController extends Controller { }; const [pay, notPay] = await prisma.$transaction([ - prisma.invoice.count({ where: { ...where, payment: { isNot: null } } }), - prisma.invoice.count({ where: { ...where, payment: null } }), + prisma.invoice.count({ + where: { + ...where, + payment: { paymentStatus: { not: PaymentStatus.PaymentSuccess } }, + }, + }), + prisma.invoice.count({ + where: { + ...where, + payment: { paymentStatus: PaymentStatus.PaymentSuccess }, + }, + }), ]); return { pay, notPay };