How Loan Vehicle Management Works
Source: loan_vehicles_controller.rb
- Loan vehicle deletion follows a three-tier approach: if the vehicle has no loan history it is soft deleted; if it has only historical (completed) loans it is set to inactive; if it has active loans the delete is blocked entirely
- When editing an existing loan car booking, the current vehicle remains in the available vehicles list even if it would otherwise be excluded (so you can keep the same vehicle)
- The show_any parameter bypasses the default scope filter, allowing deleted and inactive vehicles to be retrieved for reporting or admin purposes
Support scenarios
- "I can't delete a loan vehicle" → If the vehicle has active loan bookings, deletion is blocked. Return or cancel all active loans first. If it has only historical loans, the system will set it to inactive rather than deleting it.
- "A deleted loan vehicle is showing up in a report" → The show_any flag may be enabled on that view, which bypasses the soft delete filter. This is expected for reporting contexts that need historical data.