fix: wrong price

This commit is contained in:
Methapon2001 2024-12-26 16:44:01 +07:00
parent 34ede08244
commit 033251c79d

View file

@ -55,7 +55,7 @@ function openList(index: number) {
function calcPricePerUnit(product: RequestWork['productService']['product']) {
return product.vatIncluded
? precisionRound(product.serviceCharge / (1 + (config.value?.vat || 0.07)))
? product.serviceCharge / (1 + (config.value?.vat || 0.07))
: product.serviceCharge;
}
@ -63,21 +63,17 @@ function calcPrice(
product: RequestWork['productService']['product'],
amount: number,
) {
const disc =
const pricePerUnit = product.serviceCharge;
const discount =
taskProduct.value.find((v) => v.productId === product.id)?.discount || 0;
const pricePerUnit = calcPricePerUnit(product);
const priceNoVat = product.vatIncluded
? pricePerUnit / (1 + (config.value?.vat || 0.07))
: pricePerUnit;
const priceDiscountNoVat = priceNoVat * amount - discount;
return precisionRound(
pricePerUnit * amount -
disc +
precisionRound(
product.calcVat
? (pricePerUnit * (disc ? amount : 1) - disc) *
(config.value?.vat || 0.07)
: 0,
) *
(!disc ? amount : 1),
);
const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07);
return precisionRound(priceNoVat * amount + rawVatTotal);
}
</script>
<template>