@crystaldesign/basket-model 26.12.0-beta.9 → 26.12.0-rc.0

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.
@@ -943,26 +943,56 @@ var _generateEKTextOfBasket = (function (basket, withoutPrices, customDivaNr, va
943
943
  return !ol.IsPartlistArticle;
944
944
  });
945
945
  var usedOrderLines = [];
946
- var _loop2 = function _loop2(_i) {
947
- var retval = processNonPartlistOrderlines(basket, orderlines[_i], setTextHeader, preisLength, withoutPrices);
948
- usedOrderLines.push(orderlines[_i]);
949
- if (retval) {
950
- setText += retval;
946
+ var _loop2 = function _loop2() {
947
+ var orderLine = orderlines[_i];
951
948
  //check if partlistarticles exists for this orderline
952
949
  var partlistArticleOrderLines = ols.filter(function (ol) {
953
- return ol.RelatedToBasketID === orderlines[_i].BasketID && ol.IsPartlistArticle;
950
+ return ol.RelatedToBasketID === orderLine.BasketID && ol.IsPartlistArticle;
954
951
  });
955
- if ((partlistArticleOrderLines === null || partlistArticleOrderLines === void 0 ? void 0 : partlistArticleOrderLines.length) > 0) {
956
- usedOrderLines.push.apply(usedOrderLines, _toConsumableArray__default["default"](partlistArticleOrderLines));
957
- var value = processPartListOrderLines(basket, partlistArticleOrderLines, setTextHeader, preisLength, withoutPrices, true);
958
- if (value) {
959
- setText += value;
952
+ var retval = isHull(basket, ols, orderLine) ? undefined : processNonPartlistOrderlines(basket, orderLine, setTextHeader, preisLength, withoutPrices);
953
+ usedOrderLines.push(orderLine);
954
+ if (retval) {
955
+ setText += retval;
956
+ if (partlistArticleOrderLines.length > 0) {
957
+ usedOrderLines.push.apply(usedOrderLines, _toConsumableArray__default["default"](partlistArticleOrderLines));
958
+ var _value = processPartListOrderLines(basket, partlistArticleOrderLines, setTextHeader, preisLength, withoutPrices, true);
959
+ if (_value) {
960
+ setText += _value;
961
+ }
960
962
  }
963
+ return 0; // continue
961
964
  }
962
- }
963
- };
965
+
966
+ // An article without a price of its own is only represented by its components. They are written here instead of after
967
+ // every other position, so that a main article keeps its place in front of the accessories that belong to it.
968
+ if (!isHull(basket, ols, orderLine)) return 0; // continue
969
+ var components = _getPartlistComponents(ols, orderLine).filter(function (component) {
970
+ return !usedOrderLines.includes(component);
971
+ });
972
+ if (components.length === 0) return 0; // continue
973
+
974
+ // Identical components of the hulls further down are merged into this position (e.g. "2 Drehtür ... 538.00" in Twist),
975
+ // as they were when the components of all hulls were written together at the end. An accessory stays below the main
976
+ // article it belongs to, so that it is clear where it is mounted (e.g. the cushions of each sofa in Brühl alba).
977
+ var groupKeys = components.map(getGroupKey);
978
+ var sameComponentsOfLaterHulls = orderlines.slice(_i + 1).filter(function (ol) {
979
+ return isHull(basket, ols, ol) && ol.RelatedToBasketID === orderLine.RelatedToBasketID;
980
+ }).flatMap(function (hull) {
981
+ return _getPartlistComponents(ols, hull);
982
+ }).filter(function (component) {
983
+ return groupKeys.includes(getGroupKey(component));
984
+ });
985
+ var positions = [].concat(_toConsumableArray__default["default"](components), _toConsumableArray__default["default"](sameComponentsOfLaterHulls));
986
+ usedOrderLines.push.apply(usedOrderLines, _toConsumableArray__default["default"](positions));
987
+ var value = processPartListOrderLines(basket, positions, setTextHeader, preisLength, withoutPrices);
988
+ if (value) {
989
+ setText += value;
990
+ }
991
+ },
992
+ _ret;
964
993
  for (var _i = 0; _i < orderlines.length; _i++) {
965
- _loop2(_i);
994
+ _ret = _loop2();
995
+ if (_ret === 0) continue;
966
996
  }
967
997
  var notUsedOls = ols.filter(function (ol) {
968
998
  return ol.IsPartlistArticle && !usedOrderLines.includes(ol);
@@ -989,6 +1019,54 @@ var _generateEKTextOfBasket = (function (basket, withoutPrices, customDivaNr, va
989
1019
  basket.OrderSets[0].SetOrderText = sbSetOrderText;
990
1020
  return basket;
991
1021
  });
1022
+
1023
+ /**
1024
+ * A component that carries the name and the price of the article it belongs to is that article written a second time.
1025
+ * Listing both prints the same position and the same price twice, so the listed prices no longer add up to the total.
1026
+ */
1027
+ var repeatsOrderLine = function repeatsOrderLine(orderLine, component) {
1028
+ var _component$Name, _orderLine$Name, _component$VKPrice, _orderLine$VKPrice;
1029
+ return DivaUtils__default["default"].stripTags((_component$Name = component.Name) !== null && _component$Name !== void 0 ? _component$Name : '') === DivaUtils__default["default"].stripTags((_orderLine$Name = orderLine.Name) !== null && _orderLine$Name !== void 0 ? _orderLine$Name : '') && ((_component$VKPrice = component.VKPrice) === null || _component$VKPrice === void 0 ? void 0 : _component$VKPrice.CalcPrice) === ((_orderLine$VKPrice = orderLine.VKPrice) === null || _orderLine$VKPrice === void 0 ? void 0 : _orderLine$VKPrice.CalcPrice);
1030
+ };
1031
+ var hasZkatOrderLine = function hasZkatOrderLine(basket, orderLine) {
1032
+ var _basket$getSAPOrderLi2;
1033
+ return !!((_basket$getSAPOrderLi2 = basket.getSAPOrderLines()) !== null && _basket$getSAPOrderLi2 !== void 0 && _basket$getSAPOrderLi2.some(function (sol) {
1034
+ return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1035
+ }));
1036
+ };
1037
+
1038
+ /**
1039
+ * An article without a price of its own that is only represented by its components: it has no ZKAT order line of its own, or
1040
+ * a component repeats it (e.g. the Brühl accessories), so writing the article as well would list the same position twice.
1041
+ * The repeating component needs a ZKAT order line of its own, as it is not written without one and the article would get lost.
1042
+ */
1043
+ var isHull = function isHull(basket, ols, orderLine) {
1044
+ var _orderLine$VKPrice2;
1045
+ return !!orderLine.HasPartlistArticle && !((_orderLine$VKPrice2 = orderLine.VKPrice) !== null && _orderLine$VKPrice2 !== void 0 && _orderLine$VKPrice2.Price) && (!hasZkatOrderLine(basket, orderLine) || _getPartlistComponents(ols, orderLine).some(function (component) {
1046
+ return hasZkatOrderLine(basket, component) && repeatsOrderLine(orderLine, component);
1047
+ }));
1048
+ };
1049
+
1050
+ /** Partlist order lines with the same key are written as one position with the summed quantity and price. */
1051
+ var getGroupKey = function getGroupKey(ol) {
1052
+ var _ol$Name, _ol$VariantBasketData2;
1053
+ return DivaUtils__default["default"].stripTags((_ol$Name = ol.Name) !== null && _ol$Name !== void 0 ? _ol$Name : '') + '|' + ol.TypeNr + '|' + ol.SetID + '|' + ol.ArticleCodex + '|' + ((_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (v) {
1054
+ return v.OPT + v.OPV;
1055
+ }).join(';'));
1056
+ };
1057
+
1058
+ /** Partlist order lines below an order line at any depth, in the order of the set. */
1059
+ var _getPartlistComponents = function getPartlistComponents(ols, orderLine) {
1060
+ var children = ols.filter(function (ol) {
1061
+ return ol.IsPartlistArticle && ol.RelatedToBasketID === orderLine.BasketID;
1062
+ });
1063
+ var components = children.flatMap(function (child) {
1064
+ return [child].concat(_toConsumableArray__default["default"](_getPartlistComponents(ols, child)));
1065
+ });
1066
+ return ols.filter(function (ol) {
1067
+ return components.includes(ol);
1068
+ });
1069
+ };
992
1070
  var addingSapOrderLinesToEkText = function addingSapOrderLinesToEkText(saporderLines, ols) {
993
1071
  //https://app.asana.com/0/686949732692179/692909200657046
994
1072
  var setText = '';
@@ -1023,27 +1101,25 @@ var processPartListOrderLines = function processPartListOrderLines(basket, ols,
1023
1101
  newArtikelLength2Row += lengthSubPostion;
1024
1102
  }
1025
1103
  var groupedOls = ols.filter(function (orderLine) {
1026
- var _basket$getSAPOrderLi2;
1027
- return ((_basket$getSAPOrderLi2 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi2 === void 0 ? void 0 : _basket$getSAPOrderLi2.find(function (sol) {
1104
+ var _basket$getSAPOrderLi3;
1105
+ return ((_basket$getSAPOrderLi3 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi3 === void 0 ? void 0 : _basket$getSAPOrderLi3.find(function (sol) {
1028
1106
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr == sol.ArticleNr;
1029
1107
  })) && orderLine.IsPartlistArticle;
1030
1108
  }).reduce(function (group, ol) {
1031
- var _ol$Name, _ol$VariantBasketData2, _group$category;
1032
- var category = DivaUtils__default["default"].stripTags((_ol$Name = ol.Name) !== null && _ol$Name !== void 0 ? _ol$Name : '') + '|' + ol.TypeNr + '|' + ol.SetID + '|' + ol.ArticleCodex + '|' + ((_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (v) {
1033
- return v.OPT + v.OPV;
1034
- }).join(';'));
1109
+ var _group$category;
1110
+ var category = getGroupKey(ol);
1035
1111
  group[category] = (_group$category = group[category]) !== null && _group$category !== void 0 ? _group$category : [];
1036
1112
  group[category].push(ol);
1037
1113
  return group;
1038
1114
  }, {});
1039
1115
  var retval = '';
1040
1116
  var _loop4 = function _loop4() {
1041
- var _basket$getSAPOrderLi3, _basket$getSAPOrderLi4, _basket$getSAPOrderLi5, _orderLine$Name, _orderLine$ConfigArti2;
1117
+ var _basket$getSAPOrderLi4, _basket$getSAPOrderLi5, _basket$getSAPOrderLi6, _orderLine$Name2, _orderLine$ConfigArti2;
1042
1118
  var groupedOl = groupedOls[key];
1043
1119
  var orderLine = groupedOl[0];
1044
- var sol = (_basket$getSAPOrderLi3 = (_basket$getSAPOrderLi4 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi4 === void 0 ? void 0 : _basket$getSAPOrderLi4.find(function (sol) {
1120
+ var sol = (_basket$getSAPOrderLi4 = (_basket$getSAPOrderLi5 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi5 === void 0 ? void 0 : _basket$getSAPOrderLi5.find(function (sol) {
1045
1121
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1046
- })) !== null && _basket$getSAPOrderLi3 !== void 0 ? _basket$getSAPOrderLi3 : (_basket$getSAPOrderLi5 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi5 === void 0 ? void 0 : _basket$getSAPOrderLi5[0];
1122
+ })) !== null && _basket$getSAPOrderLi4 !== void 0 ? _basket$getSAPOrderLi4 : (_basket$getSAPOrderLi6 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi6 === void 0 ? void 0 : _basket$getSAPOrderLi6[0];
1047
1123
  var setOrderText = '';
1048
1124
  if (!isSubPosition) {
1049
1125
  var quantity = groupedOl.reduce(function (sum, ol) {
@@ -1051,7 +1127,7 @@ var processPartListOrderLines = function processPartListOrderLines(basket, ols,
1051
1127
  }, 0).toString();
1052
1128
  setOrderText += appendToTheRight(mLength, quantity);
1053
1129
  }
1054
- var lines = getLines(artikelLength, newArtikelLength2Row, DivaUtils__default["default"].stripTags((_orderLine$Name = orderLine.Name) !== null && _orderLine$Name !== void 0 ? _orderLine$Name : ''));
1130
+ var lines = getLines(artikelLength, newArtikelLength2Row, DivaUtils__default["default"].stripTags((_orderLine$Name2 = orderLine.Name) !== null && _orderLine$Name2 !== void 0 ? _orderLine$Name2 : ''));
1055
1131
  var articleNumber = (_orderLine$ConfigArti2 = orderLine.ConfigArticleCodex) !== null && _orderLine$ConfigArti2 !== void 0 ? _orderLine$ConfigArti2 : orderLine.ArticleCodex;
1056
1132
 
1057
1133
  //Anforderung von Polypol auch die Typennummer anzugeben
@@ -1107,8 +1183,8 @@ var processNonPartlistOrderlines = function processNonPartlistOrderlines(basket,
1107
1183
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1108
1184
  });
1109
1185
  if (sol) {
1110
- var _orderLine$Name2, _orderLine$ConfigArti3, _orderLine$VariantBas, _orderLine$VariantBas2, _orderLine$ConfigPric;
1111
- var lines = getLines(artikelLength, artikelLength2Row, DivaUtils__default["default"].stripTags((_orderLine$Name2 = orderLine.Name) !== null && _orderLine$Name2 !== void 0 ? _orderLine$Name2 : ''));
1186
+ var _orderLine$Name3, _orderLine$ConfigArti3, _orderLine$VariantBas, _orderLine$VariantBas2, _orderLine$ConfigPric;
1187
+ var lines = getLines(artikelLength, artikelLength2Row, DivaUtils__default["default"].stripTags((_orderLine$Name3 = orderLine.Name) !== null && _orderLine$Name3 !== void 0 ? _orderLine$Name3 : ''));
1112
1188
  var articleNumber = (_orderLine$ConfigArti3 = orderLine.ConfigArticleCodex) !== null && _orderLine$ConfigArti3 !== void 0 ? _orderLine$ConfigArti3 : orderLine.ArticleCodex;
1113
1189
 
1114
1190
  //Anforderung von Polypol auch die Typennummer anzugeben
@@ -1128,8 +1204,8 @@ var processNonPartlistOrderlines = function processNonPartlistOrderlines(basket,
1128
1204
  sapOrderLineText += appendToTheRight(mLength, orderLine.Quantity.toString());
1129
1205
  sapOrderLineText += appendToTheRight(artikelLength, lines[0]);
1130
1206
  if (!withoutPrices) {
1131
- var _orderLine$VKPrice$Ca, _orderLine$VKPrice;
1132
- sapOrderLineText += appendToTheLeft(preisLength, formatPrice((_orderLine$VKPrice$Ca = (_orderLine$VKPrice = orderLine.VKPrice) === null || _orderLine$VKPrice === void 0 || (_orderLine$VKPrice = _orderLine$VKPrice.CalcPrice) === null || _orderLine$VKPrice === void 0 ? void 0 : _orderLine$VKPrice.toString()) !== null && _orderLine$VKPrice$Ca !== void 0 ? _orderLine$VKPrice$Ca : '0'));
1207
+ var _orderLine$VKPrice$Ca, _orderLine$VKPrice3;
1208
+ sapOrderLineText += appendToTheLeft(preisLength, formatPrice((_orderLine$VKPrice$Ca = (_orderLine$VKPrice3 = orderLine.VKPrice) === null || _orderLine$VKPrice3 === void 0 || (_orderLine$VKPrice3 = _orderLine$VKPrice3.CalcPrice) === null || _orderLine$VKPrice3 === void 0 ? void 0 : _orderLine$VKPrice3.toString()) !== null && _orderLine$VKPrice$Ca !== void 0 ? _orderLine$VKPrice$Ca : '0'));
1133
1209
  }
1134
1210
  sapOrderLineText += newLine;
1135
1211
  sapOrderLineText += writeOtherLines(lines, startPositionArtikel2Row);
@@ -931,26 +931,56 @@ var _generateEKTextOfBasket = (function (basket, withoutPrices, customDivaNr, va
931
931
  return !ol.IsPartlistArticle;
932
932
  });
933
933
  var usedOrderLines = [];
934
- var _loop2 = function _loop2(_i) {
935
- var retval = processNonPartlistOrderlines(basket, orderlines[_i], setTextHeader, preisLength, withoutPrices);
936
- usedOrderLines.push(orderlines[_i]);
937
- if (retval) {
938
- setText += retval;
934
+ var _loop2 = function _loop2() {
935
+ var orderLine = orderlines[_i];
939
936
  //check if partlistarticles exists for this orderline
940
937
  var partlistArticleOrderLines = ols.filter(function (ol) {
941
- return ol.RelatedToBasketID === orderlines[_i].BasketID && ol.IsPartlistArticle;
938
+ return ol.RelatedToBasketID === orderLine.BasketID && ol.IsPartlistArticle;
942
939
  });
943
- if ((partlistArticleOrderLines === null || partlistArticleOrderLines === void 0 ? void 0 : partlistArticleOrderLines.length) > 0) {
944
- usedOrderLines.push.apply(usedOrderLines, _toConsumableArray(partlistArticleOrderLines));
945
- var value = processPartListOrderLines(basket, partlistArticleOrderLines, setTextHeader, preisLength, withoutPrices, true);
946
- if (value) {
947
- setText += value;
940
+ var retval = isHull(basket, ols, orderLine) ? undefined : processNonPartlistOrderlines(basket, orderLine, setTextHeader, preisLength, withoutPrices);
941
+ usedOrderLines.push(orderLine);
942
+ if (retval) {
943
+ setText += retval;
944
+ if (partlistArticleOrderLines.length > 0) {
945
+ usedOrderLines.push.apply(usedOrderLines, _toConsumableArray(partlistArticleOrderLines));
946
+ var _value = processPartListOrderLines(basket, partlistArticleOrderLines, setTextHeader, preisLength, withoutPrices, true);
947
+ if (_value) {
948
+ setText += _value;
949
+ }
948
950
  }
951
+ return 0; // continue
949
952
  }
950
- }
951
- };
953
+
954
+ // An article without a price of its own is only represented by its components. They are written here instead of after
955
+ // every other position, so that a main article keeps its place in front of the accessories that belong to it.
956
+ if (!isHull(basket, ols, orderLine)) return 0; // continue
957
+ var components = _getPartlistComponents(ols, orderLine).filter(function (component) {
958
+ return !usedOrderLines.includes(component);
959
+ });
960
+ if (components.length === 0) return 0; // continue
961
+
962
+ // Identical components of the hulls further down are merged into this position (e.g. "2 Drehtür ... 538.00" in Twist),
963
+ // as they were when the components of all hulls were written together at the end. An accessory stays below the main
964
+ // article it belongs to, so that it is clear where it is mounted (e.g. the cushions of each sofa in Brühl alba).
965
+ var groupKeys = components.map(getGroupKey);
966
+ var sameComponentsOfLaterHulls = orderlines.slice(_i + 1).filter(function (ol) {
967
+ return isHull(basket, ols, ol) && ol.RelatedToBasketID === orderLine.RelatedToBasketID;
968
+ }).flatMap(function (hull) {
969
+ return _getPartlistComponents(ols, hull);
970
+ }).filter(function (component) {
971
+ return groupKeys.includes(getGroupKey(component));
972
+ });
973
+ var positions = [].concat(_toConsumableArray(components), _toConsumableArray(sameComponentsOfLaterHulls));
974
+ usedOrderLines.push.apply(usedOrderLines, _toConsumableArray(positions));
975
+ var value = processPartListOrderLines(basket, positions, setTextHeader, preisLength, withoutPrices);
976
+ if (value) {
977
+ setText += value;
978
+ }
979
+ },
980
+ _ret;
952
981
  for (var _i = 0; _i < orderlines.length; _i++) {
953
- _loop2(_i);
982
+ _ret = _loop2();
983
+ if (_ret === 0) continue;
954
984
  }
955
985
  var notUsedOls = ols.filter(function (ol) {
956
986
  return ol.IsPartlistArticle && !usedOrderLines.includes(ol);
@@ -977,6 +1007,54 @@ var _generateEKTextOfBasket = (function (basket, withoutPrices, customDivaNr, va
977
1007
  basket.OrderSets[0].SetOrderText = sbSetOrderText;
978
1008
  return basket;
979
1009
  });
1010
+
1011
+ /**
1012
+ * A component that carries the name and the price of the article it belongs to is that article written a second time.
1013
+ * Listing both prints the same position and the same price twice, so the listed prices no longer add up to the total.
1014
+ */
1015
+ var repeatsOrderLine = function repeatsOrderLine(orderLine, component) {
1016
+ var _component$Name, _orderLine$Name, _component$VKPrice, _orderLine$VKPrice;
1017
+ return DivaUtils.stripTags((_component$Name = component.Name) !== null && _component$Name !== void 0 ? _component$Name : '') === DivaUtils.stripTags((_orderLine$Name = orderLine.Name) !== null && _orderLine$Name !== void 0 ? _orderLine$Name : '') && ((_component$VKPrice = component.VKPrice) === null || _component$VKPrice === void 0 ? void 0 : _component$VKPrice.CalcPrice) === ((_orderLine$VKPrice = orderLine.VKPrice) === null || _orderLine$VKPrice === void 0 ? void 0 : _orderLine$VKPrice.CalcPrice);
1018
+ };
1019
+ var hasZkatOrderLine = function hasZkatOrderLine(basket, orderLine) {
1020
+ var _basket$getSAPOrderLi2;
1021
+ return !!((_basket$getSAPOrderLi2 = basket.getSAPOrderLines()) !== null && _basket$getSAPOrderLi2 !== void 0 && _basket$getSAPOrderLi2.some(function (sol) {
1022
+ return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1023
+ }));
1024
+ };
1025
+
1026
+ /**
1027
+ * An article without a price of its own that is only represented by its components: it has no ZKAT order line of its own, or
1028
+ * a component repeats it (e.g. the Brühl accessories), so writing the article as well would list the same position twice.
1029
+ * The repeating component needs a ZKAT order line of its own, as it is not written without one and the article would get lost.
1030
+ */
1031
+ var isHull = function isHull(basket, ols, orderLine) {
1032
+ var _orderLine$VKPrice2;
1033
+ return !!orderLine.HasPartlistArticle && !((_orderLine$VKPrice2 = orderLine.VKPrice) !== null && _orderLine$VKPrice2 !== void 0 && _orderLine$VKPrice2.Price) && (!hasZkatOrderLine(basket, orderLine) || _getPartlistComponents(ols, orderLine).some(function (component) {
1034
+ return hasZkatOrderLine(basket, component) && repeatsOrderLine(orderLine, component);
1035
+ }));
1036
+ };
1037
+
1038
+ /** Partlist order lines with the same key are written as one position with the summed quantity and price. */
1039
+ var getGroupKey = function getGroupKey(ol) {
1040
+ var _ol$Name, _ol$VariantBasketData2;
1041
+ return DivaUtils.stripTags((_ol$Name = ol.Name) !== null && _ol$Name !== void 0 ? _ol$Name : '') + '|' + ol.TypeNr + '|' + ol.SetID + '|' + ol.ArticleCodex + '|' + ((_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (v) {
1042
+ return v.OPT + v.OPV;
1043
+ }).join(';'));
1044
+ };
1045
+
1046
+ /** Partlist order lines below an order line at any depth, in the order of the set. */
1047
+ var _getPartlistComponents = function getPartlistComponents(ols, orderLine) {
1048
+ var children = ols.filter(function (ol) {
1049
+ return ol.IsPartlistArticle && ol.RelatedToBasketID === orderLine.BasketID;
1050
+ });
1051
+ var components = children.flatMap(function (child) {
1052
+ return [child].concat(_toConsumableArray(_getPartlistComponents(ols, child)));
1053
+ });
1054
+ return ols.filter(function (ol) {
1055
+ return components.includes(ol);
1056
+ });
1057
+ };
980
1058
  var addingSapOrderLinesToEkText = function addingSapOrderLinesToEkText(saporderLines, ols) {
981
1059
  //https://app.asana.com/0/686949732692179/692909200657046
982
1060
  var setText = '';
@@ -1011,27 +1089,25 @@ var processPartListOrderLines = function processPartListOrderLines(basket, ols,
1011
1089
  newArtikelLength2Row += lengthSubPostion;
1012
1090
  }
1013
1091
  var groupedOls = ols.filter(function (orderLine) {
1014
- var _basket$getSAPOrderLi2;
1015
- return ((_basket$getSAPOrderLi2 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi2 === void 0 ? void 0 : _basket$getSAPOrderLi2.find(function (sol) {
1092
+ var _basket$getSAPOrderLi3;
1093
+ return ((_basket$getSAPOrderLi3 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi3 === void 0 ? void 0 : _basket$getSAPOrderLi3.find(function (sol) {
1016
1094
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr == sol.ArticleNr;
1017
1095
  })) && orderLine.IsPartlistArticle;
1018
1096
  }).reduce(function (group, ol) {
1019
- var _ol$Name, _ol$VariantBasketData2, _group$category;
1020
- var category = DivaUtils.stripTags((_ol$Name = ol.Name) !== null && _ol$Name !== void 0 ? _ol$Name : '') + '|' + ol.TypeNr + '|' + ol.SetID + '|' + ol.ArticleCodex + '|' + ((_ol$VariantBasketData2 = ol.VariantBasketDatas) === null || _ol$VariantBasketData2 === void 0 ? void 0 : _ol$VariantBasketData2.map(function (v) {
1021
- return v.OPT + v.OPV;
1022
- }).join(';'));
1097
+ var _group$category;
1098
+ var category = getGroupKey(ol);
1023
1099
  group[category] = (_group$category = group[category]) !== null && _group$category !== void 0 ? _group$category : [];
1024
1100
  group[category].push(ol);
1025
1101
  return group;
1026
1102
  }, {});
1027
1103
  var retval = '';
1028
1104
  var _loop4 = function _loop4() {
1029
- var _basket$getSAPOrderLi3, _basket$getSAPOrderLi4, _basket$getSAPOrderLi5, _orderLine$Name, _orderLine$ConfigArti2;
1105
+ var _basket$getSAPOrderLi4, _basket$getSAPOrderLi5, _basket$getSAPOrderLi6, _orderLine$Name2, _orderLine$ConfigArti2;
1030
1106
  var groupedOl = groupedOls[key];
1031
1107
  var orderLine = groupedOl[0];
1032
- var sol = (_basket$getSAPOrderLi3 = (_basket$getSAPOrderLi4 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi4 === void 0 ? void 0 : _basket$getSAPOrderLi4.find(function (sol) {
1108
+ var sol = (_basket$getSAPOrderLi4 = (_basket$getSAPOrderLi5 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi5 === void 0 ? void 0 : _basket$getSAPOrderLi5.find(function (sol) {
1033
1109
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1034
- })) !== null && _basket$getSAPOrderLi3 !== void 0 ? _basket$getSAPOrderLi3 : (_basket$getSAPOrderLi5 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi5 === void 0 ? void 0 : _basket$getSAPOrderLi5[0];
1110
+ })) !== null && _basket$getSAPOrderLi4 !== void 0 ? _basket$getSAPOrderLi4 : (_basket$getSAPOrderLi6 = basket.getSAPOrderLines()) === null || _basket$getSAPOrderLi6 === void 0 ? void 0 : _basket$getSAPOrderLi6[0];
1035
1111
  var setOrderText = '';
1036
1112
  if (!isSubPosition) {
1037
1113
  var quantity = groupedOl.reduce(function (sum, ol) {
@@ -1039,7 +1115,7 @@ var processPartListOrderLines = function processPartListOrderLines(basket, ols,
1039
1115
  }, 0).toString();
1040
1116
  setOrderText += appendToTheRight(mLength, quantity);
1041
1117
  }
1042
- var lines = getLines(artikelLength, newArtikelLength2Row, DivaUtils.stripTags((_orderLine$Name = orderLine.Name) !== null && _orderLine$Name !== void 0 ? _orderLine$Name : ''));
1118
+ var lines = getLines(artikelLength, newArtikelLength2Row, DivaUtils.stripTags((_orderLine$Name2 = orderLine.Name) !== null && _orderLine$Name2 !== void 0 ? _orderLine$Name2 : ''));
1043
1119
  var articleNumber = (_orderLine$ConfigArti2 = orderLine.ConfigArticleCodex) !== null && _orderLine$ConfigArti2 !== void 0 ? _orderLine$ConfigArti2 : orderLine.ArticleCodex;
1044
1120
 
1045
1121
  //Anforderung von Polypol auch die Typennummer anzugeben
@@ -1095,8 +1171,8 @@ var processNonPartlistOrderlines = function processNonPartlistOrderlines(basket,
1095
1171
  return sol.ArticleNrPrefix === 'ZKAT' && orderLine.RetailArticleNr === sol.ArticleNr;
1096
1172
  });
1097
1173
  if (sol) {
1098
- var _orderLine$Name2, _orderLine$ConfigArti3, _orderLine$VariantBas, _orderLine$VariantBas2, _orderLine$ConfigPric;
1099
- var lines = getLines(artikelLength, artikelLength2Row, DivaUtils.stripTags((_orderLine$Name2 = orderLine.Name) !== null && _orderLine$Name2 !== void 0 ? _orderLine$Name2 : ''));
1174
+ var _orderLine$Name3, _orderLine$ConfigArti3, _orderLine$VariantBas, _orderLine$VariantBas2, _orderLine$ConfigPric;
1175
+ var lines = getLines(artikelLength, artikelLength2Row, DivaUtils.stripTags((_orderLine$Name3 = orderLine.Name) !== null && _orderLine$Name3 !== void 0 ? _orderLine$Name3 : ''));
1100
1176
  var articleNumber = (_orderLine$ConfigArti3 = orderLine.ConfigArticleCodex) !== null && _orderLine$ConfigArti3 !== void 0 ? _orderLine$ConfigArti3 : orderLine.ArticleCodex;
1101
1177
 
1102
1178
  //Anforderung von Polypol auch die Typennummer anzugeben
@@ -1116,8 +1192,8 @@ var processNonPartlistOrderlines = function processNonPartlistOrderlines(basket,
1116
1192
  sapOrderLineText += appendToTheRight(mLength, orderLine.Quantity.toString());
1117
1193
  sapOrderLineText += appendToTheRight(artikelLength, lines[0]);
1118
1194
  if (!withoutPrices) {
1119
- var _orderLine$VKPrice$Ca, _orderLine$VKPrice;
1120
- sapOrderLineText += appendToTheLeft(preisLength, formatPrice((_orderLine$VKPrice$Ca = (_orderLine$VKPrice = orderLine.VKPrice) === null || _orderLine$VKPrice === void 0 || (_orderLine$VKPrice = _orderLine$VKPrice.CalcPrice) === null || _orderLine$VKPrice === void 0 ? void 0 : _orderLine$VKPrice.toString()) !== null && _orderLine$VKPrice$Ca !== void 0 ? _orderLine$VKPrice$Ca : '0'));
1195
+ var _orderLine$VKPrice$Ca, _orderLine$VKPrice3;
1196
+ sapOrderLineText += appendToTheLeft(preisLength, formatPrice((_orderLine$VKPrice$Ca = (_orderLine$VKPrice3 = orderLine.VKPrice) === null || _orderLine$VKPrice3 === void 0 || (_orderLine$VKPrice3 = _orderLine$VKPrice3.CalcPrice) === null || _orderLine$VKPrice3 === void 0 ? void 0 : _orderLine$VKPrice3.toString()) !== null && _orderLine$VKPrice$Ca !== void 0 ? _orderLine$VKPrice$Ca : '0'));
1121
1197
  }
1122
1198
  sapOrderLineText += newLine;
1123
1199
  sapOrderLineText += writeOtherLines(lines, startPositionArtikel2Row);
@@ -1 +1 @@
1
- {"version":3,"file":"EKTextGenerator.d.ts","sourceRoot":"","sources":["../../../../src/EKTextGenerator.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;iCAed,UAAU,kBAAkB,OAAO,iBAAiB,MAAM,cAAc,MAAM;AAAtG,wBAoHE"}
1
+ {"version":3,"file":"EKTextGenerator.d.ts","sourceRoot":"","sources":["../../../../src/EKTextGenerator.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;iCAed,UAAU,kBAAkB,OAAO,iBAAiB,MAAM,cAAc,MAAM;AAAtG,wBAkJE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EKTextGenerator.hullArticles.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EKTextGenerator.hullArticles.test.d.ts","sourceRoot":"","sources":["../../../../../../src/tests/unit/EKTextGenerator.hullArticles.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystaldesign/basket-model",
3
- "version": "26.12.0-beta.9",
3
+ "version": "26.12.0-rc.0",
4
4
  "description": "Shared data model for baskets, order lines, clients and configuration prices.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -17,5 +17,5 @@
17
17
  "lodash": "^4.17.21"
18
18
  },
19
19
  "main": "build/cjs/index.js",
20
- "gitHead": "62f51ceee2ea71c54b990c666eb7ae864f13d374"
20
+ "gitHead": "12ba245952d1dfdef154b037eb66dbdbc09650eb"
21
21
  }