How Invoice Splitting Works
Source: invoices_controller.rb:660-718
- Cannot split processed or closed invoices -- only open invoices can be split
- A new invoice is created with identical settings (customer, vehicle, tax, etc.)
- Items are moved to the new invoice with the specified quantities; if the full quantity is moved, the original item is destroyed
- Labor items are only transferred when the full quantity of their parent item moves
- An excess_amount on the split creates a WS_EXCESS_AMOUNT product automatically if one does not already exist
- Both invoices are linked via split flags and IDs so the system tracks the relationship
- The new invoice starts as open with job status booked
Support scenarios
- "Why can't I split this invoice?" -> it must be in open status; processed or closed invoices cannot be split
- "Some labour times didn't move to the new invoice" -> labour items only transfer when the entire quantity of the parent line item is moved
- "There's a WS_EXCESS_AMOUNT line on the split invoice" -> the split had a value discrepancy that was captured as an excess amount product