From 6c299b8c1b3cc4dd66dbc1afb9fd7cd9c9c112de Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:51:53 +0700 Subject: [PATCH] fix: calc price --- src/pages/05_quotation/QuotationForm.vue | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index c1edbf4d..4ea677b6 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -704,18 +704,22 @@ function handleUpdateProductTable( newInstallmentNo: number; }, ) { + handleChangePayType(quotationFormData.value.payCondition); // calc price const calc = (c: QuotationPayload['productServiceList'][number]) => { - const pricePerUnit = c.pricePerUnit || 0; - const discount = c.discount || 0; - - return ( - pricePerUnit * c.amount - - discount + - (c.product.calcVat - ? (pricePerUnit * c.amount - discount) * (config.value?.vat || 0.07) - : 0) + const originalPrice = c.pricePerUnit || 0; + const finalPriceWithVat = precisionRound( + originalPrice * (1 + (config.value?.vat || 0.07)), ); + const finalPriceNoVat = + finalPriceWithVat / (1 + (config.value?.vat || 0.07)); + + const price = finalPriceNoVat * c.amount; + const vat = c.product.calcVat + ? (finalPriceNoVat * c.amount - (c.discount || 0)) * + (config.value?.vat || 0.07) + : 0; + return precisionRound(price + vat); }; // installment @@ -2057,23 +2061,20 @@ watch(