tripstorekrabi-shared 1.13.63 → 1.13.65

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 (3) hide show
  1. package/package.json +1 -1
  2. package/price.js +28 -0
  3. package/utils.js +25 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.63",
3
+ "version": "1.13.65",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -311,6 +311,34 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
311
311
  });
312
312
  }
313
313
 
314
+ export function getActiveExtraPayments(extraPayments) {
315
+ return extraPayments
316
+ .filter(([id, item]) => !item.disabled)
317
+ .sort(([id1, item1], [id2, item2]) =>
318
+ item1.description.localeCompare(item2.description)
319
+ );
320
+ }
321
+
322
+ export function getExtraPaymentsOperatorPrice(extraPayments) {
323
+ return getActiveExtraPayments(extraPayments).reduce(
324
+ (prev, curr) => {
325
+ let price;
326
+ let item = curr[1];
327
+ if (item.paymentMethod === PAY_ON_TOUR) {
328
+ let ourCommission = item.price - item.operatorPrice;
329
+ if (ourCommission > 0) {
330
+ price = -ourCommission;
331
+ }
332
+ } else {
333
+ price = item.operatorPrice;
334
+ }
335
+
336
+ return prev + price;
337
+ },
338
+ 0
339
+ );
340
+ }
341
+
314
342
  export function calculateAddOnsPrice(booking, product, options = { mode: SELLING_MODE }) {
315
343
  let total = 0;
316
344
  let isSelling = options.mode in [SELLING_MODE, PARTNER_MODE];
package/utils.js CHANGED
@@ -353,41 +353,39 @@ export function getBookingSummary(booking, options = {}) {
353
353
  export function getItemSummary(item, product) {
354
354
  let summary = item.description;
355
355
 
356
- if (product) {
357
- if (item.departureDate) {
358
- summary += ", " + dayjs(item.departureDate).tz("Asia/Bangkok").format("DD.MM.YYYY");
359
- }
356
+ if (item.departureDate) {
357
+ summary += ", " + dayjs(item.departureDate).tz("Asia/Bangkok").format("DD.MM.YYYY");
358
+ }
360
359
 
361
- if (item.schedule) {
362
- summary += ", " + item.schedule;
363
- }
360
+ if (item.schedule) {
361
+ summary += ", " + item.schedule;
362
+ }
364
363
 
365
- if (item.adults || item.children || item.infants) {
366
- summary += ", " + formatPeople(item) + ", ";
367
- }
364
+ if (item.adults || item.children || item.infants) {
365
+ summary += ", " + formatPeople(item) + ", ";
366
+ }
368
367
 
369
- if (item.startingPointId) {
370
- let startingPointDescription = findStartingPoint(product, item.startingPointId).value;
371
- if (isHotelPickup(startingPointDescription)) {
372
- if (item.noHotelYet === true) {
373
- summary += "Hotel pickup (hotel not known yet)";
374
- } else {
375
- summary += "Hotel pickup from " + item.pickupHotel;
368
+ if (item.startingPointId) {
369
+ let startingPointDescription = findStartingPoint(product, item.startingPointId).value;
370
+ if (isHotelPickup(startingPointDescription)) {
371
+ if (item.noHotelYet === true) {
372
+ summary += "Hotel pickup (hotel not known yet)";
373
+ } else {
374
+ summary += "Hotel pickup from " + item.pickupHotel;
376
375
 
377
- if (item.roomNumber) {
378
- summary += ` (${item.roomNumber})`;
379
- }
376
+ if (item.roomNumber) {
377
+ summary += ` (${item.roomNumber})`;
380
378
  }
381
- } else {
382
- summary += startingPointDescription;
383
379
  }
380
+ } else {
381
+ summary += startingPointDescription;
384
382
  }
383
+ }
385
384
 
386
- if (item.endPointId) {
387
- let endPointDescription = findEndPoint(product, item.endPointId).value;
388
- if (isHotelDropOff(endPointDescription) && item.dropoffHotel) {
389
- summary += ", Hotel drop-off at " + item.dropoffHotel;
390
- }
385
+ if (item.endPointId) {
386
+ let endPointDescription = findEndPoint(product, item.endPointId).value;
387
+ if (isHotelDropOff(endPointDescription) && item.dropoffHotel) {
388
+ summary += ", Hotel drop-off at " + item.dropoffHotel;
391
389
  }
392
390
  }
393
391