fix: peticiones.py usa pedimento_app + post_or_update_document (T2025-09-004)
El stack viejo de descarga (utils/peticiones.py, via api_v1 + signal en backend) armaba el nombre con campos crudos en vez de pedimento_app (vu_EDC, app 042_240_...) y posteaba con post_document (sin reemplazar) -> documentos sin ligar la FK y partidas duplicadas. Las 8 funciones get_soap_* (pedimento_completo, remesas, partidas, acuse, acuseCOVE, estado, edocument, cove) ahora arman el nombre con pedimento_app (identico a api_v2) y postean con post_or_update_document + identifier. Corrige tambien el prefijo vu_EDC -> vu_ED. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -301,14 +301,17 @@ async def get_soap_pedimento_completo(credenciales, response_service, soap_contr
|
||||
tipo_operacion = data.get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
|
||||
_file_name = f"vu_PC_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}.xml"
|
||||
# T2025-09-004: nombre canónico con pedimento_app (igual que api_v2) y
|
||||
# post_or_update_document para reemplazar el previo en vez de duplicar.
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_PC_{pedimento_app}.xml"
|
||||
# Enviar el documento XML como respuesta
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=2,
|
||||
document_type=2,
|
||||
)
|
||||
|
||||
data['organizacion'] = response_service['organizacion']
|
||||
@@ -392,9 +395,11 @@ async def get_soap_remesas(credenciales, response_service, soap_controller): # T
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
|
||||
_file_name = f"vu_RM_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}.xml"
|
||||
# T2025-09-004: pedimento_app + post_or_update_document (no duplicar).
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_RM_{pedimento_app}.xml"
|
||||
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
@@ -481,7 +486,9 @@ async def get_soap_partidas(credenciales, response_service, soap_controller, par
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
|
||||
_file_name = f"vu_PT_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}_{partida}.xml"
|
||||
# T2025-09-004: pedimento_app (igual que api_v2) en lugar de campos crudos.
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_PT_{pedimento_app}_{partida}.xml"
|
||||
|
||||
|
||||
# Aqui entra proceso de alonso
|
||||
@@ -497,12 +504,13 @@ async def get_soap_partidas(credenciales, response_service, soap_controller, par
|
||||
# 4. Generar una respues
|
||||
|
||||
# Enviar el documento XML como respuesta
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=1
|
||||
document_type=1,
|
||||
identifier=f"_PT_{pedimento_app}_{partida}_",
|
||||
)
|
||||
|
||||
|
||||
@@ -603,16 +611,19 @@ async def get_soap_acuse(credenciales, response_service, soap_controller, edocum
|
||||
no_partidas = response_service['pedimento'].get('numero_partidas', 0)
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
_file_name = f"vu_AC_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}_{edocument['numero_edocument']}.pdf"
|
||||
|
||||
# T2025-09-004: pedimento_app + post_or_update_document (no duplicar).
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_AC_{pedimento_app}_{edocument['numero_edocument']}.pdf"
|
||||
|
||||
# Enviar el documento PDF usando binary_content
|
||||
logger.info(f"Enviando documento PDF: {_file_name} ({len(pdf_bytes)} bytes)")
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
binary_content=pdf_bytes,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=4
|
||||
document_type=4,
|
||||
identifier=edocument['numero_edocument'],
|
||||
)
|
||||
return {
|
||||
"servicio": response_service,
|
||||
@@ -710,16 +721,19 @@ async def get_soap_acuseCOVE(credenciales, response_service, soap_controller, co
|
||||
no_partidas = response_service['pedimento'].get('numero_partidas', 0)
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
_file_name = f"vu_AC_COVE_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}_{cove['numero_cove']}.pdf"
|
||||
# T2025-09-004: pedimento_app + post_or_update_document (no duplicar).
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_AC_COVE_{pedimento_app}_{cove['numero_cove']}.pdf"
|
||||
|
||||
# Enviar el documento PDF usando binary_content
|
||||
logger.info(f"Enviando documento PDF: {_file_name} ({len(pdf_bytes)} bytes)")
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
binary_content=pdf_bytes,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=7
|
||||
document_type=7,
|
||||
identifier=cove['numero_cove'],
|
||||
)
|
||||
return {
|
||||
"servicio": response_service,
|
||||
@@ -781,9 +795,11 @@ async def get_estado_pedimento(credenciales, response_service, soap_controller):
|
||||
tipo_operacion = data.get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
|
||||
_file_name = f"vu_EP_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}.xml"
|
||||
# T2025-09-004: pedimento_app + post_or_update_document (no duplicar).
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_EP_{pedimento_app}.xml"
|
||||
# Enviar el documento XML como respuesta
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
@@ -884,16 +900,19 @@ async def get_soap_edocument(credenciales, response_service, soap_controller, ed
|
||||
no_partidas = response_service['pedimento'].get('numero_partidas', 0)
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
_file_name = f"vu_EDC_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}_{edocument['numero_edocument']}.pdf"
|
||||
# T2025-09-004: prefijo vu_ED (no vu_EDC) + pedimento_app + post_or_update_document.
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_ED_{pedimento_app}_{edocument['numero_edocument']}.pdf"
|
||||
|
||||
# Enviar el documento PDF usando binary_content
|
||||
logger.info(f"Enviando documento PDF: {_file_name} ({len(pdf_bytes)} bytes)")
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
binary_content=pdf_bytes,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=5
|
||||
document_type=5,
|
||||
identifier=edocument['numero_edocument'],
|
||||
)
|
||||
return {
|
||||
"servicio": response_service,
|
||||
@@ -1000,14 +1019,17 @@ async def get_soap_cove(credenciales, response_service, soap_controller, cove, i
|
||||
tipo_operacion = response_service['pedimento'].get('tipo_operacion', 'N/A')
|
||||
pedimento = response_service['pedimento'].get('pedimento', 'N/A')
|
||||
|
||||
_file_name = f"vu_COVE_{remesas}{no_partidas}{tipo_operacion}_{aduana}_{patente}_{pedimento}_{cove['numero_cove']}.xml"
|
||||
# T2025-09-004: pedimento_app + post_or_update_document (no duplicar).
|
||||
pedimento_app = response_service['pedimento'].get('pedimento_app', 'N/A')
|
||||
_file_name = f"vu_COVE_{pedimento_app}_{cove['numero_cove']}.xml"
|
||||
|
||||
document_response = await rest_controller.post_document(
|
||||
document_response = await rest_controller.post_or_update_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=response_service['organizacion'],
|
||||
pedimento=response_service['pedimento']['id'],
|
||||
file_name=_file_name,
|
||||
document_type=8,
|
||||
document_type=8,
|
||||
identifier=cove['numero_cove'],
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user