Postman collection
Customers Read

pixiSatisfiedCustomers

Returns invoiced customers (or one customer's invoice lines) within a delivery and order date window, e.g. for satisfaction surveys or review requests.

Selects invoice lines joined with their order lines and the invoice address. Results can be used to contact customers who recently received goods.

Date window: the day parameters are relative to the current server date (GETDATE()):

  • MaxDaysSinceDelivery: invoice date (InvDate) must be on or after the start of the day N days ago.
  • MinDaysSinceDelivery: invoice date must be on or before the end of the day N days ago.
  • MaxDaysSinceOrder / MinDaysSinceOrder: the same for the order date of the order line.
  • A NULL value disables the respective bound.

Further filters:

  • Invoices referenced by another invoice (RefToInvoiceKey, e.g. a credit note) with an invoice date on or after the MaxDaysSinceDelivery date are excluded.
  • Lines whose order line has status MIN and an order date on or after the MaxDaysSinceDelivery date are excluded.
  • ExcludePartialDeliveries = 1: orders (by OrderNr) that still have order lines in status ANG or EIN are excluded.
  • NoOrderSince = 1: customers who have any order line with an order date on or after the MinDaysSinceDelivery date are excluded.
  • Only lines with ItemQty >= 0.

Two modes:

  • CustomerNrExternal is NULL: one row per external customer number (GROUP BY Addresses.CustomerNrExternal), sorted by customer number. ItemQty is the number of matching invoice lines.
  • CustomerNrExternal is set: only lines of that customer, one row per invoice line (GROUP BY Invlinekey), no explicit sort order. ItemQty is the quantity of the line.

Notes

  • All tables are read WITH (NOLOCK); results may contain uncommitted data.
  • In customer mode every column is aggregated independently with MAX/MIN, so InvoiceNr, ItemText, ItemPrice, ItemNrShop etc. can come from different invoices or lines of the same customer.
  • Addresses without an external customer number are grouped together into one NULL row in customer mode.
  • The credit-note filter and the MIN status filter only work when MaxDaysSinceDelivery is set; with NULL the comparison never matches and nothing is excluded.
  • NoOrderSince = 1 only has an effect when MinDaysSinceDelivery is set, because it compares against that date.
  • The table owning ItemQty, ItemText, ItemPrice, orderdate and Status is not qualified in the code; presumably invoice lines resp. order lines.
  • The meaning of the order line statuses MIN, ANG and EIN is not defined in the code.

Tables used

Invoices · Read Invlines · Read Orderlines · Read Addresses · Read Items · Read
SQL object:
dbo.pipiSatisfiedCustomers
Updated at 2026-10-30