How Payment Voiding and Deletion Work
Source: customer_payment.rb:272-313, customer_payments_controller.rb:104,297-317
- Cannot delete payments that are processed (closed) or synced with Xero (have a xero_id)
- Cannot void a payment that has not been processed -- error directs user to delete instead
- Voiding a payment: all dispersals are marked voided, all methods voided, all items voided
- Each invoice's balance_due is increased back to its pre-payment amount and status reverts from closed to processed
- Customer account is debited (reversed) for the payment amount
- Void is synced to Xero/MYOB in a background thread after the local void completes
- Cannot update or add items to closed (processed) payments
- Cannot delete payment items that are Xero-synced or on closed payments
- Payment item validates that the linked invoice must be in processed status (not closed) for new items
Support scenarios
- "Why can't I delete this payment?" -> it has been processed (closed) or synced to Xero; void it instead
- "Why does it say to delete instead of void?" -> the payment has not been processed yet; unprocessed payments are deleted, processed ones are voided
- "Will the void sync to Xero/MYOB?" -> yes, it runs in a background thread; there may be a short delay
- "The invoice went back to processed after I voided the payment" -> voiding restores the invoice to its pre-payment state with the original balance_due