From 6092eaa5321a13cb584d57bfd6ed249272418fac Mon Sep 17 00:00:00 2001 From: bleeson Date: Fri, 7 Feb 2025 13:24:18 -0800 Subject: [PATCH] Adjustment to 944s for imports and minor updates --- edi_850.py | 14 ++++++++------ edi_944.py | 17 +++++++++++++---- edi_997_outbound.py | 1 + master_contoller.py | 2 ++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/edi_850.py b/edi_850.py index f6fcf7e..c2b6f80 100644 --- a/edi_850.py +++ b/edi_850.py @@ -49,7 +49,7 @@ def new_850_alert(ordref, orddat): msg['Subject'] = 'New PO from Shandex' msg['Precedence'] = 'bulk' msg['From'] = 'x3report@stashtea.com' - msg['To'] = 'icortes@yamamotoyama.com' + msg['To'] = 'icortes@yamamotoyama.com,alai@yamamotoyama.com,sbravo@yamamotoyama.com,scplanning@yamamotoyama.com' msg['CC'] = 'bleeson@stashtea.com' emailtext = f'Ref: {ordref}\nDate: {orddat}' msg.attach(MIMEText(emailtext, 'plain')) @@ -59,15 +59,15 @@ def new_850_alert(ordref, orddat): def combine_zpohs(): """ - Collect all ZPOH imports into a single file for easy import. + Collect all ZPOHB imports into a single file for easy import. """ archive_directory = IMPORTS_DIRECTORY / "archive" archive_directory.mkdir(exist_ok=True) - with (IMPORTS_DIRECTORY / "ZPOH.dat").open( + with (IMPORTS_DIRECTORY / "ZPOHB.dat").open( "w", encoding="utf-8", newline="\n" ) as combined_import_file: for individual_import_filename in IMPORTS_DIRECTORY.glob( - "ZPOH_*.dat" + "ZPOHB_*.dat" ): with individual_import_filename.open( "r", encoding="utf-8", newline="\n" @@ -137,7 +137,7 @@ def process_file(edi_filename: pathlib.Path): time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") new_850_alert(ordref, purchase_order.header.orddat)#TODO new alert type, after it hits X3? with yamamotoyama.x3_imports.open_import_file( - IMPORTS_DIRECTORY / f"ZPOH_{purchase_order.header.ordref}_{time_stamp}.dat" + IMPORTS_DIRECTORY / f"ZPOHB_{purchase_order.header.ordref}_{time_stamp}.dat" ) as import_file: purchase_order.output(import_file) @@ -211,13 +211,14 @@ class PODetail: @dataclasses.dataclass class POHeader: """ - Information that goes on a po header, taken from ZPOH template. + Information that goes on a po header, taken from ZPOHB template. """ pohfcy: str = "" pohnum: str = "" orddat: datetime.date = datetime.date(1753, 1, 1) bpsnum: str = "" + buy: str = "SC001" ordref: str = "" bpsnum: str = "" cur: str = "USD" @@ -238,6 +239,7 @@ class POHeader: '',#self.pohnum, self.orddat.strftime("%Y%m%d"), self.bpsnum, + self.buy, self.ordref, self.cur, self.star71, diff --git a/edi_944.py b/edi_944.py index 7460bf0..9a2d70a 100644 --- a/edi_944.py +++ b/edi_944.py @@ -40,7 +40,7 @@ def main(): if SHANDEX_944_FILENAME_RE.match(edi_filename.name): process_file(edi_filename) # file moved to 997 processing folder to be sent later - shutil.move(edi_filename, EDI_997_DIRECTORY / edi_filename.name) + shutil.move(edi_filename, EDI_997_DIRECTORY / edi_filename.name)#TODO uncomment combine_zpthis() @@ -49,7 +49,7 @@ def new_944_alert(sdhnum, pohnum, rcpdat): msg['Subject'] = 'New Receipt from Shandex' msg['Precedence'] = 'bulk' msg['From'] = 'x3report@stashtea.com' - msg['To'] = 'isenn@yamamotoyama.com' + msg['To'] = 'icortes@yamamotoyama.com,mdelacruz@yamamotoyama.com,dalmanza@yamamotoyama.com,jpena@yamamotoyama.com' msg['CC'] = 'bleeson@stashtea.com' emailtext = f'Delivery: {sdhnum}\nPO: {pohnum}\nDate: {rcpdat}' msg.attach(MIMEText(emailtext, 'plain')) @@ -63,7 +63,7 @@ def validation_alert(sdhnum): msg['Subject'] = 'New Receipt from Shandex' msg['Precedence'] = 'bulk' msg['From'] = 'x3report@stashtea.com' - msg['To'] = 'isenn@yamamotoyama.com' + msg['To'] = 'icortes@yamamotoyama.com,mdelacruz@yamamotoyama.com,dalmanza@yamamotoyama.com,jpena@yamamotoyama.com' msg['CC'] = 'bleeson@stashtea.com' emailtext = f'A Shandex receipt for {sdhnum} could not be loaded into X3 because the shipment is not validated.' msg.attach(MIMEText(emailtext, 'plain')) @@ -189,6 +189,8 @@ def process_file(edi_filename: pathlib.Path): ), subdetail, ) + for thing in warehouse_receipt.details: + pprint.pprint(thing) time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") new_944_alert(sdhnum, pohnum, warehouse_receipt.header.rcpdat) with yamamotoyama.x3_imports.open_import_file( @@ -211,6 +213,9 @@ class ReceiptSubDetail: bpslot: str = "" sernum: str = "" + def append(self, receipt_subdetail): + self.qtypcu += receipt_subdetail.qtypcu + def stojous(self, shipment, item) -> typing.List[str]: """ Convert grouped lot quantities into individual STOJOU records to fit on receipt @@ -442,7 +447,11 @@ class ReceiptDetailList: itmref = receipt_detail.itmref if itmref in self._item_set: for detail in self._details: - if detail == itmref: + for subdetail in detail.subdetails: + if subdetail.lot == receipt_subdetail.lot: + subdetail.append(receipt_subdetail) + return + if detail.itmref == itmref: detail.subdetails.append(receipt_subdetail) return self._item_set.add(itmref) diff --git a/edi_997_outbound.py b/edi_997_outbound.py index 29e39a1..fc84e36 100644 --- a/edi_997_outbound.py +++ b/edi_997_outbound.py @@ -28,6 +28,7 @@ AK1_MAPPING = { "947" : "AW", "846" : "IB", "867" : "PT", +"850" : "PO", } def main(): diff --git a/master_contoller.py b/master_contoller.py index 27359e4..1154ad6 100644 --- a/master_contoller.py +++ b/master_contoller.py @@ -17,6 +17,7 @@ import update_shandex_dashboard import edi_943 import unprocessed_files_report import import_867s +import edi_850 THIS_DIRECTORY = pathlib.Path(__file__).parent X12_SHANDEX_OUTGOING = THIS_DIRECTORY / "outgoing" @@ -38,6 +39,7 @@ def main(): edi_944.main() edi_947.main() edi_846.main() + edi_850.main() edi_867_to_table.main() import_867s.main()