diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue index 5276ff60..0ea8f62c 100644 --- a/src/components/05_quotation/ProductItem.vue +++ b/src/components/05_quotation/ProductItem.vue @@ -432,7 +432,12 @@ watch( /> - {{ formatNumberDecimal(props.row.pricePerUnit, 2) }} + {{ + formatNumberDecimal( + props.row.pricePerUnit * props.row.amount, + 2, + ) + }} {{ diff --git a/src/i18n/eng.ts b/src/i18n/eng.ts index f0072a67..6c06fd9f 100644 --- a/src/i18n/eng.ts +++ b/src/i18n/eng.ts @@ -79,7 +79,7 @@ export default { calculateVat: 'Calculate VAT', discountAfterVat: 'Discount after vat', totalAfterDiscount: 'Total after discount', - totalVatExcluded: 'Tax exemption amount', + totalVatExcluded: 'Tax-exempt amoun', totalVatIncluded: 'Taxable amount', vat: 'VAT {msg}', totalAmount: 'Total amount (Baht)', diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 93b5a1f3..4654979d 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -81,7 +81,7 @@ export default { discountAfterVat: 'ส่วนลดหลังคำนวณภาษี', calculateVat: 'คำนวณภาษี', totalAfterDiscount: 'จำนวนเงินหลังหักส่วนลด', - totalVatExcluded: 'จำนวนเงินยกเว้นภาษี', + totalVatExcluded: 'จำนวนเงินที่ไม่มี/ยกเว้นภาษี', totalVatIncluded: 'จำนวนเงินที่คำนวณภาษี', vat: 'ภาษีมูลค่าเพิ่ม {msg}', totalAmount: 'จำนวนเงินรวมทั้งสิ้น (บาท)', diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index fd7d1d95..5a180905 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -259,7 +259,7 @@ function getPrice( a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : precisionRound(a.vatExcluded + vat); + : precisionRound(a.vatExcluded + price); a.finalPrice = precisionRound( a.totalPrice - a.totalDiscount + diff --git a/src/pages/05_quotation/preview/ViewForm.vue b/src/pages/05_quotation/preview/ViewForm.vue index cc80d367..2131535e 100644 --- a/src/pages/05_quotation/preview/ViewForm.vue +++ b/src/pages/05_quotation/preview/ViewForm.vue @@ -44,6 +44,7 @@ type Product = { discount: number; vat: number; value: number; + calcVat: boolean; }; type SummaryPrice = { @@ -250,6 +251,7 @@ onMounted(async () => { discount: v.discount || 0, vat: v.vat || 0, value: precisionRound(price + (v.product.calcVat ? vat : 0)), + calcVat: v.product.calcVat, }; }, ) || []; @@ -276,7 +278,7 @@ onMounted(async () => { a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : precisionRound(a.vatExcluded + vat); + : precisionRound(a.vatExcluded + price); a.finalPrice = precisionRound( a.totalPrice - a.totalDiscount + @@ -363,7 +365,17 @@ function print() { {{ formatNumberDecimal(v.discount, 2) }} - {{ formatNumberDecimal(v.vat, 2) }} + {{ + formatNumberDecimal( + v.calcVat + ? precisionRound( + (v.priceUnit * v.amount - v.discount) * + (config?.vat || 0.07), + ) + : 0, + 2, + ) + }} {{ formatNumberDecimal(v.value, 2) }} diff --git a/src/pages/09_task-order/document_view/MainPage.vue b/src/pages/09_task-order/document_view/MainPage.vue index 7233fcb3..8f281dd2 100644 --- a/src/pages/09_task-order/document_view/MainPage.vue +++ b/src/pages/09_task-order/document_view/MainPage.vue @@ -214,8 +214,10 @@ onMounted(async () => { priceUnit: precisionRound(priceNoVat), amount: c.amount, discount: c.discount, - vat: precisionRound(rawVat), - value: precisionRound(priceNoVat * c.amount + rawVatTotal), + vat: c.product.calcVat ? precisionRound(rawVat) : 0, + value: precisionRound( + priceNoVat * c.amount + (c.product.calcVat ? rawVatTotal : 0), + ), }); a.totalPrice = a.totalPrice + priceDiscountNoVat; @@ -223,7 +225,7 @@ onMounted(async () => { a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : a.vatExcluded + rawVatTotal; + : precisionRound(a.vatExcluded + priceNoVat); a.finalPrice = a.totalPrice - a.totalDiscount + a.vat; return a; }, diff --git a/src/pages/09_task-order/expansion/ProductExpansion.vue b/src/pages/09_task-order/expansion/ProductExpansion.vue index 734f616f..e714f826 100644 --- a/src/pages/09_task-order/expansion/ProductExpansion.vue +++ b/src/pages/09_task-order/expansion/ProductExpansion.vue @@ -86,7 +86,9 @@ function calcPrice( : pricePerUnit; const priceDiscountNoVat = priceNoVat * amount - discount; - const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07); + const rawVatTotal = product.calcVat + ? priceDiscountNoVat * (config.value?.vat || 0.07) + : 0; return precisionRound(priceNoVat * amount + rawVatTotal); } diff --git a/src/pages/09_task-order/order_view/MainPage.vue b/src/pages/09_task-order/order_view/MainPage.vue index 703acf9b..3609c1fd 100644 --- a/src/pages/09_task-order/order_view/MainPage.vue +++ b/src/pages/09_task-order/order_view/MainPage.vue @@ -41,6 +41,7 @@ import { UserTaskStatus, } from 'src/stores/task-order/types'; import { RequestWork } from 'src/stores/request-list'; +import { precisionRound } from 'src/utils/arithmetic'; const taskOrderFormStore = useTaskOrderForm(); const taskOrderStore = useTaskOrderStore(); @@ -146,7 +147,7 @@ function getPrice( a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat; a.vatExcluded = c.product.calcVat ? a.vatExcluded - : a.vatExcluded + rawVatTotal; + : precisionRound(a.vatExcluded + priceNoVat); a.finalPrice = a.totalPrice - a.totalDiscount + a.vat; return a; },