diff --git a/src/pages/09_task-order/document_view/MainPage.vue b/src/pages/09_task-order/document_view/MainPage.vue index 6fe5ed02..a9d5eb22 100644 --- a/src/pages/09_task-order/document_view/MainPage.vue +++ b/src/pages/09_task-order/document_view/MainPage.vue @@ -199,7 +199,7 @@ onMounted(async () => { }) .reduce( (a, c) => { - const priceNoVat = c.product.vatIncluded + const priceNoVat = c.product.serviceChargeVatIncluded ? c.pricePerUnit / (1 + (config.value?.vat || 0.07)) : c.pricePerUnit; const adjustedPriceWithVat = precisionRound( @@ -219,9 +219,10 @@ onMounted(async () => { priceUnit: precisionRound(priceNoVat), amount: c.amount, discount: c.discount, - vat: c.product.calcVat ? precisionRound(rawVat) : 0, + vat: c.product.serviceChargeCalcVat ? precisionRound(rawVat) : 0, value: precisionRound( - priceNoVat * c.amount + (c.product.calcVat ? rawVatTotal : 0), + priceNoVat * c.amount + + (c.product.serviceChargeCalcVat ? rawVatTotal : 0), ), }); diff --git a/src/pages/09_task-order/expansion/ProductExpansion.vue b/src/pages/09_task-order/expansion/ProductExpansion.vue index f38b2507..f5f059f6 100644 --- a/src/pages/09_task-order/expansion/ProductExpansion.vue +++ b/src/pages/09_task-order/expansion/ProductExpansion.vue @@ -56,18 +56,25 @@ function openList(index: number) { } function calcPricePerUnit(product: RequestWork['productService']['product']) { - return product.vatIncluded - ? (props.creditNote + const val = props.creditNote + ? props.agentPrice + ? product.agentPrice + : product.price + : product.serviceCharge; + + if ( + product[ + props.creditNote ? props.agentPrice - ? product.agentPrice - : product.price - : product.serviceCharge) / - (1 + (config.value?.vat || 0.07)) - : props.creditNote - ? props.agentPrice - ? product.agentPrice - : product.price - : product.serviceCharge; + ? 'agentPriceCalcVat' + : 'calcVat' + : 'serviceChargeCalcVat' + ] + ) { + return val / (1 + (config.value?.vat || 0.07)); + } else { + return val; + } } function calcPrice( @@ -81,12 +88,24 @@ function calcPrice( : product.serviceCharge; const discount = taskProduct.value.find((v) => v.productId === product.id)?.discount || 0; - const priceNoVat = product.vatIncluded + const priceNoVat = product[ + props.creditNote + ? props.agentPrice + ? 'agentPriceVatIncluded' + : 'vatIncluded' + : 'serviceChargeVatIncluded' + ] ? pricePerUnit / (1 + (config.value?.vat || 0.07)) : pricePerUnit; const priceDiscountNoVat = priceNoVat * amount - discount; - const rawVatTotal = product.calcVat + const rawVatTotal = product[ + props.creditNote + ? props.agentPrice + ? 'agentPriceCalcVat' + : 'calcVat' + : 'serviceChargeCalcVat' + ] ? priceDiscountNoVat * (config.value?.vat || 0.07) : 0; diff --git a/src/pages/09_task-order/order_view/MainPage.vue b/src/pages/09_task-order/order_view/MainPage.vue index f89f3222..0451b76b 100644 --- a/src/pages/09_task-order/order_view/MainPage.vue +++ b/src/pages/09_task-order/order_view/MainPage.vue @@ -135,7 +135,7 @@ function getPrice( const discount = taskProduct.value.find((v) => v.productId === c.product.id)?.discount || 0; - const priceNoVat = c.product.vatIncluded + const priceNoVat = c.product.serviceChargeVatIncluded ? pricePerUnit / (1 + (config.value?.vat || 0.07)) : pricePerUnit; const adjustedPriceWithVat = precisionRound( @@ -149,8 +149,8 @@ function getPrice( a.totalPrice = a.totalPrice + priceDiscountNoVat; a.totalDiscount = a.totalDiscount + Number(discount); - a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat; - a.vatExcluded = c.product.calcVat + a.vat = c.product.serviceChargeCalcVat ? a.vat + rawVatTotal : a.vat; + a.vatExcluded = c.product.serviceChargeCalcVat ? a.vatExcluded : precisionRound(a.vatExcluded + priceDiscountNoVat); a.finalPrice = a.totalPrice - a.totalDiscount + a.vat; diff --git a/src/pages/11_credit-note/FormPage.vue b/src/pages/11_credit-note/FormPage.vue index dc305bf5..b567f158 100644 --- a/src/pages/11_credit-note/FormPage.vue +++ b/src/pages/11_credit-note/FormPage.vue @@ -195,12 +195,13 @@ function getPrice( ) { return list.reduce( (a, c) => { - const pricePerUnit = quotationData.value?.agentPrice - ? c.product.agentPrice - : c.product.price; + const agentPrice = !!quotationData.value?.agentPrice; + const pricePerUnit = agentPrice ? c.product.agentPrice : c.product.price; const amount = c.list.length; const discount = 0; - const priceNoVat = c.product.vatIncluded + const priceNoVat = c.product[ + agentPrice ? 'agentPriceVatIncluded' : 'vatIncluded' + ] ? pricePerUnit / (1 + (config.value?.vat || 0.07)) : pricePerUnit; const priceDiscountNoVat = priceNoVat * amount - discount; @@ -210,8 +211,12 @@ function getPrice( a.totalPrice = a.totalPrice + priceDiscountNoVat; a.totalDiscount = a.totalDiscount + Number(discount); - a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat; - a.vatExcluded = c.product.calcVat ? a.vatExcluded : a.vat + rawVatTotal; + a.vat = c.product[agentPrice ? 'agentPriceCalcVat' : 'calcVat'] + ? a.vat + rawVatTotal + : a.vat; + a.vatExcluded = c.product[agentPrice ? 'agentPriceCalcVat' : 'calcVat'] + ? a.vatExcluded + : a.vat + rawVatTotal; a.finalPrice = a.totalPrice - a.totalDiscount + a.vat; return a; },