tripstorekrabi-shared 1.13.17 → 1.13.19

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 +32 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.17",
3
+ "version": "1.13.19",
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,4 +1,3 @@
1
-
2
1
  import { getBookingType } from "./utils.js";
3
2
 
4
3
  export const MAX_PAX = 30;
@@ -7,13 +6,13 @@ export const ALREADY_PAID = "Already paid";
7
6
  export const PAY_BEFORE = "Pay before";
8
7
  export const STARTING_POINT_EXTRA_PAYMENT = 'STARTING POINT';
9
8
  export const END_POINT_EXTRA_PAYMENT = 'END POINT';
10
- export const NATIONAL_PARK_FEEE_XTRA_PAYMENT = 'NATIONAL PARK FEE';
9
+ export const NATIONAL_PARK_FEE_EXTRA_PAYMENT = 'NATIONAL PARK FEE';
11
10
  export const PAX_EXTRA_PAYMENT = 'PAX';
12
11
  export const ADD_ON_EXTRA_PAYMENT = 'ADD-ON';
13
12
  export const OTHER_EXTRA_PAYMENT = 'OTHER';
14
13
  export const EXTRA_PAYMENT_CATEGORIES = [STARTING_POINT_EXTRA_PAYMENT,
15
14
  END_POINT_EXTRA_PAYMENT,
16
- NATIONAL_PARK_FEEE_XTRA_PAYMENT,
15
+ NATIONAL_PARK_FEE_EXTRA_PAYMENT,
17
16
  PAX_EXTRA_PAYMENT,
18
17
  ADD_ON_EXTRA_PAYMENT,
19
18
  OTHER_EXTRA_PAYMENT];
@@ -135,18 +134,6 @@ export function getTotalAmountToBeReceived(booking) {
135
134
  return total;
136
135
  }
137
136
 
138
- export function getTotalOperatorNetPrice(booking) {
139
- let total;
140
-
141
- if (booking.operatorPaymentStatus === "No Charge") {
142
- total = 0;
143
- } else {
144
- total = booking.operatorNetPrice + calculateExtraPayments(booking, false);
145
- }
146
-
147
- return total;
148
- }
149
-
150
137
  export function calculateTotalPrice(booking, product, mode = "retail") {
151
138
  let total = calculateProductPrice(booking, product.pricing, mode);
152
139
  total += calculateStartEndPointPrice(booking, findStartingPoint(product, booking.startingPointId, false), mode === "retail" || mode === "partner");
@@ -190,6 +177,36 @@ export function calculateExtraPayments(booking, selling = true, calculationMode
190
177
  return total;
191
178
  }
192
179
 
180
+ export function getExtraPaymentsPaidWithPartner(booking, product) {
181
+ return [
182
+ {
183
+ category: STARTING_POINT_EXTRA_PAYMENT,
184
+ description: startingPoint.name,
185
+ price: calculateStartEndPointPrice(booking, startingPoint, true),
186
+ operatorPrice: calculateStartEndPointPrice(booking, startingPoint, false),
187
+ },
188
+ {
189
+ category: END_POINT_EXTRA_PAYMENT,
190
+ description: endPoint.name,
191
+ price: calculateStartEndPointPrice(booking, endPoint, true),
192
+ operatorPrice: calculateStartEndPointPrice(booking, endPoint, false),
193
+ },
194
+ {
195
+ category: NATIONAL_PARK_FEE_EXTRA_PAYMENT,
196
+ description: `Entrance fee to ${product.nationalPark?.title}`,
197
+ price: calculateNationalParkFee(booking, product),
198
+ operatorPrice: calculateNationalParkFee(booking, product),
199
+ },
200
+ ].filter(
201
+ (item) =>
202
+ (item.price > 0 || item.operatoPrice > 0) &&
203
+ Object.values(data.extraPayments ?? {}).find(
204
+ (extraPayment) =>
205
+ extraPayment.category === item.category && !item.disabled
206
+ ) == null
207
+ );
208
+ }
209
+
193
210
  export function calculateAddOnsPrice(booking, product, selling = true) {
194
211
  let total = 0;
195
212
  if (booking.addOns) {