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