feat(workshop): make brand/model required, plate optional, remove VIN
- 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:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user