Added X3 information to return.
parent
d6606e0c17
commit
9184f0dce5
|
@ -218,9 +218,9 @@ def process_return(edi_filename: pathlib.Path):
|
|||
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':
|
||||
#N9*ZZ*INFO
|
||||
reason = fields[2]
|
||||
if fields[0] == 'N9' and fields[1] == 'ZZ' and fields[2] == 'INFO':
|
||||
#N9*ZZ*INFO*REFUSAL AS OVERAGE
|
||||
reason = fields[3]
|
||||
if fields[0] == 'N9' and fields[1] == 'CR':
|
||||
shandex_customer = fields[2]
|
||||
shandex_customer = customer_map_lookup(shandex_customer + '%') + '\n'
|
||||
|
@ -232,13 +232,30 @@ def process_return(edi_filename: pathlib.Path):
|
|||
uom = fix_uom(uom)
|
||||
line_data.append(f'{x3_sku}, {gtin}, {qty_str}, {uom}, {lot}')
|
||||
customer_info = customer_lookup(po)
|
||||
line_data = [f'Return#: {return_num}\n' + customer_info + f'Return date: {rcpdat}\nReason: {reason}\nPO: {po}\nCases: {running_sum}'] + line_data
|
||||
simple_email_notification.email_noticication(['bleeson@stashtea.com','scrinvoices@stashtea.com','business@stashtea.com'],
|
||||
'Shandex Return',line_data)
|
||||
shipment_info = shipment_lookup(po)
|
||||
line_data = [f'Return#: {return_num}\n' + customer_info + shipment_info +f'Return date: {rcpdat}\nReason: {reason}\nPO: {po}\nCases: {running_sum}'] + line_data
|
||||
simple_email_notification.email_noticication(['bleeson@stashtea.com','scrinvoices@stashtea.com','business@stashtea.com'],'Shandex Return',line_data)
|
||||
# simple_email_notification.email_noticication(['bleeson@stashtea.com'],#testing
|
||||
# f'New Shandex Return {return_num}',line_data)
|
||||
|
||||
|
||||
def shipment_lookup(po_number):
|
||||
with yamamotoyama.get_connection() as data_base:
|
||||
result = data_base.query(
|
||||
"""
|
||||
SELECT
|
||||
string_agg(SDH.SDHNUM_0+' - '+SDH.BPCORD_0,', ')[Customers]
|
||||
FROM [staging].[dbo].[shandex_shipments]
|
||||
left join x3.PROD.SDELIVERY SDH
|
||||
on [shandex_shipments].ylicplate = SDH.YLICPLATE_0
|
||||
and SDH.STOFCY_0 = 'WON'
|
||||
where yclippership = :po_number
|
||||
""",
|
||||
po_number=po_number,
|
||||
).first()
|
||||
return f"X3 Shipment Info: {result['Customers']}\n"
|
||||
|
||||
|
||||
def customer_map_lookup(customer_code):
|
||||
possible_customers = []
|
||||
with yamamotoyama.get_connection() as data_base:
|
||||
|
|
Loading…
Reference in New Issue