fix: price not match with original price by .01
This will calculate quantity later when no discount is set. However when discount is set there may be some number that can introduce +-0.01
This commit is contained in:
parent
5afe625290
commit
e0d24b49cb
2 changed files with 12 additions and 6 deletions
|
|
@ -54,9 +54,13 @@ function calcPrice(c: (typeof rows.value)[number]) {
|
|||
return precisionRound(
|
||||
c.pricePerUnit * c.amount -
|
||||
c.discount +
|
||||
(c.product.calcVat
|
||||
? (c.pricePerUnit * c.amount - c.discount) * (config.value?.vat || 0.07)
|
||||
: 0),
|
||||
precisionRound(
|
||||
c.product.calcVat
|
||||
? (c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
|
||||
(config.value?.vat || 0.07)
|
||||
: 0,
|
||||
) *
|
||||
(!c.discount ? c.amount : 1),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,9 +214,11 @@ function getPrice(
|
|||
}
|
||||
|
||||
const price = precisionRound(c.pricePerUnit * c.amount);
|
||||
const vat = precisionRound(
|
||||
(c.pricePerUnit * c.amount - c.discount) * (config.value?.vat || 0.07),
|
||||
);
|
||||
const vat =
|
||||
precisionRound(
|
||||
(c.pricePerUnit * (c.discount ? c.amount : 1) - c.discount) *
|
||||
(config.value?.vat || 0.07),
|
||||
) * (!c.discount ? c.amount : 1);
|
||||
|
||||
a.totalPrice = precisionRound(a.totalPrice + price);
|
||||
a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue