Postman collection
Invoices Write

pixiSetInvoicePaid

Marks an invoice as paid by creating a manual booking event in the customer account and matching it against the invoice's open amount.

Wrapper around the internal procedure pixi_SetInvoicePaid. It returns a status row with Status and Message.

Steps of the internal procedure:

  1. Looks up the invoice in Invoices by InvoiceNR. It reads the customer, the total, the paid sum, the currency and the exchange rate.
  2. Determines the customer account entry of the invoice with Pixi_CA_GetCustomerAccountforInvoice. The booking amount is the negated OpenToMatch of that entry.
  3. Validates the input in this order:
    • paid must be 1. Setting an invoice to unpaid is not supported.
    • The invoice must exist.
    • The invoice must not be fully paid already (total = PayedSum).
    • eventID must be given.
    • The event must exist in CustomerAccountEvents with IsManual = 1 and OriginalAmountMultiply = 1, i.e. a manual, positive event.
    • PaidDate (default: current date and time) must not lie in the future.
  4. Creates a manual booking event with Pixi_CA_InsertManualBookingEvent:
    • The event uses the invoice's currency and exchange rate.
    • The user name is API.
    • The event is matched against the invoice's customer account entry.

On success the call returns Status = Success. If an error reaches the wrapper, it returns Status = Error with the error text.

Notes

  • PaidSum has no effect on the booked amount. A value of 0 is replaced by NULL, but the parameter is not used otherwise. The booking always covers the full open amount (OpenToMatch) of the invoice's customer account entry.
  • The internal procedure runs in its own transaction, or in a savepoint if a transaction is already open. XACT_ABORT is on, and the transaction is rolled back on error.
  • In its CATCH block the internal procedure calls log.InsertError with parameter 1. That object is not attached. Whether it re-raises the error is therefore unknown. Only if it does will the wrapper return the Error row; otherwise a failed call could still report Success.
  • The customer account lookup runs before the validation. For a non-existing invoice it is called with NULL keys.
  • Invoices and CustomerAccountEvents are read with NOLOCK.
  • The tables written by Pixi_CA_InsertManualBookingEvent are not visible in the attached code.
  • The 'already paid' check compares total and PayedSum for exact equality. A partially paid invoice is booked with its remaining open amount.

Tables used

Invoices · Read CustomerAccountEvents · Read
SQL object:
dbo.pipiSetInvoicePaid
Updated at 2026-10-30