@nimee/calculations 1.0.9 → 1.0.11
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 +3 -3
- package/dist/prices.js.map +1 -1
- package/package.json +1 -1
- package/src/prices.ts +5 -3
- package/tests/prices.test.ts +2 -2
package/dist/prices.js
CHANGED
|
@@ -30,15 +30,15 @@ const calculateFinalPriceWithNimiFee = (totalPriceWithoutCouponDiscount, event,
|
|
|
30
30
|
return { finalPriceWithNimiFee: 0, nimiFee: 0, nimiFeePercentage: 0, marketplaceFee: 0 };
|
|
31
31
|
}
|
|
32
32
|
// 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
|
-
const unroundedFee = Math.max(3, (
|
|
34
|
-
let roundedFee =
|
|
33
|
+
const unroundedFee = Math.max(3, (totalPriceWithCouponDiscount * 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
|
+
let roundedFee = roundToTwoDecimals(unroundedFee);
|
|
35
35
|
// 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
|
|
36
36
|
// const nimiFeePercentage = Math.min(59, (roundedFee / totalPriceWithCouponDiscount) * 100); // we use here totalPriceWithCouponDiscount because we send payme the price after the discount plus the nimiFee (roundedFee) so we need to know the percentage of the fee from the final price
|
|
37
37
|
// we need to make sure we send marketFee that is greater or equal to 0 so we use max and we must subtract payme fee from nimiFeePercentage because payme ask to send them the fee without their fee
|
|
38
38
|
// const nimiFeePercentageMinusPaymeFee = Math.max(0, nimiFeePercentage - 1.1 * 1.17);
|
|
39
39
|
const totalFee = roundToTwoDecimals(((roundedFee + totalPriceWithCouponDiscount) * (account.marketFee + exports.paymeFee)) / 100);
|
|
40
40
|
if (roundedFee < totalFee) {
|
|
41
|
-
logger_1.default.debug(`roundedFee is less than totalFee roundedFee: ${roundedFee} and totalFee: ${totalFee} `);
|
|
41
|
+
logger_1.default.debug(`roundedFee is less than totalFee roundedFee: ${roundedFee} and totalFee: ${totalFee} for event: ${event._id}`);
|
|
42
42
|
roundedFee = totalFee;
|
|
43
43
|
}
|
|
44
44
|
const marketplaceFeeOfON_TOP_OF_TICKET = roundedFee - totalFee; // payme takes the percentage from the price. so we calculate payme and nimi fee from the price and we substruct the result from the roundedFee
|
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,2DAAmC;AACnC,wDAAmD;AACtC,QAAA,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAC;AAEnC,qGAAqG;AACrG,wFAAwF;AACxF,uEAAuE;AACvE,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAEjE,MAAM,8BAA8B,GAAG,CAC5C,+BAAuC,EACvC,KAAkB,EAClB,OAAsB,EACtB,4BAAoC,EACmE,EAAE;IACzG,QAAQ,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,KAAK,iCAAkB,CAAC,sBAAsB;YAC5C,MAAM,sCAAsC,GAC1C,CAAC,4BAA4B,GAAG,CAAC,OAAO,CAAC,iBAAiB,GAAG,gBAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC;YACpG,OAAO;gBACL,qBAAqB,EAAE,4BAA4B;gBACnD,OAAO,EAAE,CAAC;gBACV,iBAAiB,EAAE,OAAO,CAAC,SAAS;gBACpC,cAAc,EAAE,kBAAkB,CAAC,sCAAsC,CAAC;aAC3E,CAAC,CAAC,gHAAgH;QACrH,KAAK,iCAAkB,CAAC,gBAAgB;YACtC,oGAAoG;YACpG,IAAI,4BAA4B,KAA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mCAAmC,EACnC,GAAG,EACH,uCAAuC,KAAK,CAAC,iBAAiB,EAAE,CACjE,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAhEW,QAAA,8BAA8B,kCAgEzC;AACK,MAAM,qCAAqC,GAAG,CAAC,UAAkB,EAAE,cAAsB,EAAU,EAAE,CAC1G,UAAU,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,cAAc,CAAC;AADvD,QAAA,qCAAqC,yCACkB;AAC7D,MAAM,0CAA0C,GAAG,CAAC,UAAkB,EAAE,gCAAqC,EAAU,EAAE,CAC9H,UAAU,GAAG,gCAAgC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,gCAAgC,CAAC;AAD3F,QAAA,0CAA0C,8CACiD;AACxG,0FAA0F;AAC1F,iGAAiG;AACjG,gIAAgI;AAChI,6CAA6C;AAC7C,yHAAyH;AACzH,4BAA4B;AAC5B,6BAA6B;AAC7B,iDAAiD;AACjD,aAAa;AACb,mHAAmH;AACnH,SAAS;AACT,MAAM;AAEN,wHAAwH;AACxH,0CAA0C;AAC1C,mBAAmB;AACnB,MAAM;AAEN,0BAA0B;AAC1B,qHAAqH;AACrH,yCAAyC;AACzC,qBAAqB;AACrB,QAAQ;AACR,MAAM;AAEN,kBAAkB;AAClB,KAAK"}
|
package/package.json
CHANGED
package/src/prices.ts
CHANGED
|
@@ -32,15 +32,17 @@ export const calculateFinalPriceWithNimiFee = (
|
|
|
32
32
|
return { finalPriceWithNimiFee: 0, nimiFee: 0, nimiFeePercentage: 0, marketplaceFee: 0 };
|
|
33
33
|
}
|
|
34
34
|
// 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
|
|
35
|
-
const unroundedFee = Math.max(3, (
|
|
36
|
-
let roundedFee =
|
|
35
|
+
const unroundedFee = Math.max(3, (totalPriceWithCouponDiscount * 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)
|
|
36
|
+
let roundedFee = roundToTwoDecimals(unroundedFee);
|
|
37
37
|
// 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
|
|
38
38
|
// const nimiFeePercentage = Math.min(59, (roundedFee / totalPriceWithCouponDiscount) * 100); // we use here totalPriceWithCouponDiscount because we send payme the price after the discount plus the nimiFee (roundedFee) so we need to know the percentage of the fee from the final price
|
|
39
39
|
// we need to make sure we send marketFee that is greater or equal to 0 so we use max and we must subtract payme fee from nimiFeePercentage because payme ask to send them the fee without their fee
|
|
40
40
|
// const nimiFeePercentageMinusPaymeFee = Math.max(0, nimiFeePercentage - 1.1 * 1.17);
|
|
41
41
|
const totalFee = roundToTwoDecimals(((roundedFee + totalPriceWithCouponDiscount) * (account.marketFee + paymeFee)) / 100);
|
|
42
42
|
if (roundedFee < totalFee) {
|
|
43
|
-
logger.debug(
|
|
43
|
+
logger.debug(
|
|
44
|
+
`roundedFee is less than totalFee roundedFee: ${roundedFee} and totalFee: ${totalFee} for event: ${event._id}`
|
|
45
|
+
);
|
|
44
46
|
roundedFee = totalFee;
|
|
45
47
|
}
|
|
46
48
|
const marketplaceFeeOfON_TOP_OF_TICKET = roundedFee - totalFee; // payme takes the percentage from the price. so we calculate payme and nimi fee from the price and we substruct the result from the roundedFee
|
package/tests/prices.test.ts
CHANGED
|
@@ -43,7 +43,7 @@ describe("calculateFinalPriceWithNimiFee", () => {
|
|
|
43
43
|
account as any,
|
|
44
44
|
totalPriceWithCouponDiscount
|
|
45
45
|
);
|
|
46
|
-
const nimiFee = 3.
|
|
46
|
+
const nimiFee = 3.06;
|
|
47
47
|
const expectedMarketplaceFee = parseFloat(
|
|
48
48
|
(nimiFee - ((totalPriceWithCouponDiscount + nimiFee) * (paymeFee + account.marketFee)) / 100).toFixed(2)
|
|
49
49
|
);
|
|
@@ -67,7 +67,7 @@ describe("calculateFinalPriceWithNimiFee", () => {
|
|
|
67
67
|
totalPriceWithCouponDiscount
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
-
const nimiFee = 3.
|
|
70
|
+
const nimiFee = 3.06;
|
|
71
71
|
const expectedMarketplaceFee = parseFloat(
|
|
72
72
|
(nimiFee - ((totalPriceWithCouponDiscount + nimiFee) * (paymeFee + account.marketFee)) / 100).toFixed(2)
|
|
73
73
|
);
|