thm-p3-configurator 0.0.237 → 0.0.239
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.
|
@@ -155,11 +155,12 @@ const ProductCartSide = () => {
|
|
|
155
155
|
marginPercentage: 0
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
+
const hasLocationTotal = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== undefined && (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== null;
|
|
158
159
|
|
|
159
160
|
// Get prices directly from product objects and calculate excl VAT for location
|
|
160
|
-
const purchasePrice =
|
|
161
|
+
const purchasePrice = hasLocationTotal ? cartItem.locationTotal : 0;
|
|
161
162
|
const salesPrice = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) || 0;
|
|
162
|
-
const margin = salesPrice - purchasePrice;
|
|
163
|
+
const margin = hasLocationTotal ? salesPrice - purchasePrice : 0;
|
|
163
164
|
const marginPercentage = purchasePrice ? margin / purchasePrice * 100 : 0;
|
|
164
165
|
return {
|
|
165
166
|
purchasePrice,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require("core-js/modules/es.array.includes.js");
|
|
4
4
|
require("core-js/modules/es.array.reduce.js");
|
|
5
5
|
require("core-js/modules/es.json.stringify.js");
|
|
6
|
-
require("core-js/modules/es.parse-float.js");
|
|
7
6
|
require("core-js/modules/es.regexp.to-string.js");
|
|
8
7
|
require("core-js/modules/es.string.includes.js");
|
|
9
8
|
require("core-js/modules/es.weak-map.js");
|
|
@@ -23,7 +22,6 @@ exports.default = void 0;
|
|
|
23
22
|
require("core-js/modules/es.array.includes.js");
|
|
24
23
|
require("core-js/modules/es.array.reduce.js");
|
|
25
24
|
require("core-js/modules/es.json.stringify.js");
|
|
26
|
-
require("core-js/modules/es.parse-float.js");
|
|
27
25
|
require("core-js/modules/es.regexp.to-string.js");
|
|
28
26
|
require("core-js/modules/es.string.includes.js");
|
|
29
27
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
@@ -187,6 +185,12 @@ const ProductCartTable = () => {
|
|
|
187
185
|
// Subtotal calculation variables
|
|
188
186
|
let mainProductsSubtotal = 0;
|
|
189
187
|
let accessoireProductsSubtotal = 0;
|
|
188
|
+
const calculatePurchaseSubtotal = products => {
|
|
189
|
+
return products.reduce((total, product) => {
|
|
190
|
+
var _product$priceInfo;
|
|
191
|
+
return total + Number((product === null || product === void 0 || (_product$priceInfo = product.priceInfo) === null || _product$priceInfo === void 0 ? void 0 : _product$priceInfo.purchasePrice) || 0);
|
|
192
|
+
}, 0);
|
|
193
|
+
};
|
|
190
194
|
|
|
191
195
|
/**
|
|
192
196
|
* Calculate item prices from a cart item
|
|
@@ -233,11 +237,12 @@ const ProductCartTable = () => {
|
|
|
233
237
|
let purchasePrice = 0;
|
|
234
238
|
let salesPrice = 0;
|
|
235
239
|
const hasLocationTotal = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== undefined && (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== null;
|
|
240
|
+
const locationTotal = hasLocationTotal ? Number(cartItem.locationTotal) : 0;
|
|
236
241
|
|
|
237
242
|
// Get prices directly from product objects
|
|
238
243
|
if (APP_CONFIG.internal) {
|
|
239
|
-
purchasePrice =
|
|
240
|
-
salesPrice = isToggled ? (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) / 1.21 :
|
|
244
|
+
purchasePrice = locationTotal;
|
|
245
|
+
salesPrice = isToggled ? (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) / 1.21 : hasLocationTotal ? locationTotal : (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) || 0;
|
|
241
246
|
} else {
|
|
242
247
|
purchasePrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
|
|
243
248
|
salesPrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
|
|
@@ -281,14 +286,14 @@ const ProductCartTable = () => {
|
|
|
281
286
|
});
|
|
282
287
|
|
|
283
288
|
// Calculate subtotals based on locationTotal (purchasePrice)
|
|
284
|
-
mainProductsSubtotal = mainProducts
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
mainProductsSubtotal = calculatePurchaseSubtotal(mainProducts);
|
|
290
|
+
accessoireProductsSubtotal = calculatePurchaseSubtotal(accessoireProducts);
|
|
291
|
+
}
|
|
292
|
+
const shouldIncludeMarketCorrection = isToggled && (marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal);
|
|
293
|
+
if (shouldIncludeMarketCorrection) {
|
|
294
|
+
const marketCorrectionPrice = Number(marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal) || 0;
|
|
295
|
+
mainProductsSubtotal += marketCorrectionPrice;
|
|
290
296
|
}
|
|
291
|
-
mainProductsSubtotal = mainProductsSubtotal + (marketCorrection !== null && marketCorrection !== void 0 && marketCorrection.locationTotal ? parseFloat(marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal) : 0);
|
|
292
297
|
if (isLoadingProducts) {
|
|
293
298
|
return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
|
|
294
299
|
}
|