tripstorekrabi-shared 1.13.47 → 1.13.49

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 +9 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tripstorekrabi-shared",
3
- "version": "1.13.47",
3
+ "version": "1.13.49",
4
4
  "description": "Shared library for Trip Store Krabi",
5
5
  "author": "Stefan Sommer <tonprince@gmail.com>",
6
6
  "repository": {
package/price.js CHANGED
@@ -22,15 +22,15 @@ const PARTNER_MODE = 1;
22
22
  const OPERATOR_MODE = 2;
23
23
 
24
24
  export function calculateProductSellingPrice(booking, pricing) {
25
- return calculateProductPrice(booking, pricing, { mode: SELLING_MODE });
25
+ return booking.customerPaymentStatus === "Refunded" ? 0 : calculateProductPrice(booking, pricing, { mode: SELLING_MODE });
26
26
  }
27
27
 
28
28
  export function calculateProductPartnerNetPrice(booking, pricing) {
29
- return calculateProductPrice(booking, pricing, { mode: PARTNER_MODE });
29
+ return booking.customerPaymentStatus === "Refunded" ? 0 : calculateProductPrice(booking, pricing, { mode: PARTNER_MODE });
30
30
  }
31
31
 
32
32
  export function calculateProductOperatorPrice(booking, pricing) {
33
- return calculateProductPrice(booking, pricing, { mode: OPERATOR_MODE });
33
+ return booking.operatorPaymentStatus === "No Charge" ? 0 : calculateProductPrice(booking, pricing, { mode: OPERATOR_MODE });
34
34
  }
35
35
 
36
36
  function calculateSellingPrice(commissionRate, price) {
@@ -139,15 +139,7 @@ export function countMaxPeople(pricing) {
139
139
  }
140
140
 
141
141
  export function getTotalAmountToBeReceived(booking, options = {}) {
142
- let total;
143
-
144
- if (booking.customerPaymentStatus === "Refunded") {
145
- total = 0;
146
- } else {
147
- total = booking.partnerNetPrice + calculateExtraPayments(booking, { mode: SELLING_MODE, ...options });
148
- }
149
-
150
- return total;
142
+ return booking.customerPaymentStatus === "Refunded" ? 0 : booking.partnerNetPrice + calculateExtraPayments(booking, { mode: SELLING_MODE, ...options })
151
143
  }
152
144
 
153
145
  export function calculatePartnerNetPrice(booking, product) {
@@ -164,15 +156,15 @@ export function calculatePartnerNetPrice(booking, product) {
164
156
  }
165
157
 
166
158
  export function calculateTotalSellingPrice(booking, product) {
167
- return calculateTotalPrice(booking, product, { mode: SELLING_MODE });
159
+ return booking.customerPaymentStatus === "Refunded" ? 0 : calculateTotalPrice(booking, product, { mode: SELLING_MODE });
168
160
  }
169
161
 
170
- export function calculateTotalOperatorPrice(booking, product) {
171
- return calculateTotalPrice(booking, product, { mode: OPERATOR_MODE });
162
+ export function calculateTotalPartnerNetPrice(booking, product) {
163
+ return booking.customerPaymentStatus === "Refunded" ? 0 : calculateTotalPrice(booking, product, { mode: PARTNER_MODE });
172
164
  }
173
165
 
174
- export function calculateTotalPartnerNetPrice(booking, product) {
175
- return calculateTotalPrice(booking, product, { mode: PARTNER_MODE });
166
+ export function calculateTotalOperatorPrice(booking, product) {
167
+ return booking.operatorPaymentStatus === "No Charge" ? 0 : calculateTotalPrice(booking, product, { mode: OPERATOR_MODE });
176
168
  }
177
169
 
178
170
  function calculateTotalPrice(booking, product, options = { mode: SELLING_MODE }) {