Adjustment to 944s for imports and minor updates

master
bleeson 2025-02-07 13:24:18 -08:00
parent dd7fc8f119
commit 6092eaa532
4 changed files with 24 additions and 10 deletions

View File

@ -49,7 +49,7 @@ def new_850_alert(ordref, orddat):
msg['Subject'] = 'New PO from Shandex' msg['Subject'] = 'New PO from Shandex'
msg['Precedence'] = 'bulk' msg['Precedence'] = 'bulk'
msg['From'] = 'x3report@stashtea.com' 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' msg['CC'] = 'bleeson@stashtea.com'
emailtext = f'Ref: {ordref}\nDate: {orddat}' emailtext = f'Ref: {ordref}\nDate: {orddat}'
msg.attach(MIMEText(emailtext, 'plain')) msg.attach(MIMEText(emailtext, 'plain'))
@ -59,15 +59,15 @@ def new_850_alert(ordref, orddat):
def combine_zpohs(): 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 = IMPORTS_DIRECTORY / "archive"
archive_directory.mkdir(exist_ok=True) archive_directory.mkdir(exist_ok=True)
with (IMPORTS_DIRECTORY / "ZPOH.dat").open( with (IMPORTS_DIRECTORY / "ZPOHB.dat").open(
"w", encoding="utf-8", newline="\n" "w", encoding="utf-8", newline="\n"
) as combined_import_file: ) as combined_import_file:
for individual_import_filename in IMPORTS_DIRECTORY.glob( for individual_import_filename in IMPORTS_DIRECTORY.glob(
"ZPOH_*.dat" "ZPOHB_*.dat"
): ):
with individual_import_filename.open( with individual_import_filename.open(
"r", encoding="utf-8", newline="\n" "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") 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? new_850_alert(ordref, purchase_order.header.orddat)#TODO new alert type, after it hits X3?
with yamamotoyama.x3_imports.open_import_file( 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: ) as import_file:
purchase_order.output(import_file) purchase_order.output(import_file)
@ -211,13 +211,14 @@ class PODetail:
@dataclasses.dataclass @dataclasses.dataclass
class POHeader: 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 = "" pohfcy: str = ""
pohnum: str = "" pohnum: str = ""
orddat: datetime.date = datetime.date(1753, 1, 1) orddat: datetime.date = datetime.date(1753, 1, 1)
bpsnum: str = "" bpsnum: str = ""
buy: str = "SC001"
ordref: str = "" ordref: str = ""
bpsnum: str = "" bpsnum: str = ""
cur: str = "USD" cur: str = "USD"
@ -238,6 +239,7 @@ class POHeader:
'',#self.pohnum, '',#self.pohnum,
self.orddat.strftime("%Y%m%d"), self.orddat.strftime("%Y%m%d"),
self.bpsnum, self.bpsnum,
self.buy,
self.ordref, self.ordref,
self.cur, self.cur,
self.star71, self.star71,

View File

@ -40,7 +40,7 @@ def main():
if SHANDEX_944_FILENAME_RE.match(edi_filename.name): if SHANDEX_944_FILENAME_RE.match(edi_filename.name):
process_file(edi_filename) process_file(edi_filename)
# file moved to 997 processing folder to be sent later # 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() combine_zpthis()
@ -49,7 +49,7 @@ def new_944_alert(sdhnum, pohnum, rcpdat):
msg['Subject'] = 'New Receipt from Shandex' msg['Subject'] = 'New Receipt from Shandex'
msg['Precedence'] = 'bulk' msg['Precedence'] = 'bulk'
msg['From'] = 'x3report@stashtea.com' 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' msg['CC'] = 'bleeson@stashtea.com'
emailtext = f'Delivery: {sdhnum}\nPO: {pohnum}\nDate: {rcpdat}' emailtext = f'Delivery: {sdhnum}\nPO: {pohnum}\nDate: {rcpdat}'
msg.attach(MIMEText(emailtext, 'plain')) msg.attach(MIMEText(emailtext, 'plain'))
@ -63,7 +63,7 @@ def validation_alert(sdhnum):
msg['Subject'] = 'New Receipt from Shandex' msg['Subject'] = 'New Receipt from Shandex'
msg['Precedence'] = 'bulk' msg['Precedence'] = 'bulk'
msg['From'] = 'x3report@stashtea.com' 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' msg['CC'] = 'bleeson@stashtea.com'
emailtext = f'A Shandex receipt for {sdhnum} could not be loaded into X3 because the shipment is not validated.' emailtext = f'A Shandex receipt for {sdhnum} could not be loaded into X3 because the shipment is not validated.'
msg.attach(MIMEText(emailtext, 'plain')) msg.attach(MIMEText(emailtext, 'plain'))
@ -189,6 +189,8 @@ def process_file(edi_filename: pathlib.Path):
), ),
subdetail, subdetail,
) )
for thing in warehouse_receipt.details:
pprint.pprint(thing)
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
new_944_alert(sdhnum, pohnum, warehouse_receipt.header.rcpdat) new_944_alert(sdhnum, pohnum, warehouse_receipt.header.rcpdat)
with yamamotoyama.x3_imports.open_import_file( with yamamotoyama.x3_imports.open_import_file(
@ -211,6 +213,9 @@ class ReceiptSubDetail:
bpslot: str = "" bpslot: str = ""
sernum: str = "" sernum: str = ""
def append(self, receipt_subdetail):
self.qtypcu += receipt_subdetail.qtypcu
def stojous(self, shipment, item) -> typing.List[str]: def stojous(self, shipment, item) -> typing.List[str]:
""" """
Convert grouped lot quantities into individual STOJOU records to fit on receipt Convert grouped lot quantities into individual STOJOU records to fit on receipt
@ -442,7 +447,11 @@ class ReceiptDetailList:
itmref = receipt_detail.itmref itmref = receipt_detail.itmref
if itmref in self._item_set: if itmref in self._item_set:
for detail in self._details: 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) detail.subdetails.append(receipt_subdetail)
return return
self._item_set.add(itmref) self._item_set.add(itmref)

View File

@ -28,6 +28,7 @@ AK1_MAPPING = {
"947" : "AW", "947" : "AW",
"846" : "IB", "846" : "IB",
"867" : "PT", "867" : "PT",
"850" : "PO",
} }
def main(): def main():

View File

@ -17,6 +17,7 @@ import update_shandex_dashboard
import edi_943 import edi_943
import unprocessed_files_report import unprocessed_files_report
import import_867s import import_867s
import edi_850
THIS_DIRECTORY = pathlib.Path(__file__).parent THIS_DIRECTORY = pathlib.Path(__file__).parent
X12_SHANDEX_OUTGOING = THIS_DIRECTORY / "outgoing" X12_SHANDEX_OUTGOING = THIS_DIRECTORY / "outgoing"
@ -38,6 +39,7 @@ def main():
edi_944.main() edi_944.main()
edi_947.main() edi_947.main()
edi_846.main() edi_846.main()
edi_850.main()
edi_867_to_table.main() edi_867_to_table.main()
import_867s.main() import_867s.main()