tripstorekrabi-shared 1.22.5 → 1.22.7

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 +9 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.22.5",
3
+ "version": "1.22.7",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -47,14 +47,17 @@ function calculateSellingPrice(commissionRate = 0, price) {
47
47
  );
48
48
  }
49
49
 
50
- export function caluclateInflatedSellingPrice(price, config) {
51
- if (!config || !config.inflatedPrices) {
50
+ export function calculateInflatedSellingPrice(price, config, forceInflation = false) {
51
+ if (!config || (!config.inflatedPrices && !forceInflation)) {
52
52
  return price;
53
53
  }
54
54
 
55
55
  const discountRate = Number(config.discount) || 0;
56
56
 
57
- if (!isFinite(discountRate)) return price;
57
+ if (discountRate === 0 || !isFinite(discountRate)) {
58
+ return price;
59
+ }
60
+
58
61
  const denominator = 100 - discountRate;
59
62
 
60
63
  if (denominator <= 0) {
@@ -96,13 +99,13 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
96
99
  const commissionRate = pricing.commissionRates?.[bookingSourceKey];
97
100
  const baseNetPriceAdult = customPricing.adult.partnerNetPrice;
98
101
  const baseRetailPriceAdult = calculateSellingPrice(commissionRate, baseNetPriceAdult);
99
- const finalPriceAdult = caluclateInflatedSellingPrice(baseRetailPriceAdult, customPricing);
102
+ const finalPriceAdult = calculateInflatedSellingPrice(baseRetailPriceAdult, customPricing);
100
103
 
101
104
  let finalPriceChild = 0;
102
105
  if (pricing.ageBands.child.active && volume.child && booking.children) {
103
106
  const baseNetPriceChild = customPricing.child.partnerNetPrice;
104
107
  const baseRetailPriceChild = calculateSellingPrice(commissionRate, baseNetPriceChild);
105
- finalPriceChild = caluclateInflatedSellingPrice(baseRetailPriceChild, customPricing);
108
+ finalPriceChild = calculateInflatedSellingPrice(baseRetailPriceChild, customPricing);
106
109
  }
107
110
 
108
111
  total = booking.adults * finalPriceAdult + (booking.children ? booking.children * finalPriceChild : 0);
@@ -136,7 +139,7 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
136
139
  const commissionRate = pricing.commissionRates?.[bookingSourceKey];
137
140
  const baseNetPrice = customPricing.partnerNetPrice;
138
141
  const baseRetailPrice = calculateSellingPrice(commissionRate, baseNetPrice);
139
- const finalPrice = applyPromotionDiscount(baseRetailPrice, customPricing);
142
+ const finalPrice = calculateInflatedSellingPrice(baseRetailPrice, customPricing);
140
143
  total = finalPrice;
141
144
  } else if (options.mode === PARTNER_MODE) {
142
145
  total = customPricing.partnerNetPrice