Postman collection
Invoices Write

pixiSetReminderLevel

Sets the reminder (dunning) level of an invoice identified by its invoice number.

Looks up the invoice by InvoiceNR (Invoices.InvoiceNr) and passes its key to the internal procedure Pixi_CA_R_SetLevel, using API as user name.

That procedure works as follows:

  • Level greater than 0: It searches the reminders (Reminders) that contain a reminder line (ReminderLines) for this invoice and whose HighestReminderLevel equals ReminderLevel.
    • If a matching reminder exists:
      • The invoice gets the new ReminderLevel.
      • UpdateEmp is set to API.
      • UpdateDate is set to the date of that reminder, not to the current time.
      • All reminder lines of the invoice are reassigned to that reminder (ReminderRef).
    • If no matching reminder exists: Only the invoice is updated, with UpdateDate set to the current time.
  • Level 0 or NULL: The invoice's ReminderLevel is reset to NULL. UpdateEmp = API and UpdateDate = now.

The call returns no result set.

Notes

  • No feedback: There is no status row and no error handling. If the invoice number does not exist, nothing is updated and the call still succeeds silently.
  • Ambiguous invoice numbers: The invoice key is read with a scalar subquery. If several invoices share the same InvoiceNr, SQL Server raises error 512 ("Subquery returned more than 1 value").
  • Locking: The lookups in Invoices, Reminders and ReminderLines use NOLOCK.
  • Transactions: The updates run without an explicit transaction.
  • No validation: ReminderLevel is not checked against a range; any integer is written.
  • Several matching reminders: The reminder is picked by variable assignment with ORDER BY ReminderDate. In practice this usually yields the latest one, but SQL Server does not guarantee which row is used.
  • Reassignment of lines: When a matching reminder is found, all reminder lines of the invoice are moved to it, including lines that belonged to other reminders.
  • Level 0: The check that is meant to treat 0 as "no level" never applies (NULLIF(@ReminderLevel, 0) = 0 is never true). With 0 the code therefore still searches for reminders with HighestReminderLevel = 0. The invoice level ends up as NULL either way.

Tables used

Invoices · Write Reminders · Read ReminderLines · Write
SQL object:
dbo.pipiSetReminderLevel
Updated at 2026-10-30