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