@crystaldesign/diva-backoffice 26.13.0-beta.20 → 26.13.0-beta.21

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
@@ -60171,6 +60171,15 @@ var PRICE_FACTOR_FIELDS = {
60171
60171
  serie: 'seriePricefactors'
60172
60172
  };
60173
60173
 
60174
+ /** Pricelist field per scope holding, index by index beside the factors, whether each factor is shown as discount. */
60175
+ var PRICE_FACTOR_DISCOUNT_FIELDS = {
60176
+ article: 'articlePricefactorsIsDiscount',
60177
+ typeKey: 'typeKeyPricefactorsIsDiscount',
60178
+ priceFeatureGroup: 'pfgPricefactorsIsDiscount',
60179
+ priceGroup: 'pgPricefactorsIsDiscount',
60180
+ serie: 'seriePricefactorsIsDiscount'
60181
+ };
60182
+
60174
60183
  /** Pricelist field per scope holding the priority list map — only PFG and PG scopes support priority. */
60175
60184
  var PRICE_FACTOR_PRIORITY_FIELDS = {
60176
60185
  priceFeatureGroup: 'pfgPricefactorsPriority',
@@ -60178,11 +60187,21 @@ var PRICE_FACTOR_PRIORITY_FIELDS = {
60178
60187
  };
60179
60188
 
60180
60189
  /**
60181
- * Computes the single-field `setNodeDataValue` patch that applies — or, with an empty `value`, clears —
60182
- * a price factor for a scope/key on a serie. `key` is unused for scope 'serie'.
60190
+ * Computes the `setNodeDataValue` patch that applies — or, with an empty `value`, clears — a price factor for a
60191
+ * scope/key on a serie. `key` is unused for scope 'serie'. `isDiscount` flags the factors shown as discount, index
60192
+ * by index; empty when none is, which also clears flags left from before (e.g. when the agent sets factors).
60183
60193
  */
60184
60194
  function applyPriceFactor(pricelist, serieNo, scope, key, value) {
60185
- var field = PRICE_FACTOR_FIELDS[scope];
60195
+ var isDiscount = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
60196
+ var patch = applyToFactorMap(pricelist, PRICE_FACTOR_FIELDS[scope], serieNo, scope, key, value);
60197
+ var discountField = PRICE_FACTOR_DISCOUNT_FIELDS[scope];
60198
+ // A pricelist that never had flags gets none, so a plain factor change stays a single-field patch
60199
+ if (isDiscount.length === 0 && pricelist[discountField] === undefined) return patch;
60200
+ return _objectSpread$16(_objectSpread$16({}, patch), applyToFactorMap(pricelist, discountField, serieNo, scope, key, isDiscount));
60201
+ }
60202
+
60203
+ /** Sets or, with an empty `value`, prunes the entry of a scope/key on a serie in one serie-scoped map field. */
60204
+ function applyToFactorMap(pricelist, field, serieNo, scope, key, value) {
60186
60205
  if (scope === 'serie') {
60187
60206
  var _newFactors = _objectSpread$16({}, pricelist[field]);
60188
60207
  if (value.length === 0) {
@@ -79151,17 +79170,14 @@ var removeFloatNoise = function removeFloatNoise(value) {
79151
79170
  return parseFloat(value.toFixed(10));
79152
79171
  };
79153
79172
 
79154
- /** State container for both factor and discount entries */
79155
-
79156
79173
  /**
79157
79174
  * Formats a list of values for display in the cell
79158
79175
  * For both types, displays the actual factor value (e.g., 0.8 for 20% discount)
79159
79176
  * @param values - The values to format
79160
- * @param type - The type of price modification
79161
79177
  * @param locale - The locale to use for formatting
79162
79178
  * @returns The formatted string with values separated by semicolons
79163
79179
  */
79164
- var formatListValue = function formatListValue(values, type, locale) {
79180
+ var formatListValue = function formatListValue(values, locale) {
79165
79181
  if (!(values !== null && values !== void 0 && values.length)) return '-';
79166
79182
  var formatter = new Intl.NumberFormat(locale, {
79167
79183
  minimumFractionDigits: 1,
@@ -79203,7 +79219,7 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
79203
79219
 
79204
79220
  /**
79205
79221
  * Validates if an input value is valid for the given type
79206
- * For factors: must be >= 1
79222
+ * For factors: must be > 0 (factors below 1 lower the price, factors above 1 raise it)
79207
79223
  * For discounts: the discount must be between 0 and 99.99999 percent
79208
79224
  * @param value - The value to validate
79209
79225
  * @param type - The type of price modification
@@ -79212,14 +79228,14 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
79212
79228
  var isValidInput = function isValidInput(value, type) {
79213
79229
  var numValue = parseFloat(value);
79214
79230
  if (isNaN(numValue)) return false;
79215
- if (type === 'factor') return numValue >= 1;
79231
+ if (type === 'factor') return numValue > 0;
79216
79232
  var discount = removeFloatNoise((1 - numValue) * 100);
79217
79233
  return discount >= 0 && discount <= MAX_DISCOUNT;
79218
79234
  };
79219
79235
 
79220
79236
  /**
79221
79237
  * Checks if a value is effective (should be saved)
79222
- * For factors: must be > 1 (1 is valid but not effective)
79238
+ * For factors: must not be 1 (1 is valid but leaves the price unchanged)
79223
79239
  * For discounts: must be < 1 (a 0% discount is valid but not effective)
79224
79240
  * @param value - The value to check
79225
79241
  * @param type - The type of price modification
@@ -79227,7 +79243,7 @@ var isValidInput = function isValidInput(value, type) {
79227
79243
  */
79228
79244
  var isEffectiveValue = function isEffectiveValue(value, type) {
79229
79245
  var numValue = parseFloat(value);
79230
- return type === 'factor' ? numValue > 1 : numValue < 1;
79246
+ return type === 'factor' ? numValue !== 1 : numValue < 1;
79231
79247
  };
79232
79248
 
79233
79249
  /**
@@ -79250,151 +79266,131 @@ var isDefaultValue = function isDefaultValue(value) {
79250
79266
 
79251
79267
  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; }
79252
79268
  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; }
79269
+ var createDefaultEntry = function createDefaultEntry() {
79270
+ return {
79271
+ value: getDefaultValue(),
79272
+ type: 'factor',
79273
+ isValid: true
79274
+ };
79275
+ };
79276
+
79253
79277
  /**
79254
79278
  * Custom hook to manage price factor state and logic
79255
79279
  * @param props - Hook configuration
79256
79280
  * @param props.data - Data of the row
79257
79281
  * @param props.initialValue - Initial array of values
79258
- * @param props.onSave - Callback to save values
79282
+ * @param props.initialIsDiscount - Initial discount flags of the values
79283
+ * @param props.onSave - Callback to save values and their discount flags
79259
79284
  * @param props.onRefreshCell - Callback to refresh the cell after save
79260
79285
  */
79261
79286
  function usePriceFactor(_ref) {
79262
79287
  var _ref$data = _ref.data,
79263
79288
  data = _ref$data === void 0 ? {} : _ref$data,
79264
79289
  initialValue = _ref.initialValue,
79290
+ initialIsDiscount = _ref.initialIsDiscount,
79265
79291
  onSave = _ref.onSave,
79266
79292
  onRefreshCell = _ref.onRefreshCell;
79267
79293
  var _useState = useState(false),
79268
79294
  _useState2 = _slicedToArray(_useState, 2),
79269
79295
  isModalOpen = _useState2[0],
79270
79296
  setIsModalOpen = _useState2[1];
79271
- var _useState3 = useState('factor'),
79297
+ var _useState3 = useState([]),
79272
79298
  _useState4 = _slicedToArray(_useState3, 2),
79273
- type = _useState4[0],
79274
- setType = _useState4[1];
79275
- var _useState5 = useState({
79276
- factor: [],
79277
- discount: []
79278
- }),
79279
- _useState6 = _slicedToArray(_useState5, 2),
79280
- entries = _useState6[0],
79281
- setEntries = _useState6[1];
79282
- var _useState7 = useState(false),
79283
- _useState8 = _slicedToArray(_useState7, 2),
79284
- hasChangedCurrentType = _useState8[0],
79285
- setHasChangedCurrentType = _useState8[1];
79286
- var updateEntries = function updateEntries(newTypeEntries) {
79287
- setHasChangedCurrentType(true);
79288
- setEntries(function (prev) {
79289
- return _objectSpread$B(_objectSpread$B({}, prev), {}, _defineProperty(_defineProperty({}, type, newTypeEntries), type === 'factor' ? 'discount' : 'factor', []));
79290
- });
79291
- };
79299
+ entries = _useState4[0],
79300
+ setEntries = _useState4[1];
79292
79301
  var handleModalOpen = useCallback(function () {
79293
79302
  var values = initialValue || [];
79294
- var firstValue = values[0];
79295
- var initialType = firstValue ? firstValue > 1 ? 'factor' : 'discount' : 'factor';
79296
- var initialEntries = values.map(function (val) {
79303
+ var initialEntries = values.map(function (val, index) {
79304
+ var type = initialIsDiscount !== null && initialIsDiscount !== void 0 && initialIsDiscount[index] ? 'discount' : 'factor';
79297
79305
  return {
79298
79306
  value: val.toString(),
79299
- isValid: isValidInput(val.toString(), initialType)
79307
+ type: type,
79308
+ isValid: isValidInput(val.toString(), type)
79300
79309
  };
79301
79310
  });
79302
79311
 
79303
79312
  // Ensure at least one entry
79304
79313
  if (initialEntries.length === 0) {
79305
- initialEntries.push({
79306
- value: getDefaultValue(),
79307
- isValid: true
79308
- });
79314
+ initialEntries.push(createDefaultEntry());
79309
79315
  }
79310
- setType(initialType);
79311
- setEntries({
79312
- factor: initialType === 'factor' ? initialEntries : [],
79313
- discount: initialType === 'discount' ? initialEntries : []
79314
- });
79315
- setHasChangedCurrentType(false);
79316
+ setEntries(initialEntries);
79316
79317
  setIsModalOpen(true);
79317
- }, [initialValue]);
79318
+ }, [initialValue, initialIsDiscount]);
79318
79319
  var handleModalClose = function handleModalClose() {
79319
79320
  return setIsModalOpen(false);
79320
79321
  };
79321
- var handleTypeChange = function handleTypeChange(newType) {
79322
- setType(newType);
79323
- // Always ensure at least one entry when switching types
79324
- var newEntries = hasChangedCurrentType ? [] : entries[newType];
79325
- setEntries(function (prev) {
79326
- return _objectSpread$B(_objectSpread$B({}, prev), {}, _defineProperty({}, newType, newEntries.length > 0 ? newEntries : [{
79327
- value: getDefaultValue(),
79328
- isValid: true
79329
- }]));
79322
+ var handleEntryTypeChange = function handleEntryTypeChange(index, newType) {
79323
+ // Restarts the row at the default (factor 1, i.e. 0 % discount) instead of converting what was entered
79324
+ var newEntries = _toConsumableArray(entries);
79325
+ newEntries[index] = _objectSpread$B(_objectSpread$B({}, createDefaultEntry()), {}, {
79326
+ type: newType
79330
79327
  });
79331
- setHasChangedCurrentType(false);
79328
+ setEntries(newEntries);
79332
79329
  };
79333
79330
  var handleAddEntry = function handleAddEntry() {
79334
- var defaultValue = getDefaultValue();
79335
- updateEntries([].concat(_toConsumableArray(entries[type]), [{
79336
- value: defaultValue,
79337
- isValid: true
79338
- }]));
79331
+ setEntries([].concat(_toConsumableArray(entries), [createDefaultEntry()]));
79339
79332
  };
79340
79333
  var handleRemoveEntry = function handleRemoveEntry(index) {
79341
- var currentEntries = entries[type];
79342
- if (currentEntries.length === 1) {
79334
+ if (entries.length === 1) {
79343
79335
  // Reset to default when removing last entry
79344
- updateEntries([{
79345
- value: getDefaultValue(),
79346
- isValid: true
79347
- }]);
79336
+ setEntries([createDefaultEntry()]);
79348
79337
  } else {
79349
- updateEntries(currentEntries.filter(function (_, i) {
79338
+ setEntries(entries.filter(function (_, i) {
79350
79339
  return i !== index;
79351
79340
  }));
79352
79341
  }
79353
79342
  };
79354
79343
  var handleEntryValueChange = function handleEntryValueChange(index, displayValue) {
79355
- var actualValue = convertFromDisplayValue(displayValue, type);
79356
- var newEntries = _toConsumableArray(entries[type]);
79344
+ // A comma counts as decimal point; anything that is no unsigned decimal number is not taken over
79345
+ var input = displayValue.replace(',', '.');
79346
+ if (!/^\d*\.?\d*$/.test(input)) return;
79347
+ var type = entries[index].type;
79348
+ var actualValue = convertFromDisplayValue(input, type);
79349
+ var newEntries = _toConsumableArray(entries);
79357
79350
  newEntries[index] = {
79358
79351
  value: actualValue,
79359
- input: displayValue,
79352
+ input: input,
79353
+ type: type,
79360
79354
  isValid: isValidInput(actualValue, type)
79361
79355
  };
79362
- updateEntries(newEntries);
79356
+ setEntries(newEntries);
79363
79357
  };
79364
79358
  var handleSave = /*#__PURE__*/function () {
79365
79359
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
79366
- var currentEntries, effectiveValues;
79360
+ var effectiveEntries, isDiscount;
79367
79361
  return _regeneratorRuntime.wrap(function _callee$(_context) {
79368
79362
  while (1) switch (_context.prev = _context.next) {
79369
79363
  case 0:
79370
- currentEntries = entries[type]; // Don't save if we only have a default entry
79371
- if (!(currentEntries.length === 1 && isDefaultValue(currentEntries[0].value))) {
79372
- _context.next = 7;
79364
+ if (!(entries.length === 1 && isDefaultValue(entries[0].value))) {
79365
+ _context.next = 6;
79373
79366
  break;
79374
79367
  }
79375
- _context.next = 4;
79376
- return onSave(data, []);
79377
- case 4:
79368
+ _context.next = 3;
79369
+ return onSave(data, [], []);
79370
+ case 3:
79378
79371
  onRefreshCell();
79379
79372
  setIsModalOpen(false);
79380
79373
  return _context.abrupt("return");
79381
- case 7:
79382
- if (currentEntries.every(function (entry) {
79374
+ case 6:
79375
+ if (entries.every(function (entry) {
79383
79376
  return entry.isValid;
79384
79377
  })) {
79385
- _context.next = 9;
79378
+ _context.next = 8;
79386
79379
  break;
79387
79380
  }
79388
79381
  return _context.abrupt("return");
79389
- case 9:
79382
+ case 8:
79390
79383
  // Filter out default and invalid values
79391
- effectiveValues = currentEntries.filter(function (entry) {
79392
- return !isDefaultValue(entry.value) && isEffectiveValue(entry.value, type);
79393
- }).map(function (entry) {
79394
- return parseFloat(entry.value);
79384
+ effectiveEntries = entries.filter(function (entry) {
79385
+ return !isDefaultValue(entry.value) && isEffectiveValue(entry.value, entry.type);
79386
+ });
79387
+ isDiscount = effectiveEntries.map(function (entry) {
79388
+ return entry.type === 'discount';
79395
79389
  });
79396
79390
  _context.next = 12;
79397
- return onSave(data, effectiveValues.length > 0 ? effectiveValues : []);
79391
+ return onSave(data, effectiveEntries.map(function (entry) {
79392
+ return parseFloat(entry.value);
79393
+ }), isDiscount.some(Boolean) ? isDiscount : []);
79398
79394
  case 12:
79399
79395
  onRefreshCell();
79400
79396
  setIsModalOpen(false);
@@ -79409,12 +79405,11 @@ function usePriceFactor(_ref) {
79409
79405
  };
79410
79406
  }();
79411
79407
  return {
79412
- type: type,
79413
- entries: entries[type],
79408
+ entries: entries,
79414
79409
  isModalOpen: isModalOpen,
79415
79410
  handleModalOpen: handleModalOpen,
79416
79411
  handleModalClose: handleModalClose,
79417
- handleTypeChange: handleTypeChange,
79412
+ handleEntryTypeChange: handleEntryTypeChange,
79418
79413
  handleAddEntry: handleAddEntry,
79419
79414
  handleRemoveEntry: handleRemoveEntry,
79420
79415
  handleEntryValueChange: handleEntryValueChange,
@@ -79423,12 +79418,11 @@ function usePriceFactor(_ref) {
79423
79418
  }
79424
79419
 
79425
79420
  var cell = "cell-Noc7s";
79426
- var typeSelector = "typeSelector-Y8Yly";
79427
79421
  var space = "space-T5Mkd";
79428
79422
  var input$1 = "input-SK-Fo";
79429
79423
  var addButton = "addButton-AVN8Y";
79430
79424
  var helpText = "helpText-QYQQF";
79431
- var css_248z$j = ".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";
79425
+ var css_248z$j = ".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";
79432
79426
  styleInject(css_248z$j);
79433
79427
 
79434
79428
  function PriceFactorCellRenderer(props) {
@@ -79437,43 +79431,21 @@ function PriceFactorCellRenderer(props) {
79437
79431
  colDef = props.colDef,
79438
79432
  node = props.node,
79439
79433
  column = props.column,
79440
- onSave = props.onSave,
79434
+ _onSave = props.onSave,
79435
+ getIsDiscount = props.getIsDiscount,
79441
79436
  api = props.api,
79442
79437
  isNotInAGGrid = props.isNotInAGGrid;
79443
79438
  var _useTranslation = useTranslation(),
79444
79439
  t = _useTranslation.t,
79445
79440
  i18n = _useTranslation.i18n;
79446
79441
  var clickTimer = useRef(null);
79447
- var applySave = useCallback(/*#__PURE__*/function () {
79448
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value) {
79449
- return _regeneratorRuntime.wrap(function _callee$(_context) {
79450
- while (1) switch (_context.prev = _context.next) {
79451
- case 0:
79452
- if (!onSave) {
79453
- _context.next = 5;
79454
- break;
79455
- }
79456
- _context.next = 3;
79457
- return onSave(data, value);
79458
- case 3:
79459
- _context.next = 6;
79460
- break;
79461
- case 5:
79462
- node === null || node === void 0 || node.setDataValue(colDef === null || colDef === void 0 ? void 0 : colDef.field, value);
79463
- case 6:
79464
- case "end":
79465
- return _context.stop();
79466
- }
79467
- }, _callee);
79468
- }));
79469
- return function (_x, _x2) {
79470
- return _ref.apply(this, arguments);
79471
- };
79472
- }(), [onSave, node, colDef === null || colDef === void 0 ? void 0 : colDef.field]);
79473
79442
  var _usePriceFactor = usePriceFactor({
79474
79443
  data: data,
79475
79444
  initialValue: value,
79476
- onSave: applySave,
79445
+ initialIsDiscount: getIsDiscount === null || getIsDiscount === void 0 ? void 0 : getIsDiscount(data),
79446
+ onSave: function onSave(data, value, isDiscount) {
79447
+ return _onSave(data, value, isDiscount, node === null || node === void 0 ? void 0 : node.id);
79448
+ },
79477
79449
  onRefreshCell: function onRefreshCell() {
79478
79450
  return api === null || api === void 0 ? void 0 : api.refreshCells({
79479
79451
  suppressFlash: true,
@@ -79482,12 +79454,11 @@ function PriceFactorCellRenderer(props) {
79482
79454
  });
79483
79455
  }
79484
79456
  }),
79485
- type = _usePriceFactor.type,
79486
79457
  entries = _usePriceFactor.entries,
79487
79458
  isModalOpen = _usePriceFactor.isModalOpen,
79488
79459
  handleModalOpen = _usePriceFactor.handleModalOpen,
79489
79460
  handleModalClose = _usePriceFactor.handleModalClose,
79490
- handleTypeChange = _usePriceFactor.handleTypeChange,
79461
+ handleEntryTypeChange = _usePriceFactor.handleEntryTypeChange,
79491
79462
  handleAddEntry = _usePriceFactor.handleAddEntry,
79492
79463
  handleRemoveEntry = _usePriceFactor.handleRemoveEntry,
79493
79464
  handleEntryValueChange = _usePriceFactor.handleEntryValueChange,
@@ -79549,7 +79520,6 @@ function PriceFactorCellRenderer(props) {
79549
79520
  if (clickTimer.current) clearTimeout(clickTimer.current);
79550
79521
  };
79551
79522
  }, []);
79552
- var isDiscount = type === 'discount';
79553
79523
  var isSingleDefaultEntry = entries.length === 1 && isDefaultValue(entries[0].value);
79554
79524
  var hasInvalidEntries = entries.some(function (entry) {
79555
79525
  return entry.isValid === false;
@@ -79559,7 +79529,7 @@ function PriceFactorCellRenderer(props) {
79559
79529
  className: cell,
79560
79530
  onClick: onClick,
79561
79531
  onDoubleClick: onDoubleClick,
79562
- children: formatListValue(value || [], type, i18n.language)
79532
+ children: formatListValue(value || [], i18n.language)
79563
79533
  }), /*#__PURE__*/jsxs(Modal$2, {
79564
79534
  title: colDef === null || colDef === void 0 ? void 0 : colDef.headerName,
79565
79535
  open: isModalOpen,
@@ -79572,40 +79542,43 @@ function PriceFactorCellRenderer(props) {
79572
79542
  cancelText: t('backoffice.idmCatalog.prices.priceFactor.cancel'),
79573
79543
  width: 500,
79574
79544
  wrapClassName: "ag-custom-component-popup",
79575
- children: [/*#__PURE__*/jsx("div", {
79576
- className: typeSelector,
79577
- children: /*#__PURE__*/jsxs(Radio.Group, {
79578
- value: type,
79579
- onChange: function onChange(e) {
79580
- return handleTypeChange(e.target.value);
79581
- },
79582
- children: [/*#__PURE__*/jsx(Radio.Button, {
79583
- value: "factor",
79584
- children: t('backoffice.idmCatalog.prices.priceFactor.type.factor')
79585
- }), /*#__PURE__*/jsx(Radio.Button, {
79586
- value: "discount",
79587
- children: t('backoffice.idmCatalog.prices.priceFactor.type.discount')
79588
- })]
79589
- })
79590
- }), /*#__PURE__*/jsx(List$1, {
79545
+ children: [/*#__PURE__*/jsx(List$1, {
79591
79546
  dataSource: entries,
79592
79547
  renderItem: function renderItem(entry, index) {
79593
79548
  var _entry$input;
79549
+ var isDiscount = entry.type === 'discount';
79594
79550
  return /*#__PURE__*/jsx(List$1.Item, {
79595
79551
  children: /*#__PURE__*/jsx(Form$2.Item, {
79596
79552
  validateStatus: entry.isValid === false ? 'error' : undefined,
79597
79553
  help: entry.isValid === false ? t(isDiscount ? 'backoffice.idmCatalog.prices.priceFactor.error.invalidDiscount' : 'backoffice.idmCatalog.prices.priceFactor.error.invalidFactor') : undefined,
79598
79554
  className: space,
79599
79555
  children: /*#__PURE__*/jsxs(Space, {
79600
- children: [/*#__PURE__*/jsx(Input$1, {
79601
- type: "number",
79602
- value: (_entry$input = entry.input) !== null && _entry$input !== void 0 ? _entry$input : convertToDisplayValue(entry.value, type),
79556
+ children: [/*#__PURE__*/jsx(Select, {
79557
+ value: entry.type,
79558
+ onChange: function onChange(newType) {
79559
+ return handleEntryTypeChange(index, newType);
79560
+ },
79561
+ options: [{
79562
+ value: 'factor',
79563
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.factor')
79564
+ }, {
79565
+ value: 'discount',
79566
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.discount')
79567
+ }],
79568
+ style: {
79569
+ width: 140
79570
+ },
79571
+ classNames: {
79572
+ popup: {
79573
+ root: 'ag-custom-component-popup'
79574
+ }
79575
+ }
79576
+ }), /*#__PURE__*/jsx(Input$1, {
79577
+ inputMode: "decimal",
79578
+ value: (_entry$input = entry.input) !== null && _entry$input !== void 0 ? _entry$input : convertToDisplayValue(entry.value, entry.type),
79603
79579
  onChange: function onChange(e) {
79604
79580
  return handleEntryValueChange(index, e.target.value);
79605
79581
  },
79606
- step: isDiscount ? 'any' : '0.1',
79607
- min: isDiscount ? '0' : '1',
79608
- max: isDiscount ? String(MAX_DISCOUNT) : undefined,
79609
79582
  className: input$1,
79610
79583
  addonAfter: isDiscount ? '%' : undefined
79611
79584
  }), /*#__PURE__*/jsx(Button, {
@@ -79630,9 +79603,13 @@ function PriceFactorCellRenderer(props) {
79630
79603
  icon: /*#__PURE__*/jsx(PlusOutlined, {}),
79631
79604
  children: t('backoffice.idmCatalog.prices.priceFactor.action.add')
79632
79605
  })
79633
- }), /*#__PURE__*/jsx("div", {
79606
+ }), /*#__PURE__*/jsxs("div", {
79634
79607
  className: helpText,
79635
- children: type === 'factor' ? t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange') : t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
79608
+ children: [/*#__PURE__*/jsx("div", {
79609
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange')
79610
+ }), /*#__PURE__*/jsx("div", {
79611
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
79612
+ })]
79636
79613
  })]
79637
79614
  })]
79638
79615
  });
@@ -79706,20 +79683,28 @@ var disabled = "disabled-Llkqu";
79706
79683
  var css_248z$h = ".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";
79707
79684
  styleInject(css_248z$h);
79708
79685
 
79709
- var _excluded$8 = ["onSave", "value"];
79686
+ var _excluded$8 = ["onSave", "value", "isDiscount"];
79710
79687
  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; }
79711
79688
  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; }
79712
79689
  function PriceFactorInput(_ref) {
79713
79690
  var _onSave = _ref.onSave,
79714
79691
  value = _ref.value,
79692
+ isDiscount = _ref.isDiscount,
79715
79693
  props = _objectWithoutProperties(_ref, _excluded$8);
79716
79694
  var _useState = useState(value),
79717
79695
  _useState2 = _slicedToArray(_useState, 2),
79718
79696
  innerValue = _useState2[0],
79719
79697
  setInnerValue = _useState2[1];
79698
+ var _useState3 = useState(isDiscount),
79699
+ _useState4 = _slicedToArray(_useState3, 2),
79700
+ innerIsDiscount = _useState4[0],
79701
+ setInnerIsDiscount = _useState4[1];
79720
79702
  useEffect(function () {
79721
79703
  setInnerValue(value);
79722
79704
  }, [value]);
79705
+ useEffect(function () {
79706
+ setInnerIsDiscount(isDiscount);
79707
+ }, [isDiscount]);
79723
79708
  return /*#__PURE__*/jsx(Tooltip$1, {
79724
79709
  title: props.tooltip,
79725
79710
  children: /*#__PURE__*/jsx("div", {
@@ -79727,9 +79712,13 @@ function PriceFactorInput(_ref) {
79727
79712
  children: /*#__PURE__*/jsx(PriceFactorCellRenderer, _objectSpread$A(_objectSpread$A({}, props), {}, {
79728
79713
  isNotInAGGrid: true,
79729
79714
  value: innerValue,
79730
- onSave: function onSave(data, value) {
79715
+ getIsDiscount: function getIsDiscount() {
79716
+ return innerIsDiscount;
79717
+ },
79718
+ onSave: function onSave(data, value, isDiscount) {
79731
79719
  setInnerValue(value);
79732
- return _onSave(data, value);
79720
+ setInnerIsDiscount(isDiscount);
79721
+ return _onSave(data, value, isDiscount);
79733
79722
  }
79734
79723
  }))
79735
79724
  })
@@ -79747,6 +79736,7 @@ function PriceFactorHeaderComponent(_ref) {
79747
79736
  priority = _ref.priority,
79748
79737
  priorityForced = _ref.priorityForced,
79749
79738
  value = _ref.value,
79739
+ isDiscount = _ref.isDiscount,
79750
79740
  inputTooltip = _ref.inputTooltip,
79751
79741
  checkboxTooltip = _ref.checkboxTooltip;
79752
79742
  var _useTranslation = useTranslation$1(),
@@ -79762,6 +79752,7 @@ function PriceFactorHeaderComponent(_ref) {
79762
79752
  children: [/*#__PURE__*/jsx(PriceFactorInput, {
79763
79753
  onSave: onSave,
79764
79754
  value: value,
79755
+ isDiscount: isDiscount,
79765
79756
  className: factorInput,
79766
79757
  tooltip: t(inputTooltip)
79767
79758
  }), /*#__PURE__*/jsx(Tooltip$1, {
@@ -79786,7 +79777,7 @@ function PriceFactorHeaderComponent(_ref) {
79786
79777
  * endpoint instead of the grid's excel export, because the served file is a report, not the grid content.
79787
79778
  */
79788
79779
  var Prices = observer(function (props) {
79789
- var _pricelist$seriePrice;
79780
+ var _pricelist$seriePrice, _pricelist$seriePrice2;
79790
79781
  var organizationId = props.organizationId,
79791
79782
  selectedPackage = props.selectedPackage,
79792
79783
  apiConfig = props.apiConfig,
@@ -79843,9 +79834,9 @@ var Prices = observer(function (props) {
79843
79834
  }
79844
79835
  }, _callee, null, [[2, 8, 11, 14]]);
79845
79836
  })), [apiConfig.enricherService, readPackageId, pricelist, selectedSerie, root.dataStore.jwt, showLoadingModal, showErrorModal, closeModal, t]);
79846
- var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
79837
+ var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
79847
79838
  if (!selectedSerie) return;
79848
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value));
79839
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value, isDiscount));
79849
79840
  }, [selectedSerie, pricelist, setNodeDataValue]);
79850
79841
  var updatePfgPriority = useCallback(function (priceFeatureGroupItem, value) {
79851
79842
  if (!selectedSerie) return;
@@ -79855,21 +79846,21 @@ var Prices = observer(function (props) {
79855
79846
  if (!selectedSerie) return;
79856
79847
  setNodeDataValue(applyPriceFactorPriority(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
79857
79848
  }, [pricelist, selectedSerie, setNodeDataValue]);
79858
- var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
79849
+ var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
79859
79850
  if (!selectedSerie) return;
79860
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
79851
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value, isDiscount));
79861
79852
  }, [pricelist, selectedSerie, setNodeDataValue]);
79862
- var updateArticlePriceFactor = useCallback(function (typeNo, value) {
79853
+ var updateArticlePriceFactor = useCallback(function (typeNo, value, isDiscount) {
79863
79854
  if (!selectedSerie) return;
79864
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value));
79855
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value, isDiscount));
79865
79856
  }, [pricelist, selectedSerie, setNodeDataValue]);
79866
- var updateTypeKeyPriceFactor = useCallback(function (typeKey, value) {
79857
+ var updateTypeKeyPriceFactor = useCallback(function (typeKey, value, isDiscount) {
79867
79858
  if (!selectedSerie) return;
79868
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value));
79859
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value, isDiscount));
79869
79860
  }, [pricelist, selectedSerie, setNodeDataValue]);
79870
- var updateSeriePriceFactor = useCallback(function (value) {
79861
+ var updateSeriePriceFactor = useCallback(function (value, isDiscount) {
79871
79862
  if (!selectedSerie) return;
79872
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value));
79863
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value, isDiscount));
79873
79864
  }, [pricelist, selectedSerie, setNodeDataValue]);
79874
79865
  function deleteManualPrices() {
79875
79866
  return _deleteManualPrices.apply(this, arguments);
@@ -79942,19 +79933,23 @@ var Prices = observer(function (props) {
79942
79933
  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];
79943
79934
  },
79944
79935
  cellRendererParams: {
79936
+ getIsDiscount: function getIsDiscount(data) {
79937
+ var _pricelist$articlePri2;
79938
+ 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];
79939
+ },
79945
79940
  onSave: function () {
79946
- var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value) {
79941
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value, isDiscount) {
79947
79942
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
79948
79943
  while (1) switch (_context2.prev = _context2.next) {
79949
79944
  case 0:
79950
- updateArticlePriceFactor(data.typeNo, value);
79945
+ updateArticlePriceFactor(data.typeNo, value, isDiscount);
79951
79946
  case 1:
79952
79947
  case "end":
79953
79948
  return _context2.stop();
79954
79949
  }
79955
79950
  }, _callee2);
79956
79951
  }));
79957
- function onSave(_x, _x2) {
79952
+ function onSave(_x, _x2, _x3) {
79958
79953
  return _onSave.apply(this, arguments);
79959
79954
  }
79960
79955
  return onSave;
@@ -79984,19 +79979,23 @@ var Prices = observer(function (props) {
79984
79979
  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];
79985
79980
  },
79986
79981
  cellRendererParams: {
79982
+ getIsDiscount: function getIsDiscount(data) {
79983
+ var _pricelist$typeKeyPri2;
79984
+ 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];
79985
+ },
79987
79986
  onSave: function () {
79988
- var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value) {
79987
+ var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value, isDiscount) {
79989
79988
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
79990
79989
  while (1) switch (_context3.prev = _context3.next) {
79991
79990
  case 0:
79992
- updateTypeKeyPriceFactor(data.typeKey, value);
79991
+ updateTypeKeyPriceFactor(data.typeKey, value, isDiscount);
79993
79992
  case 1:
79994
79993
  case "end":
79995
79994
  return _context3.stop();
79996
79995
  }
79997
79996
  }, _callee3);
79998
79997
  }));
79999
- function onSave(_x3, _x4) {
79998
+ function onSave(_x4, _x5, _x6) {
80000
79999
  return _onSave2.apply(this, arguments);
80001
80000
  }
80002
80001
  return onSave;
@@ -80006,29 +80005,30 @@ var Prices = observer(function (props) {
80006
80005
  sortable: false,
80007
80006
  editable: false
80008
80007
  }].concat(_toConsumableArray((_priceFeatureGroups$m = priceFeatureGroups === null || priceFeatureGroups === void 0 ? void 0 : priceFeatureGroups.map(function (priceFeatureGroup) {
80009
- var _pricelist$pfgPricefa, _pricelist$pfgPricefa2, _priceFeatureGroup$ke, _priceFeatureGroup$ke2;
80008
+ var _pricelist$pfgPricefa, _pricelist$pfgPricefa2, _pricelist$pfgPricefa3, _priceFeatureGroup$ke, _priceFeatureGroup$ke2;
80010
80009
  return {
80011
80010
  headerName: priceFeatureGroup.displayText,
80012
80011
  headerClass: inputHeader,
80013
80012
  headerGroupComponentParams: {
80014
80013
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
80015
80014
  onSave: (/*#__PURE__*/function () {
80016
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value) {
80015
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value, isDiscount) {
80017
80016
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
80018
80017
  while (1) switch (_context4.prev = _context4.next) {
80019
80018
  case 0:
80020
- updatePfgPriceFactor(priceFeatureGroup.id, value);
80019
+ updatePfgPriceFactor(priceFeatureGroup.id, value, isDiscount);
80021
80020
  case 1:
80022
80021
  case "end":
80023
80022
  return _context4.stop();
80024
80023
  }
80025
80024
  }, _callee4);
80026
80025
  }));
80027
- return function (_x5, _x6) {
80026
+ return function (_x7, _x8, _x9) {
80028
80027
  return _ref4.apply(this, arguments);
80029
80028
  };
80030
80029
  }()),
80031
80030
  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],
80031
+ 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],
80032
80032
  onPriorityChange: (/*#__PURE__*/function () {
80033
80033
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(value) {
80034
80034
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
@@ -80041,18 +80041,18 @@ var Prices = observer(function (props) {
80041
80041
  }
80042
80042
  }, _callee5);
80043
80043
  }));
80044
- return function (_x7) {
80044
+ return function (_x10) {
80045
80045
  return _ref5.apply(this, arguments);
80046
80046
  };
80047
80047
  }()),
80048
- 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)),
80048
+ 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)),
80049
80049
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfg',
80050
80050
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfgPriority'
80051
80051
  })
80052
80052
  },
80053
80053
  marryChildren: true,
80054
80054
  children: _toConsumableArray((_priceFeatureGroup$ke = (_priceFeatureGroup$ke2 = priceFeatureGroup.keys) === null || _priceFeatureGroup$ke2 === void 0 ? void 0 : _priceFeatureGroup$ke2.map(function (priceGroup, j) {
80055
- var _priceFeatureGroup$ke3, _pricelist$pgPricefac, _pricelist$pgPricefac2, _pricelist$pfgPricefa3;
80055
+ var _priceFeatureGroup$ke3, _pricelist$pgPricefac, _pricelist$pgPricefac2, _pricelist$pgPricefac3, _pricelist$pfgPricefa4;
80056
80056
  return {
80057
80057
  headerName: priceGroup,
80058
80058
  field: "prices.".concat(priceGroup),
@@ -80072,22 +80072,23 @@ var Prices = observer(function (props) {
80072
80072
  headerComponentParams: {
80073
80073
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
80074
80074
  onSave: (/*#__PURE__*/function () {
80075
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value) {
80075
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value, isDiscount) {
80076
80076
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
80077
80077
  while (1) switch (_context6.prev = _context6.next) {
80078
80078
  case 0:
80079
- updatePgPriceFactor(priceGroup, value);
80079
+ updatePgPriceFactor(priceGroup, value, isDiscount);
80080
80080
  case 1:
80081
80081
  case "end":
80082
80082
  return _context6.stop();
80083
80083
  }
80084
80084
  }, _callee6);
80085
80085
  }));
80086
- return function (_x8, _x9) {
80086
+ return function (_x11, _x12, _x13) {
80087
80087
  return _ref6.apply(this, arguments);
80088
80088
  };
80089
80089
  }()),
80090
80090
  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],
80091
+ 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],
80091
80092
  onPriorityChange: (/*#__PURE__*/function () {
80092
80093
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(value) {
80093
80094
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
@@ -80100,12 +80101,12 @@ var Prices = observer(function (props) {
80100
80101
  }
80101
80102
  }, _callee7);
80102
80103
  }));
80103
- return function (_x10) {
80104
+ return function (_x14) {
80104
80105
  return _ref7.apply(this, arguments);
80105
80106
  };
80106
80107
  }()),
80107
- 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)),
80108
- 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)),
80108
+ 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)),
80109
+ 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)),
80109
80110
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pg',
80110
80111
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pgPriority'
80111
80112
  })
@@ -80197,19 +80198,20 @@ var Prices = observer(function (props) {
80197
80198
  tooltip: t('backoffice.idmCatalog.prices.priceFactor.tooltip.series'),
80198
80199
  children: /*#__PURE__*/jsx(PriceFactorInput, {
80199
80200
  value: (_pricelist$seriePrice = pricelist.seriePricefactors) === null || _pricelist$seriePrice === void 0 ? void 0 : _pricelist$seriePrice[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
80201
+ isDiscount: (_pricelist$seriePrice2 = pricelist.seriePricefactorsIsDiscount) === null || _pricelist$seriePrice2 === void 0 ? void 0 : _pricelist$seriePrice2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
80200
80202
  onSave: (/*#__PURE__*/function () {
80201
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value) {
80203
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value, isDiscount) {
80202
80204
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
80203
80205
  while (1) switch (_context8.prev = _context8.next) {
80204
80206
  case 0:
80205
- updateSeriePriceFactor(value);
80207
+ updateSeriePriceFactor(value, isDiscount);
80206
80208
  case 1:
80207
80209
  case "end":
80208
80210
  return _context8.stop();
80209
80211
  }
80210
80212
  }, _callee8);
80211
80213
  }));
80212
- return function (_x11, _x12) {
80214
+ return function (_x15, _x16, _x17) {
80213
80215
  return _ref8.apply(this, arguments);
80214
80216
  };
80215
80217
  }()),
@@ -80432,6 +80434,43 @@ var TablePriceList = observer(function () {
80432
80434
  field: 'pricefactors',
80433
80435
  cellDataType: 'number',
80434
80436
  cellRenderer: PriceFactorCellRenderer,
80437
+ cellRendererParams: {
80438
+ getIsDiscount: function getIsDiscount(data) {
80439
+ return data === null || data === void 0 ? void 0 : data.pricefactorsIsDiscount;
80440
+ },
80441
+ // One write for factors and flags, so both reach the pricelist in the same update. The node id comes
80442
+ // first: a row created in this session keeps its temporary id as row id, also once it has its _id.
80443
+ onSave: function () {
80444
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value, isDiscount, nodeId) {
80445
+ var _spreadsheetRef$curre;
80446
+ var rowId;
80447
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
80448
+ while (1) switch (_context.prev = _context.next) {
80449
+ case 0:
80450
+ rowId = nodeId !== null && nodeId !== void 0 ? nodeId : data === null || data === void 0 ? void 0 : data._id;
80451
+ if (rowId) {
80452
+ _context.next = 3;
80453
+ break;
80454
+ }
80455
+ return _context.abrupt("return");
80456
+ case 3:
80457
+ _context.next = 5;
80458
+ return (_spreadsheetRef$curre = spreadsheetRef.current) === null || _spreadsheetRef$curre === void 0 ? void 0 : _spreadsheetRef$curre.setNodeDataValue(rowId, {
80459
+ pricefactors: value,
80460
+ pricefactorsIsDiscount: isDiscount.length > 0 ? isDiscount : undefined
80461
+ });
80462
+ case 5:
80463
+ case "end":
80464
+ return _context.stop();
80465
+ }
80466
+ }, _callee);
80467
+ }));
80468
+ function onSave(_x, _x2, _x3, _x4) {
80469
+ return _onSave.apply(this, arguments);
80470
+ }
80471
+ return onSave;
80472
+ }()
80473
+ },
80435
80474
  editable: false,
80436
80475
  filter: false,
80437
80476
  equals: function equals(a, b) {
@@ -80551,6 +80590,38 @@ var TablePriceList = observer(function () {
80551
80590
  cellDataType: 'object',
80552
80591
  editable: false,
80553
80592
  hide: true
80593
+ },
80594
+ // Per factor whether the price factor dialog shows it as discount, beside the factor fields above
80595
+ {
80596
+ field: 'pricefactorsIsDiscount',
80597
+ cellDataType: 'object',
80598
+ editable: false,
80599
+ hide: true
80600
+ }, {
80601
+ field: 'seriePricefactorsIsDiscount',
80602
+ cellDataType: 'object',
80603
+ editable: false,
80604
+ hide: true
80605
+ }, {
80606
+ field: 'articlePricefactorsIsDiscount',
80607
+ cellDataType: 'object',
80608
+ editable: false,
80609
+ hide: true
80610
+ }, {
80611
+ field: 'typeKeyPricefactorsIsDiscount',
80612
+ cellDataType: 'object',
80613
+ editable: false,
80614
+ hide: true
80615
+ }, {
80616
+ field: 'pgPricefactorsIsDiscount',
80617
+ cellDataType: 'object',
80618
+ editable: false,
80619
+ hide: true
80620
+ }, {
80621
+ field: 'pfgPricefactorsIsDiscount',
80622
+ cellDataType: 'object',
80623
+ editable: false,
80624
+ hide: true
80554
80625
  }]
80555
80626
  };
80556
80627
  }, [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.13.0-beta.20",
3
+ "version": "26.13.0-beta.21",
4
4
  "description": "Ant Design backoffice shell (configuration modules), the Diva Data Engine component hosting the IDM and enricher editors, and the Produkt Onboarding component hosting the Assortment Manager.",
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.13.0-beta.20",
20
- "@crystaldesign/content-box": "26.13.0-beta.20",
21
- "@crystaldesign/content-item": "26.13.0-beta.20",
22
- "@crystaldesign/diva-agent": "26.13.0-beta.20",
23
- "@crystaldesign/diva-core": "26.13.0-beta.20",
24
- "@crystaldesign/diva-utils": "26.13.0-beta.20",
25
- "@crystaldesign/mass-configurator": "26.13.0-beta.20",
26
- "@crystaldesign/media-upload": "26.13.0-beta.20",
27
- "@crystaldesign/rtf-editor": "26.13.0-beta.20",
28
- "@crystaldesign/spreadsheet": "26.13.0-beta.20",
19
+ "@crystaldesign/classification": "26.13.0-beta.21",
20
+ "@crystaldesign/content-box": "26.13.0-beta.21",
21
+ "@crystaldesign/content-item": "26.13.0-beta.21",
22
+ "@crystaldesign/diva-agent": "26.13.0-beta.21",
23
+ "@crystaldesign/diva-core": "26.13.0-beta.21",
24
+ "@crystaldesign/diva-utils": "26.13.0-beta.21",
25
+ "@crystaldesign/mass-configurator": "26.13.0-beta.21",
26
+ "@crystaldesign/media-upload": "26.13.0-beta.21",
27
+ "@crystaldesign/rtf-editor": "26.13.0-beta.21",
28
+ "@crystaldesign/spreadsheet": "26.13.0-beta.21",
29
29
  "@dnd-kit/core": "^6.1.0",
30
30
  "@dnd-kit/sortable": "^8.0.0",
31
31
  "@dnd-kit/utilities": "^3.2.2",
@@ -63,5 +63,5 @@
63
63
  "suiteName": "diva-backoffice",
64
64
  "outputDirectory": "./test-reports"
65
65
  },
66
- "gitHead": "c2ccbc73d9da6d31fffaa527bfc490f3d2d57d01"
66
+ "gitHead": "8924c019e83cd44f3f2d2ecf41d0e26143d30128"
67
67
  }