feat: Mejorar la validación de errores en la cancelación de constancias y optimizar la búsqueda de tags por lote
This commit is contained in:
parent
cf7cfdb821
commit
2d060f9909
@ -45,13 +45,8 @@ public function cancelarConstancia(CancelConstanciaRequest $request)
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validar que el registro no tenga errores previos
|
// Avisar que tiene error
|
||||||
if ($record->error_id !== null) {
|
$hadPreviousError = $record->error_id !== null;
|
||||||
return ApiResponse::BAD_REQUEST->response([
|
|
||||||
'message' => 'No se puede cancelar un registro que tiene errores. El vehículo no fue inscrito.',
|
|
||||||
'error_id' => $record->error_id
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Guardar información del tag anterior ANTES de cancelarlo
|
// Guardar información del tag anterior ANTES de cancelarlo
|
||||||
$oldTagNumber = $tag->tag_number;
|
$oldTagNumber = $tag->tag_number;
|
||||||
|
|||||||
@ -54,11 +54,10 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tag->vehicle_id) {
|
if (!$tag->isAvailable()) {
|
||||||
return ApiResponse::BAD_REQUEST->response([
|
return ApiResponse::BAD_REQUEST->response([
|
||||||
'message' => 'El tag ya está asignado a un vehículo. Use actualizar en su lugar.',
|
'message' => 'El tag ya está asignado a un vehículo. Use actualizar en su lugar.',
|
||||||
'tag_number' => $tagNumber,
|
'current_status' => $tag->status->name,
|
||||||
'vehicle_id' => $tag->vehicle_id,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +200,10 @@ public function vehicleInscription(VehicleStoreRequest $request)
|
|||||||
// Enviar a API Repuve Nacional
|
// Enviar a API Repuve Nacional
|
||||||
$apiResponse = $this->sendToRepuveNacional($niv);
|
$apiResponse = $this->sendToRepuveNacional($niv);
|
||||||
|
|
||||||
$apiResponse["repuve_response"]["folio_ci"] = $folio; //harcodeado cambiar despues
|
if (isset($apiResponse['repuve_response']) && is_array($apiResponse['repuve_response'])) {
|
||||||
$apiResponse["repuve_response"]["identificador_ci"] = $tagNumber; //harcodeado cambiar despues
|
$apiResponse["repuve_response"]["folio_ci"] = $folio;
|
||||||
|
$apiResponse["repuve_response"]["identificador_ci"] = $tagNumber;
|
||||||
|
}
|
||||||
|
|
||||||
// Procesar respuesta
|
// Procesar respuesta
|
||||||
if (isset($apiResponse['has_error']) && $apiResponse['has_error']) {
|
if (isset($apiResponse['has_error']) && $apiResponse['has_error']) {
|
||||||
@ -428,6 +429,7 @@ public function searchRecord(Request $request)
|
|||||||
'folio',
|
'folio',
|
||||||
'vehicle_id',
|
'vehicle_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
|
'error_id',
|
||||||
'created_at'
|
'created_at'
|
||||||
])->paginate(config('app.pagination'))
|
])->paginate(config('app.pagination'))
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -20,6 +20,12 @@ public function index(Request $request)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->has('lot')) {
|
||||||
|
$tags->whereHas('package', function ($q) use ($request) {
|
||||||
|
$q->where('lot', $request->lot);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return ApiResponse::OK->response([
|
return ApiResponse::OK->response([
|
||||||
'tag' => $tags->paginate(config('app.pagination')),
|
'tag' => $tags->paginate(config('app.pagination')),
|
||||||
]);
|
]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user