Postman collection
Customers Read

pixiCustomersOpenCases

Returns the lock flag, open orders, unpaid invoices, invoice debt and open order amount of one customer, with the currency code the amounts refer to.

Returns a single row that sums up the open business of the customer identified by CustKey.

The behaviour depends on the setting MultiCurrencyEnabled.

Multi-currency disabled (setting is not 1):

  • Locked is 1 if the customer's SLocked flag is set to anything other than N, otherwise 0.
  • OpenOrders is the number of distinct order numbers that have at least one order line of this customer (Orderlines.CustRef) whose status is not a final state in OrderStates (FinalState = 'Y').
  • OpenOrderAmount is the sum of OrderLineAmount of these non-final order lines. The amounts are added up as stored, without currency conversion.
  • UnpaidInvoices is the number of invoices of the customer where the paid sum is not equal to the invoice total. A missing paid sum counts as 0.
  • DebtByInvoices is the sum of total - PayedSum over all invoices of the customer.
  • BaseCurrency is the database currency code. It comes from the setting HomeCurrency and must be a parent currency in pixi.Currency.

Multi-currency enabled (setting is 1):

  • The counts are calculated in the same way.
  • Each order line amount is divided by the exchange rate of its order header (OrderHeader.ExchRateId).
  • Each invoice debt is divided by the exchange rate of the invoice (Invoices.ExchRateId).
  • The results are therefore amounts in base currency.
  • BaseCurrency is the code of the base currency of the customer's shop (Shops.BaseCurrencyId).

If no customer with the given CustKey exists, the result set is empty.

Notes

  • All tables are read with NOLOCK, so the figures may include uncommitted data.
  • Without multi-currency, order and invoice amounts in different currencies are added up unconverted. BaseCurrency then only gives the database currency code; it is not the actual currency of the sum.
  • With multi-currency enabled, the following records are left out of the amounts and counts: order lines whose order header has no matching exchange rate, and invoices without a matching exchange rate. No row is returned if the customer's shop or its base currency cannot be found.
  • Invoices with a NULL paid sum are counted in UnpaidInvoices. Their debt is not part of DebtByInvoices, because total - NULL is ignored by SUM.
  • Overpaid invoices are also counted as unpaid and reduce DebtByInvoices.
  • DebtByInvoices is 0 if the customer has no invoices.
  • The setting value is converted to BIT. A non-numeric value other than true/false causes a conversion error.

Tables used

Settings · Read Currency · Read Customers · Read Orderlines · Read OrderStates · Read Invoices · Read OrderHeader · Read ExchRate · Read Shops · Read
SQL object:
dbo.pipiCustomersOpenCases
Updated at 2026-10-30