tripstorekrabi-shared 1.13.51 → 1.13.53

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 +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.51",
3
+ "version": "1.13.53",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -125,7 +125,13 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
125
125
 
126
126
  export function findVolume(people, pricing) {
127
127
  let total = people.adults + people.children ?? 0;
128
- return pricing.volumes.sort((v1, v2) => v1.max - v2.max).find((item) => total <= item.max);
128
+ return pricing.volumes.sort((v1, v2) => v1.max - v2.max).find((item, i) => {
129
+ if (total <= item.max) {
130
+ return true;
131
+ } else if (i === pricing.volumes.length - 1) {
132
+ return true;
133
+ }
134
+ });
129
135
  }
130
136
 
131
137
  export function countMinPeople(pricing) {
@@ -352,4 +358,8 @@ export function findAddOn(id, addOns) {
352
358
  return addOns.find((item) =>
353
359
  item.id === id
354
360
  );
361
+ }
362
+
363
+ export function inRange(expected, actual, boundary = 10) {
364
+ return ((expected - boundary) <= actual) && ((expected + boundary) >= actual);
355
365
  }