Added leftover file alerts, removed comments from 944s, leftover function added to master_controller

master
bleeson 2025-06-13 08:50:10 -07:00
parent c14ea359aa
commit 831cefb2d7
3 changed files with 41 additions and 5 deletions

View File

@ -77,7 +77,7 @@ def main():
if SHANDEX_944_FILENAME_RE.match(edi_filename.name):
determine_edi_action(edi_filename)
# file moved to 997 processing folder to be sent later
# shutil.move(edi_filename, EDI_997_DIRECTORY / edi_filename.name)#TODO uncomment
shutil.move(edi_filename, EDI_997_DIRECTORY / edi_filename.name)
def determine_edi_action(edi_filename: pathlib.Path):
@ -90,7 +90,7 @@ def determine_edi_action(edi_filename: pathlib.Path):
transaction = ''
for fields in tokens_from_edi_file(edi_filename):
if fields[0] == "W17":
transaction = fields[4]
transaction = fields[5]
break
pprint.pprint(transaction)
if transaction:
@ -252,7 +252,7 @@ def process_intersite_receipt(edi_filename: pathlib.Path):
subdetail,
)
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
#import_receipt(warehouse_receipt)#TODO uncomment
import_receipt(warehouse_receipt)
def import_receipt(warehouse_receipt):

36
leftover_file_alerts.py Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""
Shandex version, check for unprocessed EDI files and alert
that there is a problem of some kind, all files should move out of
these folders for each run of master controller
"""
import pprint
import pathlib
import simple_email_notification
#The directories we want to check for a leftover file
THIS_DIRECTORY = pathlib.Path(__file__).parent
OUTGOING_DIRECTORY = THIS_DIRECTORY / 'outgoing'
INCOMING_DIRECTORY = THIS_DIRECTORY / 'incoming'
MONITOR_LIST = [OUTGOING_DIRECTORY, INCOMING_DIRECTORY]
def main():
"""
Check for leftover files which means something unexpected happened.
"""
file_count = []
for path in MONITOR_LIST:
for file in path.iterdir():
if file.name[-4:] == '.edi' or file.name[-4:] == '.txt':
file_count.append(f'{path}\\{file.name}')
if file_count:
simple_email_notification.email_noticication(
['bleeson@stashtea.com','icarrera@yamamotoyama.com'],
'Shandex EDI leftover files',
file_count
)
if __name__ == "__main__":
main()

View File

@ -16,10 +16,10 @@ import edi_867_to_table
import edi_997_outbound
import update_shandex_dashboard
import edi_943
import unprocessed_files_report
import import_867s
import import_944s
import edi_850
import leftover_file_alerts
THIS_DIRECTORY = pathlib.Path(__file__).parent
X12_SHANDEX_OUTGOING = THIS_DIRECTORY / "outgoing"
@ -58,7 +58,7 @@ def main():
#update_shandex_dashboard.main()
#report on anything not handled
#unprocessed_files_report.main()
leftover_file_alerts.main()