Item Details work properly. Working on loading Column Formating from XML file
This commit is contained in:
2330
StorefrontUtilitiesConfig.xml
Normal file
2330
StorefrontUtilitiesConfig.xml
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
57
main.py
57
main.py
@@ -40,6 +40,10 @@ def Release_Ticket(ticket, URL, HOST):
|
|||||||
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
||||||
# print("released ticket "+ticket)
|
# print("released ticket "+ticket)
|
||||||
|
|
||||||
|
def Westfield():
|
||||||
|
print("Westfield")
|
||||||
|
exit()
|
||||||
|
|
||||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS):
|
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS):
|
||||||
|
|
||||||
ExternalID = []
|
ExternalID = []
|
||||||
@@ -166,10 +170,50 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
|||||||
for row in ws:
|
for row in ws:
|
||||||
value = "=H"+str(count)+"-G"+str(count)+"-F"+str(count)
|
value = "=H"+str(count)+"-G"+str(count)+"-F"+str(count)
|
||||||
ws.cell(column=5, row=count, value=value)
|
ws.cell(column=5, row=count, value=value)
|
||||||
count = count + 1
|
count =+ 1
|
||||||
|
|
||||||
############# Order Summary tab #############
|
############# Order Details tab #############
|
||||||
|
|
||||||
|
print("Getting Item Detail")
|
||||||
|
# ExternalID = ['G-ADA-13B0D9D1', 'G-ADA-13A8D9CF']
|
||||||
|
for z in ExternalID:
|
||||||
|
report_filter = """<filterNameOrXml><?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></filterNameOrXml>"""
|
||||||
|
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
|
# Finalize Spreadsheet and save
|
||||||
@@ -178,6 +222,8 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
|||||||
cell.font = bold
|
cell.font = bold
|
||||||
for cell in ws2["1:1"]:
|
for cell in ws2["1:1"]:
|
||||||
cell.font = bold
|
cell.font = bold
|
||||||
|
print("Enter a filename for the report: ")
|
||||||
|
filename = input()
|
||||||
wb.save('report.xlsx')
|
wb.save('report.xlsx')
|
||||||
|
|
||||||
def loadMenu():
|
def loadMenu():
|
||||||
@@ -232,6 +278,7 @@ def loadMenu():
|
|||||||
CLIENT_SUMMARY_TAB = []
|
CLIENT_SUMMARY_TAB = []
|
||||||
client_headers = []
|
client_headers = []
|
||||||
|
|
||||||
|
|
||||||
# Get Monthly Report Item Detail Fields
|
# Get Monthly Report Item Detail Fields
|
||||||
for w in y.find_all('client'):
|
for w in y.find_all('client'):
|
||||||
for x in w.find_all('monthlyreport'):
|
for x in w.find_all('monthlyreport'):
|
||||||
@@ -245,6 +292,7 @@ def loadMenu():
|
|||||||
CLIENT_DETAIL_TAB = []
|
CLIENT_DETAIL_TAB = []
|
||||||
client_detail_headers = []
|
client_detail_headers = []
|
||||||
|
|
||||||
|
|
||||||
choice = 0
|
choice = 0
|
||||||
for x in ClientName:
|
for x in ClientName:
|
||||||
print(choice, x)
|
print(choice, x)
|
||||||
@@ -252,6 +300,9 @@ def loadMenu():
|
|||||||
|
|
||||||
option = int(input())
|
option = int(input())
|
||||||
|
|
||||||
|
if ClientName[option] == "Westfield":
|
||||||
|
Westfield()
|
||||||
|
|
||||||
# create new report file and add headers based on config file
|
# create new report file and add headers based on config file
|
||||||
wb = workbook.Workbook()
|
wb = workbook.Workbook()
|
||||||
ws = wb.active
|
ws = wb.active
|
||||||
@@ -262,6 +313,8 @@ def loadMenu():
|
|||||||
ws2.append(detail_headers[option])
|
ws2.append(detail_headers[option])
|
||||||
|
|
||||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||||
|
|
||||||
|
|
||||||
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
|
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
|
||||||
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB[option]))
|
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB[option]))
|
||||||
URL_HOST = [SF_URL[option], SF_HOST[option], REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS]
|
URL_HOST = [SF_URL[option], SF_HOST[option], REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS]
|
||||||
|
|||||||
Reference in New Issue
Block a user