thm-p3-configurator 0.0.286 → 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,
|
|
@@ -368,12 +369,13 @@ const ProductCartTable = () => {
|
|
|
368
369
|
};
|
|
369
370
|
}
|
|
370
371
|
|
|
371
|
-
// TMG case
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
// TMG-style case (used for TOGGLED_TMG display mode)
|
|
373
|
+
// This provides more robust price calculations with proper fallbacks
|
|
374
|
+
if (useTmgDisplayMode && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
|
|
375
|
+
var _product$locationPric, _ref, _ref2, _product$consumerPric, _product$consumerPric2;
|
|
374
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);
|
|
375
|
-
const salesPriceRaw = (_ref = (_ref2 = (
|
|
376
|
-
const salesPrice = salesPriceRaw && !Number.isNaN(Number(salesPriceRaw)) ? Number(salesPriceRaw)
|
|
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;
|
|
377
379
|
return {
|
|
378
380
|
purchasePrice,
|
|
379
381
|
salesPrice,
|
|
@@ -387,6 +389,7 @@ const ProductCartTable = () => {
|
|
|
387
389
|
// Standard case
|
|
388
390
|
let purchasePrice = 0;
|
|
389
391
|
let salesPrice = 0;
|
|
392
|
+
let salesPriceIncl = 0;
|
|
390
393
|
if (APP_CONFIG.internal) {
|
|
391
394
|
purchasePrice = locationTotal;
|
|
392
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;
|
|
@@ -394,13 +397,16 @@ const ProductCartTable = () => {
|
|
|
394
397
|
purchasePrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
|
|
395
398
|
salesPrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
|
|
396
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;
|
|
397
403
|
return {
|
|
398
404
|
purchasePrice,
|
|
399
405
|
salesPrice,
|
|
400
406
|
margin: salesPrice - purchasePrice,
|
|
401
407
|
hasLocationTotal,
|
|
402
408
|
catalogPriceExcl: 0,
|
|
403
|
-
salesPriceIncl
|
|
409
|
+
salesPriceIncl
|
|
404
410
|
};
|
|
405
411
|
};
|
|
406
412
|
|
|
@@ -435,7 +441,7 @@ const ProductCartTable = () => {
|
|
|
435
441
|
mainProducts: rawMainProducts.map(enhanceProduct),
|
|
436
442
|
accessoireProducts: rawAccessoireProducts.map(enhanceProduct)
|
|
437
443
|
};
|
|
438
|
-
}, [products, selectedTowbar, selectedCombiset, selectedCableset, selectedBoardComputer, selectedExtras, cartLookup, consumerDiscounts,
|
|
444
|
+
}, [products, selectedTowbar, selectedCombiset, selectedCableset, selectedBoardComputer, selectedExtras, cartLookup, consumerDiscounts, useTmgDisplayMode, isToggled]);
|
|
439
445
|
|
|
440
446
|
// Calculate subtotals
|
|
441
447
|
const subtotals = (0, _react.useMemo)(() => {
|
|
@@ -452,15 +458,21 @@ const ProductCartTable = () => {
|
|
|
452
458
|
// Main products incl VAT (for default mode)
|
|
453
459
|
const mainInclVat = !isToggled ? mainProducts.reduce((total, product) => {
|
|
454
460
|
const {
|
|
461
|
+
salesPriceIncl,
|
|
455
462
|
salesPrice
|
|
456
463
|
} = product.priceInfo || {};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (!isVehicleCoding) return total;
|
|
460
|
-
}
|
|
461
|
-
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;
|
|
462
466
|
}, 0) : 0;
|
|
463
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;
|
|
464
476
|
|
|
465
477
|
// Main products excl VAT (for toggled standard mode)
|
|
466
478
|
// Use !useTmgDisplayMode to match the display mode logic (isTmg && !isTowFormula)
|
|
@@ -473,30 +485,31 @@ const ProductCartTable = () => {
|
|
|
473
485
|
const montageExclVat = isToggled && !useTmgDisplayMode ? Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) : 0;
|
|
474
486
|
const marketCorrectionExclVat = isToggled && !useTmgDisplayMode && marketCorrectionValues.hasValue ? marketCorrectionValues.salesExcl : 0;
|
|
475
487
|
|
|
476
|
-
// TMG subtotals
|
|
477
|
-
|
|
488
|
+
// TMG-style subtotals (used for TOGGLED_TMG display mode)
|
|
489
|
+
// Calculate whenever useTmgDisplayMode is true (TMG users OR THC users without discount capability)
|
|
490
|
+
const tmgCatalog = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
|
|
478
491
|
var _p$priceInfo2;
|
|
479
492
|
return t + Number((p === null || p === void 0 || (_p$priceInfo2 = p.priceInfo) === null || _p$priceInfo2 === void 0 ? void 0 : _p$priceInfo2.catalogPriceExcl) || 0);
|
|
480
493
|
}, 0) : 0;
|
|
481
|
-
const tmgMargin =
|
|
494
|
+
const tmgMargin = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
|
|
482
495
|
var _p$priceInfo3;
|
|
483
496
|
return t + Number((p === null || p === void 0 || (_p$priceInfo3 = p.priceInfo) === null || _p$priceInfo3 === void 0 ? void 0 : _p$priceInfo3.margin) || 0);
|
|
484
497
|
}, 0) + (isToggled && marketCorrectionValues.hasValue ? marketCorrectionValues.margin : 0) : 0;
|
|
485
|
-
const tmgSales =
|
|
498
|
+
const tmgSales = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
|
|
486
499
|
var _p$priceInfo4;
|
|
487
500
|
return t + Number((p === null || p === void 0 || (_p$priceInfo4 = p.priceInfo) === null || _p$priceInfo4 === void 0 ? void 0 : _p$priceInfo4.salesPrice) || 0);
|
|
488
501
|
}, 0) + Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) + (isToggled && marketCorrectionValues.hasValue ? marketCorrectionValues.salesExcl : 0) : 0;
|
|
489
502
|
|
|
490
|
-
// Accessories TMG subtotals
|
|
491
|
-
const accessoryTmgCatalog =
|
|
503
|
+
// Accessories TMG-style subtotals
|
|
504
|
+
const accessoryTmgCatalog = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
|
|
492
505
|
var _p$priceInfo5;
|
|
493
506
|
return t + Number((p === null || p === void 0 || (_p$priceInfo5 = p.priceInfo) === null || _p$priceInfo5 === void 0 ? void 0 : _p$priceInfo5.catalogPriceExcl) || 0);
|
|
494
507
|
}, 0) : 0;
|
|
495
|
-
const accessoryTmgMargin =
|
|
508
|
+
const accessoryTmgMargin = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
|
|
496
509
|
var _p$priceInfo6;
|
|
497
510
|
return t + Number((p === null || p === void 0 || (_p$priceInfo6 = p.priceInfo) === null || _p$priceInfo6 === void 0 ? void 0 : _p$priceInfo6.margin) || 0);
|
|
498
511
|
}, 0) : 0;
|
|
499
|
-
const accessoryTmgSales =
|
|
512
|
+
const accessoryTmgSales = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
|
|
500
513
|
var _p$priceInfo7;
|
|
501
514
|
return t + Number((p === null || p === void 0 || (_p$priceInfo7 = p.priceInfo) === null || _p$priceInfo7 === void 0 ? void 0 : _p$priceInfo7.salesPrice) || 0);
|
|
502
515
|
}, 0) : 0;
|
|
@@ -514,6 +527,7 @@ const ProductCartTable = () => {
|
|
|
514
527
|
},
|
|
515
528
|
accessories: {
|
|
516
529
|
purchase: accessoryPurchase,
|
|
530
|
+
inclVat: accessoryInclVat,
|
|
517
531
|
tmg: {
|
|
518
532
|
catalog: accessoryTmgCatalog,
|
|
519
533
|
margin: accessoryTmgMargin,
|
|
@@ -522,7 +536,7 @@ const ProductCartTable = () => {
|
|
|
522
536
|
}
|
|
523
537
|
}
|
|
524
538
|
};
|
|
525
|
-
}, [mainProducts, accessoireProducts, marketCorrectionValues, isToggled,
|
|
539
|
+
}, [mainProducts, accessoireProducts, marketCorrectionValues, isToggled, useTmgDisplayMode, totals]);
|
|
526
540
|
|
|
527
541
|
// ============================================================================
|
|
528
542
|
// RENDER HELPERS
|
|
@@ -574,6 +588,7 @@ const ProductCartTable = () => {
|
|
|
574
588
|
|
|
575
589
|
const showCatalogPrice = !isThc;
|
|
576
590
|
const headerColumns = (0, _cartTable2.getCartTableHeaderColumns)(displayMode, showCatalogPrice);
|
|
591
|
+
console.log(mainProducts);
|
|
577
592
|
const montageRateInputCell = isThc ? {} : {
|
|
578
593
|
text: renderMontageRateInput(),
|
|
579
594
|
className: _cartTable.CART_TABLE_PRICE_CELL_CLASS
|
|
@@ -711,7 +726,7 @@ const ProductCartTable = () => {
|
|
|
711
726
|
purchase: subtotals.accessories.purchase,
|
|
712
727
|
sales: totals === null || totals === void 0 ? void 0 : totals.totalExtrasExclVat
|
|
713
728
|
},
|
|
714
|
-
defaultSubtotal:
|
|
729
|
+
defaultSubtotal: subtotals.accessories.inclVat
|
|
715
730
|
}, showCatalogPrice)
|
|
716
731
|
})), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
|
|
717
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
|
|
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
|
|
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
|
}
|