From bb8cf98dbb1774284c5354e9e4bf283c10413714 Mon Sep 17 00:00:00 2001 From: bleeson Date: Tue, 18 Jun 2024 14:39:56 -0700 Subject: [PATCH] Better report for 944s. Customer maps for 867s. --- edi_867.py | 7 ++++- edi_944.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 84 insertions(+), 10 deletions(-) diff --git a/edi_867.py b/edi_867.py index 3bb6ec6..c84a8d4 100644 --- a/edi_867.py +++ b/edi_867.py @@ -67,6 +67,8 @@ X3_CUSTOMER_MAPPING = { 'SAMP1000_0000' : 'YARI0001', 'PURI1000_PURIQC' : 'PURI0005', 'JIVA1000_JIVABC' : 'JIVA0002', + 'WELL1000_WELL' : 'WELL0002', + 'WELL1000_WELCAL' : 'WELL0003', } def main(): @@ -182,6 +184,7 @@ def process_file(edi_filename: pathlib.Path): shipping_date = '' previous_picking_number = '' po_number = '' + cust_po_number = '' warehouse_shipment = WarehouseShipment() for fields in tokens_from_edi_file(edi_filename): if fields[0] == "DTM": @@ -190,7 +193,7 @@ def process_file(edi_filename: pathlib.Path): picking_number = fields[5] warehouse_shipment.header.ylicplate = f'{previous_picking_number}' if po_number != '': - warehouse_shipment.header.yclippership = warehouse_shipment.header.ylicplate + warehouse_shipment.header.yclippership = cust_po_number warehouse_shipment.header.ylicplate = f'{po_number}' if picking_number != previous_picking_number and previous_picking_number != '': if warehouse_shipment.header.bpdnam != 'Shandex Group': @@ -206,6 +209,8 @@ def process_file(edi_filename: pathlib.Path): po_number = '' warehouse_shipment.header.ylicplate = f'{picking_number}' previous_picking_number = picking_number + if fields[0] =='REF' and fields[1] == 'PO': + cust_po_number = fields[2] if fields[0] =='REF' and fields[1] == 'IL': po_number = fields[2] if fields[0] == "N1" and fields[1] == 'ST': diff --git a/edi_944.py b/edi_944.py index dfb4c75..d529147 100644 --- a/edi_944.py +++ b/edi_944.py @@ -14,6 +14,9 @@ import re import shutil import typing import pprint +import smtplib +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText import records # type: ignore @@ -26,14 +29,14 @@ IMPORTS_DIRECTORY = THIS_DIRECTORY / "x3_imports" EDI_997_DIRECTORY = THIS_DIRECTORY / "997_processing" SHANDEX_944_FILENAME_RE = re.compile( - r"\A 944_YAMAMOTOYAMA_ \S+ [.]edi \Z", re.X | re.M | re.S + r"\A 944_STASH-YAMAMOTOYAMA_ \S+ [.]edi \Z", re.X | re.M | re.S ) def main(): """ Do it! """ - for edi_filename in X12_DIRECTORY.iterdir(): #TODO uncomment and review + for edi_filename in X12_DIRECTORY.iterdir(): if SHANDEX_944_FILENAME_RE.match(edi_filename.name): process_file(edi_filename) # file moved to 997 processing folder to be sent later @@ -41,6 +44,33 @@ def main(): combine_zpthis() +def new_944_alert(sdhnum, pohnum, rcpdat): + msg = MIMEMultipart() + msg['Subject'] = 'New Receipt from Shandex' + msg['Precedence'] = 'bulk' + msg['From'] = 'x3report@stashtea.com' + msg['To'] = 'isenn@yamamotoyama.com' + msg['CC'] = 'bleeson@stashtea.com' + emailtext = f'Delivery: {sdhnum}\nPO: {pohnum}\nDate: {rcpdat}' + msg.attach(MIMEText(emailtext, 'plain')) + with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp: + smtp.login(user='x3reportmk2@yamamotoyama.com', password=r'n