refactor!: payment sys

This commit is contained in:
Methapon Metanipat 2024-10-25 13:58:29 +07:00
parent 3cbc157028
commit 02e17fcde4
7 changed files with 675 additions and 279 deletions

View file

@ -490,20 +490,6 @@ export class QuotationController extends Controller {
data: {
...rest,
...price,
quotationPaymentData: {
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")}`,
worker: {
@ -746,24 +732,6 @@ export class QuotationController extends Controller {
data: {
...rest,
...price,
quotationPaymentData:
price && record.quotationStatus === "PaymentPending"
? {
deleteMany: {},
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"),
worker:
sortedEmployeeId.length > 0