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:
1 parent
89886ba518
commit
51d4751d95
3 files changed
+129
-5
No files matched your search
@@ -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