How Invoice Voiding Works
Source: invoice.rb:598-689, invoices_controller.rb:838-853
- Cannot void an open invoice -- must delete instead (error: "invoice is not processed and can be deleted instead")
- All payments must be voided first before voiding the invoice
- Cannot void if credits have been applied from the invoice -- error lists which credit numbers are applied
- Cannot void internal invoices if the linked vehicle has already been sold
- Loan car must be returned (status "C" completed or "X") before voiding
- On void: product quantities are restored, purchase orders and vendor invoices are unlinked, items are soft-deleted
- Vehicle trade-ins and sales are reversed: trade-in vehicles go back to previous state, sold vehicles return to for_sale with customer reset
- Customer balances are recredited/debited to undo the original financial transaction
- Serial numbers are detached (invoice_id and invoice_item_id cleared) and each detachment is logged in TransactionLog
- Voiding a credit that contained a vehicle sale re-assigns the vehicle to the original sale customer and restores date_of_sale
Support scenarios
- "It says I should delete instead of void" -> the invoice is still open (not processed); open invoices are deleted, not voided
- "I need to void but it says there are payments" -> all customer payments on this invoice must be voided first; go to the payments section
- "I voided the credit note and the vehicle went back to sold" -> voiding a credit reversal undoes the reversal, putting the vehicle back in its sold state
- "What happened to the serial numbers after voiding?" -> they are detached from the invoice and available for re-use; check the serial number list