How Invoice Processing Updates Vehicle Records
Source: invoice.rb:354-404
- When processing a non-internal invoice with a vehicle: odometer updates if the invoice odometer value is non-zero, vehicle_hours updates if non-zero
- Last_in_date is set to the invoice's post_date
- If any line item's product is flagged as a service product, next_service_date is calculated from post_date + vehicle's service_interval, and last_service_date is set to post_date
- Follow-up date and plate/WOF renewal dates also update if values are provided on the invoice
- Trade-in vehicles are set to for_sale status: date_acquired is set and a DealershipAdvertisingVehicle record is created with all advertising flags defaulting to false
- Vehicle sale items update the vehicle's customer_id to the invoice's customer, set date_of_sale, change sale_status to not_for_sale, and disable all advertising flags and marketplace attachment flags
- Internal invoices increase the vehicle's internal_invoice_balance by the invoice total and create a dealership transaction log entry
Support scenarios
- "The vehicle's next service date changed after processing" -> a service product was on the invoice; next_service = post_date + service_interval from the vehicle record
- "The trade-in vehicle appeared in my for-sale inventory" -> processing an invoice with a trade-in automatically sets the vehicle to for_sale
- "The vehicle's odometer didn't update" -> the odometer field on the invoice was blank or zero; it only updates when a non-zero value is provided