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,11 +466,14 @@ export class QuotationController extends Controller {
...rest, ...rest,
...price, ...price,
quotationPaymentData: { quotationPaymentData: {
create: rest.paySplit?.map((v) => ({ create:
rest.payCondition === "BillSplit" || rest.payCondition === "Split"
? rest.paySplit?.map((v) => ({
paymentStatus: "PaymentWait", paymentStatus: "PaymentWait",
amount: v.amount, amount: v.amount,
date: v.date, date: v.date,
})) || { }))
: {
paymentStatus: "PaymentWait", paymentStatus: "PaymentWait",
amount: price.finalPrice, amount: price.finalPrice,
date: new Date(), date: new Date(),
@ -721,11 +724,14 @@ export class QuotationController extends Controller {
price && record.quotationStatus === "PaymentPending" price && record.quotationStatus === "PaymentPending"
? { ? {
deleteMany: {}, deleteMany: {},
create: rest.paySplit?.map((v) => ({ create:
rest.payCondition === "BillSplit" || rest.payCondition === "Split"
? rest.paySplit?.map((v) => ({
paymentStatus: "PaymentWait", paymentStatus: "PaymentWait",
amount: v.amount, amount: v.amount,
date: v.date, date: v.date,
})) || { }))
: {
paymentStatus: "PaymentWait", paymentStatus: "PaymentWait",
amount: price.finalPrice, amount: price.finalPrice,
date: new Date(), date: new Date(),