@veloceapps/sdk 6.0.0-27 → 6.0.0-29
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.
- package/bundles/veloceapps-sdk-core.umd.js +49 -10
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/cms/vendor-map.d.ts +1 -0
- package/core/utils/line-item.utils.d.ts +1 -0
- package/esm2015/core/utils/line-item.utils.js +18 -11
- package/fesm2015/veloceapps-sdk-core.js +19 -11
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/package.json +1 -1
@@ -666,17 +666,54 @@
|
|
666
666
|
};
|
667
667
|
var replaceLineItem = function (lineItem, replaceTo) {
|
668
668
|
if (lineItem.id === replaceTo.id) {
|
669
|
-
return Object.assign({}, replaceTo);
|
669
|
+
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
670
670
|
}
|
671
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
671
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) { return replaceLineItem(li, replaceTo); }) });
|
672
|
+
};
|
673
|
+
var recalculateCardinalityVariables = function (original, updated) {
|
674
|
+
var e_1, _c, e_2, _d;
|
675
|
+
var _a;
|
676
|
+
var cardinalityVariables = new Map();
|
677
|
+
try {
|
678
|
+
for (var _e = __values(updated.lineItems), _f = _e.next(); !_f.done; _f = _e.next()) {
|
679
|
+
var li = _f.value;
|
680
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
681
|
+
cardinalityVariables.set(cardinalityVariableName, ((_a = cardinalityVariables.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
682
|
+
}
|
683
|
+
}
|
684
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
685
|
+
finally {
|
686
|
+
try {
|
687
|
+
if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
|
688
|
+
}
|
689
|
+
finally { if (e_1) throw e_1.error; }
|
690
|
+
}
|
691
|
+
var _loop_1 = function (li) {
|
692
|
+
if (updated.lineItems.some(function (_c) {
|
693
|
+
var id = _c.id, qty = _c.qty;
|
694
|
+
return li.id === id && li.qty === qty;
|
695
|
+
})) {
|
696
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
697
|
+
cardinalityVariables.delete(cardinalityVariableName);
|
698
|
+
}
|
699
|
+
};
|
700
|
+
try {
|
701
|
+
for (var _g = __values(original.lineItems), _h = _g.next(); !_h.done; _h = _g.next()) {
|
702
|
+
var li = _h.value;
|
703
|
+
_loop_1(li);
|
704
|
+
}
|
705
|
+
}
|
706
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
707
|
+
finally {
|
708
|
+
try {
|
709
|
+
if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
|
710
|
+
}
|
711
|
+
finally { if (e_2) throw e_2.error; }
|
712
|
+
}
|
713
|
+
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, __spreadArray([], __read(cardinalityVariables)).map(function (_c) {
|
714
|
+
var _d = __read(_c, 2), name = _d[0], value = _d[1];
|
715
|
+
return ({ name: name, value: value });
|
716
|
+
})) });
|
680
717
|
};
|
681
718
|
var mapAttributes = function (attributes) {
|
682
719
|
return attributes.reduce(function (acc, _c) {
|
@@ -766,6 +803,7 @@
|
|
766
803
|
insertLineItem: insertLineItem,
|
767
804
|
removeLineItem: removeLineItem,
|
768
805
|
replaceLineItem: replaceLineItem,
|
806
|
+
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
769
807
|
mapAttributes: mapAttributes,
|
770
808
|
getAttributes: getAttributes,
|
771
809
|
upsertAttributes: upsertAttributes,
|
@@ -1845,6 +1883,7 @@
|
|
1845
1883
|
exports.mapAttributes = mapAttributes;
|
1846
1884
|
exports.multiplyLineItems = multiplyLineItems;
|
1847
1885
|
exports.patchAttributes = patchAttributes;
|
1886
|
+
exports.recalculateCardinalityVariables = recalculateCardinalityVariables;
|
1848
1887
|
exports.removeLineItem = removeLineItem;
|
1849
1888
|
exports.replaceLineItem = replaceLineItem;
|
1850
1889
|
exports.upsertAttributes = upsertAttributes;
|