fix the discount calculation factor, because the factor is rounded down
This commit is contained in:
parent
9ae5b96956
commit
f05f7fd47b
Binary file not shown.
@ -174,9 +174,8 @@ patch(Order.prototype, {
|
||||
for (const [, amount] of Object.entries(discountablePerTax)) {
|
||||
totalDiscountableWithoutTax += amount;
|
||||
}
|
||||
|
||||
// Calculate discount factor based on the total discountable amount without tax
|
||||
const discountFactor = totalDiscountableWithoutTax ? roundPrecision(Math.min(1, maxDiscount / totalDiscountableWithoutTax), this.pos.currency.rounding) : 1;
|
||||
|
||||
const discountFactor = totalDiscountableWithoutTax ? Math.min(1, maxDiscount / totalDiscountableWithoutTax) : 1;
|
||||
|
||||
const result = Object.entries(discountablePerTax).reduce((lst, entry) => {
|
||||
if (!entry[1]) {
|
||||
@ -184,7 +183,8 @@ patch(Order.prototype, {
|
||||
}
|
||||
const taxIds = entry[0] === "" ? [] : entry[0].split(",").map((str) => parseInt(str));
|
||||
// Calculate tax-exclusive discount value for display
|
||||
const discountAmount = roundPrecision(entry[1] * discountFactor, this.pos.currency.rounding);
|
||||
const preliminaryAmount = entry[1] * discountFactor;
|
||||
const discountAmount = roundPrecision(preliminaryAmount, this.pos.currency.rounding);
|
||||
lst.push({
|
||||
product: reward.discount_line_product_id,
|
||||
price: -discountAmount,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user