From 4e5825c236aaaced08e8bee66ad0977991a39212 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 17 Oct 2024 13:25:17 +0700 Subject: [PATCH] feat: update quotation payment data --- src/controllers/05-quotation-controller.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index aa953e2..a220f8f 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -691,6 +691,20 @@ export class QuotationController extends Controller { data: { ...rest, ...price, + quotationPaymentData: + price && record.quotationStatus === "PaymentPending" + ? { + create: rest.paySplit?.map((v) => ({ + paymentStatus: "PaymentWait", + amount: v.amount, + date: new Date(), + })) || { + paymentStatus: "PaymentWait", + amount: price.finalPrice, + date: new Date(), + }, + } + : undefined, statusOrder: +(rest.status === "INACTIVE"), worker: sortedEmployeeId.length > 0