thm-p3-configurator 0.0.112 → 0.0.113

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.
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports.default = void 0;
11
- var _TEST_ONLY_INTERNAL_ROUTES = _interopRequireDefault(require("./__pages__/internal/__TEST_ONLY_INTERNAL_ROUTES"));
12
11
  var _react = _interopRequireWildcard(require("react"));
13
12
  require("react-datepicker/src/stylesheets/datepicker-cssmodules.scss");
14
13
  var _reactGtmModule = _interopRequireDefault(require("react-gtm-module"));
@@ -26,9 +25,15 @@ var _FormulaContext = require("./__context__/FormulaContext");
26
25
  var _OrderSessionContext = require("./__context__/OrderSessionContext");
27
26
  var _cookiebot = require("./__helpers__/cookiebot");
28
27
  var _queryClient = _interopRequireDefault(require("./__helpers__/queryClient"));
28
+ var _index = _interopRequireDefault(require("./__pages__/index"));
29
29
  var _Experiments = _interopRequireDefault(require("./__services__/Experiments"));
30
30
  var _mainExternal = _interopRequireDefault(require("./__style__/main-external.scss"));
31
31
  var _main = _interopRequireDefault(require("./__style__/main.scss"));
32
+ function _interopRequireDefault(e) {
33
+ return e && e.__esModule ? e : {
34
+ default: e
35
+ };
36
+ }
32
37
  function _getRequireWildcardCache(e) {
33
38
  if ("function" != typeof WeakMap) return null;
34
39
  var r = new WeakMap(),
@@ -54,12 +59,7 @@ function _interopRequireWildcard(e, r) {
54
59
  }
55
60
  return n.default = e, t && t.set(e, n), n;
56
61
  }
57
- function _interopRequireDefault(e) {
58
- return e && e.__esModule ? e : {
59
- default: e
60
- };
61
- }
62
- // import Routes from './__pages__/index';
62
+ // import TEST_ONLY_INTERNAL_ROUTES from './__pages__/internal/__TEST_ONLY_INTERNAL_ROUTES';
63
63
 
64
64
  _reactGtmModule.default.initialize({
65
65
  gtmId: APP_CONFIG.googleTagManagerId || 'GTM-TC67SZ4'
@@ -76,6 +76,6 @@ const App = () => {
76
76
  defaultCountry: APP_CONFIG.country
77
77
  }, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
78
78
  client: _queryClient.default
79
- }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalBranchSelectorModal.default, null), APP_CONFIG.nodeEnv === 'development' && APP_CONFIG.internal === true && /*#__PURE__*/_react.default.createElement(_TEST_ONLY_INTERNAL_ROUTES.default, null))))))))));
79
+ }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalBranchSelectorModal.default, null), /*#__PURE__*/_react.default.createElement(_index.default, null))))))))));
80
80
  };
81
81
  var _default = exports.default = App;
@@ -75,7 +75,6 @@ const TextInput = _ref => {
75
75
  }, label, isRequired && /*#__PURE__*/_react.default.createElement("span", null, "*")), /*#__PURE__*/_react.default.createElement("input", {
76
76
  placeholder: placeholder,
77
77
  as: 'input',
78
- id: name,
79
78
  name: name,
80
79
  type: 'text',
81
80
  onClick: onClick,
@@ -32,6 +32,7 @@ require("core-js/modules/esnext.iterator.reduce.js");
32
32
  require("core-js/modules/web.dom-collections.iterator.js");
33
33
  var _react = _interopRequireWildcard(require("react"));
34
34
  var _logoPrimary = _interopRequireDefault(require("../../../public/assets/images/logo-primary.png"));
35
+ var _montagePlaceholder = _interopRequireDefault(require("../../../public/assets/images/montage-placeholder.png"));
35
36
  var _queries = require("../__api__/queries");
36
37
  var _TogglableCard = _interopRequireDefault(require("../__components__/Cards/TogglableCard"));
37
38
  var _ProductTableEditableRow = _interopRequireDefault(require("../__components__/ProductTable/ProductTableEditableRow"));
@@ -139,70 +140,197 @@ const ProductCartSide = () => {
139
140
  if (isLoadingProducts) {
140
141
  return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
141
142
  }
142
- const getItemPrice = cartItem => {
143
- var _product$consumerPric;
144
- if (!cartItem) return 0;
143
+
144
+ /**
145
+ * Calculate item prices from a cart item
146
+ * @param {Object} cartItem - Cart item object
147
+ * @return {Object} Calculated prices for the item
148
+ */
149
+ const getItemPrices = cartItem => {
150
+ var _product$locationPric, _product$consumerPric, _product$consumerPric2;
151
+ if (!cartItem) {
152
+ return {
153
+ purchasePrice: 0,
154
+ salesPrice: 0,
155
+ salesPriceInclVat: 0,
156
+ margin: 0,
157
+ marginPercentage: 0
158
+ };
159
+ }
145
160
 
146
161
  // Find the corresponding product
147
162
  const product = [...mainProducts, ...accessoireProducts].find(p => p.articleNumber === cartItem.articleNumber);
148
- if (isToggled) {
149
- var _product$locationPric;
150
- return ((product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0) * (cartItem.quantity || 1);
163
+ if (!product) {
164
+ return {
165
+ purchasePrice: 0,
166
+ salesPrice: 0,
167
+ salesPriceInclVat: 0,
168
+ margin: 0,
169
+ marginPercentage: 0
170
+ };
151
171
  }
152
- return cartItem.consumerTotal || ((product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceInclVat) || 0) * (cartItem.quantity || 1);
172
+
173
+ // Get prices directly from product objects
174
+ const purchasePrice = (product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0;
175
+ const salesPrice = (product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceExclVat) || 0;
176
+ const salesPriceInclVat = (product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.priceInclVat) || 0;
177
+ const margin = salesPrice - purchasePrice;
178
+ const marginPercentage = purchasePrice ? margin / purchasePrice * 100 : 0;
179
+ return {
180
+ purchasePrice,
181
+ salesPrice,
182
+ salesPriceInclVat,
183
+ margin,
184
+ marginPercentage: Math.round(marginPercentage * 100) / 100
185
+ };
153
186
  };
154
187
 
155
- // Calculate subtotal for products
156
- const subtotalPriceProducts = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
188
+ // ===== MAIN PRODUCTS PRICING =====
189
+ /**
190
+ * Calculate sum of main products price (excluding montage) including VAT
191
+ */
192
+ const mainProductsInclVat = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
157
193
  if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
158
- return acc + parseFloat(getItemPrice(item));
194
+ const {
195
+ salesPriceInclVat
196
+ } = getItemPrices(item);
197
+ return acc + salesPriceInclVat;
198
+ }
199
+ return acc;
200
+ }, 0)) || 0;
201
+
202
+ /**
203
+ * Calculate sum of main products price (excluding montage) excluding VAT
204
+ */
205
+ const mainProductsExclVat = mainProductsInclVat / 1.21;
206
+
207
+ /**
208
+ * Calculate sum of main products purchase price (excluding montage)
209
+ */
210
+ const mainProductsPurchase = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
211
+ if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
212
+ const {
213
+ purchasePrice
214
+ } = getItemPrices(item);
215
+ return acc + purchasePrice;
216
+ }
217
+ return acc;
218
+ }, 0)) || 0;
219
+
220
+ // ===== MONTAGE PRICING =====
221
+ /**
222
+ * Montage price including VAT
223
+ */
224
+ const montageInclVat = parseFloat(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat) || 0;
225
+
226
+ /**
227
+ * Montage price excluding VAT
228
+ */
229
+ const montageExclVat = parseFloat(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionExclVat) || 0;
230
+
231
+ // ===== ACCESSORIES PRICING =====
232
+ /**
233
+ * Calculate sum of accessories price including VAT
234
+ */
235
+ const accessoriesInclVat = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
236
+ if (accessoireProducts.find(product => product.articleNumber === item.articleNumber)) {
237
+ const {
238
+ salesPriceInclVat
239
+ } = getItemPrices(item);
240
+ const quantity = selectedExtras[item.articleNumber.toString()] || 1;
241
+ return acc + salesPriceInclVat * quantity;
159
242
  }
160
243
  return acc;
161
244
  }, 0)) || 0;
162
245
 
163
- // Calculate subtotal for accessories
164
- const subtotalPriceAccessoires = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
246
+ /**
247
+ * Calculate sum of accessories price excluding VAT
248
+ */
249
+ const accessoriesExclVat = accessoriesInclVat / 1.21;
250
+
251
+ /**
252
+ * Calculate sum of accessories purchase price
253
+ */
254
+ const accessoriesPurchase = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
165
255
  if (accessoireProducts.find(product => product.articleNumber === item.articleNumber)) {
166
- return acc + parseFloat(getItemPrice(item));
256
+ const {
257
+ purchasePrice
258
+ } = getItemPrices(item);
259
+ const quantity = selectedExtras[item.articleNumber.toString()] || 1;
260
+ return acc + purchasePrice * quantity;
167
261
  }
168
262
  return acc;
169
263
  }, 0)) || 0;
170
264
 
171
- // Calculate total discount
172
- const calculateTotalDiscount = () => {
173
- const totalPrice = subtotalPriceProducts + subtotalPriceAccessoires;
265
+ // ===== SUBTOTALS =====
266
+ /**
267
+ * Subtotal for main products + montage including VAT
268
+ */
269
+ const mainSubtotalInclVat = mainProductsInclVat + montageInclVat;
270
+
271
+ /**
272
+ * Subtotal for main products + montage excluding VAT
273
+ */
274
+ const mainSubtotalExclVat = mainProductsExclVat + montageExclVat;
275
+
276
+ // ===== TOTALS BEFORE DISCOUNT =====
277
+ /**
278
+ * Total purchase price (without montage)
279
+ */
280
+ const totalPurchase = mainProductsPurchase + accessoriesPurchase;
281
+
282
+ /**
283
+ * Total price excluding VAT
284
+ */
285
+ const totalExclVat = mainSubtotalExclVat + accessoriesExclVat;
286
+
287
+ /**
288
+ * Total price including VAT
289
+ */
290
+ const totalInclVat = mainSubtotalInclVat + accessoriesInclVat;
291
+
292
+ /**
293
+ * VAT amount
294
+ */
295
+ const totalVat = totalInclVat - totalExclVat;
296
+
297
+ // ===== DISCOUNT CALCULATIONS =====
298
+ /**
299
+ * Calculate discount amount
300
+ */
301
+ const getDiscountAmount = () => {
174
302
  if (discountPercentage) {
175
- return totalPrice * discountPercentage / 100;
303
+ return totalInclVat * discountPercentage / 100;
176
304
  }
177
305
  if (discountAmount) {
178
306
  return discountAmount;
179
307
  }
180
308
  return 0;
181
309
  };
310
+ const discountTotal = getDiscountAmount();
311
+ const discountExclVat = discountTotal / 1.21;
312
+ const discountVat = discountTotal - discountExclVat;
182
313
 
183
- // Calculate original total
184
- const calculateOriginalTotal = () => {
185
- return subtotalPriceProducts + subtotalPriceAccessoires;
186
- };
314
+ // ===== TOTALS AFTER DISCOUNT =====
315
+ /**
316
+ * Final price excluding VAT (after discount)
317
+ */
318
+ const finalExclVat = Math.max(0, totalExclVat - discountExclVat);
187
319
 
188
- // Calculate final totals
189
- const calculateFinalTotals = () => {
190
- const totalDiscount = calculateTotalDiscount();
191
- const originalTotal = calculateOriginalTotal();
320
+ /**
321
+ * Final VAT amount (after discount)
322
+ */
323
+ const finalVat = Math.max(0, totalVat - discountVat);
192
324
 
193
- // Calculate the proportion of the discount that applies to the excl. VAT amount
194
- const discountExclVat = totalDiscount / 1.21; // Remove VAT from discount
195
- const discountVat = totalDiscount - discountExclVat;
196
- const baseExclVat = originalTotal / 1.21; // Original price excl VAT
197
- const baseVat = originalTotal - baseExclVat; // Original VAT amount
325
+ /**
326
+ * Final price including VAT (after discount)
327
+ */
328
+ const finalInclVat = Math.max(0, totalInclVat - discountTotal);
198
329
 
199
- return {
200
- exclVat: Math.max(0, baseExclVat - discountExclVat),
201
- vat: Math.max(0, baseVat - discountVat),
202
- total: Math.max(0, originalTotal - totalDiscount),
203
- originalTotal
204
- };
205
- };
330
+ /**
331
+ * Final purchase price after discount
332
+ */
333
+ const finalPurchase = Math.max(0, totalPurchase - discountExclVat * totalPurchase / totalExclVat);
206
334
  return /*#__PURE__*/_react.default.createElement("div", {
207
335
  className: (0, _helpers__.withStyle)("col-lg mt-3")
208
336
  }, /*#__PURE__*/_react.default.createElement(_TogglableCard.default, {
@@ -225,30 +353,50 @@ const ProductCartSide = () => {
225
353
  heading: 'Trekhaakmontage'
226
354
  }, mainProducts.map(product => {
227
355
  var _product$images, _product$images2;
356
+ const cartItem = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber);
357
+ const {
358
+ purchasePrice,
359
+ salesPriceInclVat
360
+ } = getItemPrices(cartItem);
228
361
  return /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
229
362
  key: product.articleNumber,
230
- productTitle: product.name || product.subgroupName,
363
+ productTitle: product.name || product.title || product.subgroupName,
231
364
  productImage: product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
232
365
  imageId: (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
233
366
  }) : _logoPrimary.default,
234
367
  extraCells: [{}, {
235
- text: (0, _helpers__.formatPrice)(getItemPrice(cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber)) || 0),
368
+ text: (0, _helpers__.formatPrice)(isToggled ? purchasePrice : salesPriceInclVat),
236
369
  className: 'cart__table-purchase-price text-end'
237
370
  }]
238
371
  });
372
+ }), /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
373
+ productTitle: "Montage",
374
+ productImage: _montagePlaceholder.default,
375
+ extraCells: [{}, {
376
+ text: isToggled ? montageExclVat > 0 ? (0, _helpers__.formatPrice)(montageExclVat) : 'N.v.t.' : (0, _helpers__.formatPrice)(montageInclVat),
377
+ className: 'cart__table-purchase-price text-end'
378
+ }]
239
379
  }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
240
- isEditable: false,
380
+ isEditable: true,
381
+ editLabel: 'Wijzig je trekhaakpakket',
382
+ editLink: '/configurator/trekhaakpakket',
241
383
  extraCells: [{}, {
242
384
  text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
243
385
  className: 'fw-bold text-end pb-2'
244
386
  }, {
245
- text: (0, _helpers__.formatPrice)(subtotalPriceProducts),
387
+ text: (0, _helpers__.formatPrice)(isToggled ? mainSubtotalExclVat : mainSubtotalInclVat),
246
388
  className: 'fw-bold text-end pb-2'
247
389
  }]
248
390
  })), accessoireProducts.length > 0 && /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
249
391
  heading: 'Toebehoren'
250
392
  }, accessoireProducts.map(product => {
251
393
  var _product$images3, _product$images4;
394
+ const cartItem = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber);
395
+ const {
396
+ purchasePrice,
397
+ salesPriceInclVat
398
+ } = getItemPrices(cartItem);
399
+ const quantity = selectedExtras[product.articleNumber] || 1;
252
400
  return /*#__PURE__*/_react.default.createElement(_ProductTableEditableRow.default, {
253
401
  key: product.articleNumber,
254
402
  productTitle: product.name,
@@ -256,7 +404,7 @@ const ProductCartSide = () => {
256
404
  imageId: (_product$images4 = product.images) === null || _product$images4 === void 0 ? void 0 : _product$images4[0]
257
405
  }) : _logoPrimary.default,
258
406
  extraCells: [{}, {
259
- text: (0, _helpers__.formatPrice)(getItemPrice(cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber)) || 0),
407
+ text: (0, _helpers__.formatPrice)(isToggled ? purchasePrice * quantity : salesPriceInclVat * quantity),
260
408
  className: 'cart__table-purchase-price text-end'
261
409
  }],
262
410
  productAmount: selectedExtras[product.articleNumber],
@@ -285,41 +433,29 @@ const ProductCartSide = () => {
285
433
  text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
286
434
  className: 'fw-bold text-end pb-2'
287
435
  }, {
288
- text: (0, _helpers__.formatPrice)(subtotalPriceAccessoires),
436
+ text: (0, _helpers__.formatPrice)(isToggled ? accessoriesExclVat : accessoriesInclVat),
289
437
  className: 'fw-bold text-end pb-2'
290
438
  }]
291
439
  })), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
292
- rows: [...(isToggled ? [[{}, {
440
+ rows: [[{}, {
293
441
  text: 'Producten (excl. btw)',
294
442
  className: 'text-end pt-2'
295
443
  }, {
296
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
444
+ text: (0, _helpers__.formatPrice)(totalExclVat),
297
445
  className: 'text-end pt-2'
298
- }], [{}, {
446
+ }], ...(isToggled ? [[{}, {
299
447
  text: 'btw',
300
448
  className: 'text-end'
301
449
  }, {
302
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
450
+ text: (0, _helpers__.formatPrice)(totalVat),
303
451
  className: 'text-end'
304
- }], [{}, {
305
- text: 'Totaal (incl. btw)',
306
- className: 'fw-bold text-end'
307
- }, {
308
- text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
309
- className: 'fw-bold text-end'
310
- }]] : [[{}, {
311
- text: 'Producten (excl. btw)',
312
- className: 'text-end pt-2'
313
- }, {
314
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
315
- className: 'text-end pt-2'
316
- }], [{}, {
452
+ }]] : []), [{}, {
317
453
  text: 'Totaal (incl. btw)',
318
454
  className: 'fw-bold text-end'
319
455
  }, {
320
- text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
456
+ text: (0, _helpers__.formatPrice)(totalInclVat),
321
457
  className: 'fw-bold text-end'
322
- }]])]
458
+ }]]
323
459
  }), (discountAmount || discountPercentage) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
324
460
  colSpan: "3",
325
461
  className: (0, _helpers__.withStyle)('pt-4 pb-2')
@@ -328,25 +464,25 @@ const ProductCartSide = () => {
328
464
  text: discountPercentage ? "Correctie (".concat(discountPercentage, "%)") : 'Correctie',
329
465
  className: 'text-end text-success'
330
466
  }, {
331
- text: "-".concat((0, _helpers__.formatPrice)(calculateTotalDiscount())),
467
+ text: "-".concat((0, _helpers__.formatPrice)(discountTotal)),
332
468
  className: 'text-end text-success'
333
- }], ...(isToggled ? [[{}, {
469
+ }], [{}, {
334
470
  text: 'Totaal na correctie (excl. btw)',
335
471
  className: 'text-end'
336
472
  }, {
337
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
473
+ text: (0, _helpers__.formatPrice)(finalExclVat),
338
474
  className: 'text-end'
339
- }], [{}, {
340
- text: 'Correctie btw',
475
+ }], ...(isToggled ? [[{}, {
476
+ text: 'btw',
341
477
  className: 'text-end'
342
478
  }, {
343
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
479
+ text: (0, _helpers__.formatPrice)(finalVat),
344
480
  className: 'text-end'
345
481
  }]] : []), [{}, {
346
482
  text: 'Totaal na correctie (incl. btw)',
347
483
  className: 'fw-bold text-end'
348
484
  }, {
349
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().total),
485
+ text: (0, _helpers__.formatPrice)(finalInclVat),
350
486
  className: 'fw-bold text-end'
351
487
  }]]
352
488
  }))))));
@@ -3,6 +3,7 @@
3
3
  require("core-js/modules/es.array.includes.js");
4
4
  require("core-js/modules/es.array.reduce.js");
5
5
  require("core-js/modules/es.json.stringify.js");
6
+ require("core-js/modules/es.parse-float.js");
6
7
  require("core-js/modules/es.regexp.to-string.js");
7
8
  require("core-js/modules/es.string.includes.js");
8
9
  require("core-js/modules/es.weak-map.js");
@@ -20,6 +21,7 @@ exports.default = void 0;
20
21
  require("core-js/modules/es.array.includes.js");
21
22
  require("core-js/modules/es.array.reduce.js");
22
23
  require("core-js/modules/es.json.stringify.js");
24
+ require("core-js/modules/es.parse-float.js");
23
25
  require("core-js/modules/es.regexp.to-string.js");
24
26
  require("core-js/modules/es.string.includes.js");
25
27
  require("core-js/modules/esnext.iterator.constructor.js");
@@ -140,20 +142,49 @@ const ProductCartTable = () => {
140
142
  if (isLoadingProducts) {
141
143
  return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
142
144
  }
145
+
146
+ /**
147
+ * Calculate item prices from a cart item
148
+ * @param {Object} cartItem - Cart item object
149
+ * @return {Object} Calculated prices for the item
150
+ */
143
151
  const getItemPrices = cartItem => {
144
- var _product$locationPric, _product$consumerPric;
145
- if (!cartItem) return {
146
- purchasePrice: 0,
147
- salesPrice: 0,
148
- salesPriceInclVat: 0,
149
- margin: 0
150
- };
152
+ if (!cartItem) {
153
+ return {
154
+ purchasePrice: 0,
155
+ salesPrice: 0,
156
+ salesPriceInclVat: 0,
157
+ margin: 0,
158
+ marginPercentage: 0
159
+ };
160
+ }
151
161
 
152
162
  // Find the corresponding product
153
163
  const product = [...mainProducts, ...accessoireProducts].find(p => p.articleNumber === cartItem.articleNumber);
154
- const purchasePrice = (product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0;
155
- const salesPrice = (product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceExclVat) || cartItem.consumerTotal / 1.21 || 0;
156
- const salesPriceInclVat = salesPrice * 1.21;
164
+ if (!product) {
165
+ return {
166
+ purchasePrice: 0,
167
+ salesPrice: 0,
168
+ salesPriceInclVat: 0,
169
+ margin: 0,
170
+ marginPercentage: 0
171
+ };
172
+ }
173
+ let purchasePrice = 0;
174
+ let salesPrice = 0;
175
+ let salesPriceInclVat = 0;
176
+
177
+ // Get prices directly from product objects
178
+ if (APP_CONFIG.internal) {
179
+ var _product$locationPric, _product$consumerPric, _product$consumerPric2;
180
+ purchasePrice = (product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0;
181
+ salesPrice = (product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceExclVat) || 0;
182
+ salesPriceInclVat = (product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.priceInclVat) || 0;
183
+ } else {
184
+ purchasePrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
185
+ salesPrice = (product === null || product === void 0 ? void 0 : product.price) || 0;
186
+ salesPriceInclVat = (product === null || product === void 0 ? void 0 : product.price) || 0;
187
+ }
157
188
  const margin = salesPrice - purchasePrice;
158
189
  const marginPercentage = purchasePrice ? margin / purchasePrice * 100 : 0;
159
190
  return {
@@ -165,68 +196,154 @@ const ProductCartTable = () => {
165
196
  };
166
197
  };
167
198
 
168
- // Calculate subtotal for main products
169
- let subtotalPriceProducts = 0;
170
- if (isToggled) {
171
- subtotalPriceProducts = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
172
- if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
173
- const {
174
- salesPrice
175
- } = getItemPrices(item);
176
- return acc + salesPrice * 1.21;
177
- }
178
- return acc;
179
- }, 0)) || 0;
180
- } else {
181
- subtotalPriceProducts = subtotalPriceProducts + (isToggled ? totals === null || totals === void 0 ? void 0 : totals.subtotalMontagePurchaseExclVat : (totals === null || totals === void 0 ? void 0 : totals.subtotalMontageExclVat) * 1.21);
182
- }
199
+ // ===== MAIN PRODUCTS PRICING =====
200
+ /**
201
+ * Calculate sum of main products price (excluding montage) including VAT
202
+ */
203
+ const mainProductsInclVat = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
204
+ if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
205
+ const {
206
+ salesPriceInclVat
207
+ } = getItemPrices(item);
208
+ return acc + salesPriceInclVat;
209
+ }
210
+ return acc;
211
+ }, 0)) || 0;
212
+
213
+ /**
214
+ * Calculate sum of main products price (excluding montage) excluding VAT
215
+ */
216
+ const mainProductsExclVat = mainProductsInclVat / 1.21;
217
+
218
+ /**
219
+ * Calculate sum of main products purchase price (excluding montage)
220
+ */
221
+ const mainProductsPurchase = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
222
+ if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
223
+ const {
224
+ purchasePrice
225
+ } = getItemPrices(item);
226
+ return acc + purchasePrice;
227
+ }
228
+ return acc;
229
+ }, 0)) || 0;
183
230
 
184
- // Calculate subtotal for accessories
185
- const subtotalPriceAccessoires = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
231
+ // ===== MONTAGE PRICING =====
232
+ /**
233
+ * Montage price including VAT
234
+ */
235
+ const montageInclVat = parseFloat(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat) || 0;
236
+
237
+ /**
238
+ * Montage price excluding VAT
239
+ */
240
+ const montageExclVat = parseFloat(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionExclVat) || 0;
241
+
242
+ // ===== ACCESSORIES PRICING =====
243
+ /**
244
+ * Calculate sum of accessories price including VAT
245
+ */
246
+ const accessoriesInclVat = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
186
247
  if (accessoireProducts.find(product => product.articleNumber === item.articleNumber)) {
187
248
  const {
188
- salesPrice
249
+ salesPriceInclVat
189
250
  } = getItemPrices(item);
190
- return acc + salesPrice * 1.21;
251
+ const quantity = selectedExtras[item.articleNumber.toString()] || 1;
252
+ return acc + salesPriceInclVat * quantity;
191
253
  }
192
254
  return acc;
193
255
  }, 0)) || 0;
194
256
 
195
- // Calculate total discount
196
- const calculateTotalDiscount = () => {
197
- const totalPrice = subtotalPriceProducts + subtotalPriceAccessoires;
257
+ /**
258
+ * Calculate sum of accessories price excluding VAT
259
+ */
260
+ const accessoriesExclVat = accessoriesInclVat / 1.21;
261
+
262
+ /**
263
+ * Calculate sum of accessories purchase price
264
+ */
265
+ const accessoriesPurchase = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
266
+ if (accessoireProducts.find(product => product.articleNumber === item.articleNumber)) {
267
+ const {
268
+ purchasePrice
269
+ } = getItemPrices(item);
270
+ const quantity = selectedExtras[item.articleNumber.toString()] || 1;
271
+ return acc + purchasePrice * quantity;
272
+ }
273
+ return acc;
274
+ }, 0)) || 0;
275
+
276
+ // ===== SUBTOTALS =====
277
+ /**
278
+ * Subtotal for main products + montage including VAT
279
+ */
280
+ const mainSubtotalInclVat = APP_CONFIG.internal ? mainProductsInclVat + montageInclVat : totals.totalAfterDiscountInclVat;
281
+
282
+ /**
283
+ * Subtotal for main products + montage excluding VAT
284
+ */
285
+ const mainSubtotalExclVat = APP_CONFIG.internal ? mainProductsExclVat + montageExclVat : totals.totalAfterDiscountExclVat;
286
+
287
+ // ===== TOTALS BEFORE DISCOUNT =====
288
+ /**
289
+ * Total purchase price (without montage)
290
+ */
291
+ const totalPurchase = mainProductsPurchase + accessoriesPurchase;
292
+
293
+ /**
294
+ * Total price excluding VAT
295
+ */
296
+
297
+ const totalExclVat = parseFloat(mainSubtotalExclVat) + accessoriesExclVat;
298
+
299
+ /**
300
+ * Total price including VAT
301
+ */
302
+
303
+ const totalInclVat = parseFloat(mainSubtotalInclVat) + accessoriesInclVat;
304
+
305
+ /**
306
+ * VAT amount
307
+ */
308
+ const totalVat = parseFloat(totalInclVat) - totalExclVat;
309
+
310
+ // ===== DISCOUNT CALCULATIONS =====
311
+ /**
312
+ * Calculate discount amount
313
+ */
314
+ const getDiscountAmount = () => {
198
315
  if (discountPercentage) {
199
- return totalPrice * discountPercentage / 100;
316
+ return totalInclVat * discountPercentage / 100;
200
317
  }
201
318
  if (discountAmount) {
202
319
  return discountAmount;
203
320
  }
204
321
  return 0;
205
322
  };
323
+ const discountTotal = getDiscountAmount();
324
+ const discountExclVat = discountTotal / 1.21;
325
+ const discountVat = discountTotal - discountExclVat;
206
326
 
207
- // Calculate original total
208
- const calculateOriginalTotal = () => {
209
- return subtotalPriceProducts + subtotalPriceAccessoires;
210
- };
327
+ // ===== TOTALS AFTER DISCOUNT =====
328
+ /**
329
+ * Final price excluding VAT (after discount)
330
+ */
331
+ const finalExclVat = Math.max(0, totalExclVat - discountExclVat);
211
332
 
212
- // Calculate final totals
213
- const calculateFinalTotals = () => {
214
- const totalDiscount = calculateTotalDiscount();
215
- const originalTotal = calculateOriginalTotal();
333
+ /**
334
+ * Final VAT amount (after discount)
335
+ */
336
+ const finalVat = Math.max(0, totalVat - discountVat);
216
337
 
217
- // Calculate the proportion of the discount that applies to the excl. VAT amount
218
- const discountExclVat = totalDiscount / 1.21; // Remove VAT from discount
219
- const discountVat = totalDiscount - discountExclVat;
220
- const baseExclVat = originalTotal / 1.21; // Original price excl VAT
221
- const baseVat = originalTotal - baseExclVat; // Original VAT amount
338
+ /**
339
+ * Final price including VAT (after discount)
340
+ */
341
+ const finalInclVat = Math.max(0, totalInclVat - discountTotal);
222
342
 
223
- return {
224
- exclVat: Math.max(0, baseExclVat - discountExclVat),
225
- vat: Math.max(0, baseVat - discountVat),
226
- total: Math.max(0, originalTotal - totalDiscount),
227
- originalTotal
228
- };
229
- };
343
+ /**
344
+ * Final purchase price after discount
345
+ */
346
+ const finalPurchase = Math.max(0, totalPurchase - discountExclVat * totalPurchase / totalExclVat);
230
347
  return /*#__PURE__*/_react.default.createElement("div", {
231
348
  className: (0, _helpers__.withStyle)("content col-lg")
232
349
  }, /*#__PURE__*/_react.default.createElement(_TogglableCard.default, {
@@ -237,16 +354,19 @@ const ProductCartTable = () => {
237
354
  }, /*#__PURE__*/_react.default.createElement("table", {
238
355
  className: (0, _helpers__.withStyle)('cart__table table table-borderless align-middle')
239
356
  }, /*#__PURE__*/_react.default.createElement(_ProductTableHead.default, {
240
- columns: [{}, {}, {}, ...(isToggled ? [{
357
+ columns: [{}, {}, {}, {}, ...(isToggled ? [{
358
+ text: 'Marge (excl. btw)',
359
+ className: 'fw-bold text-end'
360
+ }, {
241
361
  text: 'Inkoopprijs (excl. btw)',
242
362
  className: 'fw-bold text-end'
243
363
  }, {
244
- text: 'Marge (excl. btw)',
364
+ text: 'Verkoop Prijs (excl. btw)',
245
365
  className: 'fw-bold text-end'
246
- }] : [{}, {}]), {
247
- text: isToggled ? 'Verkoop Prijs (excl. btw)' : 'Verkoop Prijs (incl. btw)',
366
+ }] : [{}, {}, {
367
+ text: 'Verkoop Prijs (incl. btw)',
248
368
  className: 'fw-bold text-end'
249
- }]
369
+ }])]
250
370
  }), /*#__PURE__*/_react.default.createElement("tbody", null, /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
251
371
  heading: 'Trekhaakmontage'
252
372
  }, mainProducts.map(product => {
@@ -265,35 +385,62 @@ const ProductCartTable = () => {
265
385
  productImage: product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
266
386
  imageId: (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
267
387
  }) : _logoPrimary.default,
268
- extraCells: [{}, {}, ...(isToggled ? [{}, {}] : [{}, {}]), {
269
- text: salesPrice !== 0 || salesPriceInclVat !== 0 ? (0, _helpers__.formatPrice)(isToggled ? salesPrice : salesPriceInclVat) : '',
388
+ extraCells: [{}, {}, {}, ...(isToggled ? [{
389
+ text: "".concat((0, _helpers__.formatPrice)(margin), " (").concat(marginPercentage, "%)"),
390
+ className: 'cart__table-price text-end'
391
+ }, {
392
+ text: (0, _helpers__.formatPrice)(purchasePrice),
270
393
  className: 'cart__table-price text-end'
271
- }]
394
+ }, {
395
+ text: (0, _helpers__.formatPrice)(salesPrice),
396
+ className: 'cart__table-price text-end'
397
+ }] : [{}, {}, {
398
+ text: salesPriceInclVat > 0 ? (0, _helpers__.formatPrice)(salesPriceInclVat) : '',
399
+ className: 'cart__table-price text-end'
400
+ }])]
272
401
  });
273
402
  }), mainProducts && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
274
- productTitle: 'Montage',
403
+ productTitle: isToggled ? 'Montage + Marktcorrectie' : 'Montage',
275
404
  productImage: _montagePlaceholder.default,
276
- extraCells: [{}, {}, ...(isToggled ? [{
277
- text: (0, _helpers__.formatPrice)(purchasePrice),
405
+ extraCells: [{}, {}, {}, ...(isToggled ? [{
406
+ text: 'N.v.t.',
278
407
  className: 'cart__table-price text-end'
279
408
  }, {
280
- text: "".concat((0, _helpers__.formatPrice)(margin), " (").concat(marginPercentage, "%)"),
409
+ text: 'N.v.t.',
281
410
  className: 'cart__table-price text-end'
282
- }] : [{}, {}]), {
283
- text: (0, _helpers__.formatPrice)(isToggled ? totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionExclVat : totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat),
411
+ }, {
412
+ text: (0, _helpers__.formatPrice)(montageExclVat),
413
+ className: 'cart__table-price text-end'
414
+ }] : [{}, {}, {
415
+ text: (0, _helpers__.formatPrice)(montageInclVat),
284
416
  className: 'cart__table-price text-end'
285
- }]
417
+ }])]
286
418
  }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
287
419
  isEditable: true,
288
420
  editLabel: 'Wijzig je trekhaakpakket',
289
421
  editLink: '/configurator/trekhaakpakket',
290
- extraCells: [{}, {}, {}, {}, {
291
- text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
422
+ extraCells: [{}, {}, ...(isToggled ? [{
423
+ text: '',
424
+ className: 'fw-bold text-end'
425
+ }, {
426
+ text: '',
427
+ className: 'fw-bold text-end'
428
+ }, {
429
+ text: 'Subtotaal (excl. btw)',
430
+ className: 'fw-bold text-end pb-2'
431
+ }] : [{}, {}, {}, {
432
+ text: 'Subtotaal (incl. btw)',
433
+ className: 'fw-bold text-end pb-2'
434
+ }]), ...(isToggled ? [{
435
+ text: (0, _helpers__.formatPrice)(mainProductsPurchase),
292
436
  className: 'fw-bold text-end pb-2'
293
437
  }, {
294
- text: (0, _helpers__.formatPrice)(isToggled ? subtotalPriceProducts / 1.21 : subtotalPriceProducts),
438
+ text: (0, _helpers__.formatPrice)(mainSubtotalExclVat),
295
439
  className: 'fw-bold text-end pb-2'
296
- }]
440
+ }] : [{
441
+ text: (0, _helpers__.formatPrice)(mainSubtotalInclVat),
442
+ className: 'fw-bold text-end pb-2'
443
+ }])]
297
444
  })), accessoireProducts.length > 0 && /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
298
445
  heading: 'Toebehoren'
299
446
  }, accessoireProducts.map(product => {
@@ -312,16 +459,19 @@ const ProductCartTable = () => {
312
459
  productImage: product !== null && product !== void 0 && (_product$images3 = product.images) !== null && _product$images3 !== void 0 && _product$images3[0] ? (0, _image.getImageFromHyper)({
313
460
  imageId: (_product$images4 = product.images) === null || _product$images4 === void 0 ? void 0 : _product$images4[0]
314
461
  }) : _logoPrimary.default,
315
- extraCells: [{}, {}, ...(isToggled ? [{
462
+ extraCells: [{}, {}, {}, ...(isToggled ? [{
463
+ text: "".concat((0, _helpers__.formatPrice)(margin), " (").concat(marginPercentage, "%)"),
464
+ className: 'cart__table-price text-end'
465
+ }, {
316
466
  text: (0, _helpers__.formatPrice)(purchasePrice),
317
467
  className: 'cart__table-price text-end'
318
468
  }, {
319
- text: "".concat((0, _helpers__.formatPrice)(margin), " (").concat(marginPercentage, "%)"),
469
+ text: (0, _helpers__.formatPrice)(salesPrice),
320
470
  className: 'cart__table-price text-end'
321
- }] : [{}, {}]), {
322
- text: (0, _helpers__.formatPrice)(isToggled ? salesPrice : salesPriceInclVat),
471
+ }] : [{}, {}, {
472
+ text: (0, _helpers__.formatPrice)(salesPriceInclVat),
323
473
  className: 'cart__table-price text-end'
324
- }],
474
+ }])],
325
475
  productAmount: selectedExtras[product.articleNumber],
326
476
  onEdit: value => {
327
477
  if (value > 0) {
@@ -343,78 +493,132 @@ const ProductCartTable = () => {
343
493
  });
344
494
  }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
345
495
  isEditable: false,
346
- extraCells: [{}, {}, {}, {}, {
347
- text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
496
+ extraCells: [{}, {}, ...(isToggled ? [{
497
+ text: '',
498
+ className: 'fw-bold text-end'
499
+ }, {
500
+ text: '',
501
+ className: 'fw-bold text-end'
502
+ }, {
503
+ text: 'Subtotaal (excl. btw)',
504
+ className: 'fw-bold text-end pb-2'
505
+ }] : [{}, {}, {}, {
506
+ text: 'Subtotaal (incl. btw)',
507
+ className: 'fw-bold text-end pb-2'
508
+ }]), ...(isToggled ? [{
509
+ text: (0, _helpers__.formatPrice)(accessoriesPurchase),
348
510
  className: 'fw-bold text-end pb-2'
349
511
  }, {
350
- text: (0, _helpers__.formatPrice)(isToggled ? subtotalPriceAccessoires / 1.21 : subtotalPriceAccessoires),
512
+ text: (0, _helpers__.formatPrice)(accessoriesExclVat),
513
+ className: 'fw-bold text-end pb-2'
514
+ }] : [{
515
+ text: (0, _helpers__.formatPrice)(accessoriesInclVat),
351
516
  className: 'fw-bold text-end pb-2'
352
- }]
517
+ }])]
353
518
  })), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
354
- rows: [...(isToggled ? [[{}, {}, {}, {}, {
355
- text: 'Producten (excl. btw)',
519
+ rows: [[{}, {}, {}, ...(isToggled ? [{
520
+ text: '',
356
521
  className: 'text-end pt-2'
357
522
  }, {
358
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
523
+ text: 'Producten (excl. btw)',
359
524
  className: 'text-end pt-2'
360
- }], [{}, {}, {}, {}, {
361
- text: 'btw',
362
- className: 'text-end'
363
- }, {
364
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
365
- className: 'text-end'
366
- }], [{}, {}, {}, {}, {
367
- text: 'Totaal (incl. btw)',
368
- className: 'fw-bold text-end'
369
- }, {
370
- text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
371
- className: 'fw-bold text-end'
372
- }]] : [[{}, {}, {}, {}, {
525
+ }] : [{}, {}, {
373
526
  text: 'Producten (excl. btw)',
374
527
  className: 'text-end pt-2'
528
+ }]), ...(isToggled ? [{
529
+ text: (0, _helpers__.formatPrice)(totalPurchase),
530
+ className: 'text-end pt-2'
375
531
  }, {
376
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
532
+ text: (0, _helpers__.formatPrice)(totalExclVat),
533
+ className: 'text-end pt-2'
534
+ }] : [{
535
+ text: (0, _helpers__.formatPrice)(totalExclVat),
377
536
  className: 'text-end pt-2'
378
- }], [{}, {}, {}, {}, {
537
+ }])], [{}, {}, {}, ...(isToggled ? [{
538
+ text: '',
539
+ className: 'text-end'
540
+ }, {
379
541
  text: 'btw',
380
542
  className: 'text-end'
543
+ }] : [{}, {}, {
544
+ text: 'btw',
545
+ className: 'text-end'
546
+ }]), ...(isToggled ? [{
547
+ text: (0, _helpers__.formatPrice)(totalVat / 1.21),
548
+ className: 'text-end'
381
549
  }, {
382
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
550
+ text: (0, _helpers__.formatPrice)(totalVat),
383
551
  className: 'text-end'
384
- }], [{}, {}, {}, {}, {
552
+ }] : [{
553
+ text: (0, _helpers__.formatPrice)(totalVat),
554
+ className: 'text-end'
555
+ }])], [{}, {}, {}, ...(isToggled ? [{
556
+ text: '',
557
+ className: 'fw-bold text-end'
558
+ }, {
559
+ text: 'Totaal (incl. btw)',
560
+ className: 'fw-bold text-end'
561
+ }] : [{}, {}, {
385
562
  text: 'Totaal (incl. btw)',
386
563
  className: 'fw-bold text-end'
564
+ }]), ...(isToggled ? [{
565
+ text: (0, _helpers__.formatPrice)(totalPurchase + totalVat / 1.21),
566
+ className: 'fw-bold text-end'
387
567
  }, {
388
- text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
568
+ text: (0, _helpers__.formatPrice)(totalInclVat),
389
569
  className: 'fw-bold text-end'
390
- }]])].filter(Boolean)
570
+ }] : [{
571
+ text: (0, _helpers__.formatPrice)(totalInclVat),
572
+ className: 'fw-bold text-end'
573
+ }])]].filter(Boolean)
391
574
  }), (discountAmount || discountPercentage) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
392
575
  colSpan: "10",
393
576
  className: (0, _helpers__.withStyle)('pt-4 pb-2')
394
577
  }, /*#__PURE__*/_react.default.createElement("hr", null))), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
395
- rows: [[{}, {}, {}, {}, {
396
- text: discountPercentage ? "Correctie (".concat(discountPercentage, "%)") : 'Correctie',
578
+ rows: [[{}, {}, {}, ...(isToggled ? [{
579
+ text: '',
397
580
  className: 'text-end text-success'
398
581
  }, {
399
- text: "-".concat((0, _helpers__.formatPrice)(calculateTotalDiscount())),
582
+ text: '',
400
583
  className: 'text-end text-success'
401
- }], [{}, {}, {}, {}, {
402
- text: 'Totaal na correctie (excl. btw)',
403
- className: 'text-end'
404
584
  }, {
405
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
585
+ text: discountPercentage ? "Correctie (".concat(discountPercentage, "%)") : 'Correctie',
586
+ className: 'text-end text-success'
587
+ }] : [{}, {}, {
588
+ text: discountPercentage ? "Correctie (".concat(discountPercentage, "%)") : 'Correctie',
589
+ className: 'text-end text-success'
590
+ }]), {
591
+ text: "-".concat((0, _helpers__.formatPrice)(discountTotal)),
592
+ className: 'text-end text-success'
593
+ }], [{}, {}, {}, ...(isToggled ? [{
594
+ text: '',
406
595
  className: 'text-end'
407
- }], [{}, {}, {}, {}, {
408
- text: 'Correctie btw',
596
+ }, {
597
+ text: '',
409
598
  className: 'text-end'
410
599
  }, {
411
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
600
+ text: 'Totaal na correctie (excl. btw)',
412
601
  className: 'text-end'
413
- }], [{}, {}, {}, {}, {
414
- text: 'Totaal na correctie (incl. btw)',
602
+ }] : [{}, {}, {
603
+ text: 'Totaal na correctie (excl. btw)',
604
+ className: 'text-end'
605
+ }]), {
606
+ text: (0, _helpers__.formatPrice)(finalExclVat),
607
+ className: 'text-end'
608
+ }], [{}, {}, {}, ...(isToggled ? [{
609
+ text: '',
610
+ className: 'fw-bold text-end'
611
+ }, {
612
+ text: '',
415
613
  className: 'fw-bold text-end'
416
614
  }, {
417
- text: (0, _helpers__.formatPrice)(calculateFinalTotals().total),
615
+ text: 'Totaal na correctie (incl. btw)',
616
+ className: 'fw-bold text-end'
617
+ }] : [{}, {}, {
618
+ text: 'Totaal na correctie (incl. btw)',
619
+ className: 'fw-bold text-end'
620
+ }]), {
621
+ text: (0, _helpers__.formatPrice)(finalInclVat),
418
622
  className: 'fw-bold text-end'
419
623
  }]]
420
624
  })))), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalDiscountForm.default, null)));
@@ -126,7 +126,7 @@ const licensePlateValidator = new _LicensePlateValidator.default();
126
126
  const internalAppointmentFormSchema = (0, _yup.object)({
127
127
  ownershipType: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
128
128
  leaseNumber: (0, _yup.string)().nullable(),
129
- firstName: (0, _yup.string)().nullable(),
129
+ firstName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
130
130
  channelType: (0, _yup.string)().when('$existingDossierId', {
131
131
  is: existingDossierId => !!existingDossierId,
132
132
  then: schema => schema.nullable(),
@@ -142,7 +142,7 @@ const internalAppointmentFormSchema = (0, _yup.object)({
142
142
  email: (0, _yup.string)().email(_constants__.FORM_ERROR_MESSAGES.email).required(_constants__.FORM_ERROR_MESSAGES.required),
143
143
  phoneNumber: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
144
144
  zipCode: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
145
- houseNumber: (0, _yup.string)().nullable(),
145
+ houseNumber: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
146
146
  houseNumberAddition: (0, _yup.string)().nullable(),
147
147
  streetName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
148
148
  city: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
@@ -205,11 +205,6 @@ const InternalAppointmentForm = _ref => {
205
205
  countries,
206
206
  isLoadingCountries
207
207
  } = (0, _queries.useCountriesQuery)();
208
- const branchType = branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title;
209
- const {
210
- marketingChannels,
211
- isLoadingMarketingChannels
212
- } = (0, _queries.useMarketingChannels)(branchType);
213
208
  const countryOptions = (0, _react.useMemo)(() => {
214
209
  var _countries$results;
215
210
  if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
@@ -218,6 +213,11 @@ const InternalAppointmentForm = _ref => {
218
213
  value: country.entityId
219
214
  }));
220
215
  }, [countries]);
216
+ const branchType = branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title;
217
+ const {
218
+ marketingChannels,
219
+ isLoadingMarketingChannels
220
+ } = (0, _queries.useMarketingChannels)(branchType);
221
221
  const initialCountry = (0, _react.useMemo)(() => {
222
222
  if (!(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) return null;
223
223
 
@@ -391,9 +391,9 @@ const InternalAppointmentForm = _ref => {
391
391
  */
392
392
  const handleAutofillButtonClicked = () => {
393
393
  dispatch({
394
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
394
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
395
395
  payload: {
396
- lastName: branchById === null || branchById === void 0 ? void 0 : branchById.name
396
+ companyName: branchById === null || branchById === void 0 ? void 0 : branchById.name
397
397
  }
398
398
  });
399
399
  dispatch({
@@ -602,7 +602,8 @@ const InternalAppointmentForm = _ref => {
602
602
  firstName: value
603
603
  }
604
604
  }),
605
- isRequired: false,
605
+ key: "firstName",
606
+ isRequired: true,
606
607
  form: "appointment",
607
608
  label: "Voornaam:",
608
609
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['firstName']
@@ -616,6 +617,7 @@ const InternalAppointmentForm = _ref => {
616
617
  infix: value
617
618
  }
618
619
  }),
620
+ key: "infix",
619
621
  isRequired: false,
620
622
  form: "appointment",
621
623
  label: "Tussenvoegsel:",
@@ -630,6 +632,7 @@ const InternalAppointmentForm = _ref => {
630
632
  lastName: value
631
633
  }
632
634
  }),
635
+ key: "lastName",
633
636
  isRequired: true,
634
637
  form: "appointment",
635
638
  label: "Achternaam:",
@@ -644,6 +647,7 @@ const InternalAppointmentForm = _ref => {
644
647
  email: value
645
648
  }
646
649
  }),
650
+ key: "email",
647
651
  isRequired: true,
648
652
  form: "appointment",
649
653
  label: "E-mailadres:",
@@ -662,6 +666,7 @@ const InternalAppointmentForm = _ref => {
662
666
  companyName: value
663
667
  }
664
668
  }),
669
+ key: "companyName",
665
670
  isRequired: true,
666
671
  form: "quotation",
667
672
  label: "Bedrijfsnaam:",
@@ -676,6 +681,7 @@ const InternalAppointmentForm = _ref => {
676
681
  kvkNumber: value
677
682
  }
678
683
  }),
684
+ key: "kvkNumber",
679
685
  isRequired: false,
680
686
  form: "quotation",
681
687
  label: "KVK-nummer:",
@@ -690,6 +696,7 @@ const InternalAppointmentForm = _ref => {
690
696
  vatNumber: value
691
697
  }
692
698
  }),
699
+ key: "vatNumber",
693
700
  isRequired: false,
694
701
  form: "quotation",
695
702
  label: "BTW-nummer:",
@@ -704,6 +711,7 @@ const InternalAppointmentForm = _ref => {
704
711
  zipCode: value
705
712
  }
706
713
  }),
714
+ key: "zipCode",
707
715
  isRequired: true,
708
716
  label: "Postcode:",
709
717
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['zipCode']
@@ -717,6 +725,7 @@ const InternalAppointmentForm = _ref => {
717
725
  houseNumber: value
718
726
  }
719
727
  }),
728
+ key: "houseNumber",
720
729
  isRequired: true,
721
730
  label: "Huisnummer:",
722
731
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumber']
@@ -730,6 +739,7 @@ const InternalAppointmentForm = _ref => {
730
739
  houseNumberAddition: value
731
740
  }
732
741
  }),
742
+ key: "houseNumberAddition",
733
743
  isRequired: false,
734
744
  label: "Huisnummer toevoeging:",
735
745
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumberAddition']
@@ -743,6 +753,7 @@ const InternalAppointmentForm = _ref => {
743
753
  streetName: value
744
754
  }
745
755
  }),
756
+ key: "streetName",
746
757
  isRequired: true,
747
758
  label: "Straat:",
748
759
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
@@ -756,6 +767,7 @@ const InternalAppointmentForm = _ref => {
756
767
  city: value
757
768
  }
758
769
  }),
770
+ key: "city",
759
771
  isRequired: true,
760
772
  label: "Stad:",
761
773
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
@@ -769,6 +781,7 @@ const InternalAppointmentForm = _ref => {
769
781
  phoneNumber: value
770
782
  }
771
783
  }),
784
+ key: "phoneNumber",
772
785
  isRequired: true,
773
786
  label: "Telefoonnummer:",
774
787
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['phoneNumber']
@@ -782,6 +795,7 @@ const InternalAppointmentForm = _ref => {
782
795
  zipCode: value
783
796
  }
784
797
  }),
798
+ key: "zipCode",
785
799
  isRequired: true,
786
800
  label: "Postcode:",
787
801
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['zipCode']
@@ -795,7 +809,8 @@ const InternalAppointmentForm = _ref => {
795
809
  houseNumber: value
796
810
  }
797
811
  }),
798
- isRequired: false,
812
+ key: "houseNumber",
813
+ isRequired: true,
799
814
  label: "Huisnummer:",
800
815
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumber']
801
816
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
@@ -808,6 +823,7 @@ const InternalAppointmentForm = _ref => {
808
823
  streetName: value
809
824
  }
810
825
  }),
826
+ key: "streetName",
811
827
  isRequired: true,
812
828
  label: "Straat:",
813
829
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
@@ -821,6 +837,7 @@ const InternalAppointmentForm = _ref => {
821
837
  city: value
822
838
  }
823
839
  }),
840
+ key: "city",
824
841
  isRequired: true,
825
842
  label: "Stad:",
826
843
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
@@ -844,7 +861,8 @@ const InternalAppointmentForm = _ref => {
844
861
  countryId: value
845
862
  }
846
863
  });
847
- }
864
+ },
865
+ key: "country"
848
866
  })))))), /*#__PURE__*/_react.default.createElement("div", {
849
867
  className: (0, _helpers__.withStyle)('col-12 mb-4')
850
868
  }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
@@ -854,6 +872,7 @@ const InternalAppointmentForm = _ref => {
854
872
  }, "Gegevens van de auto ", /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement("div", {
855
873
  className: (0, _helpers__.withStyle)('col-12')
856
874
  }, (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType) === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
875
+ key: "leaseNumber",
857
876
  placeholder: "",
858
877
  initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumber,
859
878
  name: "leaseNumber",
@@ -869,6 +888,7 @@ const InternalAppointmentForm = _ref => {
869
888
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['leaseNumber'],
870
889
  isDisabled: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumberUnknown
871
890
  }), /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
891
+ key: "leaseNumberUnknown",
872
892
  name: "leaseNumberUnknown",
873
893
  initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumberUnknown,
874
894
  onChange: val => {
@@ -882,6 +902,7 @@ const InternalAppointmentForm = _ref => {
882
902
  label: "Goedkeuringsnummer onbekend",
883
903
  isDisabled: !!(vehicle !== null && vehicle !== void 0 && vehicle.leaseNumber)
884
904
  })), !licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
905
+ key: "licensePlate",
885
906
  placeholder: "",
886
907
  initialValue: _licensePlate,
887
908
  name: "licensePlate",
@@ -891,6 +912,7 @@ const InternalAppointmentForm = _ref => {
891
912
  label: "Kenteken:",
892
913
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
893
914
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
915
+ key: "chassisNumber",
894
916
  placeholder: "",
895
917
  initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.chassisNumber,
896
918
  name: "chassisNumber",
@@ -144,7 +144,7 @@ const internalQuotationFormSchema = (0, _yup.object)({
144
144
  city: (0, _yup.string)().nullable(),
145
145
  companyName: (0, _yup.string)().when('ownershipType', {
146
146
  is: _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk,
147
- then: schema => schema.required(_constants__.FORM_ERROR_MESSAGES.required),
147
+ then: schema => schema.nullable(),
148
148
  otherwise: schema => schema.nullable()
149
149
  }),
150
150
  kvkNumber: (0, _yup.string)().nullable(),
@@ -570,7 +570,7 @@ const InternalQuotationForm = _ref => {
570
570
  companyName: value
571
571
  }
572
572
  }),
573
- isRequired: true,
573
+ isRequired: false,
574
574
  form: "quotation",
575
575
  label: "Bedrijfsnaam:",
576
576
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['companyName']
@@ -612,7 +612,7 @@ const InternalQuotationForm = _ref => {
612
612
  zipCode: value
613
613
  }
614
614
  }),
615
- isRequired: true,
615
+ isRequired: false,
616
616
  form: "quotation",
617
617
  label: "Postcode:",
618
618
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['zipCode']
@@ -626,7 +626,7 @@ const InternalQuotationForm = _ref => {
626
626
  houseNumber: value
627
627
  }
628
628
  }),
629
- isRequired: true,
629
+ isRequired: false,
630
630
  form: "quotation",
631
631
  label: "Huisnummer:",
632
632
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumber']
@@ -654,7 +654,7 @@ const InternalQuotationForm = _ref => {
654
654
  streetName: value
655
655
  }
656
656
  }),
657
- isRequired: true,
657
+ isRequired: false,
658
658
  form: "quotation",
659
659
  label: "Straat:",
660
660
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
@@ -668,7 +668,7 @@ const InternalQuotationForm = _ref => {
668
668
  city: value
669
669
  }
670
670
  }),
671
- isRequired: true,
671
+ isRequired: false,
672
672
  form: "quotation",
673
673
  label: "Stad:",
674
674
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
@@ -31,6 +31,10 @@ Sidebar
31
31
  width: 100%;
32
32
  }
33
33
  }
34
+
35
+ table {
36
+ table-layout: fixed;
37
+ }
34
38
  }
35
39
 
36
40
  @include media-breakpoint-only(xs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.112",
3
+ "version": "0.0.113",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",