Postman collection
Orderlines Read

pixiGetOrderlinesForOrder

Returns the orderlines of one or more orders, optionally with bundle orderlines collapsed into a single line, including stock, invoice and shipping data.

Collects the orders to read and returns their orderlines in a single result set.

Order selection

  • The order with OrderNr = @OrderNr is always included (if it exists).
  • If @OrderXML is given, every /ORDERS/ORDER element is read (element-centric) with the child elements ORDERNR and ORDERNREXTERNAL. Each order whose OrderNr matches ORDERNR or whose OrderNrExternal matches ORDERNREXTERNAL is added.

Bundle mode

  • @ReturnBundle decides the mode. If it is NULL, the setting APIBundleOrderlines is used (missing setting = 0).
  • 0: every orderline is returned with its own values (ArtName, Qty, Price, Status, ...).
  • 1: orderlines that belong to a bundle (BundleOrderlineRef set) are collapsed to one row per bundle (the line with the lowest OrderlineKey). Name, quantity, price, external numbers, dates, item, note, discounts, amount, tax rate and net price are taken from the bundle orderline (BundleOrderlines) where available. The status of the bundle is computed from all its orderlines depending on the setting APIBundleOneAllAUS: with 1 the common status is returned if all lines have the same status, otherwise the status with the lowest OrderStateKey; with 0 the status with the highest OrderStateKey is returned.

Calculated columns

  • StatusText: text of the status from OrderStates.
  • OrderCurrency: currency code (CodeA) of the order.
  • VATRate: H if the tax rate of the invoice line (or bundle) equals the order's TaxRateHigh, L if it equals TaxRateLow, otherwise N (also when no invoice line exists).
  • PriceNoVAT: net price of the invoice line (or bundle), rounded to 2 decimals.
  • AvailStockOrderLine: available quantity of the item at the orderline's location (location quantity minus open reservations of the item).
  • ReservedCount: the smaller of Qty and AvailStockOrderLine, but not below 0.
  • ShipDate: ScanOutDate of the related invoice.

The result has no explicit sort order.

Notes

  • All tables are read WITH (NOLOCK); uncommitted data may be returned.
  • @OrderNr has no default and must always be sent. When only @OrderXML is used, a non-existing number (e.g. 0) can be passed.
  • If the same order is selected both by @OrderNr and by @OrderXML, its key is added twice and its orderlines appear twice in the result.
  • Orderlines with several invoice lines with ItemQty >= 0 can appear more than once (one row per invoice line). Invoice lines with negative quantity (returns) are ignored.
  • In bundle mode only lines with BundleOrderlineRef IS NULL or the first line of a partition are returned. If non-bundle orderlines store 0 instead of NULL in BundleOrderlineRef, they would be grouped together and only one of them returned; this depends on the data, which is not visible in the code.
  • AvailStockOrderLine subtracts the number of reservation rows of the item across all orders (open states except EIN, FUT, FUS), not per location. It is NULL if the item has no ItemLocationSpecific row for the location; then ReservedCount is also NULL.
  • PriceNoVAT is NULL for orderlines that are not yet invoiced (unless taken from a bundle orderline).
  • Invalid XML in @OrderXML causes an SQL error from sp_xml_preparedocument.

Tables used

OrderHeader · Read Currency · Read Orderlines · Read BundleOrderlines · Read Items · Read InvLines · Read Invoices · Read OrderStates · Read Settings · Read ItemLocationSpecific · Read Reservation · Read
SQL object:
dbo.pipiGetOrderlinesForOrder
Updated at 2026-10-30