thm-p3-configurator 0.0.306 → 0.0.308

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
6
+ exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
7
7
  /**
8
8
  * Display modes for the cart table:
9
9
  * - DEFAULT: No purchase prices shown (7 columns)
@@ -26,4 +26,7 @@ const CART_TABLE_BOLD_END_CLASS = exports.CART_TABLE_BOLD_END_CLASS = 'fw-bold t
26
26
  const VAT_RATE = exports.VAT_RATE = 1.21;
27
27
 
28
28
  /** Market correction article number */
29
- const MARKET_CORRECTION_ARTICLE_NUMBER = exports.MARKET_CORRECTION_ARTICLE_NUMBER = 'MC';
29
+ const MARKET_CORRECTION_ARTICLE_NUMBER = exports.MARKET_CORRECTION_ARTICLE_NUMBER = 'MC';
30
+
31
+ /** Extra price (Meerprijs) article number */
32
+ const EXTRA_PRICE_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = 'MEERPRIJS';
@@ -66,6 +66,7 @@ var _product = require("../__helpers__/product");
66
66
  var _useIsTmg = require("../__hooks__/useIsTmg");
67
67
  var _useIsTowmotive = require("../__hooks__/useIsTowmotive");
68
68
  var _InternalDiscountForm = _interopRequireDefault(require("./internal/InternalDiscountForm"));
69
+ var _InternalExtraPriceForm = _interopRequireDefault(require("./internal/InternalExtraPriceForm"));
69
70
  function _interopRequireDefault(e) {
70
71
  return e && e.__esModule ? e : {
71
72
  default: e
@@ -170,7 +171,8 @@ const ProductCartTable = () => {
170
171
  consumerDiscounts,
171
172
  touchedConsumerDiscounts,
172
173
  montageRate,
173
- isMontageTariffFixed
174
+ isMontageTariffFixed,
175
+ extraPriceAmount
174
176
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
175
177
 
176
178
  // Determine display mode
@@ -281,7 +283,8 @@ const ProductCartTable = () => {
281
283
  discountAmount,
282
284
  discountPercentage,
283
285
  formula,
284
- montageRate: (0, _montageRate.toApiMontageRate)(montageRate)
286
+ montageRate: (0, _montageRate.toApiMontageRate)(montageRate),
287
+ extraPriceAmount
285
288
  });
286
289
  const montageHours = Number(totals === null || totals === void 0 ? void 0 : totals.montageTime) || 0;
287
290
  const montageTotalExcl = Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0);
@@ -357,6 +360,18 @@ const ProductCartTable = () => {
357
360
 
358
361
  const cartLookup = (0, _react.useMemo)(() => cart ? Object.fromEntries(cart.map(item => [item.articleNumber, item])) : {}, [cart]);
359
362
  const marketCorrection = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === _cartTable.MARKET_CORRECTION_ARTICLE_NUMBER);
363
+ const extraPriceItem = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === _cartTable.EXTRA_PRICE_ARTICLE_NUMBER);
364
+ const extraPriceValues = (0, _react.useMemo)(() => {
365
+ const consumerTotal = Number(extraPriceItem === null || extraPriceItem === void 0 ? void 0 : extraPriceItem.consumerTotal) || 0;
366
+ const hasValue = consumerTotal !== 0;
367
+ const salesIncl = consumerTotal;
368
+ const salesExcl = consumerTotal / _cartTable.VAT_RATE;
369
+ return {
370
+ salesIncl,
371
+ salesExcl,
372
+ hasValue
373
+ };
374
+ }, [extraPriceItem]);
360
375
  const marketCorrectionValues = (0, _react.useMemo)(() => {
361
376
  const purchaseExcl = Number(marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal) || 0;
362
377
  const salesIncl = (marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.consumerTotal) != null ? Number(marketCorrection.consumerTotal) : Number(totals === null || totals === void 0 ? void 0 : totals.totalMarketCorrectionInclVat) || 0;
@@ -760,6 +775,30 @@ const ProductCartTable = () => {
760
775
  },
761
776
  defaultSubtotal: subtotals.accessories.inclVat
762
777
  }, showCatalogPrice)
778
+ })), extraPriceValues.hasValue && (isTowmotive || isTmg) && /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
779
+ heading: "Meerprijs"
780
+ }, /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
781
+ productTitle: "Meerprijs",
782
+ productImage: _montagePlaceholder.default,
783
+ extraCells: (0, _cartTable2.getExtraPriceCells)(displayMode, {
784
+ salesIncl: extraPriceValues.salesIncl,
785
+ salesExcl: extraPriceValues.salesExcl
786
+ }, showCatalogPrice)
787
+ }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
788
+ isEditable: false,
789
+ extraCells: (0, _cartTable2.getSectionTotalCells)(displayMode, {
790
+ tmgSubtotals: {
791
+ catalog: 0,
792
+ margin: extraPriceValues.salesExcl,
793
+ purchase: 0,
794
+ sales: extraPriceValues.salesExcl
795
+ },
796
+ standardSubtotals: {
797
+ purchase: 0,
798
+ sales: extraPriceValues.salesExcl
799
+ },
800
+ defaultSubtotal: extraPriceValues.salesIncl
801
+ }, showCatalogPrice)
763
802
  })), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
764
803
  rows: [(0, _cartTable2.getTotalRowCells)(displayMode, {
765
804
  label: 'Producten (excl. btw)',
@@ -794,6 +833,6 @@ const ProductCartTable = () => {
794
833
  value: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.totalAfterDiscountInclVat),
795
834
  className: 'fw-bold text-end'
796
835
  }, showCatalogPrice)]
797
- })))), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalDiscountForm.default, null)));
836
+ })))), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalDiscountForm.default, null), APP_CONFIG.internal && (isTowmotive || isTmg) && /*#__PURE__*/_react.default.createElement(_InternalExtraPriceForm.default, null)));
798
837
  };
799
838
  var _default = exports.default = ProductCartTable;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.parse-float.js");
4
+ require("core-js/modules/es.regexp.exec.js");
5
+ require("core-js/modules/es.regexp.to-string.js");
6
+ require("core-js/modules/es.string.replace.js");
7
+ require("core-js/modules/es.weak-map.js");
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+ require("core-js/modules/es.weak-map.js");
10
+ Object.defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ exports.default = void 0;
14
+ require("core-js/modules/es.parse-float.js");
15
+ require("core-js/modules/es.regexp.exec.js");
16
+ require("core-js/modules/es.regexp.to-string.js");
17
+ require("core-js/modules/es.string.replace.js");
18
+ require("core-js/modules/web.dom-collections.iterator.js");
19
+ var _react = _interopRequireWildcard(require("react"));
20
+ var _LinkButton = _interopRequireDefault(require("../../__components__/Buttons/LinkButton"));
21
+ var _PrimaryButton = _interopRequireDefault(require("../../__components__/Buttons/PrimaryButton"));
22
+ var _TextInput = _interopRequireDefault(require("../../__components__/Form/TextInput"));
23
+ var _OrderSessionContext = require("../../__context__/OrderSessionContext");
24
+ var _helpers__ = require("../../__helpers__");
25
+ function _interopRequireDefault(e) {
26
+ return e && e.__esModule ? e : {
27
+ default: e
28
+ };
29
+ }
30
+ function _getRequireWildcardCache(e) {
31
+ if ("function" != typeof WeakMap) return null;
32
+ var r = new WeakMap(),
33
+ t = new WeakMap();
34
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
35
+ return e ? t : r;
36
+ })(e);
37
+ }
38
+ function _interopRequireWildcard(e, r) {
39
+ if (!r && e && e.__esModule) return e;
40
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
41
+ default: e
42
+ };
43
+ var t = _getRequireWildcardCache(r);
44
+ if (t && t.has(e)) return t.get(e);
45
+ var n = {
46
+ __proto__: null
47
+ },
48
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
49
+ for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
50
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
51
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
52
+ }
53
+ return n.default = e, t && t.set(e, n), n;
54
+ }
55
+ const InternalExtraPriceForm = () => {
56
+ const [{
57
+ extraPriceAmount,
58
+ extraPriceDescription
59
+ }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
60
+ const [amount, setAmount] = (0, _react.useState)(extraPriceAmount || '');
61
+ const [description, setDescription] = (0, _react.useState)(extraPriceDescription || '');
62
+ (0, _react.useEffect)(() => {
63
+ setAmount(extraPriceAmount || '');
64
+ setDescription(extraPriceDescription || '');
65
+ }, [extraPriceAmount, extraPriceDescription]);
66
+ const handleAmountChange = value => {
67
+ // Allow positive and negative numbers
68
+ const sanitized = value === null || value === void 0 ? void 0 : value.toString().replace(/[^0-9.-]/g, '');
69
+ setAmount(sanitized);
70
+ };
71
+ const handleDescriptionChange = value => {
72
+ setDescription(value);
73
+ };
74
+ const handleSubmit = () => {
75
+ const parsedAmount = parseFloat(amount);
76
+ if (isNaN(parsedAmount)) return;
77
+ dispatch({
78
+ type: _OrderSessionContext.orderSessionActions.SET_EXTRA_PRICE,
79
+ payload: {
80
+ amount: parsedAmount,
81
+ description: description || ''
82
+ }
83
+ });
84
+ };
85
+ const handleClear = () => {
86
+ setAmount('');
87
+ setDescription('');
88
+ dispatch({
89
+ type: _OrderSessionContext.orderSessionActions.CLEAR_EXTRA_PRICE
90
+ });
91
+ };
92
+ const isApplied = extraPriceAmount !== null && extraPriceAmount !== undefined;
93
+ const canSubmit = amount !== '' && !isNaN(parseFloat(amount));
94
+ return /*#__PURE__*/_react.default.createElement("div", {
95
+ className: (0, _helpers__.withStyle)('mx-1 mt-4')
96
+ }, /*#__PURE__*/_react.default.createElement("h5", {
97
+ className: (0, _helpers__.withStyle)('mb-3')
98
+ }, "Meerprijs:"), /*#__PURE__*/_react.default.createElement("div", {
99
+ className: (0, _helpers__.withStyle)('d-flex flex-column gap-3')
100
+ }, /*#__PURE__*/_react.default.createElement("div", {
101
+ className: (0, _helpers__.withStyle)('d-flex gap-3 align-items-end')
102
+ }, /*#__PURE__*/_react.default.createElement("div", {
103
+ style: {
104
+ width: '150px'
105
+ }
106
+ }, /*#__PURE__*/_react.default.createElement("label", {
107
+ htmlFor: "extra-price-amount",
108
+ className: (0, _helpers__.withStyle)('form-label mb-1')
109
+ }, "Bedrag"), /*#__PURE__*/_react.default.createElement("input", {
110
+ id: "extra-price-amount",
111
+ name: "extra-price-amount",
112
+ type: "text",
113
+ value: amount,
114
+ onChange: e => handleAmountChange(e.target.value),
115
+ placeholder: "0.00",
116
+ className: (0, _helpers__.withStyle)('form-control')
117
+ })), /*#__PURE__*/_react.default.createElement("div", {
118
+ style: {
119
+ flex: 1
120
+ }
121
+ }, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
122
+ name: "extra-price-description",
123
+ label: "Opmerking",
124
+ placeholder: "Omschrijving meerprijs...",
125
+ value: description,
126
+ onChange: handleDescriptionChange,
127
+ isRequired: false
128
+ })), /*#__PURE__*/_react.default.createElement("div", {
129
+ className: (0, _helpers__.withStyle)('d-flex align-items-end gap-2')
130
+ }, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
131
+ isDisabled: !canSubmit,
132
+ onClick: handleSubmit,
133
+ label: "Toepassen",
134
+ isNarrow: true
135
+ }), /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
136
+ isDisabled: !isApplied,
137
+ onClick: handleClear,
138
+ label: "Verwijderen"
139
+ })))));
140
+ };
141
+ var _default = exports.default = InternalExtraPriceForm;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.symbol.description.js");
3
4
  require("core-js/modules/es.json.stringify.js");
4
5
  require("core-js/modules/es.weak-map.js");
5
6
  require("core-js/modules/esnext.iterator.constructor.js");
@@ -14,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
14
15
  value: true
15
16
  });
16
17
  exports.useOrderSession = exports.orderSessionActions = exports.OrderSessionController = void 0;
18
+ require("core-js/modules/es.symbol.description.js");
17
19
  require("core-js/modules/es.json.stringify.js");
18
20
  require("core-js/modules/esnext.iterator.constructor.js");
19
21
  require("core-js/modules/esnext.iterator.filter.js");
@@ -147,6 +149,8 @@ const INITIAL_ORDER_SESSION_STATE = {
147
149
  },
148
150
  discountAmount: null,
149
151
  discountPercentage: null,
152
+ extraPriceAmount: null,
153
+ extraPriceDescription: null,
150
154
  channel: {
151
155
  channelId: null,
152
156
  channelType: null
@@ -244,6 +248,8 @@ const orderSessionActions = exports.orderSessionActions = {
244
248
  SET_DISCOUNT_AMOUNT: 'SET_DISCOUNT_AMOUNT',
245
249
  SET_DISCOUNT_PERCENTAGE: 'SET_DISCOUNT_PERCENTAGE',
246
250
  CLEAR_DISCOUNT: 'CLEAR_DISCOUNT',
251
+ SET_EXTRA_PRICE: 'SET_EXTRA_PRICE',
252
+ CLEAR_EXTRA_PRICE: 'CLEAR_EXTRA_PRICE',
247
253
  SET_VEHICLE_CHASSIS_NUMBER: 'SET_VEHICLE_CHASSIS_NUMBER',
248
254
  SET_FRANCHISE_NAME: 'SET_FRANCHISE_NAME',
249
255
  SET_PRICE_CALCULATION_DATE: 'SET_PRICE_CALCULATION_DATE',
@@ -1039,6 +1045,24 @@ const orderSessionReducer = (state, action) => {
1039
1045
  discountAmount: null
1040
1046
  });
1041
1047
  }
1048
+ case orderSessionActions.SET_EXTRA_PRICE:
1049
+ {
1050
+ const {
1051
+ amount,
1052
+ description
1053
+ } = action.payload;
1054
+ return _objectSpread(_objectSpread({}, state), {}, {
1055
+ extraPriceAmount: amount,
1056
+ extraPriceDescription: description
1057
+ });
1058
+ }
1059
+ case orderSessionActions.CLEAR_EXTRA_PRICE:
1060
+ {
1061
+ return _objectSpread(_objectSpread({}, state), {}, {
1062
+ extraPriceAmount: null,
1063
+ extraPriceDescription: null
1064
+ });
1065
+ }
1042
1066
  case orderSessionActions.SET_FRANCHISE_NAME:
1043
1067
  {
1044
1068
  const {
@@ -5,7 +5,7 @@ require("core-js/modules/web.dom-collections.iterator.js");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.textCell = exports.priceCell = exports.getTotalRowCells = exports.getSectionTotalCells = exports.getMontageCells = exports.getMarketCorrectionCells = exports.getMainProductCells = exports.getDiscountRowCells = exports.getCartTableHeaderColumns = exports.getCartTableDisplayMode = exports.getAccessoryProductCells = exports.emptyCells = exports.emptyCell = void 0;
8
+ exports.textCell = exports.priceCell = exports.getTotalRowCells = exports.getSectionTotalCells = exports.getMontageCells = exports.getMarketCorrectionCells = exports.getMainProductCells = exports.getExtraPriceCells = exports.getDiscountRowCells = exports.getCartTableHeaderColumns = exports.getCartTableDisplayMode = exports.getAccessoryProductCells = exports.emptyCells = exports.emptyCell = void 0;
9
9
  require("core-js/modules/esnext.iterator.map.js");
10
10
  require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _cartTable = require("../__constants__/cartTable");
@@ -257,6 +257,45 @@ const getMarketCorrectionCells = exports.getMarketCorrectionCells = function get
257
257
  }
258
258
  };
259
259
 
260
+ /**
261
+ * Generate extra cells for extra price (Meerprijs) rows
262
+ * @param {string} displayMode - Current display mode
263
+ * @param {Object} values - Price values
264
+ * @param {number} values.salesIncl - Sales price incl VAT
265
+ * @param {number} values.salesExcl - Sales price excl VAT
266
+ * @param {boolean} showCatalogPrice - Whether to show the catalog price column
267
+ * @returns {Array} Array of cell configuration objects
268
+ */
269
+ const getExtraPriceCells = exports.getExtraPriceCells = function getExtraPriceCells(displayMode, _ref4) {
270
+ let {
271
+ salesIncl,
272
+ salesExcl
273
+ } = _ref4;
274
+ let showCatalogPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
275
+ const baseCells = [{}, {}, {}];
276
+ switch (displayMode) {
277
+ case _cartTable.CART_TABLE_DISPLAY_MODES.TOGGLED_TMG:
278
+ // TMG style: Inkoopprijs - Marge - [Catalogprijs] - Verkoopprijs
279
+ return [...baseCells, priceCell(0),
280
+ // Purchase price is 0
281
+ priceCell(salesExcl),
282
+ // Margin equals sales
283
+ ...(showCatalogPrice ? [textCell('N.v.t.', _cartTable.CART_TABLE_PRICE_CELL_CLASS)] : []), priceCell(salesExcl)];
284
+ case _cartTable.CART_TABLE_DISPLAY_MODES.TOGGLED_STANDARD:
285
+ // Standard style: Inkoopprijs - Marge - [Catalogprijs] - Korting% - Verkoopprijs
286
+ return [...baseCells, priceCell(0),
287
+ // Purchase price is 0
288
+ priceCell(salesExcl),
289
+ // Margin equals sales
290
+ ...(showCatalogPrice ? [textCell('N.v.t.', _cartTable.CART_TABLE_PRICE_CELL_CLASS)] : []), emptyCell(_cartTable.CART_TABLE_PRICE_CELL_CLASS),
291
+ // No discount for extra price
292
+ priceCell(salesExcl)];
293
+ default:
294
+ // Default mode: Just show price incl VAT (needs 2 empty cells before price to align)
295
+ return [...baseCells, {}, {}, priceCell(salesIncl)];
296
+ }
297
+ };
298
+
260
299
  /**
261
300
  * Generate extra cells for section total rows
262
301
  * @param {string} displayMode - Current display mode
@@ -267,12 +306,12 @@ const getMarketCorrectionCells = exports.getMarketCorrectionCells = function get
267
306
  * @param {boolean} showCatalogPrice - Whether to show the catalog price column (false for THC, true otherwise)
268
307
  * @returns {Array} Array of cell configuration objects
269
308
  */
270
- const getSectionTotalCells = exports.getSectionTotalCells = function getSectionTotalCells(displayMode, _ref4) {
309
+ const getSectionTotalCells = exports.getSectionTotalCells = function getSectionTotalCells(displayMode, _ref5) {
271
310
  let {
272
311
  tmgSubtotals,
273
312
  standardSubtotals,
274
313
  defaultSubtotal
275
- } = _ref4;
314
+ } = _ref5;
276
315
  let showCatalogPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
277
316
  const baseCells = [{}, {}];
278
317
  switch (displayMode) {
@@ -308,13 +347,13 @@ const getSectionTotalCells = exports.getSectionTotalCells = function getSectionT
308
347
  * @param {boolean} showCatalogPrice - Whether to show the catalog price column (false for THC, true otherwise)
309
348
  * @returns {Array} Array of cell configuration objects
310
349
  */
311
- const getTotalRowCells = exports.getTotalRowCells = function getTotalRowCells(displayMode, _ref5) {
350
+ const getTotalRowCells = exports.getTotalRowCells = function getTotalRowCells(displayMode, _ref6) {
312
351
  let {
313
352
  label,
314
353
  locationValue,
315
354
  consumerValue,
316
355
  className = 'text-end'
317
- } = _ref5;
356
+ } = _ref6;
318
357
  let showCatalogPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
319
358
  const baseCells = [{}, {}, {}];
320
359
  switch (displayMode) {
@@ -341,12 +380,12 @@ const getTotalRowCells = exports.getTotalRowCells = function getTotalRowCells(di
341
380
  * @param {boolean} showCatalogPrice - Whether to show the catalog price column (false for THC, true otherwise)
342
381
  * @returns {Array} Array of cell configuration objects
343
382
  */
344
- const getDiscountRowCells = exports.getDiscountRowCells = function getDiscountRowCells(displayMode, _ref6) {
383
+ const getDiscountRowCells = exports.getDiscountRowCells = function getDiscountRowCells(displayMode, _ref7) {
345
384
  let {
346
385
  label,
347
386
  value,
348
387
  className = 'text-end'
349
- } = _ref6;
388
+ } = _ref7;
350
389
  let showCatalogPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
351
390
  const baseCells = [{}, {}, {}];
352
391
  switch (displayMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.306",
3
+ "version": "0.0.308",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",