refactor: edit calc vat

This commit is contained in:
Thanaphon Frappet 2025-01-24 11:49:33 +07:00
parent 42575eb5ba
commit ca9264d758
8 changed files with 33 additions and 11 deletions

View file

@ -214,8 +214,10 @@ onMounted(async () => {
priceUnit: precisionRound(priceNoVat),
amount: c.amount,
discount: c.discount,
vat: precisionRound(rawVat),
value: precisionRound(priceNoVat * c.amount + rawVatTotal),
vat: c.product.calcVat ? precisionRound(rawVat) : 0,
value: precisionRound(
priceNoVat * c.amount + (c.product.calcVat ? rawVatTotal : 0),
),
});
a.totalPrice = a.totalPrice + priceDiscountNoVat;
@ -223,7 +225,7 @@ onMounted(async () => {
a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat;
a.vatExcluded = c.product.calcVat
? a.vatExcluded
: a.vatExcluded + rawVatTotal;
: precisionRound(a.vatExcluded + priceNoVat);
a.finalPrice = a.totalPrice - a.totalDiscount + a.vat;
return a;
},