@nimee/calculations 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prices.js +5 -1
- package/dist/prices.js.map +1 -1
- package/package.json +1 -1
- package/src/prices.ts +5 -1
package/dist/prices.js
CHANGED
|
@@ -36,7 +36,11 @@ const calculateFinalPriceWithNimiFee = (totalPriceWithoutCouponDiscount, event,
|
|
|
36
36
|
case shared_types_1.IFeeCollectionType.PERCENTAGE_FROM_TICKET:
|
|
37
37
|
return { finalPriceWithNimiFee: totalPriceWithCouponDiscount, nimiFee: 0, nimiFeePercentage: account.marketFee }; // we use here marketFee (and not originalMarketFee) because we need to send the fee to payme without their fee
|
|
38
38
|
case shared_types_1.IFeeCollectionType.ON_TOP_OF_TICKET:
|
|
39
|
-
//
|
|
39
|
+
// check if the totalPrice with coupon discount is 0 then we return 0 for the fee and the percentage
|
|
40
|
+
if (totalPriceWithCouponDiscount === 0) {
|
|
41
|
+
return { finalPriceWithNimiFee: 0, nimiFee: 0, nimiFeePercentage: 0 };
|
|
42
|
+
}
|
|
43
|
+
// minimum 3 so we use max we totalPriceWithoutCouponDiscount because the fee is calculated on top of the original price and not the price after discount
|
|
40
44
|
const unroundedFee = Math.max(3, (totalPriceWithoutCouponDiscount * account.originalMarketFee) / 100); // here we use originalMarketFee because we need to calculate the fee on top of the original price (later we will subtract payme fee from the fee we send to payme)
|
|
41
45
|
const roundedFee = Math.round(unroundedFee);
|
|
42
46
|
// nimiFeePercentage has unknown range that need to be aware of - we get error when we send to payme with range above 60 so we use max
|
package/dist/prices.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prices.js","sourceRoot":"","sources":["../src/prices.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAoD;AACpD,sDAAsG;AACtG,oDAAkD;AAClD,wDAAmD;AAEnD,+EAA+E;AACxE,MAAM,qBAAqB,GAAG,CAAC,aAAgC,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,EAAE;QAClB,MAAM,qBAAqB,GAAG,IAAA,6CAAqC,EAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC;QAC9G,IAAI,qBAAqB,KAAK,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAxBW,QAAA,iBAAiB,qBAwB5B"}
|
package/package.json
CHANGED
package/src/prices.ts
CHANGED
|
@@ -29,7 +29,11 @@ export const calculateFinalPriceWithNimiFee = (
|
|
|
29
29
|
case IFeeCollectionType.PERCENTAGE_FROM_TICKET:
|
|
30
30
|
return { finalPriceWithNimiFee: totalPriceWithCouponDiscount, nimiFee: 0, nimiFeePercentage: account.marketFee }; // we use here marketFee (and not originalMarketFee) because we need to send the fee to payme without their fee
|
|
31
31
|
case IFeeCollectionType.ON_TOP_OF_TICKET:
|
|
32
|
-
//
|
|
32
|
+
// check if the totalPrice with coupon discount is 0 then we return 0 for the fee and the percentage
|
|
33
|
+
if (totalPriceWithCouponDiscount === 0) {
|
|
34
|
+
return { finalPriceWithNimiFee: 0, nimiFee: 0, nimiFeePercentage: 0 };
|
|
35
|
+
}
|
|
36
|
+
// minimum 3 so we use max we totalPriceWithoutCouponDiscount because the fee is calculated on top of the original price and not the price after discount
|
|
33
37
|
const unroundedFee = Math.max(3, (totalPriceWithoutCouponDiscount * account.originalMarketFee) / 100); // here we use originalMarketFee because we need to calculate the fee on top of the original price (later we will subtract payme fee from the fee we send to payme)
|
|
34
38
|
const roundedFee = Math.round(unroundedFee);
|
|
35
39
|
// nimiFeePercentage has unknown range that need to be aware of - we get error when we send to payme with range above 60 so we use max
|