@veloceapps/sdk 7.0.2-0 → 7.0.2-10

Sign up to get free protection for your applications and to get access to all the features.
@@ -323,19 +323,31 @@ const getRecommendedPrices = (portDomain, type) => {
323
323
  const generateModifiedAssetsMap = (lineItems) => {
324
324
  return lineItems.reduce((acc, li) => {
325
325
  var _a;
326
- if (li.rampInstanceId && li.status !== 'EXIST') {
327
- let target = li;
328
- while (target && target.rampInstanceId) {
329
- target = lineItems.find(sub => sub.id === li.rampInstanceId);
330
- }
331
- const id = (_a = target === null || target === void 0 ? void 0 : target.assetId) !== null && _a !== void 0 ? _a : target === null || target === void 0 ? void 0 : target.openOrderLineItemId;
332
- if (id) {
333
- acc[id] = true;
334
- }
326
+ const isModified = isLineItemModified(li);
327
+ if (!isModified) {
328
+ return acc;
329
+ }
330
+ const target = getOriginParent(lineItems, li);
331
+ const id = (_a = target === null || target === void 0 ? void 0 : target.assetId) !== null && _a !== void 0 ? _a : target === null || target === void 0 ? void 0 : target.openOrderLineItemId;
332
+ if (id) {
333
+ acc[id] = true;
335
334
  }
336
335
  return acc;
337
336
  }, {});
338
337
  };
338
+ const getOriginParent = (lineItems, currentLineItem) => {
339
+ let target = currentLineItem;
340
+ while (target && target.rampInstanceId) {
341
+ target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
342
+ }
343
+ return target;
344
+ };
345
+ const isLineItemModified = (lineItem) => {
346
+ if (lineItem.status === 'PENDING' && lineItem.actionCode === 'EXIST') {
347
+ return false;
348
+ }
349
+ return lineItem.status !== 'EXIST';
350
+ };
339
351
  const multiplyLineItems = (lineItem, qty, split) => {
340
352
  if (split) {
341
353
  const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
@@ -357,8 +369,10 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
357
369
  generateModifiedAssetsMap: generateModifiedAssetsMap,
358
370
  getAttributeValue: getAttributeValue,
359
371
  getAttributes: getAttributes,
372
+ getOriginParent: getOriginParent,
360
373
  getRecommendedPrices: getRecommendedPrices,
361
374
  insertLineItem: insertLineItem,
375
+ isLineItemModified: isLineItemModified,
362
376
  mapAttributes: mapAttributes,
363
377
  multiplyLineItems: multiplyLineItems,
364
378
  patchAttributes: patchAttributes,
@@ -1228,5 +1242,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1228
1242
  * Generated bundle index. Do not edit.
1229
1243
  */
1230
1244
 
1231
- export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getRecommendedPrices, insertLineItem, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1245
+ export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1232
1246
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map