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

@@ -726,7 +726,6 @@ var Workshop = (function() {
document.getElementById('nvCustomerName').value = customerName;
document.getElementById('newVehicleModal').classList.add('is-open');
document.getElementById('nvPlate').value = '';
document.getElementById('nvVIN').value = '';
document.getElementById('nvMake').value = '';
document.getElementById('nvModel').value = '';
document.getElementById('nvYear').value = '';
@@ -743,10 +742,11 @@ var Workshop = (function() {
async function saveNewVehicle() {
var plate = document.getElementById('nvPlate').value.trim();
var vin = document.getElementById('nvVIN').value.trim();
var make = document.getElementById('nvMake').value.trim();
var model = document.getElementById('nvModel').value.trim();
var customerId = parseInt(document.getElementById('nvCustomerId').value, 10) || null;
if (!plate && !vin) {
alert('Se requiere al menos placa o VIN');
if (!make || !model) {
alert('Marca y modelo son obligatorios');
return;
}
if (!customerId) {
@@ -755,17 +755,16 @@ var Workshop = (function() {
}
var payload = {
plate: plate,
vin: vin,
customer_id: customerId,
make: document.getElementById('nvMake').value.trim() || null,
model: document.getElementById('nvModel').value.trim() || null,
make: make,
model: model,
year: document.getElementById('nvYear').value ? parseInt(document.getElementById('nvYear').value, 10) : null,
color: document.getElementById('nvColor').value.trim() || null,
branch_id: (currentOrder ? currentOrder.branch_id : null) || (window.POS_USER ? window.POS_USER.branch_id : null)
};
try {
var res = await api('POST', '/vehicles', payload);
var label = plate + (payload.make ? ' · ' + payload.make : '') + (payload.model ? ' ' + payload.model : '');
var label = [payload.make, payload.model, payload.year, plate].filter(Boolean).join(' · ');
if (newVehicleContext === 'new') {
var sel = document.getElementById('noVehicle');
var opt = document.createElement('option');