Postman collection
Reports Read

pixiReport_StockMovementsForItemsWithBnBbd

Returns the stock movements of items with batch number or best-before-date management, filtered by date range, movement type, user, location, tag, category and supplier.

Wrapper around the internal report procedure Report_StockMovementsForItemsWithBnBbd. It lists entries of the stock movement log (InvBinItemLog) for items that carry the item tag -6 or -7 (batch number / best-before date).

Parameter handling

  • Empty values (and 0 for the integer parameters) are treated as NULL, which means "no filter".
  • If DateFrom is missing, the start of the current day is used. If DateTo is missing, the end of the current day is used. The time part of both dates is ignored: DateFrom is moved to 00:00:00 and DateTo to 23:59:59.997 of the given day.

Parameter checks (each failure returns one Status/Message row and stops the call)

  1. LocID must exist in Location.
  2. ItemTag, if given, must be -6 or -7.
  3. UserName must occur as a substring of UpdateEmp in at least one log entry.
  4. SMTKey must exist in StockMovementTypes.
  5. Category must exist in TontrArten.

SupplNr is not checked.

Filters

  • Movement date (UpdateDate) between DateFrom and DateTo. This filter is always active.
  • SMTKey: the stock movement type of the log entry.
  • UserName: substring match (LIKE '%…%') on the user who made the entry.
  • LocID: the location of the current bin (InvBin.BinLocID).
  • ItemTag: only items that carry this tag (-6 or -7).
  • Category: the item's ConfigType.
  • SupplNr: the supplier taken from the latest supplier information valid at the movement date.

Output One row per movement with the item, bin, moved quantity, batch number, best-before date, movement type with its translated name, user, historical supplier price and database currency. The report sorts the rows by movement date in ascending order.

Notes

  • All tables are read with NOLOCK, so uncommitted data can appear in the result.
  • The report itself sorts by movement date. The final SELECT from the temporary table has no ORDER BY, so the row order is not strictly guaranteed.
  • Because empty values are mapped to NULL, a SMTKey or ItemTag of 0 and a date of 1900-01-01 count as "not set".
  • Stock is SUM(Items.Quantity). It is the item's total stock, not the stock in the bin. If several joined rows collapse into one group, the value can be a multiple of that stock.
  • BinName holds the current bin name. For deleted bins it holds the historical name followed by Deleted. Deleted bins drop out of the result when LocID is set, because the location filter uses the current bin only.
  • If a movement has neither a current nor a deleted bin record, BinName is empty and the insert into the result table fails. This returns the "Unexpected error" row.
  • SMTName is the translation with LanguageID = 2.
  • UserName is the part of UpdateEmp before the first /.
  • The precheck for UserName (and for LocID) also fails when InvBinItemLog (or Location) is empty, even if no value was passed.
  • The supplier data come from the function fPixi_GetLatestSupplierInfo. Its definition is not attached, so the exact selection logic is not documented here.
  • The report runs as dynamic SQL via sp_executesql.
  • The report also computes the columns ParamDateFrom … ParamSupplier, but they are not returned to the caller.
  • A code comment names the tags -6 and -7 together as "BN & BBD".

Tables used

Location · Read InvBinItemLog · Read StockMovementTypes · Read TontrArten · Read Translation · Read TagMatch · Read ItemCode · Read Items · Read InvBin · Read InvBinHist · Read Tag · Read Suppliers · Read
SQL object:
dbo.pipiReport_StockMovementsForItemsWithBnBbd
Updated at 2026-10-30