diff --git a/src/pages/09_task-order/order_view/MainPage.vue b/src/pages/09_task-order/order_view/MainPage.vue index bd396fd9..acb7def2 100644 --- a/src/pages/09_task-order/order_view/MainPage.vue +++ b/src/pages/09_task-order/order_view/MainPage.vue @@ -105,26 +105,24 @@ function getPrice( ) { return list.reduce( (a, c, i) => { - const pricePerUnit = - refProductExpansion.value?.calcPricePerUnit(c.product) ?? 0; - const price = precisionRound(pricePerUnit * c.list.length); - const disc = + const pricePerUnit = c.product.serviceCharge; + const amount = c.list.length; + const discount = taskProduct.value.find((v) => v.productId === c.product.id)?.discount || 0; - const vat = - precisionRound( - (pricePerUnit * (disc ? c.list.length : 1) - disc) * - (config.value?.vat || 0.07), - ) * (!disc ? c.list.length : 1); + const priceNoVat = c.product.vatIncluded + ? pricePerUnit / (1 + (config.value?.vat || 0.07)) + : pricePerUnit; + const priceDiscountNoVat = priceNoVat * amount - discount; - a.totalPrice = precisionRound(a.totalPrice + price); - a.totalDiscount = precisionRound(a.totalDiscount + Number(disc)); - a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat; - a.vatExcluded = c.product.calcVat - ? a.vatExcluded - : precisionRound(a.vat + vat); - a.finalPrice = precisionRound(a.totalPrice - a.totalDiscount + a.vat); + const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07); + // const rawVat = rawVatTotal / amount; + 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.finalPrice = a.totalPrice - a.totalDiscount + a.vat; return a; }, {