tripstorekrabi-shared 1.20.5 → 1.21.1

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 +0 -45
  3. package/utils.js +5 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.20.5",
3
+ "version": "1.21.1",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -27,7 +27,6 @@ const SELLING_MODE = 0;
27
27
  const PARTNER_MODE = 1;
28
28
  const OPERATOR_MODE = 2;
29
29
 
30
-
31
30
  export function calculateProductSellingPrice(booking, pricing) {
32
31
  return booking.customerPaymentStatus === "Refunded" ? 0 : calculateProductPrice(booking, pricing, { mode: SELLING_MODE });
33
32
  }
@@ -423,48 +422,4 @@ export function findAddOn(id, addOns) {
423
422
 
424
423
  export function inRange(expected, actual, boundary = 10) {
425
424
  return ((expected - boundary) <= actual) && ((expected + boundary) >= actual);
426
- }
427
-
428
- export function calculatePhayunPrices(booking, product) {
429
- let productPrice;
430
- let cashOnTourAmount = 0;
431
- let activeExtraPayments = getActiveExtraPayments(Object.entries(booking.extraPayments));
432
- let bookingType = getBookingType(booking.referenceNumber);
433
-
434
- if (
435
- product.operator.default.invoicing?.operator?.create &&
436
- product.operator.default.invoicing?.operator?.partners?.[
437
- bookingType
438
- ]?.include
439
- ) {
440
- productPrice = booking.partnerNetPrice;
441
- } else {
442
- productPrice = booking.operatorNetPrice;
443
- }
444
-
445
- (product.addOns ?? []).forEach((addOnDef) => {
446
- let addOn = booking.addOns?.[addOnDef.id];
447
- let pax =
448
- (addOn?.adults ?? 0) +
449
- (addOn?.children ?? 0);
450
-
451
- if (pax > 0) {
452
- let addOnPrice =
453
- addOn.adults * addOnDef.pricing.adult.operatorNetPrice +
454
- (addOn.children ?? 0) *
455
- addOnDef.pricing.child.operatorNetPrice;
456
-
457
- // check for extra payment
458
- let extraPayment = activeExtraPayments.find(([id]) => id === addOnDef.id)?.[1];
459
- if (!extraPayment) { // add-on paid via partner
460
- productPrice -= addOnPrice;
461
- } else if (extraPayment.paymentMethod === PAY_BEFORE) { // add-on paid via extra payment
462
- productPrice -= addOnPrice;
463
- } else if (extraPayment.paymentMethod === PAY_ON_TOUR) { // add-on is paid on tour
464
- cashOnTourAmount += addOnPrice;
465
- }
466
- }
467
- });
468
-
469
- return { productPrice, cashOnTourAmount };
470
425
  }
package/utils.js CHANGED
@@ -6,7 +6,7 @@ import utc from 'dayjs/plugin/utc.js';
6
6
  import timezone from 'dayjs/plugin/timezone.js';
7
7
  import { findEndPoint, findStartingPoint } from './price.js';
8
8
  import { CUSTOMER_NOTE } from './booking.js';
9
- import { parsePhoneNumber, AsYouType } from 'libphonenumber-js';
9
+ import { parsePhoneNumberWithError, AsYouType } from 'libphonenumber-js';
10
10
 
11
11
  dayjs.extend(customParseFormat);
12
12
  dayjs.extend(advancedFormat);
@@ -37,6 +37,8 @@ export const KLK_AGENCYID_IN_PHAYUN = 'JSYggp9yw8RBdIkhuPvo';
37
37
  export const MUS_AGENCYID_IN_PHAYUN = '6VBWnnTPn2wlfhGIxG5L';
38
38
  export const EXP_AGENCYID_IN_PHAYUN = 'ECf1LkUkd67Avjb8CoAB';
39
39
  export const TIQ_AGENCYID_IN_PHAYUN = 'HPiO2Z6OdD8A3O5Zbi96';
40
+ export const CIV_AGENCYID_IN_PHAYUN = 'ZBoPc4cFtxyUJIxkFKnzG';
41
+ export const CUR_AGENCYID_IN_PHAYUN = 'BSV3FQAM_pZx7QnC67dBC';
40
42
 
41
43
  export const DIETARIES = [
42
44
  'None',
@@ -354,7 +356,7 @@ export function formatPeople(people) {
354
356
  }
355
357
 
356
358
  export function countPeople(people) {
357
- return people.adults ?? 0 + people.children ?? 0 + people.infants ?? 0;
359
+ return (people.adults ?? 0) + (people.children ?? 0) + (people.infants ?? 0);
358
360
  }
359
361
 
360
362
  export function isNumeric(n) {
@@ -712,10 +714,6 @@ export function isMusementBooking(referenceNumber) {
712
714
  return referenceNumber.startsWith('MUS');
713
715
  }
714
716
 
715
- export function isAirbnbBooking(referenceNumber) {
716
- return referenceNumber.startsWith('Airbnb-');
717
- }
718
-
719
717
  export function isTiqetsBooking(referenceNumber) {
720
718
  return referenceNumber.startsWith('TIQ-');
721
719
  }
@@ -747,8 +745,6 @@ export function getBookingType(referenceNumber) {
747
745
  return 'klk';
748
746
  } else if (isMusementBooking(referenceNumber)) {
749
747
  return 'mus';
750
- } else if (isAirbnbBooking(referenceNumber)) {
751
- return 'air';
752
748
  } else if (isTiqetsBooking(referenceNumber)) {
753
749
  return 'tiq';
754
750
  } else if (isCuriosidad(referenceNumber)) {
@@ -783,7 +779,7 @@ export function isJSON(text) {
783
779
  export function formatPhoneNumber(phoneNumber) {
784
780
  if (phoneNumber) {
785
781
  try {
786
- let libPhoneNumber = parsePhoneNumber(phoneNumber, 'TH');
782
+ let libPhoneNumber = parsePhoneNumberWithError(phoneNumber, 'TH');
787
783
  let asYouType = new AsYouType();
788
784
  asYouType.input(phoneNumber);
789
785