fix(utils): Fix on precision for high quantities for items when promotion is applied (#13131)

* Fix on precision for high quantities for items when promotion is applied

* Fix on precision for high quantities for items when promotion is applied
This commit is contained in:
scherddel
2025-08-03 19:16:16 +02:00
committed by GitHub
parent 89886ba518
commit 51d4751d95
3 changed files with 129 additions and 5 deletions
@@ -6,7 +6,10 @@ import {
import { MathBN } from "../math"
function getPromotionValueForPercentage(promotion, lineItemAmount) {
return MathBN.mult(MathBN.div(promotion.value, 100), lineItemAmount)
return MathBN.convert(
MathBN.mult(MathBN.div(promotion.value, 100), lineItemAmount),
2
)
}
function getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount) {
@@ -25,10 +28,10 @@ function getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount) {
promotionValueForItem
)
return MathBN.mult(
promotionValueForItem,
MathBN.div(percentage, 100)
).precision(4)
return MathBN.convert(
MathBN.mult(promotionValueForItem, MathBN.div(percentage, 100)),
2
)
}
return promotion.value
}