Minor changes to format at production introduction.

master
bleeson 2025-09-08 13:55:41 -07:00
parent 467e489ea8
commit 46556990a0
1 changed files with 25 additions and 6 deletions

View File

@ -34,7 +34,7 @@ SHANDEX_944_FILENAME_RE = re.compile(
)
SHANDEX_RETURN_944_FILENAME_RE = re.compile(
r"\A 944_RET_YAMAMOTOYAMA.*[.]edi\Z", re.X | re.M | re.S
r"\A 944_RET_STASH-YAMAMOTOYAMA.*[.]edi\Z", re.X | re.M | re.S
)
INSERT_RECEIPT = """
@ -156,6 +156,23 @@ def find_shipment_line(sdhnum, itmref):
return result
def find_coman_po_line(sdhnum, itmref):
with yamamotoyama.get_connection() as database:
result = database.query(
"""
select
POPLIN_0
from PROD.PORDERQ
where
POHNUM_0 = :sdhnum
and ITMREF_0 = :itmref
""",
sdhnum=sdhnum,
itmref=itmref
).first()['POPLIN_0']
return result
def check_shipment_status(delivery):
with yamamotoyama.get_connection() as database:
result = database.query(
@ -196,12 +213,14 @@ def process_return(edi_filename: pathlib.Path):
if fields[0] == "W17":
#_, _, rcpdat, _, sohnum, sdhnum = fields[:6]
#W17*F*20250327*143365*RA9000022
_, _, rcpdat, _, return_num, sohnum_0 = fields[:6]
#W17*F*20250826*147651*RA1729253
_, _, rcpdat, _, return_num = fields[:5]
rcpdat = datetime.datetime.strptime(rcpdat, "%Y%m%d").date() # 20230922
if fields[0] == 'N9' and fields[1] == 'PO':
po = fields[2]
if fields[0] == 'N9' and fields[1] == 'ZZ':
reason = fields[3]
#N9*ZZ*INFO
reason = fields[2]
if fields[0] == 'N9' and fields[1] == 'CR':
shandex_customer = fields[2]
shandex_customer = customer_map_lookup(shandex_customer + '%') + '\n'
@ -352,8 +371,8 @@ def process_coman_receipt(edi_filename: pathlib.Path):
for fields in tokens_from_edi_file(edi_filename):
if fields[0] == "W17":
_, _, rcpdat, _, pohnum = fields[:5]
warehouse_receipt.sdhnum = get_coman_shipment(pohnum)
validated = check_shipment_status(warehouse_receipt.sdhnum)
warehouse_receipt.sdhnum = pohnum
#validated = check_shipment_status(warehouse_receipt.sdhnum)
warehouse_receipt.header.rcpdat = datetime.datetime.strptime(
rcpdat, "%Y%m%d"
).date() # 20230922
@ -372,7 +391,7 @@ def process_coman_receipt(edi_filename: pathlib.Path):
if fields[0] == 'N9' and fields[1] == 'LI':
# N9*LI*1000
#line = fields[2] #This line isn't the line number from X3, it needs to be looked up
line = find_shipment_line(warehouse_receipt.sdhnum, itmref)
line = find_coman_po_line_line(warehouse_receipt.sdhnum, itmref)
warehouse_receipt.append(
ReceiptDetail(
sdhnum=warehouse_receipt.sdhnum,