From 5fa6e4d2f9801b89186eaebd31a0cb755e94fa4f Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 7 Nov 2024 10:49:40 +0700 Subject: [PATCH] fix: wrong update --- src/controllers/05-payment-controller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controllers/05-payment-controller.ts b/src/controllers/05-payment-controller.ts index f10cfb7..67e20d9 100644 --- a/src/controllers/05-payment-controller.ts +++ b/src/controllers/05-payment-controller.ts @@ -150,7 +150,10 @@ export class QuotationPayment extends Controller { const payment = await tx.payment.update({ where: { id: paymentId, invoice: { quotationId: quotation.id } }, - data: body, + data: { + ...body, + code: last ? `RE${year}${month}${last.value.toString().padStart(6, "0")}` : undefined, + }, }); const paymentSum = await prisma.payment.aggregate({ @@ -170,7 +173,6 @@ export class QuotationPayment extends Controller { await tx.quotation.update({ where: { id: quotation.id }, data: { - code: last ? `RE${year}${month}${last.value.toString().padStart(6, "0")}` : undefined, quotationStatus: paymentSum._sum.amount || 0 >= quotation.finalPrice ? "PaymentSuccess"