Postman collection
Shipping Read

pixiGetShippedOrdersPerLocation

Returns shipped orders (based on invoices) for a date range per location, either as detail rows or as order count and total per location and currency.

Determines shipped orders through their invoices and returns them per location (LocationID of the order lines).

Step 1 – select invoices. An invoice qualifies if:

  • at least one of its invoice lines belongs to an order line that has an OrderHistory entry with status EIN,
  • its date is between @FromDate and @ToDate (inclusive). With @SearchByScanOutDate = 1 the scan-out date (ScanOutDate) is used, otherwise the invoice date (InvDate),
  • its total is greater than 0. With @IncludeOrdersWithTotalZero = 1 invoices with a total of exactly 0 are included as well. Negative totals are never included,
  • if @CustomerNrExternal is set (blanks are trimmed, empty means no filter), the customer of the invoice has this external customer number.

Step 2 – orders per invoice and location. For each selected invoice, the distinct combinations of LocationID and OrderNrExternal of the order lines on that invoice are collected. If @LocId is set, only order lines of this location are considered. Each combination is numbered per invoice, ordered by OrderNrExternal.

Step 3 – output.

  • @ShowDetails = 1 (default): one row per invoice, location and external order number with invoice data, customer name, shipping address, currency, shipping vendor and tracking ID. Invoice values are repeated if an invoice contains several external orders or locations. Sorted by InvDate.
  • Any other value: one row per location and currency with the number of rows (NrOfOrders) and the sum of the invoice totals (Total). No sort order is defined.

Notes

  • All tables are read with NOLOCK; results may contain uncommitted data.
  • @FromDate and @ToDate are varchar values compared with BETWEEN. A @ToDate without time (e.g. 2024-01-31) means midnight, so invoices later on that day are excluded. Pass 2024-01-31 23:59:59 or the following day. Use an unambiguous format such as yyyy-mm-dd hh:mi:ss.
  • In summary mode NrOfOrders counts the combinations of invoice, location and external order number, not distinct invoices.
  • In summary mode an invoice total is counted only once per invoice: it is added to the location of the combination with the alphabetically first OrderNrExternal on that invoice. If an invoice contains order lines of several locations, the whole total is assigned to one location only. With @LocId set, numbering is done only over the filtered rows, so the full invoice total is attributed to that location.
  • Invoices without a matching customer are excluded; in detail mode also invoices without a matching shipping address (ShipAdrRef) or currency are excluded (inner joins).
  • Invoices whose order lines have no OrderHistory status EIN are not returned, regardless of the date.

Tables used

Invoices · Read Customers · Read Invlines · Read OrderHistory · Read Orderlines · Read Addresses · Read Currency · Read
SQL object:
dbo.pipiGetShippedOrdersPerLocation
Updated at 2026-10-30