How Invoice Processing Preconditions Are Enforced
Source: invoices_controller.rb:2830-2879
- Cannot process a quote -- must change type to invoice first
- Cannot process an invoice with zero items
- Cannot process an already-processed or closed invoice
- Negative total invoices are blocked when Xero, MYOB, or QuickBooks is connected -- error says "Please submit this as a CREDIT"
- An invoice containing only a trade-in product must be issued as a credit instead
- Serial number count must exactly match item quantity for products requiring serial numbers -- too many or too few blocks processing
- Vehicles on sale items must still have sale_status of for_sale at processing time
- In-progress labor items (clocked on but not clocked off) block processing
- BOM parent items cannot contain themselves as children (infinite loop protection)
- If company.limit_invoice_process_if_on_order is enabled, unreceived purchase orders or open vendor invoices on any line item block processing
Support scenarios
- "It says I need to submit as a credit" -> invoice total is negative due to trade-in or discount; accounting integrations require credits for negative amounts
- "I can't process because of a labour item still clocked on" -> a mechanic hasn't clocked off; go to the labour section and end the timer
- "It says there's an order yet to be received" -> a line item is linked to a purchase order that hasn't been received; receive or unlink it first
- "Wrong number of serial numbers" -> each line item requiring serial tracking needs exactly as many serial numbers as the quantity