From 2c7ab0cb2e6ad4f1ce181f816dbbc85c099ca516 Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Tue, 31 Mar 2026 12:30:19 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20mejora=20l=C3=B3gica=20de=20inscripci?= =?UTF-8?q?=C3=B3n=20de=20veh=C3=ADculos=20y=20logging=20-=20Se=20actualiz?= =?UTF-8?q?=C3=B3=20la=20validaci=C3=B3n=20de=20asignaci=C3=B3n=20de=20m?= =?UTF-8?q?=C3=B3dulo=20de=20tags.=20-=20Se=20mejor=C3=B3=20el=20registro?= =?UTF-8?q?=20de=20eventos=20(logging).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dev/docker-compose.yml | 2 +- .../Repuve/InscriptionController.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Docker/Dev/docker-compose.yml b/Docker/Dev/docker-compose.yml index ed7dc7d..a1598c9 100644 --- a/Docker/Dev/docker-compose.yml +++ b/Docker/Dev/docker-compose.yml @@ -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: diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index 8369295..f6c8515 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -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