@crystaldesign/diva-backoffice 26.12.3-rc.0 → 26.12.3-rc.1

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.
Files changed (16) hide show
  1. package/build/esm/index.js +257 -186
  2. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.d.ts +7 -2
  3. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.d.ts.map +1 -1
  4. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.d.ts +4 -2
  5. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.d.ts.map +1 -1
  6. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/index.d.ts.map +1 -1
  7. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.d.ts +6 -3
  8. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.d.ts.map +1 -1
  9. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.d.ts +7 -1
  10. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.d.ts.map +1 -1
  11. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.d.ts +5 -11
  12. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.d.ts.map +1 -1
  13. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.d.ts +8 -5
  14. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.d.ts.map +1 -1
  15. package/build/types/backoffice/src/ui/IDMEnricherEditor/modules/TablePriceList/index.d.ts.map +1 -1
  16. package/package.json +12 -12
@@ -72467,6 +72467,15 @@ var PRICE_FACTOR_FIELDS = {
72467
72467
  serie: 'seriePricefactors'
72468
72468
  };
72469
72469
 
72470
+ /** Pricelist field per scope holding, index by index beside the factors, whether each factor is shown as discount. */
72471
+ var PRICE_FACTOR_DISCOUNT_FIELDS = {
72472
+ article: 'articlePricefactorsIsDiscount',
72473
+ typeKey: 'typeKeyPricefactorsIsDiscount',
72474
+ priceFeatureGroup: 'pfgPricefactorsIsDiscount',
72475
+ priceGroup: 'pgPricefactorsIsDiscount',
72476
+ serie: 'seriePricefactorsIsDiscount'
72477
+ };
72478
+
72470
72479
  /** Pricelist field per scope holding the priority list map — only PFG and PG scopes support priority. */
72471
72480
  var PRICE_FACTOR_PRIORITY_FIELDS = {
72472
72481
  priceFeatureGroup: 'pfgPricefactorsPriority',
@@ -72474,11 +72483,21 @@ var PRICE_FACTOR_PRIORITY_FIELDS = {
72474
72483
  };
72475
72484
 
72476
72485
  /**
72477
- * Computes the single-field `setNodeDataValue` patch that applies — or, with an empty `value`, clears —
72478
- * a price factor for a scope/key on a serie. `key` is unused for scope 'serie'.
72486
+ * Computes the `setNodeDataValue` patch that applies — or, with an empty `value`, clears — a price factor for a
72487
+ * scope/key on a serie. `key` is unused for scope 'serie'. `isDiscount` flags the factors shown as discount, index
72488
+ * by index; empty when none is, which also clears flags left from before (e.g. when the agent sets factors).
72479
72489
  */
72480
72490
  function applyPriceFactor(pricelist, serieNo, scope, key, value) {
72481
- var field = PRICE_FACTOR_FIELDS[scope];
72491
+ var isDiscount = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
72492
+ var patch = applyToFactorMap(pricelist, PRICE_FACTOR_FIELDS[scope], serieNo, scope, key, value);
72493
+ var discountField = PRICE_FACTOR_DISCOUNT_FIELDS[scope];
72494
+ // A pricelist that never had flags gets none, so a plain factor change stays a single-field patch
72495
+ if (isDiscount.length === 0 && pricelist[discountField] === undefined) return patch;
72496
+ return _objectSpread$C(_objectSpread$C({}, patch), applyToFactorMap(pricelist, discountField, serieNo, scope, key, isDiscount));
72497
+ }
72498
+
72499
+ /** Sets or, with an empty `value`, prunes the entry of a scope/key on a serie in one serie-scoped map field. */
72500
+ function applyToFactorMap(pricelist, field, serieNo, scope, key, value) {
72482
72501
  if (scope === 'serie') {
72483
72502
  var _newFactors = _objectSpread$C({}, pricelist[field]);
72484
72503
  if (value.length === 0) {
@@ -90203,17 +90222,14 @@ var removeFloatNoise = function removeFloatNoise(value) {
90203
90222
  return parseFloat(value.toFixed(10));
90204
90223
  };
90205
90224
 
90206
- /** State container for both factor and discount entries */
90207
-
90208
90225
  /**
90209
90226
  * Formats a list of values for display in the cell
90210
90227
  * For both types, displays the actual factor value (e.g., 0.8 for 20% discount)
90211
90228
  * @param values - The values to format
90212
- * @param type - The type of price modification
90213
90229
  * @param locale - The locale to use for formatting
90214
90230
  * @returns The formatted string with values separated by semicolons
90215
90231
  */
90216
- var formatListValue = function formatListValue(values, type, locale) {
90232
+ var formatListValue = function formatListValue(values, locale) {
90217
90233
  if (!(values !== null && values !== void 0 && values.length)) return '-';
90218
90234
  var formatter = new Intl.NumberFormat(locale, {
90219
90235
  minimumFractionDigits: 1,
@@ -90255,7 +90271,7 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
90255
90271
 
90256
90272
  /**
90257
90273
  * Validates if an input value is valid for the given type
90258
- * For factors: must be >= 1
90274
+ * For factors: must be > 0 (factors below 1 lower the price, factors above 1 raise it)
90259
90275
  * For discounts: the discount must be between 0 and 99.99999 percent
90260
90276
  * @param value - The value to validate
90261
90277
  * @param type - The type of price modification
@@ -90264,14 +90280,14 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
90264
90280
  var isValidInput = function isValidInput(value, type) {
90265
90281
  var numValue = parseFloat(value);
90266
90282
  if (isNaN(numValue)) return false;
90267
- if (type === 'factor') return numValue >= 1;
90283
+ if (type === 'factor') return numValue > 0;
90268
90284
  var discount = removeFloatNoise((1 - numValue) * 100);
90269
90285
  return discount >= 0 && discount <= MAX_DISCOUNT;
90270
90286
  };
90271
90287
 
90272
90288
  /**
90273
90289
  * Checks if a value is effective (should be saved)
90274
- * For factors: must be > 1 (1 is valid but not effective)
90290
+ * For factors: must not be 1 (1 is valid but leaves the price unchanged)
90275
90291
  * For discounts: must be < 1 (a 0% discount is valid but not effective)
90276
90292
  * @param value - The value to check
90277
90293
  * @param type - The type of price modification
@@ -90279,7 +90295,7 @@ var isValidInput = function isValidInput(value, type) {
90279
90295
  */
90280
90296
  var isEffectiveValue = function isEffectiveValue(value, type) {
90281
90297
  var numValue = parseFloat(value);
90282
- return type === 'factor' ? numValue > 1 : numValue < 1;
90298
+ return type === 'factor' ? numValue !== 1 : numValue < 1;
90283
90299
  };
90284
90300
 
90285
90301
  /**
@@ -90302,151 +90318,131 @@ var isDefaultValue = function isDefaultValue(value) {
90302
90318
 
90303
90319
  function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
90304
90320
  function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
90321
+ var createDefaultEntry = function createDefaultEntry() {
90322
+ return {
90323
+ value: getDefaultValue(),
90324
+ type: 'factor',
90325
+ isValid: true
90326
+ };
90327
+ };
90328
+
90305
90329
  /**
90306
90330
  * Custom hook to manage price factor state and logic
90307
90331
  * @param props - Hook configuration
90308
90332
  * @param props.data - Data of the row
90309
90333
  * @param props.initialValue - Initial array of values
90310
- * @param props.onSave - Callback to save values
90334
+ * @param props.initialIsDiscount - Initial discount flags of the values
90335
+ * @param props.onSave - Callback to save values and their discount flags
90311
90336
  * @param props.onRefreshCell - Callback to refresh the cell after save
90312
90337
  */
90313
90338
  function usePriceFactor(_ref) {
90314
90339
  var _ref$data = _ref.data,
90315
90340
  data = _ref$data === void 0 ? {} : _ref$data,
90316
90341
  initialValue = _ref.initialValue,
90342
+ initialIsDiscount = _ref.initialIsDiscount,
90317
90343
  onSave = _ref.onSave,
90318
90344
  onRefreshCell = _ref.onRefreshCell;
90319
90345
  var _useState = useState(false),
90320
90346
  _useState2 = _slicedToArray(_useState, 2),
90321
90347
  isModalOpen = _useState2[0],
90322
90348
  setIsModalOpen = _useState2[1];
90323
- var _useState3 = useState('factor'),
90349
+ var _useState3 = useState([]),
90324
90350
  _useState4 = _slicedToArray(_useState3, 2),
90325
- type = _useState4[0],
90326
- setType = _useState4[1];
90327
- var _useState5 = useState({
90328
- factor: [],
90329
- discount: []
90330
- }),
90331
- _useState6 = _slicedToArray(_useState5, 2),
90332
- entries = _useState6[0],
90333
- setEntries = _useState6[1];
90334
- var _useState7 = useState(false),
90335
- _useState8 = _slicedToArray(_useState7, 2),
90336
- hasChangedCurrentType = _useState8[0],
90337
- setHasChangedCurrentType = _useState8[1];
90338
- var updateEntries = function updateEntries(newTypeEntries) {
90339
- setHasChangedCurrentType(true);
90340
- setEntries(function (prev) {
90341
- return _objectSpread$b(_objectSpread$b({}, prev), {}, _defineProperty(_defineProperty({}, type, newTypeEntries), type === 'factor' ? 'discount' : 'factor', []));
90342
- });
90343
- };
90351
+ entries = _useState4[0],
90352
+ setEntries = _useState4[1];
90344
90353
  var handleModalOpen = useCallback(function () {
90345
90354
  var values = initialValue || [];
90346
- var firstValue = values[0];
90347
- var initialType = firstValue ? firstValue > 1 ? 'factor' : 'discount' : 'factor';
90348
- var initialEntries = values.map(function (val) {
90355
+ var initialEntries = values.map(function (val, index) {
90356
+ var type = initialIsDiscount !== null && initialIsDiscount !== void 0 && initialIsDiscount[index] ? 'discount' : 'factor';
90349
90357
  return {
90350
90358
  value: val.toString(),
90351
- isValid: isValidInput(val.toString(), initialType)
90359
+ type: type,
90360
+ isValid: isValidInput(val.toString(), type)
90352
90361
  };
90353
90362
  });
90354
90363
 
90355
90364
  // Ensure at least one entry
90356
90365
  if (initialEntries.length === 0) {
90357
- initialEntries.push({
90358
- value: getDefaultValue(),
90359
- isValid: true
90360
- });
90366
+ initialEntries.push(createDefaultEntry());
90361
90367
  }
90362
- setType(initialType);
90363
- setEntries({
90364
- factor: initialType === 'factor' ? initialEntries : [],
90365
- discount: initialType === 'discount' ? initialEntries : []
90366
- });
90367
- setHasChangedCurrentType(false);
90368
+ setEntries(initialEntries);
90368
90369
  setIsModalOpen(true);
90369
- }, [initialValue]);
90370
+ }, [initialValue, initialIsDiscount]);
90370
90371
  var handleModalClose = function handleModalClose() {
90371
90372
  return setIsModalOpen(false);
90372
90373
  };
90373
- var handleTypeChange = function handleTypeChange(newType) {
90374
- setType(newType);
90375
- // Always ensure at least one entry when switching types
90376
- var newEntries = hasChangedCurrentType ? [] : entries[newType];
90377
- setEntries(function (prev) {
90378
- return _objectSpread$b(_objectSpread$b({}, prev), {}, _defineProperty({}, newType, newEntries.length > 0 ? newEntries : [{
90379
- value: getDefaultValue(),
90380
- isValid: true
90381
- }]));
90374
+ var handleEntryTypeChange = function handleEntryTypeChange(index, newType) {
90375
+ // Restarts the row at the default (factor 1, i.e. 0 % discount) instead of converting what was entered
90376
+ var newEntries = _toConsumableArray(entries);
90377
+ newEntries[index] = _objectSpread$b(_objectSpread$b({}, createDefaultEntry()), {}, {
90378
+ type: newType
90382
90379
  });
90383
- setHasChangedCurrentType(false);
90380
+ setEntries(newEntries);
90384
90381
  };
90385
90382
  var handleAddEntry = function handleAddEntry() {
90386
- var defaultValue = getDefaultValue();
90387
- updateEntries([].concat(_toConsumableArray(entries[type]), [{
90388
- value: defaultValue,
90389
- isValid: true
90390
- }]));
90383
+ setEntries([].concat(_toConsumableArray(entries), [createDefaultEntry()]));
90391
90384
  };
90392
90385
  var handleRemoveEntry = function handleRemoveEntry(index) {
90393
- var currentEntries = entries[type];
90394
- if (currentEntries.length === 1) {
90386
+ if (entries.length === 1) {
90395
90387
  // Reset to default when removing last entry
90396
- updateEntries([{
90397
- value: getDefaultValue(),
90398
- isValid: true
90399
- }]);
90388
+ setEntries([createDefaultEntry()]);
90400
90389
  } else {
90401
- updateEntries(currentEntries.filter(function (_, i) {
90390
+ setEntries(entries.filter(function (_, i) {
90402
90391
  return i !== index;
90403
90392
  }));
90404
90393
  }
90405
90394
  };
90406
90395
  var handleEntryValueChange = function handleEntryValueChange(index, displayValue) {
90407
- var actualValue = convertFromDisplayValue(displayValue, type);
90408
- var newEntries = _toConsumableArray(entries[type]);
90396
+ // A comma counts as decimal point; anything that is no unsigned decimal number is not taken over
90397
+ var input = displayValue.replace(',', '.');
90398
+ if (!/^\d*\.?\d*$/.test(input)) return;
90399
+ var type = entries[index].type;
90400
+ var actualValue = convertFromDisplayValue(input, type);
90401
+ var newEntries = _toConsumableArray(entries);
90409
90402
  newEntries[index] = {
90410
90403
  value: actualValue,
90411
- input: displayValue,
90404
+ input: input,
90405
+ type: type,
90412
90406
  isValid: isValidInput(actualValue, type)
90413
90407
  };
90414
- updateEntries(newEntries);
90408
+ setEntries(newEntries);
90415
90409
  };
90416
90410
  var handleSave = /*#__PURE__*/function () {
90417
90411
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
90418
- var currentEntries, effectiveValues;
90412
+ var effectiveEntries, isDiscount;
90419
90413
  return _regeneratorRuntime.wrap(function _callee$(_context) {
90420
90414
  while (1) switch (_context.prev = _context.next) {
90421
90415
  case 0:
90422
- currentEntries = entries[type]; // Don't save if we only have a default entry
90423
- if (!(currentEntries.length === 1 && isDefaultValue(currentEntries[0].value))) {
90424
- _context.next = 7;
90416
+ if (!(entries.length === 1 && isDefaultValue(entries[0].value))) {
90417
+ _context.next = 6;
90425
90418
  break;
90426
90419
  }
90427
- _context.next = 4;
90428
- return onSave(data, []);
90429
- case 4:
90420
+ _context.next = 3;
90421
+ return onSave(data, [], []);
90422
+ case 3:
90430
90423
  onRefreshCell();
90431
90424
  setIsModalOpen(false);
90432
90425
  return _context.abrupt("return");
90433
- case 7:
90434
- if (currentEntries.every(function (entry) {
90426
+ case 6:
90427
+ if (entries.every(function (entry) {
90435
90428
  return entry.isValid;
90436
90429
  })) {
90437
- _context.next = 9;
90430
+ _context.next = 8;
90438
90431
  break;
90439
90432
  }
90440
90433
  return _context.abrupt("return");
90441
- case 9:
90434
+ case 8:
90442
90435
  // Filter out default and invalid values
90443
- effectiveValues = currentEntries.filter(function (entry) {
90444
- return !isDefaultValue(entry.value) && isEffectiveValue(entry.value, type);
90445
- }).map(function (entry) {
90446
- return parseFloat(entry.value);
90436
+ effectiveEntries = entries.filter(function (entry) {
90437
+ return !isDefaultValue(entry.value) && isEffectiveValue(entry.value, entry.type);
90438
+ });
90439
+ isDiscount = effectiveEntries.map(function (entry) {
90440
+ return entry.type === 'discount';
90447
90441
  });
90448
90442
  _context.next = 12;
90449
- return onSave(data, effectiveValues.length > 0 ? effectiveValues : []);
90443
+ return onSave(data, effectiveEntries.map(function (entry) {
90444
+ return parseFloat(entry.value);
90445
+ }), isDiscount.some(Boolean) ? isDiscount : []);
90450
90446
  case 12:
90451
90447
  onRefreshCell();
90452
90448
  setIsModalOpen(false);
@@ -90461,12 +90457,11 @@ function usePriceFactor(_ref) {
90461
90457
  };
90462
90458
  }();
90463
90459
  return {
90464
- type: type,
90465
- entries: entries[type],
90460
+ entries: entries,
90466
90461
  isModalOpen: isModalOpen,
90467
90462
  handleModalOpen: handleModalOpen,
90468
90463
  handleModalClose: handleModalClose,
90469
- handleTypeChange: handleTypeChange,
90464
+ handleEntryTypeChange: handleEntryTypeChange,
90470
90465
  handleAddEntry: handleAddEntry,
90471
90466
  handleRemoveEntry: handleRemoveEntry,
90472
90467
  handleEntryValueChange: handleEntryValueChange,
@@ -90475,12 +90470,11 @@ function usePriceFactor(_ref) {
90475
90470
  }
90476
90471
 
90477
90472
  var cell = "cell-Noc7s";
90478
- var typeSelector = "typeSelector-Y8Yly";
90479
90473
  var space = "space-T5Mkd";
90480
90474
  var input$1 = "input-SK-Fo";
90481
90475
  var addButton = "addButton-AVN8Y";
90482
90476
  var helpText = "helpText-QYQQF";
90483
- var css_248z$3 = ".cell-Noc7s {\n min-width: 50px;\n height: 100%;\n}\n\n.typeSelector-Y8Yly {\n margin-bottom: 16px;\n}\n\n.space-T5Mkd {\n width: 100%;\n}\n\n.input-SK-Fo {\n width: 160px;\n}\n\n.addButton-AVN8Y {\n margin-top: 16px;\n text-align: right;\n}\n\n.helpText-QYQQF {\n margin-top: 8px;\n font-size: 12px;\n color: #666;\n}\n";
90477
+ var css_248z$3 = ".cell-Noc7s {\n min-width: 50px;\n height: 100%;\n}\n\n.space-T5Mkd {\n width: 100%;\n}\n\n.input-SK-Fo {\n width: 160px;\n}\n\n.addButton-AVN8Y {\n margin-top: 16px;\n text-align: right;\n}\n\n.helpText-QYQQF {\n margin-top: 8px;\n font-size: 12px;\n color: #666;\n}\n";
90484
90478
  styleInject(css_248z$3);
90485
90479
 
90486
90480
  function PriceFactorCellRenderer(props) {
@@ -90489,43 +90483,21 @@ function PriceFactorCellRenderer(props) {
90489
90483
  colDef = props.colDef,
90490
90484
  node = props.node,
90491
90485
  column = props.column,
90492
- onSave = props.onSave,
90486
+ _onSave = props.onSave,
90487
+ getIsDiscount = props.getIsDiscount,
90493
90488
  api = props.api,
90494
90489
  isNotInAGGrid = props.isNotInAGGrid;
90495
90490
  var _useTranslation = useTranslation(),
90496
90491
  t = _useTranslation.t,
90497
90492
  i18n = _useTranslation.i18n;
90498
90493
  var clickTimer = useRef(null);
90499
- var applySave = useCallback(/*#__PURE__*/function () {
90500
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value) {
90501
- return _regeneratorRuntime.wrap(function _callee$(_context) {
90502
- while (1) switch (_context.prev = _context.next) {
90503
- case 0:
90504
- if (!onSave) {
90505
- _context.next = 5;
90506
- break;
90507
- }
90508
- _context.next = 3;
90509
- return onSave(data, value);
90510
- case 3:
90511
- _context.next = 6;
90512
- break;
90513
- case 5:
90514
- node === null || node === void 0 || node.setDataValue(colDef === null || colDef === void 0 ? void 0 : colDef.field, value);
90515
- case 6:
90516
- case "end":
90517
- return _context.stop();
90518
- }
90519
- }, _callee);
90520
- }));
90521
- return function (_x, _x2) {
90522
- return _ref.apply(this, arguments);
90523
- };
90524
- }(), [onSave, node, colDef === null || colDef === void 0 ? void 0 : colDef.field]);
90525
90494
  var _usePriceFactor = usePriceFactor({
90526
90495
  data: data,
90527
90496
  initialValue: value,
90528
- onSave: applySave,
90497
+ initialIsDiscount: getIsDiscount === null || getIsDiscount === void 0 ? void 0 : getIsDiscount(data),
90498
+ onSave: function onSave(data, value, isDiscount) {
90499
+ return _onSave(data, value, isDiscount, node === null || node === void 0 ? void 0 : node.id);
90500
+ },
90529
90501
  onRefreshCell: function onRefreshCell() {
90530
90502
  return api === null || api === void 0 ? void 0 : api.refreshCells({
90531
90503
  suppressFlash: true,
@@ -90534,12 +90506,11 @@ function PriceFactorCellRenderer(props) {
90534
90506
  });
90535
90507
  }
90536
90508
  }),
90537
- type = _usePriceFactor.type,
90538
90509
  entries = _usePriceFactor.entries,
90539
90510
  isModalOpen = _usePriceFactor.isModalOpen,
90540
90511
  handleModalOpen = _usePriceFactor.handleModalOpen,
90541
90512
  handleModalClose = _usePriceFactor.handleModalClose,
90542
- handleTypeChange = _usePriceFactor.handleTypeChange,
90513
+ handleEntryTypeChange = _usePriceFactor.handleEntryTypeChange,
90543
90514
  handleAddEntry = _usePriceFactor.handleAddEntry,
90544
90515
  handleRemoveEntry = _usePriceFactor.handleRemoveEntry,
90545
90516
  handleEntryValueChange = _usePriceFactor.handleEntryValueChange,
@@ -90601,7 +90572,6 @@ function PriceFactorCellRenderer(props) {
90601
90572
  if (clickTimer.current) clearTimeout(clickTimer.current);
90602
90573
  };
90603
90574
  }, []);
90604
- var isDiscount = type === 'discount';
90605
90575
  var isSingleDefaultEntry = entries.length === 1 && isDefaultValue(entries[0].value);
90606
90576
  var hasInvalidEntries = entries.some(function (entry) {
90607
90577
  return entry.isValid === false;
@@ -90611,7 +90581,7 @@ function PriceFactorCellRenderer(props) {
90611
90581
  className: cell,
90612
90582
  onClick: onClick,
90613
90583
  onDoubleClick: onDoubleClick,
90614
- children: formatListValue(value || [], type, i18n.language)
90584
+ children: formatListValue(value || [], i18n.language)
90615
90585
  }), /*#__PURE__*/jsxs(Modal$2, {
90616
90586
  title: colDef === null || colDef === void 0 ? void 0 : colDef.headerName,
90617
90587
  open: isModalOpen,
@@ -90624,40 +90594,43 @@ function PriceFactorCellRenderer(props) {
90624
90594
  cancelText: t('backoffice.idmCatalog.prices.priceFactor.cancel'),
90625
90595
  width: 500,
90626
90596
  wrapClassName: "ag-custom-component-popup",
90627
- children: [/*#__PURE__*/jsx("div", {
90628
- className: typeSelector,
90629
- children: /*#__PURE__*/jsxs(Radio.Group, {
90630
- value: type,
90631
- onChange: function onChange(e) {
90632
- return handleTypeChange(e.target.value);
90633
- },
90634
- children: [/*#__PURE__*/jsx(Radio.Button, {
90635
- value: "factor",
90636
- children: t('backoffice.idmCatalog.prices.priceFactor.type.factor')
90637
- }), /*#__PURE__*/jsx(Radio.Button, {
90638
- value: "discount",
90639
- children: t('backoffice.idmCatalog.prices.priceFactor.type.discount')
90640
- })]
90641
- })
90642
- }), /*#__PURE__*/jsx(List$1, {
90597
+ children: [/*#__PURE__*/jsx(List$1, {
90643
90598
  dataSource: entries,
90644
90599
  renderItem: function renderItem(entry, index) {
90645
90600
  var _entry$input;
90601
+ var isDiscount = entry.type === 'discount';
90646
90602
  return /*#__PURE__*/jsx(List$1.Item, {
90647
90603
  children: /*#__PURE__*/jsx(Form$2.Item, {
90648
90604
  validateStatus: entry.isValid === false ? 'error' : undefined,
90649
90605
  help: entry.isValid === false ? t(isDiscount ? 'backoffice.idmCatalog.prices.priceFactor.error.invalidDiscount' : 'backoffice.idmCatalog.prices.priceFactor.error.invalidFactor') : undefined,
90650
90606
  className: space,
90651
90607
  children: /*#__PURE__*/jsxs(Space, {
90652
- children: [/*#__PURE__*/jsx(Input$1, {
90653
- type: "number",
90654
- value: (_entry$input = entry.input) !== null && _entry$input !== void 0 ? _entry$input : convertToDisplayValue(entry.value, type),
90608
+ children: [/*#__PURE__*/jsx(Select, {
90609
+ value: entry.type,
90610
+ onChange: function onChange(newType) {
90611
+ return handleEntryTypeChange(index, newType);
90612
+ },
90613
+ options: [{
90614
+ value: 'factor',
90615
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.factor')
90616
+ }, {
90617
+ value: 'discount',
90618
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.discount')
90619
+ }],
90620
+ style: {
90621
+ width: 140
90622
+ },
90623
+ classNames: {
90624
+ popup: {
90625
+ root: 'ag-custom-component-popup'
90626
+ }
90627
+ }
90628
+ }), /*#__PURE__*/jsx(Input$1, {
90629
+ inputMode: "decimal",
90630
+ value: (_entry$input = entry.input) !== null && _entry$input !== void 0 ? _entry$input : convertToDisplayValue(entry.value, entry.type),
90655
90631
  onChange: function onChange(e) {
90656
90632
  return handleEntryValueChange(index, e.target.value);
90657
90633
  },
90658
- step: isDiscount ? 'any' : '0.1',
90659
- min: isDiscount ? '0' : '1',
90660
- max: isDiscount ? String(MAX_DISCOUNT) : undefined,
90661
90634
  className: input$1,
90662
90635
  addonAfter: isDiscount ? '%' : undefined
90663
90636
  }), /*#__PURE__*/jsx(Button, {
@@ -90682,9 +90655,13 @@ function PriceFactorCellRenderer(props) {
90682
90655
  icon: /*#__PURE__*/jsx(PlusOutlined, {}),
90683
90656
  children: t('backoffice.idmCatalog.prices.priceFactor.action.add')
90684
90657
  })
90685
- }), /*#__PURE__*/jsx("div", {
90658
+ }), /*#__PURE__*/jsxs("div", {
90686
90659
  className: helpText,
90687
- children: type === 'factor' ? t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange') : t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
90660
+ children: [/*#__PURE__*/jsx("div", {
90661
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange')
90662
+ }), /*#__PURE__*/jsx("div", {
90663
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
90664
+ })]
90688
90665
  })]
90689
90666
  })]
90690
90667
  });
@@ -90758,20 +90735,28 @@ var disabled = "disabled-Llkqu";
90758
90735
  var css_248z$1 = ".input-leHam {\n position: relative;\n width: 200px;\n height: 32px;\n border: 1px solid #d9d9d9;\n background: #ffffff;\n padding: 0 11px;\n border-radius: 6px;\n font-size: 14px;\n line-height: 30px;\n cursor: pointer;\n}\n\n.darkmode .input-leHam {\n background: #141414;\n border: 1px solid #424242;\n}\n\n.input-leHam.disabled-Llkqu {\n cursor: default;\n color: rgba(0, 0, 0, 0.25);\n}\n\n.darkmode .input-leHam.disabled-Llkqu {\n color: rgba(255, 255, 255, 0.25);\n}\n\n.input-leHam:hover {\n border-color: #4096ff;\n}\n";
90759
90736
  styleInject(css_248z$1);
90760
90737
 
90761
- var _excluded$2 = ["onSave", "value"];
90738
+ var _excluded$2 = ["onSave", "value", "isDiscount"];
90762
90739
  function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
90763
90740
  function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
90764
90741
  function PriceFactorInput(_ref) {
90765
90742
  var _onSave = _ref.onSave,
90766
90743
  value = _ref.value,
90744
+ isDiscount = _ref.isDiscount,
90767
90745
  props = _objectWithoutProperties(_ref, _excluded$2);
90768
90746
  var _useState = useState(value),
90769
90747
  _useState2 = _slicedToArray(_useState, 2),
90770
90748
  innerValue = _useState2[0],
90771
90749
  setInnerValue = _useState2[1];
90750
+ var _useState3 = useState(isDiscount),
90751
+ _useState4 = _slicedToArray(_useState3, 2),
90752
+ innerIsDiscount = _useState4[0],
90753
+ setInnerIsDiscount = _useState4[1];
90772
90754
  useEffect(function () {
90773
90755
  setInnerValue(value);
90774
90756
  }, [value]);
90757
+ useEffect(function () {
90758
+ setInnerIsDiscount(isDiscount);
90759
+ }, [isDiscount]);
90775
90760
  return /*#__PURE__*/jsx(Tooltip$1, {
90776
90761
  title: props.tooltip,
90777
90762
  children: /*#__PURE__*/jsx("div", {
@@ -90779,9 +90764,13 @@ function PriceFactorInput(_ref) {
90779
90764
  children: /*#__PURE__*/jsx(PriceFactorCellRenderer, _objectSpread$a(_objectSpread$a({}, props), {}, {
90780
90765
  isNotInAGGrid: true,
90781
90766
  value: innerValue,
90782
- onSave: function onSave(data, value) {
90767
+ getIsDiscount: function getIsDiscount() {
90768
+ return innerIsDiscount;
90769
+ },
90770
+ onSave: function onSave(data, value, isDiscount) {
90783
90771
  setInnerValue(value);
90784
- return _onSave(data, value);
90772
+ setInnerIsDiscount(isDiscount);
90773
+ return _onSave(data, value, isDiscount);
90785
90774
  }
90786
90775
  }))
90787
90776
  })
@@ -90799,6 +90788,7 @@ function PriceFactorHeaderComponent(_ref) {
90799
90788
  priority = _ref.priority,
90800
90789
  priorityForced = _ref.priorityForced,
90801
90790
  value = _ref.value,
90791
+ isDiscount = _ref.isDiscount,
90802
90792
  inputTooltip = _ref.inputTooltip,
90803
90793
  checkboxTooltip = _ref.checkboxTooltip;
90804
90794
  var _useTranslation = useTranslation$1(),
@@ -90814,6 +90804,7 @@ function PriceFactorHeaderComponent(_ref) {
90814
90804
  children: [/*#__PURE__*/jsx(PriceFactorInput, {
90815
90805
  onSave: onSave,
90816
90806
  value: value,
90807
+ isDiscount: isDiscount,
90817
90808
  className: factorInput,
90818
90809
  tooltip: t(inputTooltip)
90819
90810
  }), /*#__PURE__*/jsx(Tooltip$1, {
@@ -90838,7 +90829,7 @@ function PriceFactorHeaderComponent(_ref) {
90838
90829
  * endpoint instead of the grid's excel export, because the served file is a report, not the grid content.
90839
90830
  */
90840
90831
  var Prices = observer(function (props) {
90841
- var _pricelist$seriePrice;
90832
+ var _pricelist$seriePrice, _pricelist$seriePrice2;
90842
90833
  var organizationId = props.organizationId,
90843
90834
  selectedPackage = props.selectedPackage,
90844
90835
  apiConfig = props.apiConfig,
@@ -90895,9 +90886,9 @@ var Prices = observer(function (props) {
90895
90886
  }
90896
90887
  }, _callee, null, [[2, 8, 11, 14]]);
90897
90888
  })), [apiConfig.enricherService, readPackageId, pricelist, selectedSerie, root.dataStore.jwt, showLoadingModal, showErrorModal, closeModal, t]);
90898
- var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
90889
+ var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
90899
90890
  if (!selectedSerie) return;
90900
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value));
90891
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value, isDiscount));
90901
90892
  }, [selectedSerie, pricelist, setNodeDataValue]);
90902
90893
  var updatePfgPriority = useCallback(function (priceFeatureGroupItem, value) {
90903
90894
  if (!selectedSerie) return;
@@ -90907,21 +90898,21 @@ var Prices = observer(function (props) {
90907
90898
  if (!selectedSerie) return;
90908
90899
  setNodeDataValue(applyPriceFactorPriority(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
90909
90900
  }, [pricelist, selectedSerie, setNodeDataValue]);
90910
- var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
90901
+ var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
90911
90902
  if (!selectedSerie) return;
90912
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
90903
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value, isDiscount));
90913
90904
  }, [pricelist, selectedSerie, setNodeDataValue]);
90914
- var updateArticlePriceFactor = useCallback(function (typeNo, value) {
90905
+ var updateArticlePriceFactor = useCallback(function (typeNo, value, isDiscount) {
90915
90906
  if (!selectedSerie) return;
90916
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value));
90907
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value, isDiscount));
90917
90908
  }, [pricelist, selectedSerie, setNodeDataValue]);
90918
- var updateTypeKeyPriceFactor = useCallback(function (typeKey, value) {
90909
+ var updateTypeKeyPriceFactor = useCallback(function (typeKey, value, isDiscount) {
90919
90910
  if (!selectedSerie) return;
90920
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value));
90911
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value, isDiscount));
90921
90912
  }, [pricelist, selectedSerie, setNodeDataValue]);
90922
- var updateSeriePriceFactor = useCallback(function (value) {
90913
+ var updateSeriePriceFactor = useCallback(function (value, isDiscount) {
90923
90914
  if (!selectedSerie) return;
90924
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value));
90915
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value, isDiscount));
90925
90916
  }, [pricelist, selectedSerie, setNodeDataValue]);
90926
90917
  function deleteManualPrices() {
90927
90918
  return _deleteManualPrices.apply(this, arguments);
@@ -90994,19 +90985,23 @@ var Prices = observer(function (props) {
90994
90985
  return (_pricelist$articlePri = pricelist.articlePricefactors) === null || _pricelist$articlePri === void 0 || (_pricelist$articlePri = _pricelist$articlePri[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$articlePri === void 0 ? void 0 : _pricelist$articlePri[data.typeNo];
90995
90986
  },
90996
90987
  cellRendererParams: {
90988
+ getIsDiscount: function getIsDiscount(data) {
90989
+ var _pricelist$articlePri2;
90990
+ return (_pricelist$articlePri2 = pricelist.articlePricefactorsIsDiscount) === null || _pricelist$articlePri2 === void 0 || (_pricelist$articlePri2 = _pricelist$articlePri2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$articlePri2 === void 0 ? void 0 : _pricelist$articlePri2[data.typeNo];
90991
+ },
90997
90992
  onSave: function () {
90998
- var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value) {
90993
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value, isDiscount) {
90999
90994
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
91000
90995
  while (1) switch (_context2.prev = _context2.next) {
91001
90996
  case 0:
91002
- updateArticlePriceFactor(data.typeNo, value);
90997
+ updateArticlePriceFactor(data.typeNo, value, isDiscount);
91003
90998
  case 1:
91004
90999
  case "end":
91005
91000
  return _context2.stop();
91006
91001
  }
91007
91002
  }, _callee2);
91008
91003
  }));
91009
- function onSave(_x, _x2) {
91004
+ function onSave(_x, _x2, _x3) {
91010
91005
  return _onSave.apply(this, arguments);
91011
91006
  }
91012
91007
  return onSave;
@@ -91036,19 +91031,23 @@ var Prices = observer(function (props) {
91036
91031
  return (_pricelist$typeKeyPri = pricelist.typeKeyPricefactors) === null || _pricelist$typeKeyPri === void 0 || (_pricelist$typeKeyPri = _pricelist$typeKeyPri[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$typeKeyPri === void 0 ? void 0 : _pricelist$typeKeyPri[data.typeKey];
91037
91032
  },
91038
91033
  cellRendererParams: {
91034
+ getIsDiscount: function getIsDiscount(data) {
91035
+ var _pricelist$typeKeyPri2;
91036
+ return (_pricelist$typeKeyPri2 = pricelist.typeKeyPricefactorsIsDiscount) === null || _pricelist$typeKeyPri2 === void 0 || (_pricelist$typeKeyPri2 = _pricelist$typeKeyPri2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$typeKeyPri2 === void 0 ? void 0 : _pricelist$typeKeyPri2[data.typeKey];
91037
+ },
91039
91038
  onSave: function () {
91040
- var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value) {
91039
+ var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value, isDiscount) {
91041
91040
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
91042
91041
  while (1) switch (_context3.prev = _context3.next) {
91043
91042
  case 0:
91044
- updateTypeKeyPriceFactor(data.typeKey, value);
91043
+ updateTypeKeyPriceFactor(data.typeKey, value, isDiscount);
91045
91044
  case 1:
91046
91045
  case "end":
91047
91046
  return _context3.stop();
91048
91047
  }
91049
91048
  }, _callee3);
91050
91049
  }));
91051
- function onSave(_x3, _x4) {
91050
+ function onSave(_x4, _x5, _x6) {
91052
91051
  return _onSave2.apply(this, arguments);
91053
91052
  }
91054
91053
  return onSave;
@@ -91058,29 +91057,30 @@ var Prices = observer(function (props) {
91058
91057
  sortable: false,
91059
91058
  editable: false
91060
91059
  }].concat(_toConsumableArray((_priceFeatureGroups$m = priceFeatureGroups === null || priceFeatureGroups === void 0 ? void 0 : priceFeatureGroups.map(function (priceFeatureGroup) {
91061
- var _pricelist$pfgPricefa, _pricelist$pfgPricefa2, _priceFeatureGroup$ke, _priceFeatureGroup$ke2;
91060
+ var _pricelist$pfgPricefa, _pricelist$pfgPricefa2, _pricelist$pfgPricefa3, _priceFeatureGroup$ke, _priceFeatureGroup$ke2;
91062
91061
  return {
91063
91062
  headerName: priceFeatureGroup.displayText,
91064
91063
  headerClass: inputHeader,
91065
91064
  headerGroupComponentParams: {
91066
91065
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
91067
91066
  onSave: (/*#__PURE__*/function () {
91068
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value) {
91067
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value, isDiscount) {
91069
91068
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
91070
91069
  while (1) switch (_context4.prev = _context4.next) {
91071
91070
  case 0:
91072
- updatePfgPriceFactor(priceFeatureGroup.id, value);
91071
+ updatePfgPriceFactor(priceFeatureGroup.id, value, isDiscount);
91073
91072
  case 1:
91074
91073
  case "end":
91075
91074
  return _context4.stop();
91076
91075
  }
91077
91076
  }, _callee4);
91078
91077
  }));
91079
- return function (_x5, _x6) {
91078
+ return function (_x7, _x8, _x9) {
91080
91079
  return _ref4.apply(this, arguments);
91081
91080
  };
91082
91081
  }()),
91083
91082
  value: (_pricelist$pfgPricefa = pricelist.pfgPricefactors) === null || _pricelist$pfgPricefa === void 0 || (_pricelist$pfgPricefa = _pricelist$pfgPricefa[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$pfgPricefa === void 0 ? void 0 : _pricelist$pfgPricefa[priceFeatureGroup.id],
91083
+ isDiscount: (_pricelist$pfgPricefa2 = pricelist.pfgPricefactorsIsDiscount) === null || _pricelist$pfgPricefa2 === void 0 || (_pricelist$pfgPricefa2 = _pricelist$pfgPricefa2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$pfgPricefa2 === void 0 ? void 0 : _pricelist$pfgPricefa2[priceFeatureGroup.id],
91084
91084
  onPriorityChange: (/*#__PURE__*/function () {
91085
91085
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(value) {
91086
91086
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
@@ -91093,18 +91093,18 @@ var Prices = observer(function (props) {
91093
91093
  }
91094
91094
  }, _callee5);
91095
91095
  }));
91096
- return function (_x7) {
91096
+ return function (_x10) {
91097
91097
  return _ref5.apply(this, arguments);
91098
91098
  };
91099
91099
  }()),
91100
- priority: !!((_pricelist$pfgPricefa2 = pricelist.pfgPricefactorsPriority) !== null && _pricelist$pfgPricefa2 !== void 0 && (_pricelist$pfgPricefa2 = _pricelist$pfgPricefa2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pfgPricefa2 !== void 0 && _pricelist$pfgPricefa2.includes(priceFeatureGroup.id)),
91100
+ priority: !!((_pricelist$pfgPricefa3 = pricelist.pfgPricefactorsPriority) !== null && _pricelist$pfgPricefa3 !== void 0 && (_pricelist$pfgPricefa3 = _pricelist$pfgPricefa3[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pfgPricefa3 !== void 0 && _pricelist$pfgPricefa3.includes(priceFeatureGroup.id)),
91101
91101
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfg',
91102
91102
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfgPriority'
91103
91103
  })
91104
91104
  },
91105
91105
  marryChildren: true,
91106
91106
  children: _toConsumableArray((_priceFeatureGroup$ke = (_priceFeatureGroup$ke2 = priceFeatureGroup.keys) === null || _priceFeatureGroup$ke2 === void 0 ? void 0 : _priceFeatureGroup$ke2.map(function (priceGroup, j) {
91107
- var _priceFeatureGroup$ke3, _pricelist$pgPricefac, _pricelist$pgPricefac2, _pricelist$pfgPricefa3;
91107
+ var _priceFeatureGroup$ke3, _pricelist$pgPricefac, _pricelist$pgPricefac2, _pricelist$pgPricefac3, _pricelist$pfgPricefa4;
91108
91108
  return {
91109
91109
  headerName: priceGroup,
91110
91110
  field: "prices.".concat(priceGroup),
@@ -91124,22 +91124,23 @@ var Prices = observer(function (props) {
91124
91124
  headerComponentParams: {
91125
91125
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
91126
91126
  onSave: (/*#__PURE__*/function () {
91127
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value) {
91127
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value, isDiscount) {
91128
91128
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
91129
91129
  while (1) switch (_context6.prev = _context6.next) {
91130
91130
  case 0:
91131
- updatePgPriceFactor(priceGroup, value);
91131
+ updatePgPriceFactor(priceGroup, value, isDiscount);
91132
91132
  case 1:
91133
91133
  case "end":
91134
91134
  return _context6.stop();
91135
91135
  }
91136
91136
  }, _callee6);
91137
91137
  }));
91138
- return function (_x8, _x9) {
91138
+ return function (_x11, _x12, _x13) {
91139
91139
  return _ref6.apply(this, arguments);
91140
91140
  };
91141
91141
  }()),
91142
91142
  value: (_pricelist$pgPricefac = pricelist.pgPricefactors) === null || _pricelist$pgPricefac === void 0 || (_pricelist$pgPricefac = _pricelist$pgPricefac[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$pgPricefac === void 0 ? void 0 : _pricelist$pgPricefac[priceGroup],
91143
+ isDiscount: (_pricelist$pgPricefac2 = pricelist.pgPricefactorsIsDiscount) === null || _pricelist$pgPricefac2 === void 0 || (_pricelist$pgPricefac2 = _pricelist$pgPricefac2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) === null || _pricelist$pgPricefac2 === void 0 ? void 0 : _pricelist$pgPricefac2[priceGroup],
91143
91144
  onPriorityChange: (/*#__PURE__*/function () {
91144
91145
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(value) {
91145
91146
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
@@ -91152,12 +91153,12 @@ var Prices = observer(function (props) {
91152
91153
  }
91153
91154
  }, _callee7);
91154
91155
  }));
91155
- return function (_x10) {
91156
+ return function (_x14) {
91156
91157
  return _ref7.apply(this, arguments);
91157
91158
  };
91158
91159
  }()),
91159
- priority: !!((_pricelist$pgPricefac2 = pricelist.pgPricefactorsPriority) !== null && _pricelist$pgPricefac2 !== void 0 && (_pricelist$pgPricefac2 = _pricelist$pgPricefac2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pgPricefac2 !== void 0 && _pricelist$pgPricefac2.includes(priceGroup)),
91160
- priorityForced: !!((_pricelist$pfgPricefa3 = pricelist.pfgPricefactorsPriority) !== null && _pricelist$pfgPricefa3 !== void 0 && (_pricelist$pfgPricefa3 = _pricelist$pfgPricefa3[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pfgPricefa3 !== void 0 && _pricelist$pfgPricefa3.includes(priceFeatureGroup.id)),
91160
+ priority: !!((_pricelist$pgPricefac3 = pricelist.pgPricefactorsPriority) !== null && _pricelist$pgPricefac3 !== void 0 && (_pricelist$pgPricefac3 = _pricelist$pgPricefac3[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pgPricefac3 !== void 0 && _pricelist$pgPricefac3.includes(priceGroup)),
91161
+ priorityForced: !!((_pricelist$pfgPricefa4 = pricelist.pfgPricefactorsPriority) !== null && _pricelist$pfgPricefa4 !== void 0 && (_pricelist$pfgPricefa4 = _pricelist$pfgPricefa4[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo]) !== null && _pricelist$pfgPricefa4 !== void 0 && _pricelist$pfgPricefa4.includes(priceFeatureGroup.id)),
91161
91162
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pg',
91162
91163
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pgPriority'
91163
91164
  })
@@ -91249,19 +91250,20 @@ var Prices = observer(function (props) {
91249
91250
  tooltip: t('backoffice.idmCatalog.prices.priceFactor.tooltip.series'),
91250
91251
  children: /*#__PURE__*/jsx(PriceFactorInput, {
91251
91252
  value: (_pricelist$seriePrice = pricelist.seriePricefactors) === null || _pricelist$seriePrice === void 0 ? void 0 : _pricelist$seriePrice[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
91253
+ isDiscount: (_pricelist$seriePrice2 = pricelist.seriePricefactorsIsDiscount) === null || _pricelist$seriePrice2 === void 0 ? void 0 : _pricelist$seriePrice2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
91252
91254
  onSave: (/*#__PURE__*/function () {
91253
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value) {
91255
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value, isDiscount) {
91254
91256
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
91255
91257
  while (1) switch (_context8.prev = _context8.next) {
91256
91258
  case 0:
91257
- updateSeriePriceFactor(value);
91259
+ updateSeriePriceFactor(value, isDiscount);
91258
91260
  case 1:
91259
91261
  case "end":
91260
91262
  return _context8.stop();
91261
91263
  }
91262
91264
  }, _callee8);
91263
91265
  }));
91264
- return function (_x11, _x12) {
91266
+ return function (_x15, _x16, _x17) {
91265
91267
  return _ref8.apply(this, arguments);
91266
91268
  };
91267
91269
  }()),
@@ -91484,6 +91486,43 @@ var TablePriceList = observer(function () {
91484
91486
  field: 'pricefactors',
91485
91487
  cellDataType: 'number',
91486
91488
  cellRenderer: PriceFactorCellRenderer,
91489
+ cellRendererParams: {
91490
+ getIsDiscount: function getIsDiscount(data) {
91491
+ return data === null || data === void 0 ? void 0 : data.pricefactorsIsDiscount;
91492
+ },
91493
+ // One write for factors and flags, so both reach the pricelist in the same update. The node id comes
91494
+ // first: a row created in this session keeps its temporary id as row id, also once it has its _id.
91495
+ onSave: function () {
91496
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value, isDiscount, nodeId) {
91497
+ var _spreadsheetRef$curre;
91498
+ var rowId;
91499
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
91500
+ while (1) switch (_context.prev = _context.next) {
91501
+ case 0:
91502
+ rowId = nodeId !== null && nodeId !== void 0 ? nodeId : data === null || data === void 0 ? void 0 : data._id;
91503
+ if (rowId) {
91504
+ _context.next = 3;
91505
+ break;
91506
+ }
91507
+ return _context.abrupt("return");
91508
+ case 3:
91509
+ _context.next = 5;
91510
+ return (_spreadsheetRef$curre = spreadsheetRef.current) === null || _spreadsheetRef$curre === void 0 ? void 0 : _spreadsheetRef$curre.setNodeDataValue(rowId, {
91511
+ pricefactors: value,
91512
+ pricefactorsIsDiscount: isDiscount.length > 0 ? isDiscount : undefined
91513
+ });
91514
+ case 5:
91515
+ case "end":
91516
+ return _context.stop();
91517
+ }
91518
+ }, _callee);
91519
+ }));
91520
+ function onSave(_x, _x2, _x3, _x4) {
91521
+ return _onSave.apply(this, arguments);
91522
+ }
91523
+ return onSave;
91524
+ }()
91525
+ },
91487
91526
  editable: false,
91488
91527
  filter: false,
91489
91528
  equals: function equals(a, b) {
@@ -91603,6 +91642,38 @@ var TablePriceList = observer(function () {
91603
91642
  cellDataType: 'object',
91604
91643
  editable: false,
91605
91644
  hide: true
91645
+ },
91646
+ // Per factor whether the price factor dialog shows it as discount, beside the factor fields above
91647
+ {
91648
+ field: 'pricefactorsIsDiscount',
91649
+ cellDataType: 'object',
91650
+ editable: false,
91651
+ hide: true
91652
+ }, {
91653
+ field: 'seriePricefactorsIsDiscount',
91654
+ cellDataType: 'object',
91655
+ editable: false,
91656
+ hide: true
91657
+ }, {
91658
+ field: 'articlePricefactorsIsDiscount',
91659
+ cellDataType: 'object',
91660
+ editable: false,
91661
+ hide: true
91662
+ }, {
91663
+ field: 'typeKeyPricefactorsIsDiscount',
91664
+ cellDataType: 'object',
91665
+ editable: false,
91666
+ hide: true
91667
+ }, {
91668
+ field: 'pgPricefactorsIsDiscount',
91669
+ cellDataType: 'object',
91670
+ editable: false,
91671
+ hide: true
91672
+ }, {
91673
+ field: 'pfgPricefactorsIsDiscount',
91674
+ cellDataType: 'object',
91675
+ editable: false,
91676
+ hide: true
91606
91677
  }]
91607
91678
  };
91608
91679
  }, [apiInterface, i18n.language, viewOnly]);
@@ -4,8 +4,9 @@ interface PriceFactorHeaderComponentProps {
4
4
  * Callback to save the price factor value
5
5
  * @param data - The data to save
6
6
  * @param value - The value to save
7
+ * @param isDiscount - Per value whether it is shown as discount ([] when none is)
7
8
  */
8
- onSave: (data: any, value: number[]) => Promise<void>;
9
+ onSave: (data: any, value: number[], isDiscount: boolean[]) => Promise<void>;
9
10
  /**
10
11
  * Callback to save the priority value
11
12
  * @param value - The value to save
@@ -23,6 +24,10 @@ interface PriceFactorHeaderComponentProps {
23
24
  * The value of the price factor
24
25
  */
25
26
  value: number[];
27
+ /**
28
+ * Per value of the price factor whether it is shown as discount
29
+ */
30
+ isDiscount?: boolean[];
26
31
  /**
27
32
  * The tooltip key for the input
28
33
  */
@@ -32,6 +37,6 @@ interface PriceFactorHeaderComponentProps {
32
37
  */
33
38
  checkboxTooltip: string;
34
39
  }
35
- export default function PriceFactorHeaderComponent({ onSave, onPriorityChange, priority, priorityForced, value, inputTooltip, checkboxTooltip, }: PriceFactorHeaderComponentProps): React.JSX.Element;
40
+ export default function PriceFactorHeaderComponent({ onSave, onPriorityChange, priority, priorityForced, value, isDiscount, inputTooltip, checkboxTooltip, }: PriceFactorHeaderComponentProps): React.JSX.Element;
36
41
  export {};
37
42
  //# sourceMappingURL=PriceFactorHeaderComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PriceFactorHeaderComponent.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,+BAA+B;IACvC;;;;OAIG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,EACjD,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,KAAK,EACL,YAAY,EACZ,eAAe,GAChB,EAAE,+BAA+B,qBAwBjC"}
1
+ {"version":3,"file":"PriceFactorHeaderComponent.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,+BAA+B;IACvC;;;;;OAKG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,EACjD,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,KAAK,EACL,UAAU,EACV,YAAY,EACZ,eAAe,GAChB,EAAE,+BAA+B,qBAwBjC"}
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  interface PriceFactorInputProps {
3
3
  value: number[];
4
- onSave: (data: any, value: number[]) => Promise<void>;
4
+ /** Per value whether it is shown as discount */
5
+ isDiscount?: boolean[];
6
+ onSave: (data: any, value: number[], isDiscount: boolean[]) => Promise<void>;
5
7
  disabled?: boolean;
6
8
  title?: string;
7
9
  tooltip?: string;
8
10
  className?: string;
9
11
  }
10
- export default function PriceFactorInput({ onSave, value, ...props }: PriceFactorInputProps): React.JSX.Element;
12
+ export default function PriceFactorInput({ onSave, value, isDiscount, ...props }: PriceFactorInputProps): React.JSX.Element;
11
13
  export {};
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,qBAsB1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,qBA6BtG"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAkB,MAAM,0BAA0B,CAAC;AAOrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAmBvE,UAAU,WAAW;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IACf,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,WAAoB,WAAW;;CA4YhD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAkB,MAAM,0BAA0B,CAAC;AAOrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAmBvE,UAAU,WAAW;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IACf,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,WAAoB,WAAW;;CAiZhD,CAAC"}
@@ -7,13 +7,16 @@
7
7
  export type PriceFactorScope = 'article' | 'typeKey' | 'priceFeatureGroup' | 'priceGroup' | 'serie';
8
8
  /** Pricelist field per scope holding the factor map. */
9
9
  export declare const PRICE_FACTOR_FIELDS: Record<PriceFactorScope, string>;
10
+ /** Pricelist field per scope holding, index by index beside the factors, whether each factor is shown as discount. */
11
+ export declare const PRICE_FACTOR_DISCOUNT_FIELDS: Record<PriceFactorScope, string>;
10
12
  /** Pricelist field per scope holding the priority list map — only PFG and PG scopes support priority. */
11
13
  export declare const PRICE_FACTOR_PRIORITY_FIELDS: Partial<Record<PriceFactorScope, string>>;
12
14
  /**
13
- * Computes the single-field `setNodeDataValue` patch that applies — or, with an empty `value`, clears —
14
- * a price factor for a scope/key on a serie. `key` is unused for scope 'serie'.
15
+ * Computes the `setNodeDataValue` patch that applies — or, with an empty `value`, clears — a price factor for a
16
+ * scope/key on a serie. `key` is unused for scope 'serie'. `isDiscount` flags the factors shown as discount, index
17
+ * by index; empty when none is, which also clears flags left from before (e.g. when the agent sets factors).
15
18
  */
16
- export declare function applyPriceFactor(pricelist: Record<string, any>, serieNo: number, scope: PriceFactorScope, key: string | undefined, value: number[]): Record<string, any>;
19
+ export declare function applyPriceFactor(pricelist: Record<string, any>, serieNo: number, scope: PriceFactorScope, key: string | undefined, value: number[], isDiscount?: boolean[]): Record<string, any>;
17
20
  /** Computes the single-field `setNodeDataValue` patch that sets/clears the priority flag of a PFG or price-group factor. */
18
21
  export declare function applyPriceFactorPriority(pricelist: Record<string, any>, serieNo: number, scope: PriceFactorScope, key: string, priority: boolean): Record<string, any>;
19
22
  //# sourceMappingURL=priceFactorMutations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"priceFactorMutations.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,mBAAmB,GAAG,YAAY,GAAG,OAAO,CAAC;AAEpG,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAMhE,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,4BAA4B,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAGlF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAuCrB;AAED,4HAA4H;AAC5H,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,OAAO,GAChB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwBrB"}
1
+ {"version":3,"file":"priceFactorMutations.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,mBAAmB,GAAG,YAAY,GAAG,OAAO,CAAC;AAEpG,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAMhE,CAAC;AAEF,sHAAsH;AACtH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAMzE,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,4BAA4B,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAGlF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,EAAE,MAAM,EAAE,EACf,UAAU,GAAE,OAAO,EAAO,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAMrB;AAiDD,4HAA4H;AAC5H,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,OAAO,GAChB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwBrB"}
@@ -10,7 +10,13 @@ export default function PriceFactorCellRenderer(props: Partial<CustomCellRendere
10
10
  };
11
11
  manualPrices: string[];
12
12
  }, number[], DivaContext>> & {
13
- onSave?: (data: any, value: number[]) => Promise<void>;
13
+ /**
14
+ * Saves the factors and, index by index, whether each is shown as discount ([] when none is).
15
+ * `nodeId` is the grid row of the cell; unset outside a grid.
16
+ */
17
+ onSave: (data: any, value: number[], isDiscount: boolean[], nodeId?: string) => Promise<void>;
18
+ /** Reads the discount flags of the factors of a row; values without a flag are shown as factors */
19
+ getIsDiscount?: (data: any) => boolean[] | null | undefined;
14
20
  /**
15
21
  * if true, the component is used outside of an ag-grid cell, thus we have to handle the click event differently
16
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAK,EAAE,OAAO,CACZ,uBAAuB,CACrB;IACE,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,EACD,MAAM,EAAE,EACR,WAAW,CACZ,CACF,GAAG;IACF,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,qBAqLF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAK,EAAE,OAAO,CACZ,uBAAuB,CACrB;IACE,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,EACD,MAAM,EAAE,EACR,WAAW,CACZ,CACF,GAAG;IACF;;;OAGG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,mGAAmG;IACnG,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5D;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,qBA4KF"}
@@ -6,27 +6,21 @@ export interface PriceEntry {
6
6
  value: string;
7
7
  /** The text as typed by the user; shown instead of the converted value so typing is not overwritten */
8
8
  input?: string;
9
+ /** Whether the row is entered as factor or as discount; the stored value is always the factor */
10
+ type: PriceType;
9
11
  /** Whether the current value is valid according to type rules */
10
12
  isValid: boolean;
11
13
  }
12
14
  /** Largest discount in percent that can be entered */
13
15
  export declare const MAX_DISCOUNT = 99.99999;
14
- /** State container for both factor and discount entries */
15
- export interface EntryState {
16
- /** List of price factor entries (values > 1) */
17
- factor: PriceEntry[];
18
- /** List of discount entries (values between 0 and 1) */
19
- discount: PriceEntry[];
20
- }
21
16
  /**
22
17
  * Formats a list of values for display in the cell
23
18
  * For both types, displays the actual factor value (e.g., 0.8 for 20% discount)
24
19
  * @param values - The values to format
25
- * @param type - The type of price modification
26
20
  * @param locale - The locale to use for formatting
27
21
  * @returns The formatted string with values separated by semicolons
28
22
  */
29
- export declare const formatListValue: (values: number[], type: PriceType, locale: string) => string;
23
+ export declare const formatListValue: (values: number[], locale: string) => string;
30
24
  /**
31
25
  * Converts an internal value to its display representation
32
26
  * For factors: keeps the decimal value
@@ -48,7 +42,7 @@ export declare const convertToDisplayValue: (value: string, type: PriceType) =>
48
42
  export declare const convertFromDisplayValue: (value: string, type: PriceType) => string;
49
43
  /**
50
44
  * Validates if an input value is valid for the given type
51
- * For factors: must be >= 1
45
+ * For factors: must be > 0 (factors below 1 lower the price, factors above 1 raise it)
52
46
  * For discounts: the discount must be between 0 and 99.99999 percent
53
47
  * @param value - The value to validate
54
48
  * @param type - The type of price modification
@@ -57,7 +51,7 @@ export declare const convertFromDisplayValue: (value: string, type: PriceType) =
57
51
  export declare const isValidInput: (value: string, type: PriceType) => boolean;
58
52
  /**
59
53
  * Checks if a value is effective (should be saved)
60
- * For factors: must be > 1 (1 is valid but not effective)
54
+ * For factors: must not be 1 (1 is valid but leaves the price unchanged)
61
55
  * For discounts: must be < 1 (a 0% discount is valid but not effective)
62
56
  * @param value - The value to check
63
57
  * @param type - The type of price modification
@@ -1 +1 @@
1
- {"version":3,"file":"priceFactorHelpers.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9C,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,sDAAsD;AACtD,eAAO,MAAM,YAAY,WAAW,CAAC;AAKrC,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,wDAAwD;IACxD,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,EAAE,QAAQ,SAAS,UAAU,MAAM,KAAG,MASnF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,QAAQ,SAAS,KAAG,MAItE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,UAAW,MAAM,QAAQ,SAAS,KAAG,MAIxE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,QAAQ,SAAS,KAAG,OAM7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,QAAQ,SAAS,KAAG,OAGjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAAa,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,OAE9C,CAAC"}
1
+ {"version":3,"file":"priceFactorHelpers.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9C,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,uGAAuG;IACvG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,IAAI,EAAE,SAAS,CAAC;IAChB,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,sDAAsD;AACtD,eAAO,MAAM,YAAY,WAAW,CAAC;AAKrC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,EAAE,UAAU,MAAM,KAAG,MASlE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,QAAQ,SAAS,KAAG,MAItE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,UAAW,MAAM,QAAQ,SAAS,KAAG,MAIxE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,QAAQ,SAAS,KAAG,OAM7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,QAAQ,SAAS,KAAG,OAGjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,MAAa,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,OAE9C,CAAC"}
@@ -2,16 +2,18 @@ import { PriceType, PriceEntry } from './priceFactorHelpers';
2
2
  interface UseFactorProps {
3
3
  data: any;
4
4
  initialValue?: number[] | null;
5
- onSave: (data: any, value: number[]) => Promise<void>;
5
+ /** Per value whether it is shown as discount; values without a flag are shown as factors */
6
+ initialIsDiscount?: boolean[] | null;
7
+ /** Saves the factors and, index by index, whether each is a discount ([] when none is) */
8
+ onSave: (data: any, value: number[], isDiscount: boolean[]) => Promise<void>;
6
9
  onRefreshCell: () => void;
7
10
  }
8
11
  interface UseFactorReturn {
9
- type: PriceType;
10
12
  entries: PriceEntry[];
11
13
  isModalOpen: boolean;
12
14
  handleModalOpen: () => void;
13
15
  handleModalClose: () => void;
14
- handleTypeChange: (newType: PriceType) => void;
16
+ handleEntryTypeChange: (index: number, newType: PriceType) => void;
15
17
  handleAddEntry: () => void;
16
18
  handleRemoveEntry: (index: number) => void;
17
19
  handleEntryValueChange: (index: number, displayValue: string) => void;
@@ -22,9 +24,10 @@ interface UseFactorReturn {
22
24
  * @param props - Hook configuration
23
25
  * @param props.data - Data of the row
24
26
  * @param props.initialValue - Initial array of values
25
- * @param props.onSave - Callback to save values
27
+ * @param props.initialIsDiscount - Initial discount flags of the values
28
+ * @param props.onSave - Callback to save values and their discount flags
26
29
  * @param props.onRefreshCell - Callback to refresh the cell after save
27
30
  */
28
- export declare function usePriceFactor({ data, initialValue, onSave, onRefreshCell }: UseFactorProps): UseFactorReturn;
31
+ export declare function usePriceFactor({ data, initialValue, initialIsDiscount, onSave, onRefreshCell }: UseFactorProps): UseFactorReturn;
29
32
  export {};
30
33
  //# sourceMappingURL=usePriceFactor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePriceFactor.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,UAAU,EAOX,MAAM,sBAAsB,CAAC;AAE9B,UAAU,cAAc;IACtB,IAAI,EAAE,GAAG,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,sBAAsB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAAE,IAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,cAAc,GAAG,eAAe,CAmIlH"}
1
+ {"version":3,"file":"usePriceFactor.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,UAAU,EAMX,MAAM,sBAAsB,CAAC;AAE9B,UAAU,cAAc;IACtB,IAAI,EAAE,GAAG,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/B,4FAA4F;IAC5F,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACrC,0FAA0F;IAC1F,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;IACnE,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,sBAAsB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAQD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,EAAE,IAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,cAAc,GAAG,eAAe,CAiGrI"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/modules/TablePriceList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAevE,eAAO,MAAM,cAAc;;CA4VzB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/ui/IDMEnricherEditor/modules/TablePriceList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAevE,eAAO,MAAM,cAAc;;CA8YzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/diva-backoffice",
3
- "version": "26.12.3-rc.0",
3
+ "version": "26.12.3-rc.1",
4
4
  "description": "Ant Design backoffice shell (configuration modules) and the Diva Data Engine component hosting the IDM and enricher editors.",
5
5
  "license": "COMMERCIAL",
6
6
  "devDependencies": {
@@ -16,16 +16,16 @@
16
16
  "dependencies": {
17
17
  "@ant-design/icons": "6.3.4",
18
18
  "@babel/runtime": "7.24.7",
19
- "@crystaldesign/classification": "26.12.3-rc.0",
20
- "@crystaldesign/content-box": "26.12.3-rc.0",
21
- "@crystaldesign/content-item": "26.12.3-rc.0",
22
- "@crystaldesign/diva-agent": "26.12.3-rc.0",
23
- "@crystaldesign/diva-core": "26.12.3-rc.0",
24
- "@crystaldesign/diva-utils": "26.12.3-rc.0",
25
- "@crystaldesign/mass-configurator": "26.12.3-rc.0",
26
- "@crystaldesign/media-upload": "26.12.3-rc.0",
27
- "@crystaldesign/rtf-editor": "26.12.3-rc.0",
28
- "@crystaldesign/spreadsheet": "26.12.3-rc.0",
19
+ "@crystaldesign/classification": "26.12.3-rc.1",
20
+ "@crystaldesign/content-box": "26.12.3-rc.1",
21
+ "@crystaldesign/content-item": "26.12.3-rc.1",
22
+ "@crystaldesign/diva-agent": "26.12.3-rc.1",
23
+ "@crystaldesign/diva-core": "26.12.3-rc.1",
24
+ "@crystaldesign/diva-utils": "26.12.3-rc.1",
25
+ "@crystaldesign/mass-configurator": "26.12.3-rc.1",
26
+ "@crystaldesign/media-upload": "26.12.3-rc.1",
27
+ "@crystaldesign/rtf-editor": "26.12.3-rc.1",
28
+ "@crystaldesign/spreadsheet": "26.12.3-rc.1",
29
29
  "@dnd-kit/core": "^6.1.0",
30
30
  "@dnd-kit/sortable": "^8.0.0",
31
31
  "@dnd-kit/utilities": "^3.2.2",
@@ -59,5 +59,5 @@
59
59
  },
60
60
  "module": "build/esm/index.js",
61
61
  "types": "./build/types/backoffice/src/index.d.ts",
62
- "gitHead": "70eda410f16b90e408aceccfa04515a797b580a4"
62
+ "gitHead": "e97d09d1f288ce4b5cd96d3447a848d6b255096a"
63
63
  }