From d1bb5041741a892a4c737de94f79892a738e7440 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Fri, 11 Apr 2025 11:43:52 +0700 Subject: [PATCH] feat: add VAT parameter to calcPrice function and update related calculations --- src/pages/11_credit-note/document-view/MainPage.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/11_credit-note/document-view/MainPage.vue b/src/pages/11_credit-note/document-view/MainPage.vue index 73024f36..e15fe13d 100644 --- a/src/pages/11_credit-note/document-view/MainPage.vue +++ b/src/pages/11_credit-note/document-view/MainPage.vue @@ -248,6 +248,7 @@ function calcPricePerUnit(product: RequestWork['productService']['product']) { function calcPrice( product: RequestWork['productService']['product'], amount: number, + vat: number = 0, ) { const pricePerUnit = agentPrice.value ? product.agentPrice : product.price; @@ -256,7 +257,8 @@ function calcPrice( : pricePerUnit; const priceDiscountNoVat = priceNoVat * amount - 0; - const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07); + const rawVatTotal = + vat === 0 ? 0 : priceDiscountNoVat * (config.value?.vat || 0.07); return precisionRound(priceNoVat * amount + rawVatTotal); } @@ -346,7 +348,7 @@ function closeAble() { {{ formatNumberDecimal( - calcPrice(v.product.product, v.list.length), + calcPrice(v.product.product, v.list.length, v.product.vat), 2, ) }} @@ -431,7 +433,7 @@ function closeAble() { class="column set-width bg-color full-height" style="padding: 12px" > - ({{ ThaiBahtText(summaryPrice.finalPrice) }}) + ({{ ThaiBahtText(precisionRound(summaryPrice.finalPrice)) }})