@@ -3,13 +3,10 @@ import {
3
3
ApplicationMethodAllocation ,
4
4
ApplicationMethodType ,
5
5
} from "../../promotion"
6
- import { MathBN } from "../math"
6
+ import { MathBN , MEDUSA_EPSILON } from "../math"
7
7
8
8
function 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 )
13
10
}
14
11
15
12
function getPromotionValueForFixed ( promotion , lineItemAmount , lineItemsAmount ) {
@@ -28,10 +25,7 @@ function getPromotionValueForFixed(promotion, lineItemAmount, lineItemsAmount) {
28
25
promotionValueForItem
29
26
)
30
27
31
- return MathBN . convert (
32
- MathBN . mult ( promotionValueForItem , MathBN . div ( percentage , 100 ) ) ,
33
- 2
34
- )
28
+ return MathBN . mult ( promotionValueForItem , MathBN . div ( percentage , 100 ) )
35
29
}
36
30
return promotion . value
37
31
}
@@ -104,8 +98,8 @@ export function calculateAdjustmentAmountFromPromotion(
104
98
)
105
99
const applicableAmount = MathBN . sub ( lineItemAmount , promotion . applied_value )
106
100
107
- if ( MathBN . lte ( applicableAmount , 0 ) ) {
108
- return applicableAmount
101
+ if ( MathBN . lte ( applicableAmount , MEDUSA_EPSILON ) ) {
102
+ return MathBN . convert ( 0 )
109
103
}
110
104
111
105
const promotionValue = getPromotionValue (
@@ -153,7 +147,7 @@ export function calculateAdjustmentAmountFromPromotion(
153
147
maximumPromotionAmount
154
148
)
155
149
156
- if ( MathBN . lte ( applicableAmount , 0 ) ) {
150
+ if ( MathBN . lte ( applicableAmount , MEDUSA_EPSILON ) ) {
157
151
return MathBN . convert ( 0 )
158
152
}
159
153
0 commit comments