Order import template change for ship date problem.
parent
4cef690956
commit
ec5a81fbdc
|
@ -2,7 +2,7 @@
|
||||||
"""
|
"""
|
||||||
Pull shipment files from the Stash AWS FTP.
|
Pull shipment files from the Stash AWS FTP.
|
||||||
After copying file, move file to archive folder on FTP.
|
After copying file, move file to archive folder on FTP.
|
||||||
Create ZSHPORD import files, which X3 will consume on a schedule via ZECMSL recurring task.
|
Create ZSHPORDE import files, which X3 will consume on a schedule via ZECMSL recurring task.
|
||||||
Copy file to the archive and then pass it to the shipment maker directory.
|
Copy file to the archive and then pass it to the shipment maker directory.
|
||||||
|
|
||||||
TODO: Source needs to send us real data for final adjustments (site, discount, multilot, etc.)
|
TODO: Source needs to send us real data for final adjustments (site, discount, multilot, etc.)
|
||||||
|
@ -80,15 +80,15 @@ def retrieve_x12_edi_files():
|
||||||
|
|
||||||
def combine_zshpords():
|
def combine_zshpords():
|
||||||
"""
|
"""
|
||||||
Collect all ZSHPORD imports into a single file for easy import.
|
Collect all ZSHPORDE imports into a single file for easy import.
|
||||||
"""
|
"""
|
||||||
archive_directory = SOH_IMPORT_DIRECTORY / "archive"
|
archive_directory = SOH_IMPORT_DIRECTORY / "archive"
|
||||||
archive_directory.mkdir(exist_ok=True)
|
archive_directory.mkdir(exist_ok=True)
|
||||||
with (SOH_IMPORT_DIRECTORY / "ZSHPORD.dat").open(
|
with (SOH_IMPORT_DIRECTORY / "ZSHPORDE.dat").open(
|
||||||
"w", encoding="utf-8", newline="\n"
|
"w", encoding="utf-8", newline="\n"
|
||||||
) as combined_import_file:
|
) as combined_import_file:
|
||||||
for individual_import_filename in SOH_IMPORT_DIRECTORY.glob(
|
for individual_import_filename in SOH_IMPORT_DIRECTORY.glob(
|
||||||
"ZSHPORD_*.dat"
|
"ZSHPORDE_*.dat"
|
||||||
):
|
):
|
||||||
with individual_import_filename.open(
|
with individual_import_filename.open(
|
||||||
"r", encoding="utf-8", newline="\n"
|
"r", encoding="utf-8", newline="\n"
|
||||||
|
@ -115,7 +115,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
if sales_order.header.cusordref != '':
|
if sales_order.header.cusordref != '':
|
||||||
with yamamotoyama.x3_imports.open_import_file(
|
with yamamotoyama.x3_imports.open_import_file(
|
||||||
SOH_IMPORT_DIRECTORY / f"ZSHPORD_{previous_order}_{time_stamp}_{sales_order.header.cusordref}.dat"
|
SOH_IMPORT_DIRECTORY / f"ZSHPORDE_{previous_order}_{time_stamp}_{sales_order.header.cusordref}.dat"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
sales_order.output(import_file)
|
sales_order.output(import_file)
|
||||||
sales_order = SalesOrder()
|
sales_order = SalesOrder()
|
||||||
|
@ -134,6 +134,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
ship_site = row[0]
|
ship_site = row[0]
|
||||||
order_id = row[6]
|
order_id = row[6]
|
||||||
order_date = row[9]
|
order_date = row[9]
|
||||||
|
ship_date = row[17]
|
||||||
customer_name = row[10]
|
customer_name = row[10]
|
||||||
# shipadd1 = row[9] # address information is not stored in X3
|
# shipadd1 = row[9] # address information is not stored in X3
|
||||||
# shipadd2 = row[10]
|
# shipadd2 = row[10]
|
||||||
|
@ -147,6 +148,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
discount = shopify_order_info[0]['current_total_discounts']#row[24]
|
discount = shopify_order_info[0]['current_total_discounts']#row[24]
|
||||||
sales_order.header.cusordref = order_id
|
sales_order.header.cusordref = order_id
|
||||||
sales_order.header.orddat = datetime.datetime.strptime(order_date,'%m/%d/%Y %I:%M:%S %p').strftime('%Y%m%d') # what comes from SL
|
sales_order.header.orddat = datetime.datetime.strptime(order_date,'%m/%d/%Y %I:%M:%S %p').strftime('%Y%m%d') # what comes from SL
|
||||||
|
sales_order.header.shidat = datetime.datetime.strptime(ship_date,'%m/%d/%Y %I:%M:%S %p').strftime('%Y%m%d')
|
||||||
#sales_order.header.orddat = datetime.datetime.strptime(order_date,'%m/%d/%Y %H:%M').strftime('%Y%m%d') #default when we sort in Excel
|
#sales_order.header.orddat = datetime.datetime.strptime(order_date,'%m/%d/%Y %H:%M').strftime('%Y%m%d') #default when we sort in Excel
|
||||||
sales_order.header.stofcy = ship_site
|
sales_order.header.stofcy = ship_site
|
||||||
sales_order.header.bpdnam = customer_name
|
sales_order.header.bpdnam = customer_name
|
||||||
|
@ -164,7 +166,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
# shopify_line_dict = remove_item_from_shopify_order(shopify_line_dict, shopify_item_data['sku'], shopify_item_data['quantity'],shopify_item_data['price'])
|
# shopify_line_dict = remove_item_from_shopify_order(shopify_line_dict, shopify_item_data['sku'], shopify_item_data['quantity'],shopify_item_data['price'])
|
||||||
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
time_stamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
with yamamotoyama.x3_imports.open_import_file(
|
with yamamotoyama.x3_imports.open_import_file(
|
||||||
SOH_IMPORT_DIRECTORY / f"ZSHPORD_{current_order}_{time_stamp}_{sales_order.header.cusordref}.dat"
|
SOH_IMPORT_DIRECTORY / f"ZSHPORDE_{current_order}_{time_stamp}_{sales_order.header.cusordref}.dat"
|
||||||
) as import_file:
|
) as import_file:
|
||||||
sales_order.output(import_file)
|
sales_order.output(import_file)
|
||||||
|
|
||||||
|
@ -233,7 +235,7 @@ def get_details_from_shopify(order):
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class SalesOrderDetail:
|
class SalesOrderDetail:
|
||||||
"""
|
"""
|
||||||
Information that goes on ann order detail line, taken from ZSHPORD template.
|
Information that goes on ann order detail line, taken from ZSHPORDE template.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
itmref: str = ""
|
itmref: str = ""
|
||||||
|
@ -332,7 +334,7 @@ class SalesOrderDetail:
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class SalesOrderHeader:
|
class SalesOrderHeader:
|
||||||
"""
|
"""
|
||||||
Information that goes on an order header, taken from ZSHPORD template.
|
Information that goes on an order header, taken from ZSHPORDE template.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sohnum: str = ""
|
sohnum: str = ""
|
||||||
|
@ -372,6 +374,7 @@ class SalesOrderHeader:
|
||||||
yimport: int = 0
|
yimport: int = 0
|
||||||
pjt: str = ""
|
pjt: str = ""
|
||||||
yedinotes: str = ""
|
yedinotes: str = ""
|
||||||
|
shidat: datetime.date = datetime.date(1753, 1, 1)
|
||||||
|
|
||||||
def convert_to_strings(self) -> typing.List[str]:
|
def convert_to_strings(self) -> typing.List[str]:
|
||||||
"""
|
"""
|
||||||
|
@ -416,7 +419,8 @@ class SalesOrderHeader:
|
||||||
self.invdtaamt_8,
|
self.invdtaamt_8,
|
||||||
self.yimport,
|
self.yimport,
|
||||||
self.pjt,
|
self.pjt,
|
||||||
self.yedinotes
|
self.yedinotes,
|
||||||
|
self.shidat
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue