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

@@ -415,11 +415,12 @@ def create_customer_for_workshop():
def create_vehicle_for_workshop():
"""Create a fleet vehicle directly from the workshop flow.
Vehicles must be assigned to a customer.
Vehicles must be assigned to a customer. Brand and model are required;
plate is optional and VIN is not used.
"""
data = request.get_json() or {}
if not data.get('plate') and not data.get('vin'):
return jsonify({'error': 'Se requiere placa o VIN'}), 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
@@ -434,12 +435,12 @@ def create_vehicle_for_workshop():
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
""", (
data.get('branch_id', g.branch_id), data['customer_id'], data.get('plate'), data.get('vin'),
data.get('branch_id', g.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'), cust[0], data.get('notes'),