tripstorekrabi-shared 1.13.14 → 1.13.16

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 +10 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.14",
3
+ "version": "1.13.16",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -117,7 +117,7 @@ export function getTotalAmountToBeReceived(booking) {
117
117
  if (booking.customerPaymentStatus === "Refunded") {
118
118
  total = 0;
119
119
  } else {
120
- total = calculateExtraPayments(booking, true);
120
+ total = booking.partnerNetPrice + calculateExtraPayments(booking, true);
121
121
  }
122
122
 
123
123
  return total;
@@ -129,7 +129,7 @@ export function getTotalOperatorNetPrice(booking) {
129
129
  if (booking.operatorPaymentStatus === "No Charge") {
130
130
  total = 0;
131
131
  } else {
132
- total = calculateExtraPayments(booking, false);
132
+ total = booking.operatorNetPrice + calculateExtraPayments(booking, false);
133
133
  }
134
134
 
135
135
  return total;
@@ -151,27 +151,27 @@ export function calculateNationalParkFee(booking, product) {
151
151
 
152
152
  export function calculateExtraPayments(booking, selling = true, calculationMode = false) {
153
153
  let total = 0;
154
- for (const extraPayment of Object.values(booking.extraPayments ?? {}).filter((item) => !item.disabled)) {
154
+ for (const item of Object.values(booking.extraPayments ?? {}).filter((item) => !item.disabled)) {
155
155
  if (selling) {
156
- if (extraPayment.paymentMethod === PAY_ON_TOUR) {
156
+ if (item.paymentMethod === PAY_ON_TOUR) {
157
157
  if (calculationMode && item.category !== "OTHER") {
158
- total -= extraPayment.price;
158
+ total -= item.price;
159
159
  }
160
160
  } else if (!calculationMode || item.category === "OTHER") {
161
- total += extraPayment.receivedAmount ? extraPayment.receivedAmount : extraPayment.price;
161
+ total += item.receivedAmount ? item.receivedAmount : item.price;
162
162
  }
163
163
  } else {
164
- if (extraPayment.paymentMethod === PAY_ON_TOUR) {
164
+ if (item.paymentMethod === PAY_ON_TOUR) {
165
165
  if (calculationMode && item.category !== "OTHER") {
166
- total -= extraPayment.operatorPrice;
166
+ total -= item.operatorPrice;
167
167
  }
168
168
 
169
- let ourCommission = extraPayment.price - extraPayment.operatorPrice;
169
+ let ourCommission = item.price - item.operatorPrice;
170
170
  if (ourCommission > 0) {
171
171
  total -= ourCommission;
172
172
  }
173
173
  } else if (!calculationMode || item.category === "OTHER") {
174
- total += extraPayment.operatorPrice;
174
+ total += item.operatorPrice;
175
175
  }
176
176
  }
177
177
  }