fix: inaccurate .01 price

This commit is contained in:
Methapon2001 2025-01-23 10:20:46 +07:00
parent ec61c73342
commit e12a87f496
3 changed files with 73 additions and 42 deletions

View file

@ -57,11 +57,18 @@ const currentBtnOpen = ref<{ title: string; opened: boolean[] }[]>([
]);
function calcPrice(c: (typeof rows.value)[number]) {
const price = c.pricePerUnit * c.amount;
const originalPrice = c.pricePerUnit;
const finalPriceWithVat = precisionRound(
originalPrice +
(c.product.vatIncluded || c.vat !== 0
? 0
: originalPrice * (config.value?.vat || 0.07)),
);
const finalPriceNoVat = finalPriceWithVat / (1 + (config.value?.vat || 0.07));
const price = finalPriceNoVat * c.amount;
const vat = c.product.calcVat
? (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
(config.value?.vat || 0.07) *
(!c.discount ? c.amount : 1)
? (finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07)
: 0;
return precisionRound(price + vat);
}