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 };