Postman collection
Invoices Read

pixiGetInvoicesUnpaid

Returns all unpaid invoices, or with `PaidInvoices` = 1 all paid invoices, with payment, bank, address and currency details, sorted by invoice date.

Reads invoices from Invoices together with the customer, the payment method, the invoice (billing) address, its country and the invoice currency.

The parameter PaidInvoices selects one of two modes:

  • 0 (default): unpaid invoices. An invoice is returned if the paid sum (PayedSum, NULL counts as 0) is not exactly equal to the invoice total rounded to 2 decimals, and there is no entry in CustomerAccount for this customer and invoice that has DoNotRefund = 1 and no bank line, DTAUS or manual booking reference.
  • 1: paid invoices. An invoice is returned if the paid sum differs from the rounded total by less than 0.01, or such a DoNotRefund entry in CustomerAccount exists.

Only invoices for which a currency, a customer, a payment method (Payments.Code = invoice payment code) and an invoice address exist are returned (inner joins). The country is optional.

The result is sorted by invoice date ascending. There is no paging; all matching invoices are returned.

Column logic:

  • Paid is 1 only if the paid sum equals the rounded total exactly; otherwise 0.
  • PaymentDate is the invoice pay day if Paid = 1, otherwise NULL.
  • PaymentText is the text of the payment method, falling back to the payment code.
  • Currency and OrderCurrency both contain the currency code of the invoice; total, TotalToPay and TotalToPay_OrderCurr all contain the invoice total.

Notes

  • All tables are read WITH (NOLOCK); results can contain uncommitted data.
  • In mode 1 the filter uses a tolerance of 0.01, but Paid and PaymentDate use an exact comparison. Invoices with a tiny difference or invoices included only because of a DoNotRefund entry are therefore returned with Paid = 0 and PaymentDate = NULL.
  • Passing NULL for PaidInvoices returns no rows.
  • Invoices whose payment code has no entry in Payments, or whose customer, address or currency is missing, are silently excluded.
  • The result contains sensitive payment data (credit card number, name and expiry, bank account, BLZ).
  • Without paging the result can be large on databases with many invoices.
  • A code comment states that the currency handling (Currency = invoice currency) is provisional until multi-currency is fully supported.

Tables used

Invoices · Read Currency · Read Customers · Read Payments · Read Addresses · Read Countries · Read CustomerAccount · Read
SQL object:
dbo.pipiGetInvoicesUnpaid
Updated at 2026-10-30