thm-p3-configurator 0.0.254 → 0.0.256

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