Skip to content
English
  • There are no suggestions because the search field is empty.

How Vehicle Soft-Delete and Archiving Works

Source: `vehicle.rb`, `vehicles_controller.rb`

  • The default scope on Vehicle excludes both deleted and archived vehicles from all queries, identical to the customer scoping behaviour
  • A vehicle cannot be archived if it has a for-sale or pending status; the sale status must be cleared first
  • A vehicle cannot be unarchived if its owner customer is archived; the customer must be unarchived FIRST before the vehicle can be unarchived
  • Vehicle deletion is a soft-delete (sets deleted=true), and is blocked if the vehicle has a sale status, linked invoices, or linked events
  • In multibranch setups, deleting a branch vehicle cascades the deletion, but it is blocked if any linked store vehicle has invoices or events

Support scenarios

  • "I can't archive this vehicle, it says it's for sale" → Vehicles with for-sale or pending status cannot be archived. Remove the sale status first (mark as not for sale), then archive.
  • "I can't unarchive this vehicle" → Check if the owning customer is archived. The customer must be unarchived before any of their vehicles can be unarchived.
  • "I can't delete this vehicle, it has invoices" → Vehicle deletion is blocked by linked invoices or events. The vehicle can be archived instead, or the invoices would need to be reassigned (which may not be possible depending on their status).
  • "I deleted a vehicle at head office and it affected other stores" → In multibranch setups, branch vehicle deletion cascades to linked store vehicles. This is expected. However, the cascade is blocked if any store vehicle has invoices or events.