fix: wrong update

This commit is contained in:
Methapon Metanipat 2024-11-07 10:49:40 +07:00
parent a811c17bde
commit 5fa6e4d2f9

View file

@ -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"