Postman collection
Invoices Read

pixiGetInvoice

Returns invoice headers with totals, VAT, payment status, bank data and linked order numbers, filtered by invoice number, shop, dates, order or payment state, with key-based paging.

Selects invoices from Invoices (joined with Customers) and returns one row per invoice with amounts, payment and shipping data.

Parameter normalisation

  • Empty strings in InvoiceNr, ShopID, PaymentType, OrderNRExternal and OrderNR = 0 are treated as no filter.
  • RowCount NULL or 0 becomes 1000.
  • Date parameters before 1990-01-01 are ignored.

Filters (all combined with AND, only applied when set)

  • StartKey > 0: only invoices with InvoiceKey greater than StartKey.
  • InvoiceNr: exact invoice number.
  • InvDateFrom/InvDateTo: invoice date, ShipDateFrom/ShipDateTo: scan-out (ship) date, UpdateDateFrom/UpdateDateTo: last update. All date comparisons are exclusive (> and <).
  • ShopID: shop of the customer (Customers.CustomerOF).
  • PaymentType: payment code of the invoice.
  • OrderNR / OrderNRExternal: invoice must have at least one invoice line belonging to an order line with that order number / external order number.
  • OnlyUnpaidInvoices = 1: paid sum differs from the rounded total, and there is no open customer account entry (without bank line, DTAUS or manual booking) flagged DoNotRefund.

Paging The first RowCount matching invoices ordered by InvoiceKey are selected. To read the next page, pass the highest InvoiceKey of the previous result as StartKey.

Result

  • OrderNr/OrderNrExternal are the highest order numbers of the orders linked through the invoice lines (restricted to matching order lines if an order filter is set).
  • CcpPayID is filled only with AddCCPPayID = 1 and contains a comma-separated list of payment IDs of the linked orders.
  • PaymentDate is the latest matching date from customer account matching.
  • Paid is 1 if the paid sum equals the total rounded to 2 decimals.
  • Discount_Invoice is the gross voucher sum for B2C invoices, otherwise the net voucher sum.
  • VATHigh/VATLow/VATSum include VAT on shipping and return costs.

Rows are sorted by InvoiceDate.

Notes

  • All reads use NOLOCK; uncommitted data may appear.
  • The main selection is built as dynamic SQL (sp_executesql) with parameters.
  • TotalRows is the number of rows of the selection step, which is limited by RowCount; it is not the total number of matching invoices.
  • A negative StartKey returns no rows.
  • Date filters are exclusive: InvDateTo = 2024-03-31 excludes invoices dated exactly at that moment and later on that day.
  • The final query uses inner joins to CustomerAccount, Payments, Addresses, pixi.Currency and pixi.ExchRate. Invoices without a matching record there are not returned (but are counted in TotalRows). An invoice with several customer account entries, or linked orders with different ccpPayID values, can appear in several rows.
  • Temporary tables use unique indexes on the invoice key; if an invoice has several customer account entries or ambiguous order data, the call may fail with a duplicate key error from SQL Server.

Tables used

Invoices · Read Customers · Read InvLines · Read Orderlines · Read OrderHeader · Read CustomerAccount · Read CustomerAccountMatch · Read Currency · Read Payments · Read Addresses · Read ExchRate · Read
SQL object:
dbo.pipiGetInvoice
Updated at 2026-10-30