tripstorekrabi-shared 1.13.16 → 1.13.17

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 +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.16",
3
+ "version": "1.13.17",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -5,6 +5,18 @@ export const MAX_PAX = 30;
5
5
  export const PAY_ON_TOUR = 'Pay on tour';
6
6
  export const ALREADY_PAID = "Already paid";
7
7
  export const PAY_BEFORE = "Pay before";
8
+ export const STARTING_POINT_EXTRA_PAYMENT = 'STARTING POINT';
9
+ export const END_POINT_EXTRA_PAYMENT = 'END POINT';
10
+ export const NATIONAL_PARK_FEEE_XTRA_PAYMENT = 'NATIONAL PARK FEE';
11
+ export const PAX_EXTRA_PAYMENT = 'PAX';
12
+ export const ADD_ON_EXTRA_PAYMENT = 'ADD-ON';
13
+ export const OTHER_EXTRA_PAYMENT = 'OTHER';
14
+ export const EXTRA_PAYMENT_CATEGORIES = [STARTING_POINT_EXTRA_PAYMENT,
15
+ END_POINT_EXTRA_PAYMENT,
16
+ NATIONAL_PARK_FEEE_XTRA_PAYMENT,
17
+ PAX_EXTRA_PAYMENT,
18
+ ADD_ON_EXTRA_PAYMENT,
19
+ OTHER_EXTRA_PAYMENT];
8
20
 
9
21
  export function calculateProductPrice(booking, pricing, mode = "retail") {
10
22
  let type = pricing.type;
@@ -154,15 +166,15 @@ export function calculateExtraPayments(booking, selling = true, calculationMode
154
166
  for (const item of Object.values(booking.extraPayments ?? {}).filter((item) => !item.disabled)) {
155
167
  if (selling) {
156
168
  if (item.paymentMethod === PAY_ON_TOUR) {
157
- if (calculationMode && item.category !== "OTHER") {
169
+ if (calculationMode && item.category !== OTHER_EXTRA_PAYMENT) {
158
170
  total -= item.price;
159
171
  }
160
- } else if (!calculationMode || item.category === "OTHER") {
172
+ } else if (!calculationMode || item.category === OTHER_EXTRA_PAYMENT) {
161
173
  total += item.receivedAmount ? item.receivedAmount : item.price;
162
174
  }
163
175
  } else {
164
176
  if (item.paymentMethod === PAY_ON_TOUR) {
165
- if (calculationMode && item.category !== "OTHER") {
177
+ if (calculationMode && item.category !== OTHER_EXTRA_PAYMENT) {
166
178
  total -= item.operatorPrice;
167
179
  }
168
180
 
@@ -170,7 +182,7 @@ export function calculateExtraPayments(booking, selling = true, calculationMode
170
182
  if (ourCommission > 0) {
171
183
  total -= ourCommission;
172
184
  }
173
- } else if (!calculationMode || item.category === "OTHER") {
185
+ } else if (!calculationMode || item.category === OTHER_EXTRA_PAYMENT) {
174
186
  total += item.operatorPrice;
175
187
  }
176
188
  }