Merge branch 'feat/separate-price-calc' into develop

This commit is contained in:
Methapon2001 2025-01-30 16:54:42 +07:00
commit 84282ff5ce
18 changed files with 744 additions and 332 deletions

View file

@ -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),
),
});

View file

@ -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;

View file

@ -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;