fix: wrong price
This commit is contained in:
parent
ec7d76b6fa
commit
8a071e61a6
1 changed files with 15 additions and 16 deletions
|
|
@ -178,31 +178,30 @@ onMounted(async () => {
|
|||
}))
|
||||
.reduce(
|
||||
(a, c) => {
|
||||
const price = precisionRound(c.pricePerUnit * c.amount);
|
||||
const vat =
|
||||
precisionRound(
|
||||
(c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
|
||||
(config.value?.vat || 0.07),
|
||||
) * (!c.discount ? c.amount : 1);
|
||||
const priceNoVat = c.product.calcVat
|
||||
? c.pricePerUnit / (1 + (config.value?.vat || 0.07))
|
||||
: c.pricePerUnit;
|
||||
const priceDiscountNoVat = priceNoVat * c.amount - c.discount;
|
||||
|
||||
const rawVatTotal = priceDiscountNoVat * (config.value?.vat || 0.07);
|
||||
const rawVat = rawVatTotal / c.amount;
|
||||
|
||||
product.value.push({
|
||||
id: c.product.id,
|
||||
code: c.product.code,
|
||||
detail: c.product.name,
|
||||
priceUnit: c.pricePerUnit,
|
||||
priceUnit: precisionRound(priceNoVat),
|
||||
amount: c.amount,
|
||||
discount: c.discount,
|
||||
vat,
|
||||
value: price * c.amount + vat,
|
||||
vat: precisionRound(rawVat),
|
||||
value: precisionRound(priceNoVat * c.amount + rawVatTotal),
|
||||
});
|
||||
|
||||
a.totalPrice = precisionRound(a.totalPrice + price);
|
||||
a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount));
|
||||
a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat;
|
||||
a.vatExcluded = c.product.calcVat
|
||||
? a.vatExcluded
|
||||
: precisionRound(a.vat + vat);
|
||||
a.finalPrice = precisionRound(a.totalPrice - a.totalDiscount + a.vat);
|
||||
a.totalPrice = a.totalPrice + priceDiscountNoVat;
|
||||
a.totalDiscount = a.totalDiscount + Number(c.discount);
|
||||
a.vat = c.product.calcVat ? a.vat + rawVatTotal : a.vat;
|
||||
a.vatExcluded = c.product.calcVat ? a.vatExcluded : a.vat + rawVatTotal;
|
||||
a.finalPrice = a.totalPrice - a.totalDiscount + a.vat;
|
||||
return a;
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue