fix: empty payment data on full payment

This commit is contained in:
Methapon Metanipat 2024-10-18 14:49:10 +07:00
parent b4fb53cdcf
commit 2c90c0c143

View file

@ -466,15 +466,18 @@ export class QuotationController extends Controller {
...rest, ...rest,
...price, ...price,
quotationPaymentData: { quotationPaymentData: {
create: rest.paySplit?.map((v) => ({ create:
paymentStatus: "PaymentWait", rest.payCondition === "BillSplit" || rest.payCondition === "Split"
amount: v.amount, ? rest.paySplit?.map((v) => ({
date: v.date, paymentStatus: "PaymentWait",
})) || { amount: v.amount,
paymentStatus: "PaymentWait", date: v.date,
amount: price.finalPrice, }))
date: new Date(), : {
}, paymentStatus: "PaymentWait",
amount: price.finalPrice,
date: new Date(),
},
}, },
statusOrder: +(rest.status === "INACTIVE"), statusOrder: +(rest.status === "INACTIVE"),
code: `${currentYear.toString().padStart(2, "0")}${currentMonth.toString().padStart(2, "0")}${currentDate.toString().padStart(2, "0")}${lastQuotation.value.toString().padStart(4, "0")}`, code: `${currentYear.toString().padStart(2, "0")}${currentMonth.toString().padStart(2, "0")}${currentDate.toString().padStart(2, "0")}${lastQuotation.value.toString().padStart(4, "0")}`,
@ -721,15 +724,18 @@ export class QuotationController extends Controller {
price && record.quotationStatus === "PaymentPending" price && record.quotationStatus === "PaymentPending"
? { ? {
deleteMany: {}, deleteMany: {},
create: rest.paySplit?.map((v) => ({ create:
paymentStatus: "PaymentWait", rest.payCondition === "BillSplit" || rest.payCondition === "Split"
amount: v.amount, ? rest.paySplit?.map((v) => ({
date: v.date, paymentStatus: "PaymentWait",
})) || { amount: v.amount,
paymentStatus: "PaymentWait", date: v.date,
amount: price.finalPrice, }))
date: new Date(), : {
}, paymentStatus: "PaymentWait",
amount: price.finalPrice,
date: new Date(),
},
} }
: undefined, : undefined,
statusOrder: +(rest.status === "INACTIVE"), statusOrder: +(rest.status === "INACTIVE"),