tripstorekrabi-shared 1.13.37 → 1.13.39

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/booking.js +2 -2
  2. package/package.json +1 -1
  3. package/price.js +21 -8
package/booking.js CHANGED
@@ -2,7 +2,7 @@ import dayjs from "dayjs";
2
2
  import advancedFormat from 'dayjs/plugin/advancedFormat.js';
3
3
  import utc from "dayjs/plugin/utc.js";
4
4
  import timezone from "dayjs/plugin/timezone.js";
5
- import { calculateTotalPrice } from './price.js';
5
+ import { calculateTotalOperatorPrice } from './price.js';
6
6
 
7
7
  dayjs.extend(advancedFormat);
8
8
  dayjs.extend(utc);
@@ -106,7 +106,7 @@ export function addBookingFromInvoice(firestore, admin, invoice, paymentData, co
106
106
  }
107
107
 
108
108
  if (productSnapshot) {
109
- data.operatorNetPrice = calculateTotalPrice(data, productSnapshot.data(), "operator");
109
+ data.operatorNetPrice = calculateTotalOperatorPrice(data, productSnapshot.data());
110
110
  } else {
111
111
  data.operatorNetPrice = 0;
112
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.37",
3
+ "version": "1.13.39",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -1,8 +1,5 @@
1
1
  import { getBookingType } from "./utils.js";
2
2
 
3
- export const SELLING_PAYMENT_MODE = 0;
4
- export const PARTNER_PAYMENT_MODE = 1;
5
- export const OPERATOR_PAYMENT_MODE = 2;
6
3
  export const MAX_PAX = 30;
7
4
  export const PAY_ON_TOUR = 'Pay on tour';
8
5
  export const ALREADY_PAID = "Already paid";
@@ -20,6 +17,10 @@ export const EXTRA_PAYMENT_CATEGORIES = [STARTING_POINT_EXTRA_PAYMENT,
20
17
  ADD_ON_EXTRA_PAYMENT,
21
18
  OTHER_EXTRA_PAYMENT];
22
19
 
20
+ const SELLING_PAYMENT_MODE = 0;
21
+ const PARTNER_PAYMENT_MODE = 1;
22
+ const OPERATOR_PAYMENT_MODE = 2;
23
+
23
24
  export function calculateProductSellingPrice(booking, pricing) {
24
25
  return calculateProductPrice(booking, pricing, { paymentMode: SELLING_PAYMENT_MODE });
25
26
  }
@@ -246,14 +247,14 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
246
247
  {
247
248
  category: STARTING_POINT_EXTRA_PAYMENT,
248
249
  description: startingPoint.name,
249
- price: calculateStartEndPointPrice(booking, startingPoint, true),
250
- operatorPrice: calculateStartEndPointPrice(booking, startingPoint, false),
250
+ price: calculateStartEndPointPrice(booking, startingPoint, { paymentMode: SELLING_PAYMENT_MODE }),
251
+ operatorPrice: calculateStartEndPointPrice(booking, startingPoint, { paymentMode: OPERATOR_PAYMENT_MODE }),
251
252
  },
252
253
  {
253
254
  category: END_POINT_EXTRA_PAYMENT,
254
255
  description: endPoint.name,
255
- price: calculateStartEndPointPrice(booking, endPoint, true),
256
- operatorPrice: calculateStartEndPointPrice(booking, endPoint, false),
256
+ price: calculateStartEndPointPrice(booking, endPoint, { paymentMode: SELLING_PAYMENT_MODE }),
257
+ operatorPrice: calculateStartEndPointPrice(booking, endPoint, { paymentMode: OPERATOR_PAYMENT_MODE }),
257
258
  },
258
259
  {
259
260
  category: NATIONAL_PARK_FEE_EXTRA_PAYMENT,
@@ -288,7 +289,19 @@ export function calculateAddOnsPrice(booking, product, options = { paymentMode:
288
289
  return total;
289
290
  }
290
291
 
291
- export function calculateStartEndPointPrice(people, startEndPoint, options = { paymentMode: SELLING_PAYMENT_MODE }) {
292
+ export function calculateStartEndPointSellingPrice(people, startEndPoint) {
293
+ return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: SELLING_PAYMENT_MODE });
294
+ }
295
+
296
+ export function calculateStartEndPointOperatorPrice(people, startEndPoint) {
297
+ return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: OPERATOR_PAYMENT_MODE });
298
+ }
299
+
300
+ export function calculateStartEndPointPartnerNetPrice(people, startEndPoint) {
301
+ return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: PARTNER_PAYMENT_MODE });
302
+ }
303
+
304
+ function calculateStartEndPointPrice(people, startEndPoint, options = { paymentMode: SELLING_PAYMENT_MODE }) {
292
305
  let pricing = startEndPoint?.pricing;
293
306
  let isSelling = options.paymentMode in [SELLING_PAYMENT_MODE, PARTNER_PAYMENT_MODE];
294
307
  if (pricing) {