How Vehicle Body Groups and Form Serial Numbers Work
Source: `vehicle_body_groups_controller.rb`, `vehicle_form_serial_numbers_controller.rb`
- System-default body types are marked with
no_deleteand cannot be destroyed, even by administrators - Body types that are in use by ANY company's vehicles across the entire system cannot be destroyed; they are globally protected
- Body group updates support creating and destroying entries in a single batch operation; body group codes are automatically uppercased on save
- Vehicle form serial numbers auto-use the company's next available form number; the
date_printedfield defaults to today's date - Duplicate form serial numbers are checked by the combination of
form_code+vehicle_id; the same form code can exist on different vehicles but not twice on the same vehicle
Support scenarios
- "I can't delete this body type" → Body types marked as system defaults (
no_delete) can never be deleted. Additionally, any body type in use by any company's vehicles anywhere in the system is protected from deletion. - "The body group code I entered was changed to uppercase" → Body group codes are automatically uppercased on save. This is normal behaviour to ensure consistency.
- "I got a duplicate form serial number error" → Duplicates are checked by form_code + vehicle_id combination. The same form code already exists on this vehicle. Use a different form code or check the existing form entry.
- "The form serial number wasn't what I expected" → Form serial numbers auto-assign from the company's next available number. If numbers appear to skip, a previous form may have been created and then deleted or the counter was advanced by another user.