ng-miam 10.6.1 → 10.7.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.
@@ -1577,7 +1577,8 @@
1577
1577
  if (found) {
1578
1578
  // Clone to avoid changing the original object reference
1579
1579
  var updatedBasketEntry = deepCloneWithClass(_this.basketEntry);
1580
- updatedBasketEntry.quantity = found.quantity + _this.basketEntry.quantityToAdd;
1580
+ var baseQuantity = found.status === 'active' ? found.quantity : 0;
1581
+ updatedBasketEntry.quantity = baseQuantity + _this.basketEntry.quantityToAdd;
1581
1582
  _this.quantity = updatedBasketEntry.quantity;
1582
1583
  return updatedBasketEntry;
1583
1584
  }
@@ -3395,12 +3396,9 @@
3395
3396
  };
3396
3397
  PointOfSalesService.prototype.loadPos = function (posId) {
3397
3398
  var _this = this;
3398
- this.posIsLoading$.next(true);
3399
3399
  if (!this.pos$.value || this.pos$.value.id !== posId) {
3400
- this.get(posId, { include: ['supplier'] }).pipe(operators.skipWhile(function (pos) { return pos.is_loading; }), operators.tap(function (pos) {
3401
- _this.pos$.next(pos);
3402
- _this.posIsLoading$.next(false);
3403
- })).subscribe();
3400
+ this.posIsLoading$.next(true);
3401
+ this.get(posId, { include: ['supplier'] }).pipe(operators.skipWhile(function (pos) { return pos.is_loading; }), operators.tap(function (pos) { return _this.pos$.next(pos); }), operators.finalize(function () { return _this.posIsLoading$.next(false); })).subscribe();
3404
3402
  }
3405
3403
  return this.pos$;
3406
3404
  };
@@ -3648,7 +3646,7 @@
3648
3646
  EventJourney["EMPTY"] = "";
3649
3647
  })(EventJourney || (EventJourney = {}));
3650
3648
 
3651
- var VERSION = "10.6.1"; // TODO: replace by ##VERSION## and update it in the CI/CD
3649
+ var VERSION = "10.7.0"; // TODO: replace by ##VERSION## and update it in the CI/CD
3652
3650
 
3653
3651
  var ContextRegistryService = /** @class */ (function () {
3654
3652
  function ContextRegistryService() {
@@ -7170,7 +7168,7 @@
7170
7168
  var lines = _this.recipesAndLineEntriesToBasketPreviewLine(recipes, lineEntries);
7171
7169
  _this._basketPreview$.next(lines);
7172
7170
  _this.basketPreviewIsCalculating$.next(false);
7173
- _this.basketStats$.next(_this.buildStats(lines));
7171
+ _this.basketStats$.next(_this.buildStats(lines, entries));
7174
7172
  }));
7175
7173
  }));
7176
7174
  };
@@ -7188,7 +7186,8 @@
7188
7186
  return _this._entries$.value;
7189
7187
  }));
7190
7188
  };
7191
- BasketsService.prototype.buildStats = function (lines) {
7189
+ BasketsService.prototype.buildStats = function (lines, entries) {
7190
+ if (entries === void 0) { entries = []; }
7192
7191
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
7193
7192
  var entriesFound = lodashEs.unionBy.apply(void 0, __spread(lines.map(function (line) { return line.entries.found; }), ['id']));
7194
7193
  var totalPrice = entriesFound.reduce(function (total, entry) {
@@ -7196,8 +7195,11 @@
7196
7195
  total += (entry.attributes.quantity || 0) * parseFloat(basketEntriesItem['unit-price']);
7197
7196
  return total;
7198
7197
  }, 0);
7198
+ // productsCount cannot be derived from `lines` alone: preview lines are recipe-only,
7199
+ // while standalone products (empty recipe-ids) live only in the full entries list.
7199
7200
  return {
7200
7201
  recipesCount: lines.length,
7202
+ productsCount: entries.filter(function (entry) { return entry.status === 'active' && entry.attributes['selected-item-id'] != null; }).length,
7201
7203
  entriesCount: entriesFound.length,
7202
7204
  totalPrice: totalPrice
7203
7205
  };
@@ -11460,6 +11462,7 @@
11460
11462
  _this.resetBasket();
11461
11463
  },
11462
11464
  recipeCount: function () { return _this.basketsService.waitForBasket.pipe(operators.switchMap(function () { return _this.basketsService.basketStats$; }), operators.skipWhile(function (bs) { return !bs; }), operators.map(function (bs) { return bs.recipesCount; }), operators.distinctUntilChanged()); },
11465
+ productCount: function () { return _this.basketsService.waitForBasket.pipe(operators.switchMap(function () { return _this.basketsService.basketStats$; }), operators.skipWhile(function (bs) { return !bs; }), operators.map(function (bs) { return bs.productsCount; }), operators.distinctUntilChanged()); },
11463
11466
  openPreview: function (analyticsPath, selectedTab) {
11464
11467
  if (analyticsPath === void 0) { analyticsPath = ''; }
11465
11468
  if (selectedTab === void 0) { selectedTab = 0; }