Postman collection
Payments Write

pixiCADeleteEvent

Deletes a customer account event (CustomerAccount entry) together with its invoice, bank matches and account matches, if deletion is allowed.

Deletes one event from the customer account (CustomerAccount), identified by its key CAref.

Steps:

  1. The common API envelope checks the call frequency limit. If the limit is exceeded, a ResultCode/ResultText row with code 502 is returned and nothing else happens.
  2. If CAref is NULL, a row with ReturnCode = 'ERROR' is returned.
  3. Otherwise the internal procedure Pixi_CA_DeleteEvent runs with the user name API inside a transaction:
    • The function fPixi_CA_canIdeleteEvent decides whether the event may be deleted. If not, nothing is changed and Success = 0 is returned.
    • If the event has a linked invoice (InvoiceRef), the invoice is deleted via Pixi_DeleteInvoice.
    • Bank matches (BankMatch) of the linked bank line (BanklineRef) are deleted.
    • UpdateEmp/UpdateDate are stamped on the event and on all CustomerAccountMatch rows where the event is CAref1 or CAref2. Those match rows are then deleted.
    • The CustomerAccount row itself is deleted.
    • Afterwards the code tries to clean up a linked DTAUS record (only if its state allows deletion) or a linked manual booking (CustomerAccountManualBookings).
  4. A row with Success (1 = deleted, 0 = not deleted) and ErrorMessage is returned.

Notes

  • All changes run in one transaction; on any error it is rolled back, the error is re-raised with RAISERROR (severity 16, returned as SqlMessage) and a row with Success = 0 and the error text is still returned.
  • The rules of fPixi_CA_canIdeleteEvent and the behaviour of Pixi_DeleteInvoice are not attached; which events are deletable and whether the invoice deletion returns additional result sets cannot be determined from this code.
  • The lookup of the linked DTAUS record and manual booking reads DTAUSref/ManualBookingRef from CustomerAccount after that row has already been deleted, so in practice these subqueries find nothing. A code comment states that a trigger handles deleting from DTAUS and CustomerAccountManualBookings; that trigger is not attached.
  • If deletion is not allowed, the internal procedure only issues a PRINT ('Event CANNOT Be Deleted'), which is not visible as a row; check Success = 0.
  • ResultCode/ResultText output parameters carry the envelope result (200/OK on normal execution).
  • Reads use NOLOCK, writes use ROWLOCK. Each call updates API_STATISTICS.

Tables used

API_STATISTICS · Write API_CONTROL · Read CustomerAccount · Write BankMatch · Write CustomerAccountMatch · Write DTAUS · Write DTAUSstates · Read CustomerAccountManualBookings · Write
SQL object:
dbo.pipiCADeleteEvent
Updated at 2026-10-30