se agregó la validación si el cliente no existe, se envia un correo, el archivo para a la carpeta erros y se continua con el siguiente archivo
This commit is contained in:
1 parent
d7c4d532b5
commit
69cd3b70d7
1 file changed
+16
-4
+16
-4
@@ -20,6 +20,7 @@ PROCESSED_DIR = Path("data/processed")
|
|||||||
OUTPUT_DIR = Path("data/output")
|
OUTPUT_DIR = Path("data/output")
|
||||||
HTML_DIR = Path("data/html")
|
HTML_DIR = Path("data/html")
|
||||||
SAP_B1_DIR = Path("data/sap_b1")
|
SAP_B1_DIR = Path("data/sap_b1")
|
||||||
|
ERRORS_DIR = Path("data/errors")
|
||||||
TEMPLATE_FILE = _BASE / "template.html"
|
TEMPLATE_FILE = _BASE / "template.html"
|
||||||
|
|
||||||
POST_TO_SAP_B1 = True
|
POST_TO_SAP_B1 = True
|
||||||
@@ -242,10 +243,21 @@ def process_file(xml_path: Path):
|
|||||||
county = result["County"]
|
county = result["County"]
|
||||||
log.info("CardCode={} (desde CRD1)".format(cardcode))
|
log.info("CardCode={} (desde CRD1)".format(cardcode))
|
||||||
else:
|
else:
|
||||||
cardcode = emisor
|
cardcode = ""
|
||||||
city = ""
|
log.warning("No se obtuvo Socio de negocios para el {}.{}".format(emisor, lugar_entrega))
|
||||||
county = ""
|
try:
|
||||||
log.info("CardCode={} (fallback emisor)".format(cardcode))
|
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)
|
item_catalog = get_item_catalog(cardcode)
|
||||||
pricelist = get_price_list(cardcode)
|
pricelist = get_price_list(cardcode)
|
||||||
|
|||||||
Reference in new issue
Block a user