Postman collection
Invoices Read

pixiGetPaidInvoices

Returns invoices that are fully paid through customer account matches with a payment posted in the given date range.

Finds invoices that have been settled in the customer account (CustomerAccount) and returns one row per invoice entry.

Steps:

  1. Selects all customer account entries with EventDate between @From and @To (inclusive, BETWEEN) and Amount > 0. These are typically the payment entries.
  2. Uses CustomerAccountMatch to find all customer account entries that are matched against those entries, in both directions (CARef1 ↔ CARef2).
  3. Keeps only matched entries that reference an invoice (InvoiceRef IS NOT NULL).
  4. Keeps only entries that are fully settled: the sum of AbsoluteMatchAmount over all matches of the entry plus the entry's own Amount must be exactly 0.

For each remaining entry the call returns:

  • the invoice key and invoice number from Invoices,
  • DatePaid: the latest EventDate of all customer account entries matched against the invoice entry (not limited to the date range),
  • ShopID: the shop of the customer (Customers.CustomerOf),
  • OrderNRExternal: the highest external order number of the order lines linked to the invoice through Invlines,
  • PaymentType: the payment method of the invoice.

No sort order is defined.

Notes

  • All tables are read WITH (NOLOCK); results can contain uncommitted data.
  • BETWEEN includes both limits. If @To is passed as a date without time (midnight), payments later on that day are not included.
  • The full-settlement check is an exact comparison with 0; rounding differences in the matches exclude an invoice.
  • If an invoice has several customer account entries that each qualify, the invoice can appear more than once.
  • DatePaid is the latest matched entry date overall and can lie outside @From/@To.
  • In the settlement check the columns Amount and CustomerAccountKey are not qualified; the code relies on them resolving to the outer CustomerAccount entry.
  • The header comment of the procedure ("Checks pixi* user credentials") does not match its function and is apparently a copy leftover.

Tables used

CustomerAccount · Read CustomerAccountMatch · Read Invoices · Read Customers · Read Orderlines · Read Invlines · Read
SQL object:
dbo.pipiGetPaidInvoices
Updated at 2026-10-30