feat(pos): fleet management module — vehicles, maintenance schedules, alerts
Add full fleet management (Feature 13): database migration for fleet_vehicles, fleet_maintenance_schedules, and fleet_maintenance_logs tables; REST API blueprint with CRUD, scheduling, logging, alerts, and stats endpoints; frontend with tabbed UI (vehicles grid, maintenance schedules, history, overdue alerts); sidebar nav entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
50
pos/migrations/v1.3_fleet.sql
Normal file
50
pos/migrations/v1.3_fleet.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
-- v1.3 Fleet Management tables
|
||||
-- Vehicles, maintenance schedules, and maintenance logs
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fleet_vehicles (
|
||||
id SERIAL PRIMARY KEY,
|
||||
branch_id INTEGER REFERENCES branches(id),
|
||||
plate VARCHAR(20),
|
||||
vin VARCHAR(17),
|
||||
make VARCHAR(100),
|
||||
model VARCHAR(100),
|
||||
year INTEGER,
|
||||
current_mileage INTEGER DEFAULT 0,
|
||||
fuel_type VARCHAR(20) DEFAULT 'gasolina',
|
||||
color VARCHAR(50),
|
||||
owner_name VARCHAR(200),
|
||||
notes TEXT,
|
||||
is_active BOOLEAN DEFAULT TRUE,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fleet_maintenance_schedules (
|
||||
id SERIAL PRIMARY KEY,
|
||||
vehicle_id INTEGER REFERENCES fleet_vehicles(id),
|
||||
maintenance_type VARCHAR(100) NOT NULL,
|
||||
interval_km INTEGER,
|
||||
interval_months INTEGER,
|
||||
last_done_at TIMESTAMPTZ,
|
||||
last_done_km INTEGER,
|
||||
next_due_at TIMESTAMPTZ,
|
||||
next_due_km INTEGER,
|
||||
notes TEXT,
|
||||
is_active BOOLEAN DEFAULT TRUE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS fleet_maintenance_logs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
vehicle_id INTEGER REFERENCES fleet_vehicles(id),
|
||||
schedule_id INTEGER REFERENCES fleet_maintenance_schedules(id),
|
||||
maintenance_type VARCHAR(100),
|
||||
mileage_at INTEGER,
|
||||
cost NUMERIC(12,2),
|
||||
parts_used TEXT,
|
||||
employee_id INTEGER REFERENCES employees(id),
|
||||
notes TEXT,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_fleet_vehicles_plate ON fleet_vehicles(plate);
|
||||
CREATE INDEX IF NOT EXISTS idx_fleet_maint_vehicle ON fleet_maintenance_schedules(vehicle_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_fleet_logs_vehicle ON fleet_maintenance_logs(vehicle_id);
|
||||
Reference in New Issue
Block a user