feat: mejora lógica de inscripción de vehículos y logging
- Se actualizó la validación de asignación de módulo de tags. - Se mejoró el registro de eventos (logging).
This commit is contained in:
parent
2fd337bd16
commit
2c7ab0cb2e
@ -56,7 +56,7 @@ services:
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
MYSQL_USER: ${DB_USERNAME}
|
||||
ports:
|
||||
- "${DB_PORT_FORWARD}:3306"
|
||||
- "${DB_PORT}:3306"
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
networks:
|
||||
|
||||
@ -75,6 +75,13 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$tag->module_id) {
|
||||
return ApiResponse::BAD_REQUEST->response([
|
||||
'message' => 'El tag no tiene módulo asignado. Debe asignarse a un módulo antes de poder usarse.',
|
||||
'folio' => $folio,
|
||||
]);
|
||||
}
|
||||
|
||||
// Iniciar transacción
|
||||
DB::beginTransaction();
|
||||
|
||||
@ -194,10 +201,12 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
||||
$tag->markAsAssigned($vehicle->id, $folio);
|
||||
|
||||
VehicleTagLog::create([
|
||||
'vehicle_id' => $vehicle->id,
|
||||
'tag_id' => $tag->id,
|
||||
'action_type' => $actionType,
|
||||
'performed_by' => Auth::id(),
|
||||
'vehicle_id' => $vehicle->id,
|
||||
'tag_id' => $tag->id,
|
||||
'action_type' => $actionType,
|
||||
'folio_anterior' => $actionType === 'sustitucion' ? $folioRepuve : null,
|
||||
'cancellation_at' => $actionType === 'sustitucion' ? now() : null,
|
||||
'performed_by' => Auth::id(),
|
||||
]);
|
||||
|
||||
// Crear registro
|
||||
@ -205,7 +214,7 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
||||
'folio' => $folio,
|
||||
'vehicle_id' => $vehicle->id,
|
||||
'user_id' => Auth::id(),
|
||||
'module_id' => Auth::user()->module_id,
|
||||
'module_id' => $tag->module_id,
|
||||
]);
|
||||
|
||||
// Procesar archivos
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user