feature/pedimento completo carga remesas, coves, edocs y acuses y aparte descarga sus documentos, se corrigieron las formulas de remesas, acuse y e documents para permitir la correcta descarga de susdocumentos y se aseguro que el status sea el correcto
This commit is contained in:
@@ -91,6 +91,46 @@ class APIRESTController:
|
||||
logger.error(traceback.format_exc())
|
||||
return None
|
||||
|
||||
async def post_or_update_document(
|
||||
self, soap_response=None, organizacion: str = None,
|
||||
pedimento: str = None, file_name: str = None,
|
||||
document_type: int = None, fuente: int = 2,
|
||||
identifier: str = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Guarda un documento VU (request o error). Si ya existe uno del mismo
|
||||
tipo/pedimento/identificador, elimina el anterior y crea el nuevo,
|
||||
evitando duplicados en ejecuciones recurrentes (tarea programada diaria).
|
||||
|
||||
identifier: cadena única del documento dentro del pedimento
|
||||
(ej: número de COVE, número de e-document). Se usa como
|
||||
filtro archivo__icontains para distinguir documentos del
|
||||
mismo tipo pertenecientes a distintos COVEs o edocs.
|
||||
"""
|
||||
try:
|
||||
query = f'record/documents/?pedimento={pedimento}&document_type={document_type}'
|
||||
if identifier:
|
||||
query += f'&archivo__icontains={identifier}'
|
||||
existing = await self._make_request_async('GET', query)
|
||||
if existing:
|
||||
results = existing.get('results', existing) if isinstance(existing, dict) else existing
|
||||
if isinstance(results, list) and results:
|
||||
existing_id = results[0].get('id')
|
||||
if existing_id:
|
||||
await self._make_request_async('DELETE', f'record/documents/{existing_id}/')
|
||||
logger.info(f"Documento VU previo eliminado: id={existing_id}, document_type={document_type}, identifier={identifier}")
|
||||
except Exception as e:
|
||||
logger.warning(f"No se pudo verificar/eliminar documento VU existente (document_type={document_type}, identifier={identifier}): {e}")
|
||||
|
||||
return await self.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=organizacion,
|
||||
pedimento=pedimento,
|
||||
file_name=file_name,
|
||||
document_type=document_type,
|
||||
fuente=fuente,
|
||||
)
|
||||
|
||||
async def put_procesamiento(self, service_id: int, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return await self._make_request_async('PUT', f'customs/procesamientopedimentos/{service_id}/', data=data)
|
||||
|
||||
@@ -457,13 +497,16 @@ class APIController:
|
||||
async def put_edocument(self, edocument_id: str, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Método para actualizar un documento digitalizado en la API.
|
||||
|
||||
|
||||
Args:
|
||||
edocument_id: UUID del documento a actualizar
|
||||
data: Diccionario con los datos a actualizar
|
||||
"""
|
||||
return await self._make_request_async('PUT', f'customs/edocuments/{edocument_id}/', data=data)
|
||||
|
||||
async def put_cove(self, cove_id: str, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return await self._make_request_async('PUT', f'customs/coves/{cove_id}/', data=data)
|
||||
|
||||
async def get_key(self, id: str) -> bytes:
|
||||
result = await self._make_request_async('GET', f'vucem/vucem/{id}/download_key/', return_bytes=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user