feat(workshop): make brand/model required, plate optional, remove VIN
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

- create_vehicle endpoints now require make and model; plate is optional; VIN is no longer stored.

- Updated new-vehicle modal: removed VIN field, plate is optional, brand/model marked required.
This commit is contained in:
2026-06-30 20:08:56 +00:00
parent 73553a3771
commit 7dc34f68ab
4 changed files with 27 additions and 30 deletions

View File

@@ -269,11 +269,12 @@ def list_all_history():
def create_vehicle():
"""Create a fleet vehicle.
Body: {customer_id, plate, vin, make, model, year, current_mileage, fuel_type, color, owner_name, notes}
Body: {customer_id, plate, make, model, year, current_mileage, fuel_type, color, owner_name, notes}
Brand and model are required; plate is optional; VIN is not used.
"""
data = request.get_json() or {}
if not data.get('plate') and not data.get('vin'):
return jsonify({'error': 'plate or vin is required'}), 400
if not data.get('make') or not data.get('model'):
return jsonify({'error': 'Marca y modelo son obligatorios'}), 400
if not data.get('customer_id'):
return jsonify({'error': 'El vehiculo debe estar asignado a un cliente'}), 400
@@ -291,12 +292,12 @@ def create_vehicle():
cur.execute("""
INSERT INTO fleet_vehicles
(branch_id, customer_id, plate, vin, make, model, year,
(branch_id, customer_id, plate, make, model, year,
current_mileage, fuel_type, color, owner_name, notes)
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
RETURNING id
""", (
branch_id, data['customer_id'], data.get('plate'), data.get('vin'),
branch_id, data['customer_id'], data.get('plate'),
data.get('make'), data.get('model'), data.get('year'),
data.get('current_mileage', 0), data.get('fuel_type', 'gasolina'),
data.get('color'), data.get('owner_name') or cust[0], data.get('notes'),