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

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 (23) hide show
  1. package/build/esm/index.js +273 -186
  2. package/build/types/backoffice/src/tests/unit/ui/IDMCatalogEditor/Tables/priceFeatureGroupSubtables.test.d.ts +2 -0
  3. package/build/types/backoffice/src/tests/unit/ui/IDMCatalogEditor/Tables/priceFeatureGroupSubtables.test.d.ts.map +1 -0
  4. package/build/types/backoffice/src/ui/IDMCatalogEditor/Tables/PriceFeatureGroupFinishes.d.ts +3 -1
  5. package/build/types/backoffice/src/ui/IDMCatalogEditor/Tables/PriceFeatureGroupFinishes.d.ts.map +1 -1
  6. package/build/types/backoffice/src/ui/IDMCatalogEditor/Tables/PriceFeatureGroupPercentageSurcharge.d.ts +3 -1
  7. package/build/types/backoffice/src/ui/IDMCatalogEditor/Tables/PriceFeatureGroupPercentageSurcharge.d.ts.map +1 -1
  8. package/build/types/backoffice/src/ui/IDMCatalogEditor/modules/TablePriceFeatureGroups/index.d.ts.map +1 -1
  9. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.d.ts +7 -2
  10. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorHeaderComponent.d.ts.map +1 -1
  11. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.d.ts +4 -2
  12. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/PriceFactorInput/index.d.ts.map +1 -1
  13. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/index.d.ts.map +1 -1
  14. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.d.ts +6 -3
  15. package/build/types/backoffice/src/ui/IDMEnricherEditor/Tables/Prices/priceFactorMutations.d.ts.map +1 -1
  16. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.d.ts +7 -1
  17. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/index.d.ts.map +1 -1
  18. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.d.ts +5 -11
  19. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/priceFactorHelpers.d.ts.map +1 -1
  20. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.d.ts +8 -5
  21. package/build/types/backoffice/src/ui/IDMEnricherEditor/components/PriceFactorCellRenderer/usePriceFactor.d.ts.map +1 -1
  22. package/build/types/backoffice/src/ui/IDMEnricherEditor/modules/TablePriceList/index.d.ts.map +1 -1
  23. 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) {
@@ -74369,6 +74388,7 @@ function PriceFeatureGroupPercentageSurcharge(_ref) {
74369
74388
  apiConfig = _ref.apiConfig,
74370
74389
  setNodeDataValue = _ref.setNodeDataValue,
74371
74390
  setIsPercentage = _ref.setIsPercentage,
74391
+ onRowsSaved = _ref.onRowsSaved,
74372
74392
  agentBoundParent = _ref.agentBoundParent;
74373
74393
  var _useTranslation = useTranslation(),
74374
74394
  i18n = _useTranslation.i18n;
@@ -74447,6 +74467,9 @@ function PriceFeatureGroupPercentageSurcharge(_ref) {
74447
74467
  // A previous group's grid keeps its hooks after the switch, and a load or save still in flight for it answers late.
74448
74468
  var shownGroupId = useRef(priceFeatureGroup._id);
74449
74469
  shownGroupId.current = priceFeatureGroup._id;
74470
+ // Read at call time: the module hands a new function on every render.
74471
+ var latestOnRowsSaved = useRef(onRowsSaved);
74472
+ latestOnRowsSaved.current = onRowsSaved;
74450
74473
  var hooks = useMemo(function () {
74451
74474
  var groupId = priceFeatureGroup._id;
74452
74475
  // The first block tells whether the group has percentage surcharges. An empty block clears only that claim, never
@@ -74454,6 +74477,9 @@ function PriceFeatureGroupPercentageSurcharge(_ref) {
74454
74477
  var firstBlockSeen = false;
74455
74478
  return {
74456
74479
  onDataUpdated: function onDataUpdated(event) {
74480
+ var _latestOnRowsSaved$cu;
74481
+ // Only a row that was saved can add a price key; a failed save reports no updates.
74482
+ if (event.updates.length) (_latestOnRowsSaved$cu = latestOnRowsSaved.current) === null || _latestOnRowsSaved$cu === void 0 || _latestOnRowsSaved$cu.call(latestOnRowsSaved);
74457
74483
  if (shownGroupId.current === groupId) _onDataUpdated(event);
74458
74484
  },
74459
74485
  onRowDataLoaded: function onRowDataLoaded(rows) {
@@ -74617,6 +74643,7 @@ function PriceFeatureGroupFinishes(_ref) {
74617
74643
  apiConfig = _ref.apiConfig,
74618
74644
  setNodeDataValue = _ref.setNodeDataValue,
74619
74645
  setIsPercentage = _ref.setIsPercentage,
74646
+ onRowsSaved = _ref.onRowsSaved,
74620
74647
  agentBoundParent = _ref.agentBoundParent;
74621
74648
  var _useTranslation = useTranslation(),
74622
74649
  t = _useTranslation.t,
@@ -74681,6 +74708,9 @@ function PriceFeatureGroupFinishes(_ref) {
74681
74708
  // A previous group's grid keeps its hooks after the switch, and a load or save still in flight for it answers late.
74682
74709
  var shownGroupId = useRef(priceFeatureGroup._id);
74683
74710
  shownGroupId.current = priceFeatureGroup._id;
74711
+ // Read at call time: the module hands a new function on every render.
74712
+ var latestOnRowsSaved = useRef(onRowsSaved);
74713
+ latestOnRowsSaved.current = onRowsSaved;
74684
74714
  var hooks = useMemo(function () {
74685
74715
  var groupId = priceFeatureGroup._id;
74686
74716
  // The first block tells whether the group has finishes: the row's isPercentage stays false after the group's last
@@ -74689,6 +74719,9 @@ function PriceFeatureGroupFinishes(_ref) {
74689
74719
  var firstBlockSeen = false;
74690
74720
  return {
74691
74721
  onDataUpdated: function onDataUpdated(event) {
74722
+ var _latestOnRowsSaved$cu;
74723
+ // Only a row that was saved can add a price key; a failed save reports no updates.
74724
+ if (event.updates.length) (_latestOnRowsSaved$cu = latestOnRowsSaved.current) === null || _latestOnRowsSaved$cu === void 0 || _latestOnRowsSaved$cu.call(latestOnRowsSaved);
74692
74725
  if (shownGroupId.current === groupId) _onDataUpdated(event);
74693
74726
  },
74694
74727
  onRowDataLoaded: function onRowDataLoaded(rows) {
@@ -74942,6 +74975,7 @@ var TablePriceFeatureGroups = observer(function () {
74942
74975
  apiConfig: apiConfig,
74943
74976
  setNodeDataValue: setNodeDataValue,
74944
74977
  setIsPercentage: setIsPercentage,
74978
+ onRowsSaved: resetSeriesSelector,
74945
74979
  agentBoundParent: _objectSpread$H(_objectSpread$H({}, boundPriceFeatureGroup), {}, {
74946
74980
  tool: 'priceFeatureGroupFinishes'
74947
74981
  })
@@ -74962,6 +74996,7 @@ var TablePriceFeatureGroups = observer(function () {
74962
74996
  apiConfig: apiConfig,
74963
74997
  setNodeDataValue: setNodeDataValue,
74964
74998
  setIsPercentage: setIsPercentage,
74999
+ onRowsSaved: resetSeriesSelector,
74965
75000
  agentBoundParent: _objectSpread$H(_objectSpread$H({}, boundPriceFeatureGroup), {}, {
74966
75001
  tool: 'priceFeatureGroupPercentageSurcharge'
74967
75002
  })
@@ -79151,17 +79186,14 @@ var removeFloatNoise = function removeFloatNoise(value) {
79151
79186
  return parseFloat(value.toFixed(10));
79152
79187
  };
79153
79188
 
79154
- /** State container for both factor and discount entries */
79155
-
79156
79189
  /**
79157
79190
  * Formats a list of values for display in the cell
79158
79191
  * For both types, displays the actual factor value (e.g., 0.8 for 20% discount)
79159
79192
  * @param values - The values to format
79160
- * @param type - The type of price modification
79161
79193
  * @param locale - The locale to use for formatting
79162
79194
  * @returns The formatted string with values separated by semicolons
79163
79195
  */
79164
- var formatListValue = function formatListValue(values, type, locale) {
79196
+ var formatListValue = function formatListValue(values, locale) {
79165
79197
  if (!(values !== null && values !== void 0 && values.length)) return '-';
79166
79198
  var formatter = new Intl.NumberFormat(locale, {
79167
79199
  minimumFractionDigits: 1,
@@ -79203,7 +79235,7 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
79203
79235
 
79204
79236
  /**
79205
79237
  * Validates if an input value is valid for the given type
79206
- * For factors: must be >= 1
79238
+ * For factors: must be > 0 (factors below 1 lower the price, factors above 1 raise it)
79207
79239
  * For discounts: the discount must be between 0 and 99.99999 percent
79208
79240
  * @param value - The value to validate
79209
79241
  * @param type - The type of price modification
@@ -79212,14 +79244,14 @@ var convertFromDisplayValue = function convertFromDisplayValue(value, type) {
79212
79244
  var isValidInput = function isValidInput(value, type) {
79213
79245
  var numValue = parseFloat(value);
79214
79246
  if (isNaN(numValue)) return false;
79215
- if (type === 'factor') return numValue >= 1;
79247
+ if (type === 'factor') return numValue > 0;
79216
79248
  var discount = removeFloatNoise((1 - numValue) * 100);
79217
79249
  return discount >= 0 && discount <= MAX_DISCOUNT;
79218
79250
  };
79219
79251
 
79220
79252
  /**
79221
79253
  * Checks if a value is effective (should be saved)
79222
- * For factors: must be > 1 (1 is valid but not effective)
79254
+ * For factors: must not be 1 (1 is valid but leaves the price unchanged)
79223
79255
  * For discounts: must be < 1 (a 0% discount is valid but not effective)
79224
79256
  * @param value - The value to check
79225
79257
  * @param type - The type of price modification
@@ -79227,7 +79259,7 @@ var isValidInput = function isValidInput(value, type) {
79227
79259
  */
79228
79260
  var isEffectiveValue = function isEffectiveValue(value, type) {
79229
79261
  var numValue = parseFloat(value);
79230
- return type === 'factor' ? numValue > 1 : numValue < 1;
79262
+ return type === 'factor' ? numValue !== 1 : numValue < 1;
79231
79263
  };
79232
79264
 
79233
79265
  /**
@@ -79250,151 +79282,131 @@ var isDefaultValue = function isDefaultValue(value) {
79250
79282
 
79251
79283
  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
79284
  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; }
79285
+ var createDefaultEntry = function createDefaultEntry() {
79286
+ return {
79287
+ value: getDefaultValue(),
79288
+ type: 'factor',
79289
+ isValid: true
79290
+ };
79291
+ };
79292
+
79253
79293
  /**
79254
79294
  * Custom hook to manage price factor state and logic
79255
79295
  * @param props - Hook configuration
79256
79296
  * @param props.data - Data of the row
79257
79297
  * @param props.initialValue - Initial array of values
79258
- * @param props.onSave - Callback to save values
79298
+ * @param props.initialIsDiscount - Initial discount flags of the values
79299
+ * @param props.onSave - Callback to save values and their discount flags
79259
79300
  * @param props.onRefreshCell - Callback to refresh the cell after save
79260
79301
  */
79261
79302
  function usePriceFactor(_ref) {
79262
79303
  var _ref$data = _ref.data,
79263
79304
  data = _ref$data === void 0 ? {} : _ref$data,
79264
79305
  initialValue = _ref.initialValue,
79306
+ initialIsDiscount = _ref.initialIsDiscount,
79265
79307
  onSave = _ref.onSave,
79266
79308
  onRefreshCell = _ref.onRefreshCell;
79267
79309
  var _useState = useState(false),
79268
79310
  _useState2 = _slicedToArray(_useState, 2),
79269
79311
  isModalOpen = _useState2[0],
79270
79312
  setIsModalOpen = _useState2[1];
79271
- var _useState3 = useState('factor'),
79313
+ var _useState3 = useState([]),
79272
79314
  _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
- };
79315
+ entries = _useState4[0],
79316
+ setEntries = _useState4[1];
79292
79317
  var handleModalOpen = useCallback(function () {
79293
79318
  var values = initialValue || [];
79294
- var firstValue = values[0];
79295
- var initialType = firstValue ? firstValue > 1 ? 'factor' : 'discount' : 'factor';
79296
- var initialEntries = values.map(function (val) {
79319
+ var initialEntries = values.map(function (val, index) {
79320
+ var type = initialIsDiscount !== null && initialIsDiscount !== void 0 && initialIsDiscount[index] ? 'discount' : 'factor';
79297
79321
  return {
79298
79322
  value: val.toString(),
79299
- isValid: isValidInput(val.toString(), initialType)
79323
+ type: type,
79324
+ isValid: isValidInput(val.toString(), type)
79300
79325
  };
79301
79326
  });
79302
79327
 
79303
79328
  // Ensure at least one entry
79304
79329
  if (initialEntries.length === 0) {
79305
- initialEntries.push({
79306
- value: getDefaultValue(),
79307
- isValid: true
79308
- });
79330
+ initialEntries.push(createDefaultEntry());
79309
79331
  }
79310
- setType(initialType);
79311
- setEntries({
79312
- factor: initialType === 'factor' ? initialEntries : [],
79313
- discount: initialType === 'discount' ? initialEntries : []
79314
- });
79315
- setHasChangedCurrentType(false);
79332
+ setEntries(initialEntries);
79316
79333
  setIsModalOpen(true);
79317
- }, [initialValue]);
79334
+ }, [initialValue, initialIsDiscount]);
79318
79335
  var handleModalClose = function handleModalClose() {
79319
79336
  return setIsModalOpen(false);
79320
79337
  };
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
- }]));
79338
+ var handleEntryTypeChange = function handleEntryTypeChange(index, newType) {
79339
+ // Restarts the row at the default (factor 1, i.e. 0 % discount) instead of converting what was entered
79340
+ var newEntries = _toConsumableArray(entries);
79341
+ newEntries[index] = _objectSpread$B(_objectSpread$B({}, createDefaultEntry()), {}, {
79342
+ type: newType
79330
79343
  });
79331
- setHasChangedCurrentType(false);
79344
+ setEntries(newEntries);
79332
79345
  };
79333
79346
  var handleAddEntry = function handleAddEntry() {
79334
- var defaultValue = getDefaultValue();
79335
- updateEntries([].concat(_toConsumableArray(entries[type]), [{
79336
- value: defaultValue,
79337
- isValid: true
79338
- }]));
79347
+ setEntries([].concat(_toConsumableArray(entries), [createDefaultEntry()]));
79339
79348
  };
79340
79349
  var handleRemoveEntry = function handleRemoveEntry(index) {
79341
- var currentEntries = entries[type];
79342
- if (currentEntries.length === 1) {
79350
+ if (entries.length === 1) {
79343
79351
  // Reset to default when removing last entry
79344
- updateEntries([{
79345
- value: getDefaultValue(),
79346
- isValid: true
79347
- }]);
79352
+ setEntries([createDefaultEntry()]);
79348
79353
  } else {
79349
- updateEntries(currentEntries.filter(function (_, i) {
79354
+ setEntries(entries.filter(function (_, i) {
79350
79355
  return i !== index;
79351
79356
  }));
79352
79357
  }
79353
79358
  };
79354
79359
  var handleEntryValueChange = function handleEntryValueChange(index, displayValue) {
79355
- var actualValue = convertFromDisplayValue(displayValue, type);
79356
- var newEntries = _toConsumableArray(entries[type]);
79360
+ // A comma counts as decimal point; anything that is no unsigned decimal number is not taken over
79361
+ var input = displayValue.replace(',', '.');
79362
+ if (!/^\d*\.?\d*$/.test(input)) return;
79363
+ var type = entries[index].type;
79364
+ var actualValue = convertFromDisplayValue(input, type);
79365
+ var newEntries = _toConsumableArray(entries);
79357
79366
  newEntries[index] = {
79358
79367
  value: actualValue,
79359
- input: displayValue,
79368
+ input: input,
79369
+ type: type,
79360
79370
  isValid: isValidInput(actualValue, type)
79361
79371
  };
79362
- updateEntries(newEntries);
79372
+ setEntries(newEntries);
79363
79373
  };
79364
79374
  var handleSave = /*#__PURE__*/function () {
79365
79375
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
79366
- var currentEntries, effectiveValues;
79376
+ var effectiveEntries, isDiscount;
79367
79377
  return _regeneratorRuntime.wrap(function _callee$(_context) {
79368
79378
  while (1) switch (_context.prev = _context.next) {
79369
79379
  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;
79380
+ if (!(entries.length === 1 && isDefaultValue(entries[0].value))) {
79381
+ _context.next = 6;
79373
79382
  break;
79374
79383
  }
79375
- _context.next = 4;
79376
- return onSave(data, []);
79377
- case 4:
79384
+ _context.next = 3;
79385
+ return onSave(data, [], []);
79386
+ case 3:
79378
79387
  onRefreshCell();
79379
79388
  setIsModalOpen(false);
79380
79389
  return _context.abrupt("return");
79381
- case 7:
79382
- if (currentEntries.every(function (entry) {
79390
+ case 6:
79391
+ if (entries.every(function (entry) {
79383
79392
  return entry.isValid;
79384
79393
  })) {
79385
- _context.next = 9;
79394
+ _context.next = 8;
79386
79395
  break;
79387
79396
  }
79388
79397
  return _context.abrupt("return");
79389
- case 9:
79398
+ case 8:
79390
79399
  // 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);
79400
+ effectiveEntries = entries.filter(function (entry) {
79401
+ return !isDefaultValue(entry.value) && isEffectiveValue(entry.value, entry.type);
79402
+ });
79403
+ isDiscount = effectiveEntries.map(function (entry) {
79404
+ return entry.type === 'discount';
79395
79405
  });
79396
79406
  _context.next = 12;
79397
- return onSave(data, effectiveValues.length > 0 ? effectiveValues : []);
79407
+ return onSave(data, effectiveEntries.map(function (entry) {
79408
+ return parseFloat(entry.value);
79409
+ }), isDiscount.some(Boolean) ? isDiscount : []);
79398
79410
  case 12:
79399
79411
  onRefreshCell();
79400
79412
  setIsModalOpen(false);
@@ -79409,12 +79421,11 @@ function usePriceFactor(_ref) {
79409
79421
  };
79410
79422
  }();
79411
79423
  return {
79412
- type: type,
79413
- entries: entries[type],
79424
+ entries: entries,
79414
79425
  isModalOpen: isModalOpen,
79415
79426
  handleModalOpen: handleModalOpen,
79416
79427
  handleModalClose: handleModalClose,
79417
- handleTypeChange: handleTypeChange,
79428
+ handleEntryTypeChange: handleEntryTypeChange,
79418
79429
  handleAddEntry: handleAddEntry,
79419
79430
  handleRemoveEntry: handleRemoveEntry,
79420
79431
  handleEntryValueChange: handleEntryValueChange,
@@ -79423,12 +79434,11 @@ function usePriceFactor(_ref) {
79423
79434
  }
79424
79435
 
79425
79436
  var cell = "cell-Noc7s";
79426
- var typeSelector = "typeSelector-Y8Yly";
79427
79437
  var space = "space-T5Mkd";
79428
79438
  var input$1 = "input-SK-Fo";
79429
79439
  var addButton = "addButton-AVN8Y";
79430
79440
  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";
79441
+ 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
79442
  styleInject(css_248z$j);
79433
79443
 
79434
79444
  function PriceFactorCellRenderer(props) {
@@ -79437,43 +79447,21 @@ function PriceFactorCellRenderer(props) {
79437
79447
  colDef = props.colDef,
79438
79448
  node = props.node,
79439
79449
  column = props.column,
79440
- onSave = props.onSave,
79450
+ _onSave = props.onSave,
79451
+ getIsDiscount = props.getIsDiscount,
79441
79452
  api = props.api,
79442
79453
  isNotInAGGrid = props.isNotInAGGrid;
79443
79454
  var _useTranslation = useTranslation(),
79444
79455
  t = _useTranslation.t,
79445
79456
  i18n = _useTranslation.i18n;
79446
79457
  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
79458
  var _usePriceFactor = usePriceFactor({
79474
79459
  data: data,
79475
79460
  initialValue: value,
79476
- onSave: applySave,
79461
+ initialIsDiscount: getIsDiscount === null || getIsDiscount === void 0 ? void 0 : getIsDiscount(data),
79462
+ onSave: function onSave(data, value, isDiscount) {
79463
+ return _onSave(data, value, isDiscount, node === null || node === void 0 ? void 0 : node.id);
79464
+ },
79477
79465
  onRefreshCell: function onRefreshCell() {
79478
79466
  return api === null || api === void 0 ? void 0 : api.refreshCells({
79479
79467
  suppressFlash: true,
@@ -79482,12 +79470,11 @@ function PriceFactorCellRenderer(props) {
79482
79470
  });
79483
79471
  }
79484
79472
  }),
79485
- type = _usePriceFactor.type,
79486
79473
  entries = _usePriceFactor.entries,
79487
79474
  isModalOpen = _usePriceFactor.isModalOpen,
79488
79475
  handleModalOpen = _usePriceFactor.handleModalOpen,
79489
79476
  handleModalClose = _usePriceFactor.handleModalClose,
79490
- handleTypeChange = _usePriceFactor.handleTypeChange,
79477
+ handleEntryTypeChange = _usePriceFactor.handleEntryTypeChange,
79491
79478
  handleAddEntry = _usePriceFactor.handleAddEntry,
79492
79479
  handleRemoveEntry = _usePriceFactor.handleRemoveEntry,
79493
79480
  handleEntryValueChange = _usePriceFactor.handleEntryValueChange,
@@ -79549,7 +79536,6 @@ function PriceFactorCellRenderer(props) {
79549
79536
  if (clickTimer.current) clearTimeout(clickTimer.current);
79550
79537
  };
79551
79538
  }, []);
79552
- var isDiscount = type === 'discount';
79553
79539
  var isSingleDefaultEntry = entries.length === 1 && isDefaultValue(entries[0].value);
79554
79540
  var hasInvalidEntries = entries.some(function (entry) {
79555
79541
  return entry.isValid === false;
@@ -79559,7 +79545,7 @@ function PriceFactorCellRenderer(props) {
79559
79545
  className: cell,
79560
79546
  onClick: onClick,
79561
79547
  onDoubleClick: onDoubleClick,
79562
- children: formatListValue(value || [], type, i18n.language)
79548
+ children: formatListValue(value || [], i18n.language)
79563
79549
  }), /*#__PURE__*/jsxs(Modal$2, {
79564
79550
  title: colDef === null || colDef === void 0 ? void 0 : colDef.headerName,
79565
79551
  open: isModalOpen,
@@ -79572,40 +79558,43 @@ function PriceFactorCellRenderer(props) {
79572
79558
  cancelText: t('backoffice.idmCatalog.prices.priceFactor.cancel'),
79573
79559
  width: 500,
79574
79560
  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, {
79561
+ children: [/*#__PURE__*/jsx(List$1, {
79591
79562
  dataSource: entries,
79592
79563
  renderItem: function renderItem(entry, index) {
79593
79564
  var _entry$input;
79565
+ var isDiscount = entry.type === 'discount';
79594
79566
  return /*#__PURE__*/jsx(List$1.Item, {
79595
79567
  children: /*#__PURE__*/jsx(Form$2.Item, {
79596
79568
  validateStatus: entry.isValid === false ? 'error' : undefined,
79597
79569
  help: entry.isValid === false ? t(isDiscount ? 'backoffice.idmCatalog.prices.priceFactor.error.invalidDiscount' : 'backoffice.idmCatalog.prices.priceFactor.error.invalidFactor') : undefined,
79598
79570
  className: space,
79599
79571
  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),
79572
+ children: [/*#__PURE__*/jsx(Select, {
79573
+ value: entry.type,
79574
+ onChange: function onChange(newType) {
79575
+ return handleEntryTypeChange(index, newType);
79576
+ },
79577
+ options: [{
79578
+ value: 'factor',
79579
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.factor')
79580
+ }, {
79581
+ value: 'discount',
79582
+ label: t('backoffice.idmCatalog.prices.priceFactor.type.discount')
79583
+ }],
79584
+ style: {
79585
+ width: 140
79586
+ },
79587
+ classNames: {
79588
+ popup: {
79589
+ root: 'ag-custom-component-popup'
79590
+ }
79591
+ }
79592
+ }), /*#__PURE__*/jsx(Input$1, {
79593
+ inputMode: "decimal",
79594
+ value: (_entry$input = entry.input) !== null && _entry$input !== void 0 ? _entry$input : convertToDisplayValue(entry.value, entry.type),
79603
79595
  onChange: function onChange(e) {
79604
79596
  return handleEntryValueChange(index, e.target.value);
79605
79597
  },
79606
- step: isDiscount ? 'any' : '0.1',
79607
- min: isDiscount ? '0' : '1',
79608
- max: isDiscount ? String(MAX_DISCOUNT) : undefined,
79609
79598
  className: input$1,
79610
79599
  addonAfter: isDiscount ? '%' : undefined
79611
79600
  }), /*#__PURE__*/jsx(Button, {
@@ -79630,9 +79619,13 @@ function PriceFactorCellRenderer(props) {
79630
79619
  icon: /*#__PURE__*/jsx(PlusOutlined, {}),
79631
79620
  children: t('backoffice.idmCatalog.prices.priceFactor.action.add')
79632
79621
  })
79633
- }), /*#__PURE__*/jsx("div", {
79622
+ }), /*#__PURE__*/jsxs("div", {
79634
79623
  className: helpText,
79635
- children: type === 'factor' ? t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange') : t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
79624
+ children: [/*#__PURE__*/jsx("div", {
79625
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.factorRange')
79626
+ }), /*#__PURE__*/jsx("div", {
79627
+ children: t('backoffice.idmCatalog.prices.priceFactor.hint.discountRange')
79628
+ })]
79636
79629
  })]
79637
79630
  })]
79638
79631
  });
@@ -79706,20 +79699,28 @@ var disabled = "disabled-Llkqu";
79706
79699
  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
79700
  styleInject(css_248z$h);
79708
79701
 
79709
- var _excluded$8 = ["onSave", "value"];
79702
+ var _excluded$8 = ["onSave", "value", "isDiscount"];
79710
79703
  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
79704
  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
79705
  function PriceFactorInput(_ref) {
79713
79706
  var _onSave = _ref.onSave,
79714
79707
  value = _ref.value,
79708
+ isDiscount = _ref.isDiscount,
79715
79709
  props = _objectWithoutProperties(_ref, _excluded$8);
79716
79710
  var _useState = useState(value),
79717
79711
  _useState2 = _slicedToArray(_useState, 2),
79718
79712
  innerValue = _useState2[0],
79719
79713
  setInnerValue = _useState2[1];
79714
+ var _useState3 = useState(isDiscount),
79715
+ _useState4 = _slicedToArray(_useState3, 2),
79716
+ innerIsDiscount = _useState4[0],
79717
+ setInnerIsDiscount = _useState4[1];
79720
79718
  useEffect(function () {
79721
79719
  setInnerValue(value);
79722
79720
  }, [value]);
79721
+ useEffect(function () {
79722
+ setInnerIsDiscount(isDiscount);
79723
+ }, [isDiscount]);
79723
79724
  return /*#__PURE__*/jsx(Tooltip$1, {
79724
79725
  title: props.tooltip,
79725
79726
  children: /*#__PURE__*/jsx("div", {
@@ -79727,9 +79728,13 @@ function PriceFactorInput(_ref) {
79727
79728
  children: /*#__PURE__*/jsx(PriceFactorCellRenderer, _objectSpread$A(_objectSpread$A({}, props), {}, {
79728
79729
  isNotInAGGrid: true,
79729
79730
  value: innerValue,
79730
- onSave: function onSave(data, value) {
79731
+ getIsDiscount: function getIsDiscount() {
79732
+ return innerIsDiscount;
79733
+ },
79734
+ onSave: function onSave(data, value, isDiscount) {
79731
79735
  setInnerValue(value);
79732
- return _onSave(data, value);
79736
+ setInnerIsDiscount(isDiscount);
79737
+ return _onSave(data, value, isDiscount);
79733
79738
  }
79734
79739
  }))
79735
79740
  })
@@ -79747,6 +79752,7 @@ function PriceFactorHeaderComponent(_ref) {
79747
79752
  priority = _ref.priority,
79748
79753
  priorityForced = _ref.priorityForced,
79749
79754
  value = _ref.value,
79755
+ isDiscount = _ref.isDiscount,
79750
79756
  inputTooltip = _ref.inputTooltip,
79751
79757
  checkboxTooltip = _ref.checkboxTooltip;
79752
79758
  var _useTranslation = useTranslation$1(),
@@ -79762,6 +79768,7 @@ function PriceFactorHeaderComponent(_ref) {
79762
79768
  children: [/*#__PURE__*/jsx(PriceFactorInput, {
79763
79769
  onSave: onSave,
79764
79770
  value: value,
79771
+ isDiscount: isDiscount,
79765
79772
  className: factorInput,
79766
79773
  tooltip: t(inputTooltip)
79767
79774
  }), /*#__PURE__*/jsx(Tooltip$1, {
@@ -79786,7 +79793,7 @@ function PriceFactorHeaderComponent(_ref) {
79786
79793
  * endpoint instead of the grid's excel export, because the served file is a report, not the grid content.
79787
79794
  */
79788
79795
  var Prices = observer(function (props) {
79789
- var _pricelist$seriePrice;
79796
+ var _pricelist$seriePrice, _pricelist$seriePrice2;
79790
79797
  var organizationId = props.organizationId,
79791
79798
  selectedPackage = props.selectedPackage,
79792
79799
  apiConfig = props.apiConfig,
@@ -79843,9 +79850,9 @@ var Prices = observer(function (props) {
79843
79850
  }
79844
79851
  }, _callee, null, [[2, 8, 11, 14]]);
79845
79852
  })), [apiConfig.enricherService, readPackageId, pricelist, selectedSerie, root.dataStore.jwt, showLoadingModal, showErrorModal, closeModal, t]);
79846
- var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
79853
+ var updatePfgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
79847
79854
  if (!selectedSerie) return;
79848
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value));
79855
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceFeatureGroup', priceFeatureGroupItem, value, isDiscount));
79849
79856
  }, [selectedSerie, pricelist, setNodeDataValue]);
79850
79857
  var updatePfgPriority = useCallback(function (priceFeatureGroupItem, value) {
79851
79858
  if (!selectedSerie) return;
@@ -79855,21 +79862,21 @@ var Prices = observer(function (props) {
79855
79862
  if (!selectedSerie) return;
79856
79863
  setNodeDataValue(applyPriceFactorPriority(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
79857
79864
  }, [pricelist, selectedSerie, setNodeDataValue]);
79858
- var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value) {
79865
+ var updatePgPriceFactor = useCallback(function (priceFeatureGroupItem, value, isDiscount) {
79859
79866
  if (!selectedSerie) return;
79860
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value));
79867
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'priceGroup', priceFeatureGroupItem, value, isDiscount));
79861
79868
  }, [pricelist, selectedSerie, setNodeDataValue]);
79862
- var updateArticlePriceFactor = useCallback(function (typeNo, value) {
79869
+ var updateArticlePriceFactor = useCallback(function (typeNo, value, isDiscount) {
79863
79870
  if (!selectedSerie) return;
79864
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value));
79871
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'article', typeNo, value, isDiscount));
79865
79872
  }, [pricelist, selectedSerie, setNodeDataValue]);
79866
- var updateTypeKeyPriceFactor = useCallback(function (typeKey, value) {
79873
+ var updateTypeKeyPriceFactor = useCallback(function (typeKey, value, isDiscount) {
79867
79874
  if (!selectedSerie) return;
79868
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value));
79875
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'typeKey', typeKey, value, isDiscount));
79869
79876
  }, [pricelist, selectedSerie, setNodeDataValue]);
79870
- var updateSeriePriceFactor = useCallback(function (value) {
79877
+ var updateSeriePriceFactor = useCallback(function (value, isDiscount) {
79871
79878
  if (!selectedSerie) return;
79872
- setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value));
79879
+ setNodeDataValue(applyPriceFactor(pricelist, selectedSerie.serieNo, 'serie', undefined, value, isDiscount));
79873
79880
  }, [pricelist, selectedSerie, setNodeDataValue]);
79874
79881
  function deleteManualPrices() {
79875
79882
  return _deleteManualPrices.apply(this, arguments);
@@ -79942,19 +79949,23 @@ var Prices = observer(function (props) {
79942
79949
  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
79950
  },
79944
79951
  cellRendererParams: {
79952
+ getIsDiscount: function getIsDiscount(data) {
79953
+ var _pricelist$articlePri2;
79954
+ 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];
79955
+ },
79945
79956
  onSave: function () {
79946
- var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value) {
79957
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data, value, isDiscount) {
79947
79958
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
79948
79959
  while (1) switch (_context2.prev = _context2.next) {
79949
79960
  case 0:
79950
- updateArticlePriceFactor(data.typeNo, value);
79961
+ updateArticlePriceFactor(data.typeNo, value, isDiscount);
79951
79962
  case 1:
79952
79963
  case "end":
79953
79964
  return _context2.stop();
79954
79965
  }
79955
79966
  }, _callee2);
79956
79967
  }));
79957
- function onSave(_x, _x2) {
79968
+ function onSave(_x, _x2, _x3) {
79958
79969
  return _onSave.apply(this, arguments);
79959
79970
  }
79960
79971
  return onSave;
@@ -79984,19 +79995,23 @@ var Prices = observer(function (props) {
79984
79995
  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
79996
  },
79986
79997
  cellRendererParams: {
79998
+ getIsDiscount: function getIsDiscount(data) {
79999
+ var _pricelist$typeKeyPri2;
80000
+ 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];
80001
+ },
79987
80002
  onSave: function () {
79988
- var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value) {
80003
+ var _onSave2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data, value, isDiscount) {
79989
80004
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
79990
80005
  while (1) switch (_context3.prev = _context3.next) {
79991
80006
  case 0:
79992
- updateTypeKeyPriceFactor(data.typeKey, value);
80007
+ updateTypeKeyPriceFactor(data.typeKey, value, isDiscount);
79993
80008
  case 1:
79994
80009
  case "end":
79995
80010
  return _context3.stop();
79996
80011
  }
79997
80012
  }, _callee3);
79998
80013
  }));
79999
- function onSave(_x3, _x4) {
80014
+ function onSave(_x4, _x5, _x6) {
80000
80015
  return _onSave2.apply(this, arguments);
80001
80016
  }
80002
80017
  return onSave;
@@ -80006,29 +80021,30 @@ var Prices = observer(function (props) {
80006
80021
  sortable: false,
80007
80022
  editable: false
80008
80023
  }].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;
80024
+ var _pricelist$pfgPricefa, _pricelist$pfgPricefa2, _pricelist$pfgPricefa3, _priceFeatureGroup$ke, _priceFeatureGroup$ke2;
80010
80025
  return {
80011
80026
  headerName: priceFeatureGroup.displayText,
80012
80027
  headerClass: inputHeader,
80013
80028
  headerGroupComponentParams: {
80014
80029
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
80015
80030
  onSave: (/*#__PURE__*/function () {
80016
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value) {
80031
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data, value, isDiscount) {
80017
80032
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
80018
80033
  while (1) switch (_context4.prev = _context4.next) {
80019
80034
  case 0:
80020
- updatePfgPriceFactor(priceFeatureGroup.id, value);
80035
+ updatePfgPriceFactor(priceFeatureGroup.id, value, isDiscount);
80021
80036
  case 1:
80022
80037
  case "end":
80023
80038
  return _context4.stop();
80024
80039
  }
80025
80040
  }, _callee4);
80026
80041
  }));
80027
- return function (_x5, _x6) {
80042
+ return function (_x7, _x8, _x9) {
80028
80043
  return _ref4.apply(this, arguments);
80029
80044
  };
80030
80045
  }()),
80031
80046
  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],
80047
+ 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
80048
  onPriorityChange: (/*#__PURE__*/function () {
80033
80049
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(value) {
80034
80050
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
@@ -80041,18 +80057,18 @@ var Prices = observer(function (props) {
80041
80057
  }
80042
80058
  }, _callee5);
80043
80059
  }));
80044
- return function (_x7) {
80060
+ return function (_x10) {
80045
80061
  return _ref5.apply(this, arguments);
80046
80062
  };
80047
80063
  }()),
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)),
80064
+ 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
80065
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfg',
80050
80066
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pfgPriority'
80051
80067
  })
80052
80068
  },
80053
80069
  marryChildren: true,
80054
80070
  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;
80071
+ var _priceFeatureGroup$ke3, _pricelist$pgPricefac, _pricelist$pgPricefac2, _pricelist$pgPricefac3, _pricelist$pfgPricefa4;
80056
80072
  return {
80057
80073
  headerName: priceGroup,
80058
80074
  field: "prices.".concat(priceGroup),
@@ -80072,22 +80088,23 @@ var Prices = observer(function (props) {
80072
80088
  headerComponentParams: {
80073
80089
  additionalElement: /*#__PURE__*/jsx(PriceFactorHeaderComponent, {
80074
80090
  onSave: (/*#__PURE__*/function () {
80075
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value) {
80091
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, value, isDiscount) {
80076
80092
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
80077
80093
  while (1) switch (_context6.prev = _context6.next) {
80078
80094
  case 0:
80079
- updatePgPriceFactor(priceGroup, value);
80095
+ updatePgPriceFactor(priceGroup, value, isDiscount);
80080
80096
  case 1:
80081
80097
  case "end":
80082
80098
  return _context6.stop();
80083
80099
  }
80084
80100
  }, _callee6);
80085
80101
  }));
80086
- return function (_x8, _x9) {
80102
+ return function (_x11, _x12, _x13) {
80087
80103
  return _ref6.apply(this, arguments);
80088
80104
  };
80089
80105
  }()),
80090
80106
  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],
80107
+ 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
80108
  onPriorityChange: (/*#__PURE__*/function () {
80092
80109
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(value) {
80093
80110
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
@@ -80100,12 +80117,12 @@ var Prices = observer(function (props) {
80100
80117
  }
80101
80118
  }, _callee7);
80102
80119
  }));
80103
- return function (_x10) {
80120
+ return function (_x14) {
80104
80121
  return _ref7.apply(this, arguments);
80105
80122
  };
80106
80123
  }()),
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)),
80124
+ 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)),
80125
+ 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
80126
  inputTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pg',
80110
80127
  checkboxTooltip: 'backoffice.idmCatalog.prices.priceFactor.label.pgPriority'
80111
80128
  })
@@ -80197,19 +80214,20 @@ var Prices = observer(function (props) {
80197
80214
  tooltip: t('backoffice.idmCatalog.prices.priceFactor.tooltip.series'),
80198
80215
  children: /*#__PURE__*/jsx(PriceFactorInput, {
80199
80216
  value: (_pricelist$seriePrice = pricelist.seriePricefactors) === null || _pricelist$seriePrice === void 0 ? void 0 : _pricelist$seriePrice[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
80217
+ isDiscount: (_pricelist$seriePrice2 = pricelist.seriePricefactorsIsDiscount) === null || _pricelist$seriePrice2 === void 0 ? void 0 : _pricelist$seriePrice2[selectedSerie === null || selectedSerie === void 0 ? void 0 : selectedSerie.serieNo],
80200
80218
  onSave: (/*#__PURE__*/function () {
80201
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value) {
80219
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_, value, isDiscount) {
80202
80220
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
80203
80221
  while (1) switch (_context8.prev = _context8.next) {
80204
80222
  case 0:
80205
- updateSeriePriceFactor(value);
80223
+ updateSeriePriceFactor(value, isDiscount);
80206
80224
  case 1:
80207
80225
  case "end":
80208
80226
  return _context8.stop();
80209
80227
  }
80210
80228
  }, _callee8);
80211
80229
  }));
80212
- return function (_x11, _x12) {
80230
+ return function (_x15, _x16, _x17) {
80213
80231
  return _ref8.apply(this, arguments);
80214
80232
  };
80215
80233
  }()),
@@ -80432,6 +80450,43 @@ var TablePriceList = observer(function () {
80432
80450
  field: 'pricefactors',
80433
80451
  cellDataType: 'number',
80434
80452
  cellRenderer: PriceFactorCellRenderer,
80453
+ cellRendererParams: {
80454
+ getIsDiscount: function getIsDiscount(data) {
80455
+ return data === null || data === void 0 ? void 0 : data.pricefactorsIsDiscount;
80456
+ },
80457
+ // One write for factors and flags, so both reach the pricelist in the same update. The node id comes
80458
+ // first: a row created in this session keeps its temporary id as row id, also once it has its _id.
80459
+ onSave: function () {
80460
+ var _onSave = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, value, isDiscount, nodeId) {
80461
+ var _spreadsheetRef$curre;
80462
+ var rowId;
80463
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
80464
+ while (1) switch (_context.prev = _context.next) {
80465
+ case 0:
80466
+ rowId = nodeId !== null && nodeId !== void 0 ? nodeId : data === null || data === void 0 ? void 0 : data._id;
80467
+ if (rowId) {
80468
+ _context.next = 3;
80469
+ break;
80470
+ }
80471
+ return _context.abrupt("return");
80472
+ case 3:
80473
+ _context.next = 5;
80474
+ return (_spreadsheetRef$curre = spreadsheetRef.current) === null || _spreadsheetRef$curre === void 0 ? void 0 : _spreadsheetRef$curre.setNodeDataValue(rowId, {
80475
+ pricefactors: value,
80476
+ pricefactorsIsDiscount: isDiscount.length > 0 ? isDiscount : undefined
80477
+ });
80478
+ case 5:
80479
+ case "end":
80480
+ return _context.stop();
80481
+ }
80482
+ }, _callee);
80483
+ }));
80484
+ function onSave(_x, _x2, _x3, _x4) {
80485
+ return _onSave.apply(this, arguments);
80486
+ }
80487
+ return onSave;
80488
+ }()
80489
+ },
80435
80490
  editable: false,
80436
80491
  filter: false,
80437
80492
  equals: function equals(a, b) {
@@ -80551,6 +80606,38 @@ var TablePriceList = observer(function () {
80551
80606
  cellDataType: 'object',
80552
80607
  editable: false,
80553
80608
  hide: true
80609
+ },
80610
+ // Per factor whether the price factor dialog shows it as discount, beside the factor fields above
80611
+ {
80612
+ field: 'pricefactorsIsDiscount',
80613
+ cellDataType: 'object',
80614
+ editable: false,
80615
+ hide: true
80616
+ }, {
80617
+ field: 'seriePricefactorsIsDiscount',
80618
+ cellDataType: 'object',
80619
+ editable: false,
80620
+ hide: true
80621
+ }, {
80622
+ field: 'articlePricefactorsIsDiscount',
80623
+ cellDataType: 'object',
80624
+ editable: false,
80625
+ hide: true
80626
+ }, {
80627
+ field: 'typeKeyPricefactorsIsDiscount',
80628
+ cellDataType: 'object',
80629
+ editable: false,
80630
+ hide: true
80631
+ }, {
80632
+ field: 'pgPricefactorsIsDiscount',
80633
+ cellDataType: 'object',
80634
+ editable: false,
80635
+ hide: true
80636
+ }, {
80637
+ field: 'pfgPricefactorsIsDiscount',
80638
+ cellDataType: 'object',
80639
+ editable: false,
80640
+ hide: true
80554
80641
  }]
80555
80642
  };
80556
80643
  }, [apiInterface, i18n.language, viewOnly]);