Postman collection
Reports Read

pixiReportStockSalesOverview

Returns a per-item overview of current stock, stock movements, invoiced sales and returns since a given date, with paging by item key.

Builds a stock and sales report for all items in Items.

For each item the call calculates:

  • Average supplier price (SupplPrice): the average SupplPrice from AddItems for the item's IntLinkNr1. Supplier MGS and empty or zero prices are ignored. If no price is found, the value is 0.
  • Current stock (StockQty): the sum of BinItemQty over all bin locations (Lagerplätze) in InvBinItem, 0 if the item has no bin entry.
  • Stock increases / decreases (StockInc, StockDec): the sum of positive or negative quantities in the bin item log InvBinItemLog with UpdateDate >= @StatDateFrom.
  • First put to stock (FirstPutToStock): the earliest log entry with a positive quantity. This value does not use @StatDateFrom.
  • Sold / returned quantity (ItemQtySold, ItemQtyReturned): the sum of positive or negative ItemQty in invoice lines (InvLines) with CreateDate >= @StatDateFrom.
  • Last sale date (LastSaleDate): the latest CreateDate of these invoice lines.

The category text comes from TontrArten and is matched by the item's ConfigType.

Filters:

  • @StatDateFrom: start of the statistics period. If it is NULL, 1970-01-01 is used, so all history is included.
  • @ItemKeyStart: only items with ItemKey >= @ItemKeyStart are returned. NULL means no lower limit.
  • @OnlyItemsOnStock = 1: only items with a current stock greater than 0 are returned.

The result is sorted by ItemKey ascending. SET ROWCOUNT @RowCount limits the number of rows. For paging, pass the last returned ItemKey + 1 as @ItemKeyStart in the next call.

Notes

  • All tables are read with NOLOCK. Values can therefore include uncommitted data.
  • The aggregations in the CTEs run over all items. The filters @ItemKeyStart and @OnlyItemsOnStock are applied only in the final SELECT. Depending on the optimizer, the call can be slow on large databases. In addition, the scalar function fPixi_GetAverageSupplPrice is evaluated per item.
  • StockDec and ItemQtyReturned are negative values or 0.
  • LastSaleDate is NULL if there are no invoice lines in the period. FirstPutToStock is NULL if the item was never put to stock.
  • @RowCount = 0 removes the row limit, because this is the behaviour of SET ROWCOUNT 0.

Tables used

Items · Read InvBinItem · Read InvBinItemLog · Read InvLines · Read TontrArten · Read AddItems · Read
SQL object:
dbo.pipiReportStockSalesOverview
Updated at 2026-10-30