Added columns for ship to customer and key to match to BPCORD
parent
17233afb2d
commit
8a3985ff0d
|
@ -24,7 +24,8 @@ SHANDEX_SFTP_PASSWORD = "ST@Pass2024$$"
|
||||||
|
|
||||||
INSERT_ORDER = """
|
INSERT_ORDER = """
|
||||||
EXECUTE [staging].[dbo].[shandex_insert_order_detail]
|
EXECUTE [staging].[dbo].[shandex_insert_order_detail]
|
||||||
:customer_order_number
|
:customerkey
|
||||||
|
,:customer_order_number
|
||||||
,:customer_po
|
,:customer_po
|
||||||
,:Order_Type
|
,:Order_Type
|
||||||
,:order_status
|
,:order_status
|
||||||
|
@ -33,6 +34,7 @@ INSERT_ORDER = """
|
||||||
,:ship_date
|
,:ship_date
|
||||||
,:customer_number
|
,:customer_number
|
||||||
,:sold_to_name
|
,:sold_to_name
|
||||||
|
,:ship_to
|
||||||
,:line_number
|
,:line_number
|
||||||
,:supplier_part_number
|
,:supplier_part_number
|
||||||
,:sku
|
,:sku
|
||||||
|
@ -72,7 +74,6 @@ def retrieve_x12_edi_files_shandex():
|
||||||
sftp_connection.rename(filename, new_filename)
|
sftp_connection.rename(filename, new_filename)
|
||||||
|
|
||||||
def process_file(file):
|
def process_file(file):
|
||||||
#open file
|
|
||||||
all_data = []
|
all_data = []
|
||||||
with file.open(encoding="utf-8", newline="") as csv_file:
|
with file.open(encoding="utf-8", newline="") as csv_file:
|
||||||
reader = csv.reader(csv_file)
|
reader = csv.reader(csv_file)
|
||||||
|
@ -80,6 +81,7 @@ def process_file(file):
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row:
|
if row:
|
||||||
key_dict = {
|
key_dict = {
|
||||||
|
"customerkey":row[0] + '_' + row[9],
|
||||||
"customer_order_number":row[0],
|
"customer_order_number":row[0],
|
||||||
"customer_po":row[1],
|
"customer_po":row[1],
|
||||||
"Order_Type":row[2],
|
"Order_Type":row[2],
|
||||||
|
@ -88,24 +90,23 @@ def process_file(file):
|
||||||
"RSD":row[5],
|
"RSD":row[5],
|
||||||
"ship_date":row[6],
|
"ship_date":row[6],
|
||||||
"customer_number":row[7],
|
"customer_number":row[7],
|
||||||
"sold_to_name":row[8],
|
"sold_to_name":row[8],
|
||||||
"line_number":row[9],
|
"ship_to":row[9],
|
||||||
"supplier_part_number":row[10],
|
"line_number":row[10],
|
||||||
"sku":row[11],
|
"supplier_part_number":row[11],
|
||||||
"description":row[12],
|
"sku":row[12],
|
||||||
"qty_ordered":row[13],
|
"description":row[13],
|
||||||
"qty_picked":row[14],
|
"qty_ordered":row[14],
|
||||||
"qty_shorted":row[15],
|
"qty_picked":row[15],
|
||||||
"uom":row[16],
|
"qty_shorted":row[16],
|
||||||
"unit_price":row[17],
|
"uom":row[17],
|
||||||
|
"unit_price":row[18],
|
||||||
}
|
}
|
||||||
all_data.append(key_dict)
|
all_data.append(key_dict)
|
||||||
if(all_data):
|
if(all_data):
|
||||||
with yamamotoyama.get_connection() as data_base:
|
with yamamotoyama.get_connection() as data_base:
|
||||||
with data_base.transaction():
|
with data_base.transaction():
|
||||||
data_base.bulk_query(INSERT_ORDER, all_data)
|
data_base.bulk_query(INSERT_ORDER, all_data)
|
||||||
#load vars and insert
|
|
||||||
#archive
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue