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