tripstorekrabi-shared 1.13.23 → 1.13.25

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 +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.23",
3
+ "version": "1.13.25",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -194,6 +194,22 @@ export function calculateExtraPayments(booking, selling = true, calculationMode
194
194
  export function getExtraPaymentsPaidWithPartner(booking, product) {
195
195
  let startingPoint = findStartingPoint(product, booking.startingPointId);
196
196
  let endPoint = findEndPoint(product, booking.endPointId);
197
+ let addOnDefs = {};
198
+ (product.addOns ?? []).forEach((addOn) => {
199
+ addOnDefs[addOn.id] = addOn;
200
+ });
201
+ let addOns = Object.keys(booking.addOns).filter((id) => addOnDefs[id] != null).map(([id, addOn]) => {
202
+ let addOnDef = addOnDefs[id];
203
+
204
+ return {
205
+ category: ADD_ON_EXTRA_PAYMENT,
206
+ description: addOnDef.title,
207
+ price: addOn.adults * addOnDef.pricing.adult.sellingPrice +
208
+ (addOn.children ?? 0) * addOnDef.pricing.child.sellingPrice,
209
+ operatorPrice: addOn.adults * addOnDef.pricing.adult.operatorNetPrice +
210
+ (addOn.children ?? 0) * addOnDef.pricing.child.operatorNetPrice
211
+ }
212
+ });
197
213
 
198
214
  return [
199
215
  {
@@ -214,6 +230,7 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
214
230
  price: calculateNationalParkFee(booking, product),
215
231
  operatorPrice: calculateNationalParkFee(booking, product),
216
232
  },
233
+ ...addOns
217
234
  ].filter(
218
235
  (item) =>
219
236
  (item.price > 0 || item.operatoPrice > 0) &&