thm-p3-configurator 0.0.287 → 0.0.288

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.
@@ -345,6 +345,7 @@ const ProductCartTable = () => {
345
345
  };
346
346
  }, [marketCorrection, totals]);
347
347
  const getItemPrices = (cartItem, product) => {
348
+ var _product$consumerPric3, _product$consumerPric4;
348
349
  if (!cartItem) {
349
350
  return {
350
351
  purchasePrice: 0,
@@ -371,10 +372,10 @@ const ProductCartTable = () => {
371
372
  // TMG-style case (used for TOGGLED_TMG display mode)
372
373
  // This provides more robust price calculations with proper fallbacks
373
374
  if (useTmgDisplayMode && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
374
- var _product$locationPric, _ref, _ref2, _cartItem$consumerTot, _product$consumerPric;
375
+ var _product$locationPric, _ref, _ref2, _product$consumerPric, _product$consumerPric2;
375
376
  const purchasePrice = locationTotal || Number((product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0);
376
- const salesPriceRaw = (_ref = (_ref2 = (_cartItem$consumerTot = cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) !== null && _cartItem$consumerTot !== void 0 ? _cartItem$consumerTot : product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceInclVat) !== null && _ref2 !== void 0 ? _ref2 : product === null || product === void 0 ? void 0 : product.price) !== null && _ref !== void 0 ? _ref : 0;
377
- const salesPrice = salesPriceRaw && !Number.isNaN(Number(salesPriceRaw)) ? Number(salesPriceRaw) / _cartTable.VAT_RATE : 0;
377
+ const salesPriceRaw = (_ref = (_ref2 = (_product$consumerPric = product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.priceExclVat) !== null && _product$consumerPric !== void 0 ? _product$consumerPric : (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) != null ? Number(cartItem.consumerTotal) / _cartTable.VAT_RATE : null) !== null && _ref2 !== void 0 ? _ref2 : product === null || product === void 0 ? void 0 : product.price) !== null && _ref !== void 0 ? _ref : 0;
378
+ const salesPrice = salesPriceRaw && !Number.isNaN(Number(salesPriceRaw)) ? Number(salesPriceRaw) : 0;
378
379
  return {
379
380
  purchasePrice,
380
381
  salesPrice,
@@ -388,6 +389,7 @@ const ProductCartTable = () => {
388
389
  // Standard case
389
390
  let purchasePrice = 0;
390
391
  let salesPrice = 0;
392
+ let salesPriceIncl = 0;
391
393
  if (APP_CONFIG.internal) {
392
394
  purchasePrice = locationTotal;
393
395
  salesPrice = isToggled ? (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) / _cartTable.VAT_RATE : hasLocationTotal ? locationTotal : (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) || 0;
@@ -395,13 +397,16 @@ const ProductCartTable = () => {
395
397
  purchasePrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
396
398
  salesPrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
397
399
  }
400
+ const consumerPriceInclVat = (_product$consumerPric3 = product === null || product === void 0 || (_product$consumerPric4 = product.consumerPrices) === null || _product$consumerPric4 === void 0 ? void 0 : _product$consumerPric4.priceInclVat) !== null && _product$consumerPric3 !== void 0 ? _product$consumerPric3 : (cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) != null ? Number(cartItem.consumerTotal) : 0;
401
+ const salesPriceNumber = Number(salesPrice) || 0;
402
+ salesPriceIncl = consumerPriceInclVat > 0 ? Number(consumerPriceInclVat) : salesPriceNumber > 0 ? salesPriceNumber * _cartTable.VAT_RATE : 0;
398
403
  return {
399
404
  purchasePrice,
400
405
  salesPrice,
401
406
  margin: salesPrice - purchasePrice,
402
407
  hasLocationTotal,
403
408
  catalogPriceExcl: 0,
404
- salesPriceIncl: 0
409
+ salesPriceIncl
405
410
  };
406
411
  };
407
412
 
@@ -453,15 +458,21 @@ const ProductCartTable = () => {
453
458
  // Main products incl VAT (for default mode)
454
459
  const mainInclVat = !isToggled ? mainProducts.reduce((total, product) => {
455
460
  const {
461
+ salesPriceIncl,
456
462
  salesPrice
457
463
  } = product.priceInfo || {};
458
- if (!APP_CONFIG.internal) {
459
- const isVehicleCoding = (product === null || product === void 0 ? void 0 : product.subgroupName) === _constants__.VEHICLE_CODING_SUBGROUP_NAME || (product === null || product === void 0 ? void 0 : product.groupName) === _constants__.VEHICLE_CODING_SUBGROUP_NAME;
460
- if (!isVehicleCoding) return total;
461
- }
462
- return salesPrice > 0 ? total + Number(salesPrice) : total;
464
+ const resolvedIncl = salesPriceIncl || (salesPrice ? Number(salesPrice) * _cartTable.VAT_RATE : 0);
465
+ return resolvedIncl > 0 ? total + Number(resolvedIncl) : total;
463
466
  }, 0) : 0;
464
467
  const montageInclVat = !isToggled && APP_CONFIG.internal ? Number((totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat) || 0) : 0;
468
+ const accessoryInclVat = !isToggled ? accessoireProducts.reduce((total, product) => {
469
+ const {
470
+ salesPriceIncl,
471
+ salesPrice
472
+ } = product.priceInfo || {};
473
+ const resolvedIncl = salesPriceIncl || (salesPrice ? Number(salesPrice) * _cartTable.VAT_RATE : 0);
474
+ return resolvedIncl > 0 ? total + Number(resolvedIncl) : total;
475
+ }, 0) : 0;
465
476
 
466
477
  // Main products excl VAT (for toggled standard mode)
467
478
  // Use !useTmgDisplayMode to match the display mode logic (isTmg && !isTowFormula)
@@ -516,6 +527,7 @@ const ProductCartTable = () => {
516
527
  },
517
528
  accessories: {
518
529
  purchase: accessoryPurchase,
530
+ inclVat: accessoryInclVat,
519
531
  tmg: {
520
532
  catalog: accessoryTmgCatalog,
521
533
  margin: accessoryTmgMargin,
@@ -576,6 +588,7 @@ const ProductCartTable = () => {
576
588
 
577
589
  const showCatalogPrice = !isThc;
578
590
  const headerColumns = (0, _cartTable2.getCartTableHeaderColumns)(displayMode, showCatalogPrice);
591
+ console.log(mainProducts);
579
592
  const montageRateInputCell = isThc ? {} : {
580
593
  text: renderMontageRateInput(),
581
594
  className: _cartTable.CART_TABLE_PRICE_CELL_CLASS
@@ -713,7 +726,7 @@ const ProductCartTable = () => {
713
726
  purchase: subtotals.accessories.purchase,
714
727
  sales: totals === null || totals === void 0 ? void 0 : totals.totalExtrasExclVat
715
728
  },
716
- defaultSubtotal: APP_CONFIG.internal ? totals === null || totals === void 0 ? void 0 : totals.totalExtrasInclVat : (totals === null || totals === void 0 ? void 0 : totals.totalExtrasExclVat) * _cartTable.VAT_RATE
729
+ defaultSubtotal: subtotals.accessories.inclVat
717
730
  }, showCatalogPrice)
718
731
  })), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
719
732
  rows: [(0, _cartTable2.getTotalRowCells)(displayMode, {
@@ -138,7 +138,8 @@ const getMainProductCells = _ref => {
138
138
  case _cartTable.CART_TABLE_DISPLAY_MODES.DEFAULT:
139
139
  default:
140
140
  {
141
- const showPrice = APP_CONFIG.internal && salesPrice > 0 ? (0, _index.formatPrice)(salesPriceIncl || salesPrice) : isVehicleCodingProduct ? (0, _index.formatPrice)(salesPriceIncl || salesPrice) : '';
141
+ const resolvedPrice = Number(salesPriceIncl || salesPrice || 0);
142
+ const showPrice = resolvedPrice > 0 ? (0, _index.formatPrice)(resolvedPrice) : '';
142
143
  return [...baseCells, {}, {}, textCell(showPrice, _cartTable.CART_TABLE_PRICE_CELL_CLASS)];
143
144
  }
144
145
  }
@@ -183,7 +184,8 @@ const getAccessoryProductCells = _ref2 => {
183
184
  case _cartTable.CART_TABLE_DISPLAY_MODES.DEFAULT:
184
185
  default:
185
186
  {
186
- const showPrice = APP_CONFIG.internal && salesPrice > 0 ? (0, _index.formatPrice)(salesPriceIncl || salesPrice) : '';
187
+ const resolvedPrice = Number(salesPriceIncl || salesPrice || 0);
188
+ const showPrice = resolvedPrice > 0 ? (0, _index.formatPrice)(resolvedPrice) : '';
187
189
  return [...baseCells, {}, {}, textCell(showPrice, _cartTable.CART_TABLE_PRICE_CELL_CLASS)];
188
190
  }
189
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.287",
3
+ "version": "0.0.288",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",