@@ -3,13 +3,10 @@ import {
33 ApplicationMethodAllocation ,
44 ApplicationMethodType ,
55} from "../../promotion"
6- import { MathBN } from "../math"
6+ import { MathBN , MEDUSA_EPSILON } from "../math"
77
88function getPromotionValueForPercentage ( promotion , lineItemAmount ) {
9- return MathBN . convert (
10- MathBN . mult ( MathBN . div ( promotion . value , 100 ) , lineItemAmount ) ,
11- 2
12- )
9+ return MathBN . mult ( MathBN . div ( promotion . value , 100 ) , lineItemAmount )
1310}
1411
1512function getPromotionValueForFixed ( promotion , lineItemAmount , lineItemsAmount ) {
@@ -28,10 +25,7 @@ function getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount) {
2825 promotionValueForItem
2926 )
3027
31- return MathBN . convert (
32- MathBN . mult ( promotionValueForItem , MathBN . div ( percentage , 100 ) ) ,
33- 2
34- )
28+ return MathBN . mult ( promotionValueForItem , MathBN . div ( percentage , 100 ) )
3529 }
3630 return promotion . value
3731}
@@ -104,8 +98,8 @@ export function calculateAdjustmentAmountFromPromotion(
10498 )
10599 const applicableAmount = MathBN . sub ( lineItemAmount , promotion . applied_value )
106100
107- if ( MathBN . lte ( applicableAmount , 0 ) ) {
108- return applicableAmount
101+ if ( MathBN . lte ( applicableAmount , MEDUSA_EPSILON ) ) {
102+ return MathBN . convert ( 0 )
109103 }
110104
111105 const promotionValue = getPromotionValue (
@@ -153,7 +147,7 @@ export function calculateAdjustmentAmountFromPromotion(
153147 maximumPromotionAmount
154148 )
155149
156- if ( MathBN . lte ( applicableAmount , 0 ) ) {
150+ if ( MathBN . lte ( applicableAmount , MEDUSA_EPSILON ) ) {
157151 return MathBN . convert ( 0 )
158152 }
159153
0 commit comments