tripstorekrabi-shared 1.13.46 → 1.13.47

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/price.js +10 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.46",
3
+ "version": "1.13.47",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -33,14 +33,15 @@ export function calculateProductOperatorPrice(booking, pricing) {
33
33
  return calculateProductPrice(booking, pricing, { mode: OPERATOR_MODE });
34
34
  }
35
35
 
36
+ function calculateSellingPrice(commissionRate, price) {
37
+ return Math.floor(
38
+ (price * 100) /
39
+ (100 -
40
+ commissionRate)
41
+ );
42
+ }
43
+
36
44
  function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE }) {
37
- function calculateRetailPrice(commissionRate, price) {
38
- return Math.floor(
39
- (price * 100) /
40
- (100 -
41
- commissionRate)
42
- );
43
- }
44
45
  let type = pricing.type;
45
46
  let total = 0;
46
47
 
@@ -60,7 +61,7 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
60
61
  let commissionRate = pricing.commissionRates?.[bookingType];
61
62
 
62
63
  if (commissionRate && commissionRate > 0) {
63
- total = booking.adults * calculateRetailPrice(commissionRate, customPricing.adult.partnerNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? (booking.children * calculateRetailPrice(commissionRate, customPricing.child.partnerNetPrice)) : 0);
64
+ total = booking.adults * calculateSellingPrice(commissionRate, customPricing.adult.partnerNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? (booking.children * calculateSellingPrice(commissionRate, customPricing.child.partnerNetPrice)) : 0);
64
65
  } else {
65
66
  total = booking.adults * customPricing.adult.retailPrice + (pricing.ageBands.child.active && volume.child && booking.children ? booking.children * customPricing.child.retailPrice : 0);
66
67
  }
@@ -95,7 +96,7 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
95
96
  let commissionRate = pricing.commissionRates?.[bookingType];
96
97
 
97
98
  if (commissionRate && commissionRate > 0) {
98
- total = calculateRetailPrice(commissionRate, customPricing.partnerNetPrice);
99
+ total = calculateSellingPrice(commissionRate, customPricing.partnerNetPrice);
99
100
  } else {
100
101
  total = customPricing.retailPrice;
101
102
  }