Postman collection
Stock Write

pixiGetChangedItemStock_LocID

Returns items whose stock changed in a time window, with physical and available stock, optionally restricted to one location and excluding bin groups.

Delta stock export per location. The call collects changed items, calculates their stock figures and returns one page of rows.

1. Candidate items

  • Candidates are non-bundle items that have entries in the stock movement log InvBinItemLog.
  • The change date is COALESCE(items.LastCalculateStockDate, InvBinItemLog.UpdateDate, now). It must lie between Since and DateTo.
  • If LocID is not empty, only log entries of that location count.
  • StockChange is the sum of the logged quantities.

2. Bundles

  • For every changed component, the bundle (parent) items it belongs to are added with BundleItem = 1.
  • Their StockChange is the component change divided by the component quantity in the bundle (integer division).

3. Paging

  • Rows are numbered (RowNr) by change date ascending, then by the highest log key.
  • Start is a zero-based offset. Rows from Start + 1 onward are kept, and at most Rowcount rows are returned.

4. Cleanup

  • Rows for items that no longer exist are removed.
  • Rows for items that are now bundles but were collected as non-bundles are removed.

5. Item data

  • ItemNrInt, EANUPC, ItemNrSuppl, Enabled and MinStockQty come from the item master.
  • PhysicalStock is the sum of all positive LocationQuantity values when LocID is empty, otherwise the location quantity of LocID.
  • AvailableStock is first set to items.Quantity.

6. Non-bundle items only

AvailableStock is recalculated as the sum of bin quantities (InvBinItem) in the location (or all locations), minus a deduction:

  • If setting ReservePrepaymentOrders is not 1: the order line quantities with status ANG or HAL are subtracted.
  • Otherwise: the number of reservation records is subtracted, counting order lines in non-final statuses except EIN, FUT and FUS.
  • Both deductions apply only when setting StockExportUsePhysicalStock is 0.

The call also fills:

  • OpenSupplierOrderQTY: open quantity of supplier order lines whose status has IsAllOpen = 1.
  • EstimatedDelivery: from Item_EstimatedDelivery.ExportEstimatedDelivery.

7. Excluded bin groups

  • If ExcludeBinGroups is set (comma-separated list), the logged quantities of all bins in these groups are summed per item. Only log entries up to DateTo count.
  • For bundles, the result is converted to bundle units.
  • This quantity is subtracted from AvailableStock, PhysicalStock and StockChange.

8. Result

The result is sorted by RowNr.

Notes

Side effect

  • Every call writes one entry into LogTable with Since, Rowcount and the duration. The entry is labelled pipiGetChangedItemStock.

Locking

  • All reads use NOLOCK, so results may include uncommitted data.

Pitfalls

  • Since = 0 / 1900-01-01 is turned into NULL. The date filter then matches nothing and the result is empty.
  • DateTo values that are NULL, 0 or on or before 1990-01-01 are replaced by the current time.
  • The time window is mainly based on items.LastCalculateStockDate, not on the individual log entry date.
  • The HAL order line filter subtracts a datetime from a datetime. With setting HalOrdersActiveDays (default 7 if 0), this effectively includes practically all HAL lines instead of only the last N days.
  • When reservations are enabled, the number of reservation rows is subtracted, not a quantity.
  • Items without any ItemLocationSpecific row (or none for LocID) keep empty item numbers, 0 stock and NULL Enabled.
  • PhysicalStock can be NULL if there is no positive location quantity and LocID is empty.
  • The bin group exclusion is not restricted to LocID.
  • For bundles, OpenSupplierOrderQTY stays 0 and EstimatedDelivery stays NULL.
  • Settings ShowLocationStockInItemSearch and OldStockExport are read but not used.

Tables used

Settings · Read OrderStates · Read InvBinItemLog · Read items · Read BundleItems · Read ItemLocationSpecific · Read InvBinItem · Read InvBin · Read Location · Read Orderlines · Read Reservation · Read Item_EstimatedDelivery · Read SupplierOrderLine · Read SupplierOrder · Read SupplierOrderStatus · Read LogTable · Write
SQL object:
dbo.pipiGetChangedItemStock_LocID
Updated at 2026-10-30