Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ee6190bc2 | ||
|
|
2bb9baecf6 | ||
|
|
1d29437189 | ||
|
|
bde35b86ac | ||
|
|
ecb9757fb5 |
@@ -1,16 +1,62 @@
|
|||||||
def client_Specific_Tabs(option):
|
import requests
|
||||||
|
from bs4 import BeautifulSoup as bs
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import time
|
||||||
|
|
||||||
|
def client_Specific_Tabs(option, wb, ticket, HOST, URL):
|
||||||
|
print("Client Specific")
|
||||||
if option == "Westfield":
|
if option == "Westfield":
|
||||||
Westfield()
|
Westfield()
|
||||||
elif option == " CCM":
|
elif option == "CCM":
|
||||||
CCM()
|
CCM(wb, ticket, HOST, URL)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def Westfield():
|
def Westfield():
|
||||||
print("Neat westfield stuff will go here")
|
return
|
||||||
exit()
|
|
||||||
|
|
||||||
def CCM():
|
def CCM(wb, ticket, HOST, URL):
|
||||||
print("Neat CCM stuff will go here")
|
|
||||||
exit()
|
print("CCM is starting")
|
||||||
|
|
||||||
|
REPORT_FIELDS = '<string>Order ID</string>, <string>Order Status</string>'
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
|
first = now.replace(day=1)
|
||||||
|
lastMonth = first - timedelta(days=1)
|
||||||
|
previous = lastMonth.strftime("%m/01/%Y")
|
||||||
|
now = now.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
ws4 = wb.create_sheet("Downloaded Items")
|
||||||
|
|
||||||
|
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="Date/Time Created" query="IsBetweenDate" minValue=""" + '"' + previous + ' 00:00"' + """ maxValue=""" + '"' + now + ' 00:00"' """/> <PFWebFilter:Step publicFieldName="PrintingFreeDownloadOnly" query="ExactEquals" minValue="download" 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>""" + 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")
|
||||||
|
|
||||||
|
ws4.append(report)
|
||||||
|
|
||||||
|
return
|
||||||
|
|||||||
180
XMLTesting.py
180
XMLTesting.py
@@ -1,74 +1,136 @@
|
|||||||
from bs4 import BeautifulSoup as bs
|
import requests
|
||||||
# import csv
|
from datetime import datetime, timedelta
|
||||||
from openpyxl import workbook
|
import time
|
||||||
|
from main import Obtain_Ticket, Release_Ticket
|
||||||
|
|
||||||
|
|
||||||
|
URL = "http://ccm.gli.us.com/store/storefrontapi.asmx"
|
||||||
|
temp1 = URL.split('://')
|
||||||
|
temp2 = temp1[1].split('/')
|
||||||
|
HOST = (temp2[0])
|
||||||
|
|
||||||
|
ticket = Obtain_Ticket(URL, HOST)
|
||||||
|
|
||||||
|
print("CCM is starting")
|
||||||
|
now = datetime.now()
|
||||||
|
first = now.replace(day=1)
|
||||||
|
lastMonth = first - timedelta(days=1)
|
||||||
|
previous = lastMonth.strftime("%m/01/%Y")
|
||||||
|
now = now.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
|
||||||
|
REPORT_FIELDS = '<string>Order ID</string>, <string>Order Status</string>'
|
||||||
|
|
||||||
|
# ws4 = wb.create_sheet("Downloaded Items")
|
||||||
|
|
||||||
|
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="Date/Time Created" query="IsBetweenDate" minValue=""" + '"' + previous + ' 00:00"' + """ maxValue=""" + '"' + now + ' 00:00"' """/> <PFWebFilter:Step publicFieldName="PrintingFreeDownloadOnly" query="ExactEquals" minValue="download" 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>"""+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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###REPORT ColumnFormat TESTING#####
|
temp1 = response.split('</GetReportResult>')
|
||||||
|
temp2 = temp1[1].split('<error />')
|
||||||
|
report = (temp2[0])
|
||||||
|
|
||||||
with open("StorefrontUtilitiesConfig.xml") as f:
|
print(report)
|
||||||
r = f.read()
|
|
||||||
|
|
||||||
y = bs(r, "lxml")
|
Release_Ticket(ticket, URL, HOST)
|
||||||
|
|
||||||
ClientName = []
|
|
||||||
SF_URL = []
|
|
||||||
SF_HOST = []
|
|
||||||
CLIENT_SUMMARY_TAB = []
|
|
||||||
SUMMARY_TAB = []
|
|
||||||
client_headers = []
|
|
||||||
headers = []
|
|
||||||
|
|
||||||
CLIENT_COLUMN_FORMAT = []
|
|
||||||
COLUMN_FORMAT = []
|
|
||||||
|
|
||||||
for x in y.find_all('name'):
|
|
||||||
# print(x.text)
|
|
||||||
ClientName.append(x.text)
|
|
||||||
# print(ClientName)
|
|
||||||
|
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('summarytab'):
|
|
||||||
for z in g.find_all('columnname'):
|
|
||||||
z.name = "string"
|
|
||||||
CLIENT_SUMMARY_TAB.append(z)
|
|
||||||
client_headers.append(z.text)
|
|
||||||
SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
|
||||||
headers.append(client_headers)
|
|
||||||
CLIENT_SUMMARY_TAB = []
|
|
||||||
client_headers = []
|
|
||||||
|
|
||||||
|
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('summarytab'):
|
|
||||||
for z in g.find_all('columnformat'):
|
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
|
||||||
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
|
||||||
CLIENT_COLUMN_FORMAT = []
|
|
||||||
|
|
||||||
|
|
||||||
option = 0
|
|
||||||
columnformat = dict.fromkeys(headers[option])
|
|
||||||
|
|
||||||
|
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('name'):
|
|
||||||
if x.text == ClientName[option]:
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('summarytab'):
|
|
||||||
for z in g.find_all('columnformat'):
|
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
|
||||||
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
# from bs4 import BeautifulSoup as bs
|
||||||
|
# # import csv
|
||||||
|
# from openpyxl import workbook
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ###REPORT ColumnFormat TESTING#####
|
||||||
|
#
|
||||||
|
# with open("StorefrontUtilitiesConfig.xml") as f:
|
||||||
|
# r = f.read()
|
||||||
|
#
|
||||||
|
# y = bs(r, "lxml")
|
||||||
|
#
|
||||||
|
# ClientName = []
|
||||||
|
# SF_URL = []
|
||||||
|
# SF_HOST = []
|
||||||
|
# CLIENT_SUMMARY_TAB = []
|
||||||
|
# SUMMARY_TAB = []
|
||||||
|
# client_headers = []
|
||||||
|
# headers = []
|
||||||
|
#
|
||||||
|
# CLIENT_COLUMN_FORMAT = []
|
||||||
|
# COLUMN_FORMAT = []
|
||||||
|
#
|
||||||
|
# for x in y.find_all('name'):
|
||||||
|
# # print(x.text)
|
||||||
|
# ClientName.append(x.text)
|
||||||
|
# # print(ClientName)
|
||||||
|
#
|
||||||
|
# for w in y.find_all('client'):
|
||||||
|
# for x in w.find_all('monthlyreport'):
|
||||||
|
# for g in x.find_all('summarytab'):
|
||||||
|
# for z in g.find_all('columnname'):
|
||||||
|
# z.name = "string"
|
||||||
|
# CLIENT_SUMMARY_TAB.append(z)
|
||||||
|
# client_headers.append(z.text)
|
||||||
|
# SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
||||||
|
# headers.append(client_headers)
|
||||||
|
# CLIENT_SUMMARY_TAB = []
|
||||||
|
# client_headers = []
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# for w in y.find_all('client'):
|
||||||
|
# for x in w.find_all('monthlyreport'):
|
||||||
|
# for g in x.find_all('summarytab'):
|
||||||
|
# for z in g.find_all('columnformat'):
|
||||||
|
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
# COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
||||||
|
# CLIENT_COLUMN_FORMAT = []
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# option = 0
|
||||||
|
# columnformat = dict.fromkeys(headers[option])
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# for w in y.find_all('client'):
|
||||||
|
# for x in w.find_all('name'):
|
||||||
|
# if x.text == ClientName[option]:
|
||||||
|
# for x in w.find_all('monthlyreport'):
|
||||||
|
# for g in x.find_all('summarytab'):
|
||||||
|
# for z in g.find_all('columnformat'):
|
||||||
|
# CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
#
|
||||||
|
# count = 0
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# # print(columnformat)
|
||||||
|
# for key in columnformat:
|
||||||
|
# columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||||
|
# count = count + 1
|
||||||
# print(columnformat)
|
# print(columnformat)
|
||||||
for key in columnformat:
|
|
||||||
columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
|
||||||
count = count + 1
|
|
||||||
print(columnformat)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
app/SFU.py
Normal file
3
app/SFU.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from app import app
|
||||||
|
|
||||||
|
|
||||||
7
app/__init__.py
Normal file
7
app/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
from app import routes
|
||||||
|
|
||||||
|
|
||||||
50
app/routes.py
Normal file
50
app/routes.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from app import app
|
||||||
|
from flask import render_template, request, redirect, url_for, send_file
|
||||||
|
from main import *
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
@app.route('/index')
|
||||||
|
|
||||||
|
def index():
|
||||||
|
ClientName = []
|
||||||
|
|
||||||
|
ClientName = loadClients()
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('index.html', title='SFU', ClientName=ClientName)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/runReport', methods=['GET', 'POST'])
|
||||||
|
def runReport():
|
||||||
|
|
||||||
|
ClientConfig = []
|
||||||
|
|
||||||
|
client = request.form['SelectedClient']
|
||||||
|
ClientConfig = GetClientConfig(client)
|
||||||
|
|
||||||
|
SF_URL = ClientConfig[0]
|
||||||
|
SF_HOST = ClientConfig[1]
|
||||||
|
REPORT_FIELDS = ClientConfig[2]
|
||||||
|
DETAIL_REPORT_FIELDS = ClientConfig[3]
|
||||||
|
summary_columnformat = ClientConfig[4]
|
||||||
|
headers = ClientConfig[5]
|
||||||
|
detail_columnformat = ClientConfig[6]
|
||||||
|
detail_headers = ClientConfig[7]
|
||||||
|
wb = ClientConfig[8]
|
||||||
|
ws = ClientConfig[9]
|
||||||
|
ws2 = ClientConfig[10]
|
||||||
|
|
||||||
|
ticket = Obtain_Ticket(SF_URL, SF_HOST)
|
||||||
|
|
||||||
|
Run_Report(ticket, SF_URL, SF_HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnformat, headers[0],
|
||||||
|
detail_columnformat, detail_headers[0], client)
|
||||||
|
|
||||||
|
Release_Ticket(ticket, SF_URL, SF_HOST)
|
||||||
|
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
filename = str(client) + str(date) + "_report.xlsx"
|
||||||
|
|
||||||
|
return send_file('report.xlsx', as_attachment=True, attachment_filename = filename)
|
||||||
|
|
||||||
|
#return(str(client),SF_URL,SF_HOST,REPORT_FIELDS,DETAIL_REPORT_FIELDS,summary_columnformat,headers,detail_columnformat,detail_headers,wb, ws, ws2 )
|
||||||
21
app/templates/index.html
Normal file
21
app/templates/index.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
<form method="post" action = "{{ url_for('runReport') }}" >
|
||||||
|
<select name = 'SelectedClient'>
|
||||||
|
{% for x in ClientName %}
|
||||||
|
<option value = {{ ClientName[loop.index0] }} > {{ ClientName[loop.index0] }} </option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
248
main.py
248
main.py
@@ -1,3 +1,6 @@
|
|||||||
|
## SET FLASK_APP=SFU.py
|
||||||
|
##Flask Run
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as bs
|
from bs4 import BeautifulSoup as bs
|
||||||
from openpyxl import workbook
|
from openpyxl import workbook
|
||||||
@@ -7,6 +10,7 @@ from ClientSpecific import *
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def Obtain_Ticket(URL, HOST):
|
def Obtain_Ticket(URL, HOST):
|
||||||
GetTicket = """<?xml version="1.0" encoding="utf-8"?>
|
GetTicket = """<?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: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">
|
||||||
@@ -21,11 +25,11 @@ def Obtain_Ticket(URL, HOST):
|
|||||||
|
|
||||||
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
||||||
response = requests.post(url=URL, data=GetTicket, headers=headers).text
|
response = requests.post(url=URL, data=GetTicket, headers=headers).text
|
||||||
# print(response)
|
#print(response)
|
||||||
temp1 = response.split('<ObtainUserTicketResult>')
|
temp1 = response.split('<ObtainUserTicketResult>')
|
||||||
temp2 = temp1[1].split('</ObtainUserTicketResult>')
|
temp2 = temp1[1].split('</ObtainUserTicketResult>')
|
||||||
ticket = temp2[0]
|
ticket = temp2[0]
|
||||||
print("got ticket: " + ticket)
|
#print("got ticket: " + ticket)
|
||||||
return ticket
|
return ticket
|
||||||
|
|
||||||
def Release_Ticket(ticket, URL, HOST):
|
def Release_Ticket(ticket, URL, HOST):
|
||||||
@@ -39,10 +43,10 @@ def Release_Ticket(ticket, URL, HOST):
|
|||||||
</soap12:Envelope>"""
|
</soap12:Envelope>"""
|
||||||
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
||||||
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
||||||
print("released ticket "+ticket)
|
#("released ticket "+ticket)
|
||||||
|
|
||||||
|
|
||||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader):
|
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader, client):
|
||||||
|
|
||||||
ExternalID = []
|
ExternalID = []
|
||||||
id = []
|
id = []
|
||||||
@@ -203,6 +207,7 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
|||||||
</soap12:Envelope>"""
|
</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'}
|
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
|
response = requests.post(url=URL, data=send, headers=headers).text
|
||||||
temp1 = response.split('</GetReportResult>')
|
temp1 = response.split('</GetReportResult>')
|
||||||
@@ -236,43 +241,53 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
|||||||
ws3['A1'] = "Product Name"
|
ws3['A1'] = "Product Name"
|
||||||
ws3['B1'] = "Quantity"
|
ws3['B1'] = "Quantity"
|
||||||
ws3['C1'] = "Item Price"
|
ws3['C1'] = "Item Price"
|
||||||
|
|
||||||
|
PrintQuantity = 0
|
||||||
|
for x in detail_SSheader:
|
||||||
|
if x != "Printing Option: PrintingQuantity":
|
||||||
|
PrintQuantity += 1
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
PrintQuantity += 1
|
||||||
|
|
||||||
|
ItemPrice = 0
|
||||||
|
for x in detail_SSheader:
|
||||||
|
if x != "Item Price":
|
||||||
|
ItemPrice += 1
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
ItemPrice += 1
|
||||||
|
|
||||||
|
PrintQuantityColumn = get_column_letter(PrintQuantity)
|
||||||
|
ItemPriceColumn = get_column_letter(ItemPrice)
|
||||||
|
|
||||||
count = 1
|
count = 1
|
||||||
for x in ws3:
|
for x in ws3:
|
||||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!G:G)"
|
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + PrintQuantityColumn + ":" + PrintQuantityColumn + ")"
|
||||||
if count != 1:
|
if count != 1:
|
||||||
ws3.cell(column = 2, row = count, value = value)
|
ws3.cell(column = 2, row = count, value = value)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
count = 1
|
count = 1
|
||||||
for x in ws3:
|
for x in ws3:
|
||||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!H:H)"
|
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + ItemPriceColumn + ":" + ItemPriceColumn + ")"
|
||||||
if count != 1:
|
if count != 1:
|
||||||
ws3.cell(column = 3, row = count, value = value)
|
ws3.cell(column = 3, row = count, value = value)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
client_Specific_Tabs(client, wb, ticket, HOST, URL)
|
||||||
# Finalize Spreadsheet and save
|
# Finalize Spreadsheet and save
|
||||||
Format_Report(ws, summary_SSheader, summary_columnFormat)
|
Format_Report(ws, summary_SSheader, summary_columnFormat)
|
||||||
Format_Report(ws2, detail_SSheader, detail_columnFormat)
|
Format_Report(ws2, detail_SSheader, detail_columnFormat)
|
||||||
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
||||||
|
|
||||||
def loadMenu():
|
|
||||||
|
|
||||||
ConfigFile = "StorefrontUtilitiesConfig.xml"
|
|
||||||
|
def loadClients():
|
||||||
|
|
||||||
|
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||||
ClientName = []
|
ClientName = []
|
||||||
SF_URL = []
|
|
||||||
SF_HOST = []
|
|
||||||
CLIENT_SUMMARY_TAB = []
|
|
||||||
SUMMARY_TAB = []
|
|
||||||
headers = []
|
|
||||||
client_headers = []
|
|
||||||
CLIENT_DETAIL_TAB = []
|
|
||||||
DETAIL_TAB = []
|
|
||||||
client_detail_headers = []
|
|
||||||
detail_headers = []
|
|
||||||
CLIENT_COLUMN_FORMAT = []
|
|
||||||
COLUMN_FORMAT = []
|
|
||||||
detail_columnformat = []
|
|
||||||
|
|
||||||
# Open the config file
|
# Open the config file
|
||||||
with open(ConfigFile) as f:
|
with open(ConfigFile) as f:
|
||||||
@@ -280,78 +295,118 @@ def loadMenu():
|
|||||||
|
|
||||||
y = bs(r, "lxml")
|
y = bs(r, "lxml")
|
||||||
|
|
||||||
# Get list of clients
|
# Get list of clients
|
||||||
for x in y.find_all('name'):
|
for x in y.find_all('name'):
|
||||||
# print(x.text)
|
# print(x.text)
|
||||||
ClientName.append(x.text)
|
ClientName.append(x.text)
|
||||||
|
|
||||||
# Get Storefront API URls
|
return ClientName
|
||||||
for x in y.find_all('storefrontapiurl'):
|
|
||||||
# print(x)
|
|
||||||
SF_URL.append(x.text)
|
|
||||||
|
|
||||||
# Get Storefront Host URLs
|
def GetClientConfig(Client):
|
||||||
for x in SF_URL:
|
|
||||||
temp1 = x.split('://')
|
SF_URL = ""
|
||||||
temp2 = temp1[1].split('/')
|
CLIENT_SUMMARY_TAB = []
|
||||||
HOST = (temp2[0])
|
client_headers = []
|
||||||
SF_HOST.append(HOST)
|
SUMMARY_TAB = []
|
||||||
|
headers =[]
|
||||||
|
CLIENT_COLUMN_FORMAT = []
|
||||||
|
COLUMN_FORMAT = []
|
||||||
|
DETAIL_TAB = []
|
||||||
|
detail_headers =[]
|
||||||
|
CLIENT_DETAIL_TAB = []
|
||||||
|
client_detail_headers = []
|
||||||
|
REPORT_FIELDS= []
|
||||||
|
DETAIL_REPORT_FIELDS = []
|
||||||
|
summary_columnformat = []
|
||||||
|
detail_columnformat = []
|
||||||
|
|
||||||
|
if Client == 'Westfield':
|
||||||
|
Westfield()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Loads config file and reads in XML
|
||||||
|
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||||
|
|
||||||
|
# Open the config file
|
||||||
|
with open(ConfigFile) as f:
|
||||||
|
r = f.read()
|
||||||
|
|
||||||
|
y = bs(r, "lxml")
|
||||||
|
|
||||||
|
|
||||||
|
# Get Storefront API URl
|
||||||
|
for w in y.find_all('client'):
|
||||||
|
for x in w.find_all('name'):
|
||||||
|
if x.text == Client:
|
||||||
|
for z in w.find('storefrontapiurl'):
|
||||||
|
print(SF_URL)
|
||||||
|
SF_URL = z
|
||||||
|
#SF_URL = "http://diabetes-storefront.gli.us.com/store/storefrontapi.asmx"
|
||||||
|
temp1 = SF_URL.split('://')
|
||||||
|
temp2 = temp1[1].split('/')
|
||||||
|
SF_HOST = (temp2[0])
|
||||||
|
|
||||||
|
# Get Storefront Host URL
|
||||||
|
|
||||||
|
|
||||||
# Get Monthly Report Summary Fields
|
# Get Monthly Report Summary 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('name'):
|
||||||
for g in x.find_all('summarytab'):
|
if x.text == Client:
|
||||||
for z in g.find_all('columnname'):
|
for x in w.find_all('monthlyreport'):
|
||||||
z.name = "string"
|
for g in x.find_all('summarytab'):
|
||||||
CLIENT_SUMMARY_TAB.append(z)
|
for z in g.find_all('columnname'):
|
||||||
client_headers.append(z.text)
|
z.name = "string"
|
||||||
SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
CLIENT_SUMMARY_TAB.append(z)
|
||||||
headers.append(client_headers)
|
client_headers.append(z.text)
|
||||||
CLIENT_SUMMARY_TAB = []
|
SUMMARY_TAB.append(CLIENT_SUMMARY_TAB)
|
||||||
client_headers = []
|
headers.append(client_headers)
|
||||||
|
CLIENT_SUMMARY_TAB = []
|
||||||
|
client_headers = []
|
||||||
|
|
||||||
# Get Monthly Report Column Format
|
# Get Monthly Report Column Format
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('summarytab'):
|
|
||||||
for z in g.find_all('columnformat'):
|
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
|
||||||
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
|
||||||
CLIENT_COLUMN_FORMAT = []
|
|
||||||
|
|
||||||
# Get Monthly Report Item Detail Fields
|
|
||||||
for w in y.find_all('client'):
|
|
||||||
for x in w.find_all('monthlyreport'):
|
|
||||||
for g in x.find_all('detailtab'):
|
|
||||||
for z in g.find_all('columnname'):
|
|
||||||
z.name = "string"
|
|
||||||
CLIENT_DETAIL_TAB.append(z)
|
|
||||||
client_detail_headers.append(z.text)
|
|
||||||
DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
|
||||||
detail_headers.append(client_detail_headers)
|
|
||||||
CLIENT_DETAIL_TAB = []
|
|
||||||
client_detail_headers = []
|
|
||||||
|
|
||||||
choice = 0
|
|
||||||
for x in ClientName:
|
|
||||||
print(choice, x)
|
|
||||||
choice = choice + 1
|
|
||||||
|
|
||||||
option = int(input())
|
|
||||||
|
|
||||||
client_Specific_Tabs(ClientName[option])
|
|
||||||
|
|
||||||
summary_columnformat = dict.fromkeys(headers[option])
|
|
||||||
|
|
||||||
# Get specific Summary Column Types for chosen client
|
|
||||||
for w in y.find_all('client'):
|
for w in y.find_all('client'):
|
||||||
for x in w.find_all('name'):
|
for x in w.find_all('name'):
|
||||||
if x.text == ClientName[option]:
|
if x.text == Client:
|
||||||
for x in w.find_all('monthlyreport'):
|
for x in w.find_all('monthlyreport'):
|
||||||
for g in x.find_all('summarytab'):
|
for g in x.find_all('summarytab'):
|
||||||
for z in g.find_all('columnformat'):
|
for z in g.find_all('columnformat'):
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
COLUMN_FORMAT.append(CLIENT_COLUMN_FORMAT)
|
||||||
|
CLIENT_COLUMN_FORMAT = []
|
||||||
|
|
||||||
|
# Get Monthly Report Item Detail Fields
|
||||||
|
for w in y.find_all('client'):
|
||||||
|
for x in w.find_all('name'):
|
||||||
|
if x.text == Client:
|
||||||
|
for x in w.find_all('monthlyreport'):
|
||||||
|
for g in x.find_all('detailtab'):
|
||||||
|
for z in g.find_all('columnname'):
|
||||||
|
z.name = "string"
|
||||||
|
CLIENT_DETAIL_TAB.append(z)
|
||||||
|
client_detail_headers.append(z.text)
|
||||||
|
DETAIL_TAB.append(CLIENT_DETAIL_TAB)
|
||||||
|
detail_headers.append(client_detail_headers)
|
||||||
|
CLIENT_DETAIL_TAB = []
|
||||||
|
client_detail_headers = []
|
||||||
|
|
||||||
|
# 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))
|
||||||
|
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB))
|
||||||
|
|
||||||
|
|
||||||
|
# Get specific Summary Column Types for chosen client
|
||||||
|
for w in y.find_all('client'):
|
||||||
|
for x in w.find_all('name'):
|
||||||
|
if x.text == Client:
|
||||||
|
for x in w.find_all('monthlyreport'):
|
||||||
|
for g in x.find_all('summarytab'):
|
||||||
|
for z in g.find_all('columnformat'):
|
||||||
|
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
|
||||||
|
|
||||||
|
summary_columnformat = dict.fromkeys(headers[0])
|
||||||
# set Summary Column Types Header Dictionary
|
# set Summary Column Types Header Dictionary
|
||||||
count = 0
|
count = 0
|
||||||
for key in summary_columnformat:
|
for key in summary_columnformat:
|
||||||
@@ -362,52 +417,31 @@ def loadMenu():
|
|||||||
# Get specific Detail Column Types for chosen client
|
# Get specific Detail Column Types for chosen client
|
||||||
for w in y.find_all('client'):
|
for w in y.find_all('client'):
|
||||||
for x in w.find_all('name'):
|
for x in w.find_all('name'):
|
||||||
if x.text == ClientName[option]:
|
if x.text == Client:
|
||||||
for x in w.find_all('monthlyreport'):
|
for x in w.find_all('monthlyreport'):
|
||||||
for g in x.find_all('detailtab'):
|
for g in x.find_all('detailtab'):
|
||||||
for z in g.find_all('columnformat'):
|
for z in g.find_all('columnformat'):
|
||||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||||
|
|
||||||
detail_columnformat = dict.fromkeys(detail_headers[option])
|
|
||||||
# set Detail Column Types Header Dictionary
|
|
||||||
|
detail_columnformat = dict.fromkeys(detail_headers[0])
|
||||||
|
# set Detail Column Types Header Dictionary
|
||||||
count = 0
|
count = 0
|
||||||
for key in detail_columnformat:
|
for key in detail_columnformat:
|
||||||
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
ws.title = "Order Summary"
|
ws.title = "Order Summary"
|
||||||
ws.append(headers[option])
|
ws.append(headers[0])
|
||||||
|
|
||||||
ws2 = wb.create_sheet("Item Detail")
|
ws2 = wb.create_sheet("Item Detail")
|
||||||
ws2.append(detail_headers[option])
|
ws2.append(detail_headers[0])
|
||||||
|
|
||||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
ClientConfig = [SF_URL, SF_HOST, REPORT_FIELDS, DETAIL_REPORT_FIELDS, summary_columnformat, headers, detail_columnformat, detail_headers, wb, ws, ws2]
|
||||||
|
|
||||||
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB[option]))
|
return ClientConfig
|
||||||
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, summary_columnformat, headers[option], detail_columnformat, detail_headers[option]]
|
|
||||||
return URL_HOST
|
|
||||||
|
|
||||||
def main():
|
|
||||||
URL_HOST = loadMenu()
|
|
||||||
URL = URL_HOST[0]
|
|
||||||
HOST = URL_HOST[1]
|
|
||||||
REPORT_FIELDS = URL_HOST[2]
|
|
||||||
wb = URL_HOST[3]
|
|
||||||
ws = URL_HOST[4]
|
|
||||||
ws2 = URL_HOST[5]
|
|
||||||
DETAIL_REPORT_FIELDS = URL_HOST[6]
|
|
||||||
summary_columnFormat = URL_HOST[7]
|
|
||||||
|
|
||||||
summary_SSheader = URL_HOST[8]
|
|
||||||
detail_columnFormat = URL_HOST[9]
|
|
||||||
detail_SSheader = URL_HOST[10]
|
|
||||||
|
|
||||||
ticket = Obtain_Ticket(URL, HOST)
|
|
||||||
Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader)
|
|
||||||
Release_Ticket(ticket, URL, HOST)
|
|
||||||
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user