From 04c9fe2d5af8b8ffbe0801c08f5152c9f9fb5796 Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Wed, 11 Feb 2026 15:36:46 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20actualizar=20tipos=20de=20acci=C3=B3n=20?= =?UTF-8?q?en=20registros=20de=20veh=C3=ADculos=20y=20migraci=C3=B3n=20par?= =?UTF-8?q?a=20'sustitucion=5Fprimera=5Fvez'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Repuve/ExcelController.php | 10 +-- .../Repuve/InscriptionController.php | 6 +- app/Models/VehicleTagLog.php | 2 +- composer.json | 4 ++ ...ucion_primera_vez_in_vehicle_tags_logs.php | 71 +++++++++++++++++++ database/seeders/RoleSeeder.php | 18 ----- 6 files changed, 84 insertions(+), 27 deletions(-) create mode 100644 database/migrations/data/2026_02_11_134121_rename_inscripcion_to_sustitucion_primera_vez_in_vehicle_tags_logs.php diff --git a/app/Http/Controllers/Repuve/ExcelController.php b/app/Http/Controllers/Repuve/ExcelController.php index edfc256..8b9639f 100644 --- a/app/Http/Controllers/Repuve/ExcelController.php +++ b/app/Http/Controllers/Repuve/ExcelController.php @@ -868,10 +868,10 @@ public function excelGeneral(Request $request) 'tag', 'cancellationReason' ]) - ->whereIn('action_type', ['inscripcion', 'sustitucion', 'actualizacion', 'cancelacion']) + ->whereIn('action_type', ['sustitucion_primera_vez', 'sustitucion', 'actualizacion', 'cancelacion']) ->where(function ($query) use ($fechaInicio, $fechaFin) { $query->where(function ($q) use ($fechaInicio, $fechaFin) { - $q->whereIn('action_type', ['inscripcion', 'sustitucion', 'actualizacion']) + $q->whereIn('action_type', ['sustitucion_primera_vez', 'sustitucion', 'actualizacion']) ->whereBetween('created_at', [$fechaInicio, $fechaFin]); }) ->orWhere(function ($q) use ($fechaInicio, $fechaFin) { @@ -946,7 +946,7 @@ public function excelGeneral(Request $request) // Motivo $motivo = $log->cancellationReason->reason ?? $log->cancellationReason->name ?? ''; if ($log->action_type == 'sustitucion') $motivo = 'SUSTITUCIÓN'; - if ($log->action_type == 'inscripcion') $motivo = 'INSCRIPCIÓN'; + if ($log->action_type == 'sustitucion_primera_vez') $motivo = 'SUSTITUCIÓN POR PRIMERA VEZ'; if ($log->action_type == 'actualizacion') $motivo = 'ACTUALIZACIÓN'; if ($log->action_type == 'cancelacion' && empty($motivo)) $motivo = 'DAÑADA'; @@ -1186,7 +1186,7 @@ public function exportSearchRecords(Request $request) 'vin' => 'nullable|string', 'tag_number' => 'nullable|string', 'module_id' => 'nullable|integer|exists:modules,id', - 'action_type' => 'nullable|string|in:inscripcion,sustitucion,cancelacion', + 'action_type' => 'nullable|string|in:sustitucion_primera_vez,sustitucion,cancelacion', 'status' => 'nullable|string', 'start_date' => 'nullable|date', 'end_date' => 'nullable|date|after_or_equal:start_date', @@ -1284,7 +1284,7 @@ public function exportSearchRecords(Request $request) // Obtener logs ordenados por fecha, excluyendo actualizaciones $vehicleLogs = $vehicle->vehicleTagLogs - ->whereIn('action_type', ['inscripcion', 'sustitucion', 'cancelacion']) + ->whereIn('action_type', ['sustitucion_primera_vez', 'sustitucion', 'cancelacion']) ->sortBy('created_at'); // Generar una fila por cada log (cada acción en el historial) diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index 7a6ff85..35dbd0d 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -162,7 +162,7 @@ public function vehicleInscription(VehicleStoreRequest $request) VehicleTagLog::create([ 'vehicle_id' => $vehicle->id, 'tag_id' => $tag->id, - 'action_type' => 'sustitucion', + 'action_type' => 'sustitucion_primera_vez', 'performed_by' => Auth::id(), ]); @@ -289,7 +289,7 @@ public function searchRecord(Request $request) 'vin' => 'nullable|string', 'tag_number' => 'nullable|string', 'module_id' => 'nullable|integer|exists:modules,id', - 'action_type' => 'nullable|string|in:inscripcion,actualizacion,sustitucion,cancelacion', + 'action_type' => 'nullable|string|in:sustitucion_primera_vez,actualizacion,sustitucion,cancelacion', 'status' => 'nullable|string', 'start_date' => 'nullable|date', 'end_date' => 'nullable|date|after_or_equal:start_date', @@ -426,7 +426,7 @@ public function searchRecord(Request $request) 'tag_number' => $tag?->tag_number, 'status' => $tag?->status?->code ?? 'unknown', 'assigned_at' => $vehicleLogs->where('tag_id', $tagId) - ->whereIn('action_type', ['inscripcion', 'sustitucion']) + ->whereIn('action_type', ['sustitucion_primera_vez', 'sustitucion']) ->first()?->created_at, 'cancelled_at' => $cancelLog?->cancellation_at, 'is_current' => $tag?->id === $record->vehicle->tag?->id, diff --git a/app/Models/VehicleTagLog.php b/app/Models/VehicleTagLog.php index 9781a12..c02096e 100644 --- a/app/Models/VehicleTagLog.php +++ b/app/Models/VehicleTagLog.php @@ -52,7 +52,7 @@ public function cancellationReason() public function isInscription() { - return $this->action_type === 'inscripcion'; + return $this->action_type === 'sustitucion_primera_vez'; } public function isUpdate() diff --git a/composer.json b/composer.json index bb6f7a3..b0729a1 100644 --- a/composer.json +++ b/composer.json @@ -84,6 +84,10 @@ "@php artisan migrate:fresh --seed", "@php artisan passport:client --personal --name=Holos" ], + "db:update": [ + "@php artisan migrate", + "@php artisan migrate --path=database/migrations/data" + ], "jobs:start": [ "pm2 start \"php artisan schedule:work\" --name holos-schedules", "pm2 start \"php artisan queue:work\" --name holos-queue" diff --git a/database/migrations/data/2026_02_11_134121_rename_inscripcion_to_sustitucion_primera_vez_in_vehicle_tags_logs.php b/database/migrations/data/2026_02_11_134121_rename_inscripcion_to_sustitucion_primera_vez_in_vehicle_tags_logs.php new file mode 100644 index 0000000..f58cd68 --- /dev/null +++ b/database/migrations/data/2026_02_11_134121_rename_inscripcion_to_sustitucion_primera_vez_in_vehicle_tags_logs.php @@ -0,0 +1,71 @@ +onCRUD('users', $users, 'api'); $userSettings = $this->onPermission('users.settings', 'Configuración de usuarios', $users, 'api'); - $userOnline = $this->onPermission('users.online', 'Usuarios en linea', $users, 'api'); $roles = PermissionType::firstOrCreate([ 'name' => 'Roles' @@ -53,23 +52,6 @@ public function run(): void $roleDestroy ] = $this->onCRUD('roles', $roles, 'api'); - $pulse = PermissionType::firstOrCreate([ - 'name' => 'Sistema' - ]); - - $systemPulse = $this->onPermission('pulse', 'Monitoreo de Pulse', $pulse, 'api'); - - $pulse = PermissionType::firstOrCreate([ - 'name' => 'Historial de actividades' - ]); - - $activityIndex = $this->onIndex( - code: 'activities', - type: $pulse, - guardName: 'api' - ); - - $modules = PermissionType::firstOrCreate([ // Modulos 'name' => 'Módulos' ]);