From 3857de8d2b0babdec6772efe4162e0543b56b607 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Fri, 4 Oct 2024 13:31:29 +0700 Subject: [PATCH] feat: detect if agent price --- src/controllers/05-quotation-controller.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index a5ced86..e4e4683 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -62,6 +62,8 @@ type QuotationCreate = { urgent?: boolean; + agentPrice?: boolean; + productServiceList: { serviceId?: string; workId?: string; @@ -325,7 +327,9 @@ export class QuotationController extends Controller { productId: v.productId, workId: v.workId, serviceId: v.serviceId, - pricePerUnit: v.pricePerUnit || product.find((p) => p.id === v.productId)?.price || 0, + pricePerUnit: + product.find((p) => p.id === v.productId)?.[body.agentPrice ? "agentPrice" : "price"] || + 0, amount: v.amount, discount: v.discount || 0, vat: v.vat || VAT_DEFAULT, @@ -518,7 +522,9 @@ export class QuotationController extends Controller { productId: v.productId, workId: v.workId, serviceId: v.serviceId, - pricePerUnit: v.pricePerUnit || product.find((p) => p.id === v.productId)?.price || 0, + pricePerUnit: + product.find((p) => p.id === v.productId)?.[record.agentPrice ? "agentPrice" : "price"] || + 0, amount: v.amount, discount: v.discount || 0, vat: v.vat || VAT_DEFAULT,