From 9053cdb4d00027d035ba63087078813cab6271c6 Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Fri, 21 Jun 2019 16:48:51 -0400 Subject: [PATCH] Started working on pulling Item Details into spreadsheet --- XMLTesting.py | 16 +++++++++++----- main.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/XMLTesting.py b/XMLTesting.py index a3fb254..662d881 100644 --- a/XMLTesting.py +++ b/XMLTesting.py @@ -2,14 +2,20 @@ from bs4 import BeautifulSoup as bs # import csv from openpyxl import workbook +external_ids = ['G-ADA-13B0D9D1', 'G-ADA-13A8D9CF', 'G-ADA-13B0D9CF', 'G-ADA-13B0D9CE', 'G-ADA-13A7D9D5', 'G-ADA-13ACD9D5', 'G-ADA-13B2D9D5', 'G-ADA-13AED9D4', 'G-ADA-13B1D9D4', 'G-ADA-13ACD9D3', 'G-ADA-13B1D9D3', 'G-ADA-13AED9D2', 'G-ADA-9F17D9CB', 'G-ADA-9F15D9CB', 'G-ADA'] + +for z in external_ids: + report_filter = """<?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue=""""" + z + """"" maxValue="" /> </PFWebFilter:UserFilter>""" + print(report_filter) -report_filter = """ - - -""" +# +# report_filter = """ +# +# +# """ + -print(report_filter) # ####XML OUTPUT TESTS##### # diff --git a/main.py b/main.py index 7ccbd5d..d7a7521 100644 --- a/main.py +++ b/main.py @@ -40,6 +40,10 @@ def Release_Ticket(ticket, URL, HOST): response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text # print("released ticket "+ticket) +def Westfield(): + print("Westfield") + exit() + def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS): ExternalID = [] @@ -168,8 +172,48 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL ws.cell(column=5, row=count, value=value) count = count + 1 -############# Order Summary tab ############# +############# Order Details tab ############# + print("Getting Item Detail") + print(ExternalID) + for z in ExternalID: + report_filter = """<?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue="""""+z+""""" maxValue="" /> </PFWebFilter:UserFilter>""" + send = """ + + + + """+ticket+""" + Items + false + """+report_filter+"""" + """+DETAIL_REPORT_FIELDS+""" + + + """ + + + headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length', 'SOAPAction': 'http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111/GetReport'} + # response = requests.post(url=URL, data=send, headers=headers).text + temp1 = response.split('') + temp2 = temp1[1].split('') + report = (temp2[0]) + + + y = bs(report, "lxml") + results = [] + + # Opens report file and writes each row + for child in y.report: + for childs in child: + if '$' in childs.text: + convert = childs.text + apply = convert[1:] + results.append(float(apply.replace(',', ''))) + else: + results.append(childs.text) + ws2.append(results) + results = [] # Finalize Spreadsheet and save @@ -252,6 +296,9 @@ def loadMenu(): option = int(input()) + if ClientName[option] == "Westfield": + Westfield() + # create new report file and add headers based on config file wb = workbook.Workbook() ws = wb.active