Started working on pulling Item Details into spreadsheet

This commit is contained in:
Dan Dembinski
2019-06-21 16:48:51 -04:00
parent 4d775482c2
commit 9053cdb4d0
2 changed files with 59 additions and 6 deletions

View File

@@ -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 = """<PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Orders">
<PFWebFilter:Step publicFieldName="Balance Due" query="ExactUnequals" minValue="0.00" maxValue="" />
<PFWebFilter:Step publicFieldName="Order Status" query="ExactEquals" minValue="Completed" maxValue="" />
</PFWebFilter:UserFilter>"""
#
# report_filter = """<PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Orders">
# <PFWebFilter:Step publicFieldName="Balance Due" query="ExactUnequals" minValue="0.00" maxValue="" />
# <PFWebFilter:Step publicFieldName="Order Status" query="ExactEquals" minValue="Completed" maxValue="" />
# </PFWebFilter:UserFilter>"""
print(report_filter)
# ####XML OUTPUT TESTS#####
#

49
main.py
View File

@@ -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 = """&lt;?xml version="1.0"?&gt; &lt;PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"&gt; &lt;PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue="""""+z+""""" maxValue="" /&gt; &lt;/PFWebFilter:UserFilter&gt;"""
send = """<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetReport xmlns="http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111">
<token>"""+ticket+"""</token>
<reportName>Items</reportName>
<archived>false</archived>
"""+report_filter+""""
<columnNames>"""+DETAIL_REPORT_FIELDS+"""</columnNames>
</GetReport>
</soap12:Body>
</soap12:Envelope>"""
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('</GetReportResult>')
temp2 = temp1[1].split('<error />')
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