thm-p3-configurator 0.0.255 → 0.0.257
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.
|
@@ -184,6 +184,11 @@ const ProductCartTable = () => {
|
|
|
184
184
|
// Subtotal calculation variables
|
|
185
185
|
let mainProductsSubtotal = 0;
|
|
186
186
|
let accessoireProductsSubtotal = 0;
|
|
187
|
+
// Market correction values (prefer cart item, fallback to totals)
|
|
188
|
+
const marketCorrectionPurchaseExcl = Number(marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal) || 0;
|
|
189
|
+
const marketCorrectionSalesIncl = (marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.consumerTotal) != null ? Number(marketCorrection.consumerTotal) : Number(totals === null || totals === void 0 ? void 0 : totals.totalMarketCorrectionInclVat) || 0;
|
|
190
|
+
const marketCorrectionSalesExcl = (marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.consumerTotal) != null ? Number(marketCorrection.consumerTotal) / 1.21 : Number(totals === null || totals === void 0 ? void 0 : totals.totalMarketCorrectionExclVat) || 0;
|
|
191
|
+
const marketCorrectionMargin = marketCorrectionSalesExcl - marketCorrectionPurchaseExcl;
|
|
187
192
|
const calculatePurchaseSubtotal = products => {
|
|
188
193
|
return products.reduce((total, product) => {
|
|
189
194
|
var _product$priceInfo;
|
|
@@ -288,10 +293,10 @@ const ProductCartTable = () => {
|
|
|
288
293
|
mainProductsSubtotal = calculatePurchaseSubtotal(mainProducts);
|
|
289
294
|
accessoireProductsSubtotal = calculatePurchaseSubtotal(accessoireProducts);
|
|
290
295
|
}
|
|
291
|
-
const
|
|
296
|
+
const hasMarketCorrectionValue = marketCorrectionPurchaseExcl > 0 || marketCorrectionSalesExcl > 0 || marketCorrectionSalesIncl > 0;
|
|
297
|
+
const shouldIncludeMarketCorrection = isToggled && hasMarketCorrectionValue && marketCorrectionPurchaseExcl > 0;
|
|
292
298
|
if (shouldIncludeMarketCorrection) {
|
|
293
|
-
|
|
294
|
-
mainProductsSubtotal += marketCorrectionPrice;
|
|
299
|
+
mainProductsSubtotal += marketCorrectionPurchaseExcl;
|
|
295
300
|
}
|
|
296
301
|
if (isLoadingProducts) {
|
|
297
302
|
return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
|
|
@@ -389,26 +394,23 @@ const ProductCartTable = () => {
|
|
|
389
394
|
text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat),
|
|
390
395
|
className: 'cart__table-price text-end'
|
|
391
396
|
}])]
|
|
392
|
-
}),
|
|
397
|
+
}), isToggled && hasMarketCorrectionValue && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
|
|
393
398
|
productTitle: 'Marktcorrectie',
|
|
394
399
|
productImage: _montagePlaceholder.default,
|
|
395
|
-
extraCells: [{}, {}, {}, ...(
|
|
400
|
+
extraCells: [{}, {}, {}, ...(isTmg ? [{}, {
|
|
396
401
|
text: 'N.v.t.',
|
|
397
402
|
className: 'cart__table-price text-end'
|
|
398
403
|
}, {
|
|
399
|
-
text: (0, _helpers__.formatPrice)(
|
|
404
|
+
text: (0, _helpers__.formatPrice)(marketCorrectionSalesIncl),
|
|
400
405
|
className: 'cart__table-price text-end'
|
|
401
406
|
}] : [{
|
|
402
|
-
text: (
|
|
407
|
+
text: (0, _helpers__.formatPrice)(marketCorrectionMargin),
|
|
403
408
|
className: 'cart__table-price text-end'
|
|
404
409
|
}, {
|
|
405
|
-
text:
|
|
410
|
+
text: (0, _helpers__.formatPrice)(marketCorrectionPurchaseExcl),
|
|
406
411
|
className: 'cart__table-price text-end'
|
|
407
412
|
}, {
|
|
408
|
-
text:
|
|
409
|
-
className: 'cart__table-price text-end'
|
|
410
|
-
}] : [{}, {}, {
|
|
411
|
-
text: 'test',
|
|
413
|
+
text: (0, _helpers__.formatPrice)(marketCorrectionSalesExcl),
|
|
412
414
|
className: 'cart__table-price text-end'
|
|
413
415
|
}])]
|
|
414
416
|
}), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
|