Postman collection
Stock Read

pixiReport_ItemsOnStockWithBatchManagement

Returns the stock per item, bin, batch number and best-before date for items with batch management, based on the pixi* report "Items on stock with BN/BBD".

Exposes the pixi* report Items on stock with BN/BBD (batch number / best-before date) as an API call.

  1. Normalisation: empty strings are treated as NULL for all text filters. ItemTag = 0 is treated as NULL. If BestBeforeDateFrom or BestBeforeDateTo is missing (or 1900-01-01), it defaults to the start or end of the current day.
  2. Prechecks: each given filter is validated. The call stops with an Error row if:
    • LocId is not in Location,
    • ItemTag is not -6 or -7,
    • Ean is not a barcode (code type 1) in pixi.ItemCode,
    • ItemNrInt is not a shop item number (code type 2) in pixi.ItemCode,
    • BinGroup is not in InvBin,
    • SupplierNr is not in Suppliers,
    • Category matches neither TontrArt nor TontrText in TontrArten,
    • BatchNumber is not in InvBinItem.
  3. Report: the internal report procedure Report_ItemsOnStockWithBatchManagement is executed:
    • Only items tagged with tag -6 (batch number) or -7 (best-before date) are considered.
    • Bin stock from InvBinItem is summed per item, bin, batch number and best-before date (QtyInBin).
    • The best-before date filter is always applied. Rows whose BestBeforeDate lies between the two dates are included, and so are rows without a best-before date.
    • Optional filters:
      • BatchNumber: exact batch number.
      • LocId: location of the bin.
      • Ean: barcode of the item.
      • ItemNrInt: shop item number.
      • ItemTag: the item must carry this tag.
      • SupplierNr: the item is assigned to this supplier in AddItems.
      • BinGroup: bin group.
      • Category: the item's ConfigType, matched by code or text.
  4. The rows are sorted by ItemName, then BinName, and returned.

Notes

  • Default date range is today only. Without BestBeforeDateFrom/BestBeforeDateTo, only stock expiring today or without a best-before date is returned. Pass a wide range to get all batches.
  • The dates are passed to the inner report as DATE, so the time part is dropped. A BestBeforeDate on the end day with a time after midnight may be excluded.
  • The prechecks only test whether a matching record exists anywhere. For example, the Ean check accepts any existing barcode, not only barcodes of batch-managed items. Without a filter value, they still require at least one row in the respective table. An empty database or empty table therefore produces the corresponding error with an empty value.
  • The inner report builds its WHERE clause as dynamic SQL. Any SQL error raised there is caught and returned as an Error row with the original error text.
  • All reads use NOLOCK, so uncommitted data may appear.
  • The report internally also produces parameter echo columns (ParamBatchNumber etc.). These are not returned to the caller.

Tables used

Location · Read ItemCode · Read InvBin · Read Suppliers · Read TontrArten · Read InvBinItem · Read Items · Read TagMatch · Read Tag · Read AddItems · Read
SQL object:
dbo.pipiReport_ItemsOnStockWithBatchManagement
Updated at 2026-10-30