From 69cd3b70d7f0bdf6c1eaf9c743aed27bdd3d172e Mon Sep 17 00:00:00 2001 From: George Date: Wed, 5 Aug 2026 07:44:29 -0500 Subject: [PATCH] =?UTF-8?q?se=20agreg=C3=B3=20la=20validaci=C3=B3n=20si=20?= =?UTF-8?q?el=20cliente=20no=20existe,=20se=20envia=20un=20correo,=20el=20?= =?UTF-8?q?archivo=20para=20a=20la=20carpeta=20erros=20y=20se=20continua?= =?UTF-8?q?=20con=20el=20siguiente=20archivo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/service.py b/service.py index 82bbe0f..c0cdde7 100755 --- a/service.py +++ b/service.py @@ -20,6 +20,7 @@ PROCESSED_DIR = Path("data/processed") OUTPUT_DIR = Path("data/output") HTML_DIR = Path("data/html") SAP_B1_DIR = Path("data/sap_b1") +ERRORS_DIR = Path("data/errors") TEMPLATE_FILE = _BASE / "template.html" POST_TO_SAP_B1 = True @@ -242,10 +243,21 @@ def process_file(xml_path: Path): county = result["County"] log.info("CardCode={} (desde CRD1)".format(cardcode)) else: - cardcode = emisor - city = "" - county = "" - log.info("CardCode={} (fallback emisor)".format(cardcode)) + cardcode = "" + log.warning("No se obtuvo Socio de negocios para el {}.{}".format(emisor, lugar_entrega)) + try: + from mail_sender import send_mail + send_mail( + subject=f"OC {cab.get('numero_oc', '')} — Sin socio de negocios", + text=f"No se obtuvo Socio de negocios para el {emisor}.{lugar_entrega}", + ) + log.info("Correo de notificación enviado") + except Exception as e: + log.warning("Error enviando correo de notificación: {}".format(e)) + ERRORS_DIR.mkdir(parents=True, exist_ok=True) + shutil.move(str(xml_path), str(ERRORS_DIR / xml_path.name)) + log.info("📁 XML movido a errors/") + return item_catalog = get_item_catalog(cardcode) pricelist = get_price_list(cardcode)