tripstorekrabi-shared 1.13.13 → 1.13.15
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 +39 -12
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -112,11 +112,27 @@ export function countMaxPeople(pricing) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function getTotalAmountToBeReceived(booking) {
|
|
115
|
-
|
|
115
|
+
let total;
|
|
116
|
+
|
|
117
|
+
if (booking.customerPaymentStatus === "Refunded") {
|
|
118
|
+
total = 0;
|
|
119
|
+
} else {
|
|
120
|
+
total = calculateExtraPayments(booking, true);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return total;
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
export function getTotalOperatorNetPrice(booking) {
|
|
119
|
-
|
|
127
|
+
let total;
|
|
128
|
+
|
|
129
|
+
if (booking.operatorPaymentStatus === "No Charge") {
|
|
130
|
+
total = 0;
|
|
131
|
+
} else {
|
|
132
|
+
total = calculateExtraPayments(booking, false);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return total;
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
export function calculateTotalPrice(booking, product, mode = "retail") {
|
|
@@ -133,18 +149,29 @@ export function calculateNationalParkFee(booking, product) {
|
|
|
133
149
|
return booking.nationalParkFee === ALREADY_PAID && product.nationalPark ? product.nationalPark.pricing.adult * booking.adults + product.nationalPark.pricing.child * booking.children : 0;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
|
-
export function calculateExtraPayments(booking, selling = true,
|
|
152
|
+
export function calculateExtraPayments(booking, selling = true, calculationMode = false) {
|
|
137
153
|
let total = 0;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
total -=
|
|
143
|
-
}
|
|
144
|
-
|
|
154
|
+
for (const item of Object.values(booking.extraPayments ?? {}).filter((item) => !item.disabled)) {
|
|
155
|
+
if (selling) {
|
|
156
|
+
if (item.paymentMethod === PAY_ON_TOUR) {
|
|
157
|
+
if (calculationMode && item.category !== "OTHER") {
|
|
158
|
+
total -= item.price;
|
|
159
|
+
}
|
|
160
|
+
} else if (!calculationMode || item.category === "OTHER") {
|
|
161
|
+
total += item.receivedAmount ? item.receivedAmount : item.price;
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
if (item.paymentMethod === PAY_ON_TOUR) {
|
|
165
|
+
if (calculationMode && item.category !== "OTHER") {
|
|
166
|
+
total -= item.operatorPrice;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let ourCommission = item.price - item.operatorPrice;
|
|
170
|
+
if (ourCommission > 0) {
|
|
171
|
+
total -= ourCommission;
|
|
145
172
|
}
|
|
146
|
-
} else if (
|
|
147
|
-
total +=
|
|
173
|
+
} else if (!calculationMode || item.category === "OTHER") {
|
|
174
|
+
total += item.operatorPrice;
|
|
148
175
|
}
|
|
149
176
|
}
|
|
150
177
|
}
|