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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user