How Multibranch Vehicle Sync Works
Source: `vehicles_controller.rb`
- Vehicle sync across branches requires both a plate number AND a VIN to be present; vehicles missing either field will not sync
- An extensive list of fields is protected from sync: id, company_id, customer_id, all financial fields, stock_number, all external integration IDs, and all HaynesPro-related fields
- The sync prevents clearing existing field values: if a sync would blank out a field that already has data, the change is reverted and a reverse sync is triggered instead to push the existing value back
- Branch vehicle invoice lists match vehicles across stores by plate number (not by database ID), so the same physical vehicle's invoices are linked regardless of which store created them
- Retrieving a vehicle from a dealer validates that the vehicle belongs to the correct customer before allowing the operation
Support scenarios
- "Vehicle changes aren't syncing to other branches" → Sync requires both plate number AND VIN to be set. Check that the vehicle has both fields populated. Also note that financial fields, stock numbers, and external IDs are protected and never sync.
- "I updated a field on a branch vehicle but it reverted" → The sync prevents clearing existing values. If the target store already had data in that field, the change is reverted and the existing value is pushed back via reverse sync. Update the field at the store that currently holds the value.
- "Invoices from another branch are showing on this vehicle" → Branch vehicle invoice lists match by plate number across stores. This is expected behaviour -- it provides a unified service history for the physical vehicle regardless of which store created the work.