How Loan Car Bookings Work
Source: loan_cars_controller.rb, loan_car.rb
- Loan car bookings require a loan date, vehicle, customer, and shop hours to be configured
- Maximum loan duration is 30 days; longer bookings are rejected
- Loan numbers are auto-assigned from the company's sequence counter
- Soft delete transitions PENDING loans to CANCELLED status; cancellation also unlinks the loan from any associated invoice and event
- Starting a loan requires the customer to agree to terms and conditions; the system captures the current local time as the start time
- Only loans in active status can be returned (marked as returned)
- Multi-day loans are split into time segments: Day 1 runs from the start time to shop close, middle days run from shop open to shop close, and the last day runs from shop open to the end time
- Loan car time entries are cleared and fully recreated on every update to keep the time splits accurate
- Vehicle availability is calculated as shop hours minus already-booked hours per vehicle per day
Support scenarios
- "I can't create a loan car booking longer than 30 days" → The system enforces a maximum 30-day loan period. For longer loans, create a second booking starting where the first ends.
- "The loan car times look wrong after I edited the booking" → Loan car times are destroyed and recreated on every update. This is normal behavior to keep the multi-day time splits accurate.
- "I can't return this loan car" → Only active loans can be returned. Check the loan status — if it is PENDING or CANCELLED, it cannot be returned. The loan must be started first.
- "The customer says they didn't agree to terms but the loan was started" → Starting a loan requires agreement to terms. The system records the agreement and the local timestamp when the loan was started.