From 3193403f9017936cee118ac431c304c49d32f493 Mon Sep 17 00:00:00 2001 From: Kanjana Date: Tue, 22 Apr 2025 16:27:13 +0700 Subject: [PATCH] check price where null --- src/controllers/04-product-controller.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/04-product-controller.ts b/src/controllers/04-product-controller.ts index ccb0b6a..dd17c5e 100644 --- a/src/controllers/04-product-controller.ts +++ b/src/controllers/04-product-controller.ts @@ -477,13 +477,15 @@ export class ProductController extends Controller { ? "serviceFee" : "processingFee", shared: item.shared === "ใช่" ? true : false, - price: +parseFloat(item.price.replace(",", "")).toFixed(6), + price: item?.price ? +parseFloat(item.price.replace(",", "")).toFixed(6) : 0, calcVat: item.calcVat === "ใช่" ? true : false, vatIncluded: item.vatIncluded === "รวม" ? true : false, - agentPrice: +parseFloat(item.agentPrice.replace(",", "")).toFixed(6), + agentPrice: item?.agentPrice ? +parseFloat(item.agentPrice.replace(",", "")).toFixed(6) : 0, agentPriceCalcVat: item.agentPriceCalcVat === "ใช่" ? true : false, agentPriceVatIncluded: item.agentPriceVatIncluded === "รวม" ? true : false, - serviceCharge: +parseFloat(item.serviceCharge.replace(",", "")).toFixed(6), + serviceCharge: item?.serviceCharge + ? +parseFloat(item.serviceCharge.replace(",", "")).toFixed(6) + : 0, serviceChargeCalcVat: item.serviceChargeCalcVat === "ใช่" ? true : false, serviceChargeVatIncluded: item.serviceChargeVatIncluded === "รวม" ? true : false, };