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

@ -259,7 +259,7 @@ function getPrice(
a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat;
a.vatExcluded = c.product.calcVat
? a.vatExcluded
: precisionRound(a.vatExcluded + vat);
: precisionRound(a.vatExcluded + price);
a.finalPrice = precisionRound(
a.totalPrice -
a.totalDiscount +

View file

@ -44,6 +44,7 @@ type Product = {
discount: number;
vat: number;
value: number;
calcVat: boolean;
};
type SummaryPrice = {
@ -250,6 +251,7 @@ onMounted(async () => {
discount: v.discount || 0,
vat: v.vat || 0,
value: precisionRound(price + (v.product.calcVat ? vat : 0)),
calcVat: v.product.calcVat,
};
},
) || [];
@ -276,7 +278,7 @@ onMounted(async () => {
a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat;
a.vatExcluded = c.product.calcVat
? a.vatExcluded
: precisionRound(a.vatExcluded + vat);
: precisionRound(a.vatExcluded + price);
a.finalPrice = precisionRound(
a.totalPrice -
a.totalDiscount +
@ -363,7 +365,17 @@ function print() {
{{ formatNumberDecimal(v.discount, 2) }}
</td>
<td style="text-align: right">
{{ formatNumberDecimal(v.vat, 2) }}
{{
formatNumberDecimal(
v.calcVat
? precisionRound(
(v.priceUnit * v.amount - v.discount) *
(config?.vat || 0.07),
)
: 0,
2,
)
}}
</td>
<td style="text-align: right">
{{ formatNumberDecimal(v.value, 2) }}