feat: Actualizar la lógica de cancelación para usar el folio correcto

This commit is contained in:
Juan Felipe Zapata Moreno 2025-11-26 17:22:45 -06:00
parent e57bb79762
commit a305c82956
3 changed files with 6 additions and 5 deletions

View File

@ -93,19 +93,19 @@ public function cancelarConstancia(CancelConstanciaRequest $request)
]); ]);
} }
// Usar el folio del NUEVO TAG // Usar el folio del request
$newTag->markAsAssigned($vehicle->id, $newTag->folio); $newTag->markAsAssigned($vehicle->id, $request->folio);
$substitutionLog = VehicleTagLog::create([ $substitutionLog = VehicleTagLog::create([
'vehicle_id' => $vehicle->id, 'vehicle_id' => $vehicle->id,
'tag_id' => $newTag->id, 'tag_id' => $newTag->id,
'action_type' => 'sustitucion', 'action_type' => 'sustitucion',
'cancellation_reason' => $request->cancellation_reason, 'cancellation_reason' => $request->cancellation_reason,
'cancellation_observations' => 'Tag sustituido. Tag anterior: ' . $oldTagNumber . 'Motivo: ' . ($request->cancellation_observations ?? ''), 'cancellation_observations' => 'Tag sustituido. Tag anterior: ' . $oldTagNumber . ' (Folio: ' . $oldFolio . '). Motivo: ' . ($request->cancellation_observations ?? ''),
'performed_by' => Auth::id(), 'performed_by' => Auth::id(),
]); ]);
$record->update(['folio' => $newTag->folio]); $record->update(['folio' => $request->folio]);
} }
DB::commit(); DB::commit();

View File

@ -21,6 +21,7 @@ public function rules(): array
{ {
return [ return [
'record_id' => 'required|exists:records,id', 'record_id' => 'required|exists:records,id',
'folio' => 'required|string',
'cancellation_reason' => 'required|in:fallo_lectura_handheld,cambio_parabrisas,roto_al_pegarlo,extravio,otro', 'cancellation_reason' => 'required|in:fallo_lectura_handheld,cambio_parabrisas,roto_al_pegarlo,extravio,otro',
'cancellation_observations' => 'nullable|string', 'cancellation_observations' => 'nullable|string',
'new_tag_number' => 'nullable|exists:tags,tag_number', 'new_tag_number' => 'nullable|exists:tags,tag_number',

View File

@ -72,7 +72,7 @@ public function markAsCancelled(): void
$this->update([ $this->update([
'status_id' => $statusCancelled->id, 'status_id' => $statusCancelled->id,
'vehicle_id' => null, 'vehicle_id' => null,
'folio' => null, // Mantener el folio porque la columna no acepta null
]); ]);
} }