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"