diff --git a/readme.txt b/readme.txt index cd3a846..ec862c3 100644 --- a/readme.txt +++ b/readme.txt @@ -27,3 +27,12 @@ To catch issues we need to look at: -possible sales order duplicates that have the same Shopify PO number -missing sales orders, that came into the shipping table, but failed to import in -missing deliveries, that failed during import, e.g. not enough stock + +To find these use the sql files in "daily sql reports" + +---------------------------------------------------------------------------------------- +Reimporting: +The open orders report finds eCommerce orders that should have shipped. This is typically +a problem because of stock shortages that we need to disassemble cases for. The +'source_ecommerce_reimport_from_archive.py' script can help mass reimport the +missing shipments diff --git a/source_ecommerce_load_shipping.py b/source_ecommerce_load_shipping.py index 282f34a..5067682 100644 --- a/source_ecommerce_load_shipping.py +++ b/source_ecommerce_load_shipping.py @@ -34,7 +34,7 @@ ARCHIVE_DIRECTORY = THIS_DIRECTORY / "incoming_shipments" / "archive" def main(): - #retrieve_x12_edi_files()#TODO uncomment + retrieve_x12_edi_files()#TODO uncomment for file in INCOMING_DIRECTORY.iterdir(): if file.name[-4:] != '.csv': continue @@ -91,15 +91,16 @@ def process_files(file): qty = row[3] lot = row[4] order_id = row[6] + tracking = row[16] ship_date = datetime.datetime.strptime(row[17],'%m/%d/%Y %I:%M:%S %p').strftime('%m/%d/%Y')# what comes from SL #ship_date = datetime.datetime.strptime(row[17],'%m/%d/%Y %H:%M').strftime('%m/%d/%Y')#default when we sort in Excel db_connection.query( """ INSERT INTO [analytics].[dbo].[SL_ECOMM] - ([site],[item],[des],[qty],[lot],[order_id],[ship_date]) + ([site],[item],[des],[qty],[lot],[order_id],[ship_date],[tracking]) VALUES - (:site,:item,:des,:qty,:lot,:order_id,:ship_date) + (:site,:item,:des,:qty,:lot,:order_id,:ship_date,:tracking) """, site=site, item=item, @@ -107,7 +108,8 @@ def process_files(file): qty=qty, lot=lot, order_id=order_id, - ship_date=ship_date + ship_date=ship_date, + tracking=tracking ) if __name__ == "__main__": diff --git a/source_ecommerce_make_order.py b/source_ecommerce_make_order.py index 6eb4024..32c25f3 100644 --- a/source_ecommerce_make_order.py +++ b/source_ecommerce_make_order.py @@ -131,9 +131,9 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order # shipzip = row[13] tracking = row[16] weight = row[18] - taxes = shopify_order_info[0]['total_tax']#row[22] + taxes = shopify_order_info[0]['current_total_tax']#row[22] ship_charge = shopify_order_info[0]['shipping_lines__price']#row[21] - discount = shopify_order_info[0]['total_discounts']#row[24] + discount = shopify_order_info[0]['current_total_discounts']#row[24] 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 %H:%M').strftime('%Y%m%d') #default when we sort in Excel @@ -175,16 +175,16 @@ def get_details_from_shopify(order): return db_connection.query( """ select - [ecommerce_orders].[order_number] - ,[ecommerce_orders].[total_tax] - ,[ecommerce_orders].[total_discounts] - ,[ecommerce_orders].[shipping_lines__price] - ,[ecommerce_order_lines].[sku] - ,[ecommerce_order_lines].[quantity] - ,[ecommerce_order_lines].[price] - from [staging].[dbo].[ecommerce_orders] - left join [staging].[dbo].[ecommerce_order_lines] - on [ecommerce_orders].[id] = [ecommerce_order_lines].[id] + [ecommerce_shipped_orders].[order_number] + ,[ecommerce_shipped_orders].[current_total_tax] + ,[ecommerce_shipped_orders].[current_total_discounts] + ,[ecommerce_shipped_orders].[shipping_lines__price] + ,[ecommerce_shipped_order_lines].[sku] + ,[ecommerce_shipped_order_lines].[quantity] + ,[ecommerce_shipped_order_lines].[price] + from [staging].[dbo].[ecommerce_shipped_orders] + left join [staging].[dbo].[ecommerce_shipped_order_lines] + on [ecommerce_shipped_orders].[id] = [ecommerce_shipped_order_lines].[id] where order_number = :shopifyorder """, shopifyorder=order, diff --git a/source_ecommerce_make_shipment.py b/source_ecommerce_make_shipment.py index a0d1ff2..bf49970 100644 --- a/source_ecommerce_make_shipment.py +++ b/source_ecommerce_make_shipment.py @@ -87,7 +87,7 @@ def process_files(file): warehouse_shipment = WarehouseShipment() previous_order = current_order sohnum = find_so_from_po(current_order) - order_date = row[9] + ship_date = row[17] customer_name = row[10] # shipadd1 = row[9] # address information is not stored in X3 # shipadd2 = row[10] @@ -102,8 +102,8 @@ def process_files(file): # discount = "?" #unused warehouse_shipment.sohnum = sohnum warehouse_shipment.header.sohnum = sohnum - warehouse_shipment.header.shidat = datetime.datetime.strptime(order_date,'%m/%d/%Y %I:%M:%S %p')# what comes from SL - #warehouse_shipment.header.shidat = datetime.datetime.strptime(order_date,'%m/%d/%Y %H:%M')#default when we sort in Excel + warehouse_shipment.header.shidat = datetime.datetime.strptime(ship_date,'%m/%d/%Y %I:%M:%S %p')# what comes from SL + #warehouse_shipment.header.shidat = datetime.datetime.strptime(ship_date,'%m/%d/%Y %H:%M')#default when we sort in Excel warehouse_shipment.header.ylicplate = tracking warehouse_shipment.header.growei = weight #gather line data @@ -289,6 +289,7 @@ class WarehouseShipmentHeader: cfmflg: int = 1 pjt: str = "" bptnum: str = "" + mdl: str = "" ylicplate: str = "" invdtaamt_2: decimal.Decimal = decimal.Decimal() invdtaamt_3: decimal.Decimal = decimal.Decimal() @@ -372,6 +373,7 @@ class WarehouseShipmentHeader: self.cfmflg, self.pjt, self.bptnum, + self.mdl, self.ylicplate, self.invdtaamt_2, self.invdtaamt_3,