From c8146ae8f1f44c40f6cae3c6ad1608dabc26881c Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Fri, 1 Nov 2024 10:27:51 +0700 Subject: [PATCH] fix: only sum from payment success status --- src/controllers/05-payment-controller.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controllers/05-payment-controller.ts b/src/controllers/05-payment-controller.ts index 5a811e9..cb23c17 100644 --- a/src/controllers/05-payment-controller.ts +++ b/src/controllers/05-payment-controller.ts @@ -137,7 +137,12 @@ export class QuotationPayment extends Controller { const paymentSum = await prisma.payment.aggregate({ _sum: { amount: true }, - where: { invoice: { quotationId: quotation.id } }, + where: { + invoice: { + quotationId: quotation.id, + payment: { paymentStatus: "PaymentSuccess" }, + }, + }, }); await tx.quotation.update({