thm-p3-configurator 0.0.258 → 0.0.259

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.
@@ -215,6 +215,8 @@ const ProductCartTable = () => {
215
215
  salesPriceIncl: 0
216
216
  };
217
217
  }
218
+ const hasLocationTotal = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== undefined && (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== null;
219
+ const locationTotal = hasLocationTotal ? Number(cartItem.locationTotal) : 0;
218
220
  if (!product) {
219
221
  return {
220
222
  purchasePrice: 0,
@@ -229,19 +231,22 @@ const ProductCartTable = () => {
229
231
 
230
232
  // TMG case: when TMG and toggled, show catalog price excl and verkoop prijs incl
231
233
  if (isTmg && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
234
+ var _product$locationPric, _ref2, _ref3, _cartItem$consumerTot, _product$consumerPric;
235
+ const purchasePrice = locationTotal || Number((product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0);
236
+ const salesPriceRaw = (_ref2 = (_ref3 = (_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 && _ref3 !== void 0 ? _ref3 : product === null || product === void 0 ? void 0 : product.price) !== null && _ref2 !== void 0 ? _ref2 : 0;
237
+ const salesPrice = salesPriceRaw && !Number.isNaN(Number(salesPriceRaw)) ? Number(salesPriceRaw) / 1.21 : 0;
238
+ const margin = salesPrice - purchasePrice;
232
239
  return {
233
- purchasePrice: 0,
234
- salesPrice: 0,
235
- margin: 0,
236
- hasLocationTotal: false,
240
+ purchasePrice,
241
+ salesPrice,
242
+ margin,
243
+ hasLocationTotal,
237
244
  catalogPriceExcl: product.consumerPrices.listPriceExclVat || 0,
238
245
  salesPriceIncl: product.consumerPrices.priceInclVat || 0
239
246
  };
240
247
  }
241
248
  let purchasePrice = 0;
242
249
  let salesPrice = 0;
243
- const hasLocationTotal = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== undefined && (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== null;
244
- const locationTotal = hasLocationTotal ? Number(cartItem.locationTotal) : 0;
245
250
 
246
251
  // Get prices directly from product objects
247
252
  if (APP_CONFIG.internal) {
@@ -325,6 +330,34 @@ const ProductCartTable = () => {
325
330
  const montageDisplayedTotalExclVat = isToggled && !isTmg ? Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) : 0;
326
331
  const marketCorrectionDisplayedTotalExclVat = isToggled && !isTmg && hasMarketCorrectionValue ? Number(marketCorrectionSalesExcl || 0) : 0;
327
332
  const trekhaakmontageSubtotalExclVat = displayedMainProductsTotalExclVat + montageDisplayedTotalExclVat + marketCorrectionDisplayedTotalExclVat;
333
+
334
+ // TMG subtotal helpers (excl. btw columns)
335
+ const tmgMainCatalogSubtotal = isTmg ? mainProducts.reduce((total, product) => {
336
+ var _product$priceInfo2;
337
+ return total + Number((product === null || product === void 0 || (_product$priceInfo2 = product.priceInfo) === null || _product$priceInfo2 === void 0 ? void 0 : _product$priceInfo2.catalogPriceExcl) || 0);
338
+ }, 0) : 0;
339
+ const tmgMainMarginSubtotal = isTmg ? mainProducts.reduce((total, product) => {
340
+ var _product$priceInfo3;
341
+ return total + Number((product === null || product === void 0 || (_product$priceInfo3 = product.priceInfo) === null || _product$priceInfo3 === void 0 ? void 0 : _product$priceInfo3.margin) || 0);
342
+ }, 0) + (isToggled && hasMarketCorrectionValue ? Number(marketCorrectionMargin || 0) : 0) : 0;
343
+ const tmgMainPurchaseSubtotal = isTmg ? mainProductsSubtotal : 0;
344
+ const tmgMainSalesSubtotal = isTmg ? mainProducts.reduce((total, product) => {
345
+ var _product$priceInfo4;
346
+ return total + Number((product === null || product === void 0 || (_product$priceInfo4 = product.priceInfo) === null || _product$priceInfo4 === void 0 ? void 0 : _product$priceInfo4.salesPrice) || 0);
347
+ }, 0) + Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) + (isToggled && hasMarketCorrectionValue ? Number(marketCorrectionSalesExcl || 0) : 0) : 0;
348
+ const tmgAccessoriesCatalogSubtotal = isTmg ? accessoireProducts.reduce((total, product) => {
349
+ var _product$priceInfo5;
350
+ return total + Number((product === null || product === void 0 || (_product$priceInfo5 = product.priceInfo) === null || _product$priceInfo5 === void 0 ? void 0 : _product$priceInfo5.catalogPriceExcl) || 0);
351
+ }, 0) : 0;
352
+ const tmgAccessoriesMarginSubtotal = isTmg ? accessoireProducts.reduce((total, product) => {
353
+ var _product$priceInfo6;
354
+ return total + Number((product === null || product === void 0 || (_product$priceInfo6 = product.priceInfo) === null || _product$priceInfo6 === void 0 ? void 0 : _product$priceInfo6.margin) || 0);
355
+ }, 0) : 0;
356
+ const tmgAccessoriesPurchaseSubtotal = isTmg ? accessoireProductsSubtotal : 0;
357
+ const tmgAccessoriesSalesSubtotal = isTmg ? accessoireProducts.reduce((total, product) => {
358
+ var _product$priceInfo7;
359
+ return total + Number((product === null || product === void 0 || (_product$priceInfo7 = product.priceInfo) === null || _product$priceInfo7 === void 0 ? void 0 : _product$priceInfo7.salesPrice) || 0);
360
+ }, 0) : 0;
328
361
  if (isLoadingProducts) {
329
362
  return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
330
363
  }
@@ -338,11 +371,17 @@ const ProductCartTable = () => {
338
371
  }, /*#__PURE__*/_react.default.createElement("table", {
339
372
  className: (0, _helpers__.withStyle)('cart__table table table-borderless align-middle')
340
373
  }, /*#__PURE__*/_react.default.createElement(_ProductTableHead.default, {
341
- columns: [{}, {}, {}, {}, ...(isToggled ? isTmg ? [{}, {
374
+ columns: [{}, {}, {}, {}, ...(isToggled ? isTmg ? [{
342
375
  text: 'Catalogprijs (excl. btw)',
343
376
  className: 'fw-bold text-end'
344
377
  }, {
345
- text: 'Verkoop Prijs (incl. btw)',
378
+ text: 'Marge (excl. btw)',
379
+ className: 'fw-bold text-end'
380
+ }, {
381
+ text: 'Inkoopprijs (excl. btw)',
382
+ className: 'fw-bold text-end'
383
+ }, {
384
+ text: 'Verkoop Prijs (excl. btw)',
346
385
  className: 'fw-bold text-end'
347
386
  }] : [{
348
387
  text: 'Marge (excl. btw)',
@@ -377,11 +416,17 @@ const ProductCartTable = () => {
377
416
  productImage: product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
378
417
  imageId: (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
379
418
  }) : _logoPrimary.default,
380
- extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
419
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{
381
420
  text: (0, _helpers__.formatPrice)(catalogPriceExcl),
382
421
  className: 'cart__table-price text-end'
383
422
  }, {
384
- text: (0, _helpers__.formatPrice)(salesPriceIncl),
423
+ text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
424
+ className: 'cart__table-price text-end'
425
+ }, {
426
+ text: hasLocationTotal ? (0, _helpers__.formatPrice)(purchasePrice) : 'N.v.t.',
427
+ className: 'cart__table-price text-end'
428
+ }, {
429
+ text: salesPrice > 0 ? (0, _helpers__.formatPrice)(salesPrice) : 'N.v.t.',
385
430
  className: 'cart__table-price text-end'
386
431
  }] : [{
387
432
  text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
@@ -401,11 +446,17 @@ const ProductCartTable = () => {
401
446
  productTitle: 'Montage',
402
447
  productSubtitle: (0, _helpers__.formatMontageTime)(totals === null || totals === void 0 ? void 0 : totals.montageTime),
403
448
  productImage: _montagePlaceholder.default,
404
- extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
449
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{
405
450
  text: 'N.v.t.',
406
451
  className: 'cart__table-price text-end'
407
452
  }, {
408
- text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.montagePriceInclVat),
453
+ text: 'N.v.t.',
454
+ className: 'cart__table-price text-end'
455
+ }, {
456
+ text: 'N.v.t.',
457
+ className: 'cart__table-price text-end'
458
+ }, {
459
+ text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat),
409
460
  className: 'cart__table-price text-end'
410
461
  }] : [{
411
462
  text: 'N.v.t.',
@@ -423,11 +474,17 @@ const ProductCartTable = () => {
423
474
  }), isToggled && hasMarketCorrectionValue && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
424
475
  productTitle: 'Marktcorrectie',
425
476
  productImage: _montagePlaceholder.default,
426
- extraCells: [{}, {}, {}, ...(isTmg ? [{}, {
477
+ extraCells: [{}, {}, {}, ...(isTmg ? [{
427
478
  text: 'N.v.t.',
428
479
  className: 'cart__table-price text-end'
429
480
  }, {
430
- text: (0, _helpers__.formatPrice)(marketCorrectionSalesIncl),
481
+ text: (0, _helpers__.formatPrice)(marketCorrectionMargin),
482
+ className: 'cart__table-price text-end'
483
+ }, {
484
+ text: (0, _helpers__.formatPrice)(marketCorrectionPurchaseExcl),
485
+ className: 'cart__table-price text-end'
486
+ }, {
487
+ text: (0, _helpers__.formatPrice)(marketCorrectionSalesExcl),
431
488
  className: 'cart__table-price text-end'
432
489
  }] : [{
433
490
  text: (0, _helpers__.formatPrice)(marketCorrectionMargin),
@@ -443,12 +500,18 @@ const ProductCartTable = () => {
443
500
  isEditable: true,
444
501
  editLabel: 'Wijzig je trekhaakpakket',
445
502
  editLink: '/configurator/trekhaakpakket',
446
- extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {
447
- text: '',
503
+ extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {}, {
504
+ text: (0, _helpers__.formatPrice)(tmgMainCatalogSubtotal),
448
505
  className: 'fw-bold text-end'
449
506
  }, {
450
- text: '',
507
+ text: (0, _helpers__.formatPrice)(tmgMainMarginSubtotal),
508
+ className: 'fw-bold text-end'
509
+ }, {
510
+ text: (0, _helpers__.formatPrice)(tmgMainPurchaseSubtotal),
451
511
  className: 'fw-bold text-end'
512
+ }, {
513
+ text: (0, _helpers__.formatPrice)(tmgMainSalesSubtotal),
514
+ className: 'fw-bold text-end pb-2'
452
515
  }] : [{
453
516
  text: '',
454
517
  className: 'fw-bold text-end'
@@ -496,11 +559,17 @@ const ProductCartTable = () => {
496
559
  productImage: product !== null && product !== void 0 && (_product$images3 = product.images) !== null && _product$images3 !== void 0 && _product$images3[0] ? (0, _image.getImageFromHyper)({
497
560
  imageId: (_product$images4 = product.images) === null || _product$images4 === void 0 ? void 0 : _product$images4[0]
498
561
  }) : _logoPrimary.default,
499
- extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
562
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{
500
563
  text: (0, _helpers__.formatPrice)(catalogPriceExcl),
501
564
  className: 'cart__table-price text-end'
502
565
  }, {
503
- text: (0, _helpers__.formatPrice)(salesPriceIncl),
566
+ text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
567
+ className: 'cart__table-price text-end'
568
+ }, {
569
+ text: hasLocationTotal ? (0, _helpers__.formatPrice)(purchasePrice) : 'N.v.t.',
570
+ className: 'cart__table-price text-end'
571
+ }, {
572
+ text: salesPrice > 0 ? (0, _helpers__.formatPrice)(salesPrice) : 'N.v.t.',
504
573
  className: 'cart__table-price text-end'
505
574
  }] : [{
506
575
  text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
@@ -536,12 +605,18 @@ const ProductCartTable = () => {
536
605
  });
537
606
  }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
538
607
  isEditable: false,
539
- extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {
540
- text: '',
608
+ extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {}, {
609
+ text: (0, _helpers__.formatPrice)(tmgAccessoriesCatalogSubtotal),
541
610
  className: 'fw-bold text-end'
542
611
  }, {
543
- text: '',
612
+ text: (0, _helpers__.formatPrice)(tmgAccessoriesMarginSubtotal),
544
613
  className: 'fw-bold text-end'
614
+ }, {
615
+ text: (0, _helpers__.formatPrice)(tmgAccessoriesPurchaseSubtotal),
616
+ className: 'fw-bold text-end'
617
+ }, {
618
+ text: (0, _helpers__.formatPrice)(tmgAccessoriesSalesSubtotal),
619
+ className: 'fw-bold text-end pb-2'
545
620
  }] : [{
546
621
  text: '',
547
622
  className: 'fw-bold text-end'
@@ -565,7 +640,7 @@ const ProductCartTable = () => {
565
640
  className: 'fw-bold text-end pb-2'
566
641
  }])]
567
642
  })), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
568
- rows: [[{}, {}, {}, ...(isToggled ? [{
643
+ rows: [[{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
569
644
  text: '',
570
645
  className: 'text-end pt-2'
571
646
  }, {
@@ -583,7 +658,7 @@ const ProductCartTable = () => {
583
658
  }] : [{
584
659
  text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalAfterDiscountExclVat),
585
660
  className: 'text-end pt-2'
586
- }])], [{}, {}, {}, ...(isToggled ? [{
661
+ }])], [{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
587
662
  text: '',
588
663
  className: 'text-end'
589
664
  }, {
@@ -601,7 +676,7 @@ const ProductCartTable = () => {
601
676
  }] : [{
602
677
  text: APP_CONFIG.internal ? (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalVatAfterDiscount) : (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalVatAfterDiscount),
603
678
  className: 'text-end'
604
- }])], [{}, {}, {}, ...(isToggled ? [{
679
+ }])], [{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
605
680
  text: '',
606
681
  className: 'fw-bold text-end'
607
682
  }, {
@@ -624,7 +699,7 @@ const ProductCartTable = () => {
624
699
  colSpan: "10",
625
700
  className: (0, _helpers__.withStyle)('pt-4 pb-2')
626
701
  }, /*#__PURE__*/_react.default.createElement("hr", null))), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
627
- rows: [[{}, {}, {}, ...(isToggled ? [{
702
+ rows: [[{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
628
703
  text: '',
629
704
  className: 'text-end text-success'
630
705
  }, {
@@ -639,7 +714,7 @@ const ProductCartTable = () => {
639
714
  }]), {
640
715
  text: "-".concat((0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.discountInclVat)),
641
716
  className: 'text-end text-success'
642
- }], [{}, {}, {}, ...(isToggled ? [{
717
+ }], [{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
643
718
  text: '',
644
719
  className: 'text-end'
645
720
  }, {
@@ -654,7 +729,7 @@ const ProductCartTable = () => {
654
729
  }]), {
655
730
  text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalAfterDiscountExclVat),
656
731
  className: 'text-end'
657
- }], [{}, {}, {}, ...(isToggled ? [{
732
+ }], [{}, {}, {}, ...(isToggled && isTmg ? [{}] : []), ...(isToggled ? [{
658
733
  text: '',
659
734
  className: 'fw-bold text-end'
660
735
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.258",
3
+ "version": "0.0.259",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",