Overview
The Vehicle data model is central to MotorDesk’s fleet management system. It tracks vehicle information, ownership, habitual drivers, and maintenance history through integrated mileage tracking.TypeScript Interface
Field Reference
Unique identifier for the vehicleFormat:
veh-XXX where XXX is a sequential numberExample: veh-001Reference to the customer who owns this vehicleType: Foreign key to Customer modelExample:
cust-001Validation: Must reference an existing customer IDReference to the customer who is the habitual driverType: Foreign key to Customer model (nullable)Example:
cust-002 or nullNote: Can be null if no habitual driver is assigned, or can be the same as propietarioIdVehicle license plate numberFormat: Typically follows format
XXX-### (3 letters, dash, 3 numbers)Example: ABC-123Validation: Must be unique across all vehiclesVehicle manufacturer/brandExample:
Toyota, Hyundai, Mercedes-BenzVehicle model nameExample:
Hilux, Tucson, SprinterYear of manufactureType: Integer (4-digit year)Example:
2020, 2018, 2022Validation: Should be a reasonable year (e.g., 1900-current year + 1)Vehicle colorExample:
Blanco, Rojo, PlataCurrent odometer reading in kilometersType: Integer or floatExample:
45000, 62500Note: This value is updated with each sale/service transactionTimestamp when the vehicle record was createdFormat: ISO 8601 datetime stringExample:
2023-10-25T10:00:00ZTimestamp of last synchronization with remote serverFormat: ISO 8601 datetime stringExample:
2023-10-25T10:01:00ZNote: Used for offline-first data synchronizationSoft delete flagDefault:
falseNote: Vehicles are soft-deleted to maintain referential integrity with historical sales dataRelationships
Owner (Propietario)
Owner (Propietario)
Each vehicle must have exactly one owner, referenced by
propietarioId.Habitual Driver (Conductor Habitual)
Habitual Driver (Conductor Habitual)
A vehicle may have an assigned habitual driver, referenced by
conductorHabitualId. This field is nullable.Sales History
Sales History
Vehicles have a one-to-many relationship with sales transactions. This enables maintenance history tracking.
Usual Products
Usual Products
Vehicles can have frequently used products associated with them for quick service recommendations.
Example Data
Toyota Hilux (2020)
Mercedes-Benz Sprinter (2022)
Business Logic
Mileage Tracking
The vehicle’s current mileage is automatically updated based on the most recent sale transaction:Service Due Calculation
Calculate when the next service is due based on product maintenance intervals:Soft Delete Implementation
Enhanced Vehicle Display Data
The application enriches vehicle data with related information for display:Data Storage
Mock Data Location
/src/data/mock/vehicles.tsTypeScript export with sample vehicle dataJSON Data Location
/src/data/json/vehicles.jsonRaw JSON array of vehicle objectsRelated Models
- Customers - Vehicle owners and drivers
- Sales - Service and maintenance transactions
- Products - Products used in vehicle maintenance
