feature/rbac-implementation #9
@@ -145,12 +145,13 @@ async def obtener_acuse(**kwargs):
|
|||||||
organizacion = pedimento.get("organizacion", None)
|
organizacion = pedimento.get("organizacion", None)
|
||||||
pedimento_id = pedimento.get("id", None)
|
pedimento_id = pedimento.get("id", None)
|
||||||
|
|
||||||
rest_response = await acuse_rest_controller.post_document(
|
rest_response = await acuse_rest_controller.post_or_update_document(
|
||||||
binary_content=pdf_bytes,
|
binary_content=pdf_bytes,
|
||||||
organizacion=organizacion,
|
organizacion=organizacion,
|
||||||
pedimento=pedimento_id,
|
pedimento=pedimento_id,
|
||||||
file_name=_file_name,
|
file_name=_file_name,
|
||||||
document_type=4
|
document_type=4,
|
||||||
|
identifier=idEdocument_efc,
|
||||||
)
|
)
|
||||||
|
|
||||||
if rest_response is None:
|
if rest_response is None:
|
||||||
|
|||||||
@@ -134,12 +134,13 @@ async def consume_ws_get_cove(**kwargs):
|
|||||||
# Enviar documento
|
# Enviar documento
|
||||||
_file_name = f"vu_COVE_{pedimento_app}_{cove}.xml"
|
_file_name = f"vu_COVE_{pedimento_app}_{cove}.xml"
|
||||||
try:
|
try:
|
||||||
document_response = await coves_rest_controller.post_document(
|
document_response = await coves_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=_file_name,
|
file_name=_file_name,
|
||||||
document_type=8,
|
document_type=8,
|
||||||
|
identifier=cove,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
||||||
@@ -318,12 +319,14 @@ async def consume_ws_get_acuse_cove(**kwargs):
|
|||||||
organizacion = pedimento.get("organizacion", None)
|
organizacion = pedimento.get("organizacion", None)
|
||||||
pedimento_id = pedimento.get("id", None)
|
pedimento_id = pedimento.get("id", None)
|
||||||
|
|
||||||
rest_response = await coves_rest_controller.post_document(
|
cove_identifier = kwargs['cove'].get('cove', '')
|
||||||
|
rest_response = await coves_rest_controller.post_or_update_document(
|
||||||
binary_content=pdf_bytes,
|
binary_content=pdf_bytes,
|
||||||
organizacion=organizacion,
|
organizacion=organizacion,
|
||||||
pedimento=pedimento_id,
|
pedimento=pedimento_id,
|
||||||
file_name=_file_name,
|
file_name=_file_name,
|
||||||
document_type=7
|
document_type=7,
|
||||||
|
identifier=cove_identifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
acuse_status = await change_acuse_status(
|
acuse_status = await change_acuse_status(
|
||||||
|
|||||||
@@ -203,12 +203,13 @@ async def obtener_edoc(**kwargs):
|
|||||||
# No guardaremos el archivo localmente por seguridad
|
# No guardaremos el archivo localmente por seguridad
|
||||||
logger.debug(f"Procesando documento {numero_documento} para pedimento {pedimento_id}")
|
logger.debug(f"Procesando documento {numero_documento} para pedimento {pedimento_id}")
|
||||||
|
|
||||||
rest_response = await edocs_rest_controller.post_document(
|
rest_response = await edocs_rest_controller.post_or_update_document(
|
||||||
binary_content=pdf_bytes,
|
binary_content=pdf_bytes,
|
||||||
organizacion=organizacion,
|
organizacion=organizacion,
|
||||||
pedimento=pedimento_id,
|
pedimento=pedimento_id,
|
||||||
file_name=_file_name,
|
file_name=_file_name,
|
||||||
document_type=5
|
document_type=5,
|
||||||
|
identifier=numero_documento,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"rest_response >>>> {rest_response}")
|
print(f"rest_response >>>> {rest_response}")
|
||||||
|
|||||||
@@ -59,12 +59,13 @@ async def consume_ws_get_partida(**kwargs):
|
|||||||
|
|
||||||
file_name_request = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_REQUEST.xml"
|
file_name_request = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_REQUEST.xml"
|
||||||
|
|
||||||
document_response = await partida_rest_controller.post_document(
|
document_response = await partida_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_xml,
|
soap_response=soap_xml,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=file_name_request,
|
file_name=file_name_request,
|
||||||
document_type=17, # Tipo de documento para petición de partidas
|
document_type=17,
|
||||||
|
identifier=f"_PT_{pedimento_app}_{partida.get('numero', '')}_",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error al enviar documento request: {e}")
|
logger.error(f"Error al enviar documento request: {e}")
|
||||||
@@ -97,12 +98,13 @@ async def consume_ws_get_partida(**kwargs):
|
|||||||
if soap_error(soap_response):
|
if soap_error(soap_response):
|
||||||
error_file_name = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_ERROR.xml"
|
error_file_name = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_ERROR.xml"
|
||||||
try:
|
try:
|
||||||
document_response = await partida_rest_controller.post_document(
|
document_response = await partida_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=error_file_name,
|
file_name=error_file_name,
|
||||||
document_type=18,
|
document_type=18,
|
||||||
|
identifier=f"_PT_{pedimento_app}_{partida.get('numero', '')}_",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error al guardar la respuesta de error: {e}")
|
logger.error(f"Error al guardar la respuesta de error: {e}")
|
||||||
@@ -127,12 +129,13 @@ async def consume_ws_get_partida(**kwargs):
|
|||||||
# Enviar documento
|
# Enviar documento
|
||||||
_file_name = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}.xml"
|
_file_name = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}.xml"
|
||||||
try:
|
try:
|
||||||
document_response = await partida_rest_controller.post_document(
|
document_response = await partida_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=_file_name,
|
file_name=_file_name,
|
||||||
document_type=1,
|
document_type=1,
|
||||||
|
identifier=f"_PT_{pedimento_app}_{partida.get('numero', '')}_",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error al enviar documento: {e}")
|
logger.error(f"Error al enviar documento: {e}")
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
|||||||
|
|
||||||
file_name_request = f"VU_PC_{pedimento_data.get('pedimento_app', 'unknown')}_REQUEST.xml"
|
file_name_request = f"VU_PC_{pedimento_data.get('pedimento_app', 'unknown')}_REQUEST.xml"
|
||||||
|
|
||||||
document_response = await pedimento_rest_controller.post_document(
|
document_response = await pedimento_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_xml,
|
soap_response=soap_xml,
|
||||||
organizacion=pedimento_data.get('organizacion'),
|
organizacion=pedimento_data.get('organizacion'),
|
||||||
pedimento=pedimento_data.get('id'),
|
pedimento=pedimento_data.get('id'),
|
||||||
file_name=file_name_request,
|
file_name=file_name_request,
|
||||||
document_type=13,
|
document_type=13,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error al enviar documento request: {e}")
|
logger.error(f"Error al enviar documento request: {e}")
|
||||||
@@ -90,12 +90,12 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
|||||||
|
|
||||||
if soap_error(soap_response):
|
if soap_error(soap_response):
|
||||||
logger.error(f"Error en respuesta SOAP: {soap_response.text if hasattr(soap_response, 'text') else 'Sin detalles'}")
|
logger.error(f"Error en respuesta SOAP: {soap_response.text if hasattr(soap_response, 'text') else 'Sin detalles'}")
|
||||||
document_response = await pedimento_rest_controller.post_document(
|
document_response = await pedimento_rest_controller.post_or_update_document(
|
||||||
soap_response=None,
|
soap_response=soap_response,
|
||||||
organizacion=pedimento_data.get('organizacion'),
|
organizacion=pedimento_data.get('organizacion'),
|
||||||
pedimento=pedimento_data.get('id'),
|
pedimento=pedimento_data.get('id'),
|
||||||
file_name=f"vu_PC_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
file_name=f"vu_PC_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
||||||
document_type=14,
|
document_type=14,
|
||||||
)
|
)
|
||||||
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
||||||
|
|
||||||
@@ -111,12 +111,12 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
|||||||
|
|
||||||
# Enviar documento
|
# Enviar documento
|
||||||
try:
|
try:
|
||||||
document_response = await pedimento_rest_controller.post_document(
|
document_response = await pedimento_rest_controller.post_or_update_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=pedimento_data.get('organizacion'),
|
organizacion=pedimento_data.get('organizacion'),
|
||||||
pedimento=pedimento_data.get('id'),
|
pedimento=pedimento_data.get('id'),
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
document_type=2,
|
document_type=2,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error al enviar documento: {e}")
|
logger.error(f"Error al enviar documento: {e}")
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class APIRESTController:
|
|||||||
self, soap_response=None, organizacion: str = None,
|
self, soap_response=None, organizacion: str = None,
|
||||||
pedimento: str = None, file_name: str = None,
|
pedimento: str = None, file_name: str = None,
|
||||||
document_type: int = None, fuente: int = 2,
|
document_type: int = None, fuente: int = 2,
|
||||||
identifier: str = None,
|
identifier: str = None, binary_content: bytes = None,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Guarda un documento VU (request o error). Si ya existe uno del mismo
|
Guarda un documento VU (request o error). Si ya existe uno del mismo
|
||||||
@@ -124,6 +124,7 @@ class APIRESTController:
|
|||||||
|
|
||||||
return await self.post_document(
|
return await self.post_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
|
binary_content=binary_content,
|
||||||
organizacion=organizacion,
|
organizacion=organizacion,
|
||||||
pedimento=pedimento,
|
pedimento=pedimento,
|
||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user