Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
256bd1ceae |
@@ -1,62 +1,16 @@
|
||||
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")
|
||||
def client_Specific_Tabs(option):
|
||||
if option == "Westfield":
|
||||
Westfield()
|
||||
elif option == "CCM":
|
||||
CCM(wb, ticket, HOST, URL)
|
||||
elif option == " CCM":
|
||||
CCM()
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
def Westfield():
|
||||
return
|
||||
print("Neat westfield stuff will go here")
|
||||
exit()
|
||||
|
||||
def CCM(wb, ticket, HOST, URL):
|
||||
|
||||
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
|
||||
def CCM():
|
||||
print("Neat CCM stuff will go here")
|
||||
exit()
|
||||
180
XMLTesting.py
180
XMLTesting.py
@@ -1,136 +1,74 @@
|
||||
import requests
|
||||
from datetime import datetime, timedelta
|
||||
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
|
||||
from bs4 import BeautifulSoup as bs
|
||||
# import csv
|
||||
from openpyxl import workbook
|
||||
|
||||
|
||||
|
||||
temp1 = response.split('</GetReportResult>')
|
||||
temp2 = temp1[1].split('<error />')
|
||||
report = (temp2[0])
|
||||
###REPORT ColumnFormat TESTING#####
|
||||
|
||||
print(report)
|
||||
with open("StorefrontUtilitiesConfig.xml") as f:
|
||||
r = f.read()
|
||||
|
||||
Release_Ticket(ticket, URL, HOST)
|
||||
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
|
||||
|
||||
|
||||
# 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)
|
||||
for key in columnformat:
|
||||
columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
print(columnformat)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from app import app
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
from app import routes
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
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 )
|
||||
@@ -1,21 +0,0 @@
|
||||
<!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>
|
||||
176
main.py
176
main.py
@@ -1,5 +1,4 @@
|
||||
## SET FLASK_APP=SFU.py
|
||||
##Flask Run
|
||||
##CLI Version
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
@@ -10,7 +9,6 @@ from ClientSpecific import *
|
||||
|
||||
|
||||
|
||||
|
||||
def Obtain_Ticket(URL, HOST):
|
||||
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">
|
||||
@@ -25,11 +23,11 @@ def Obtain_Ticket(URL, HOST):
|
||||
|
||||
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
||||
response = requests.post(url=URL, data=GetTicket, headers=headers).text
|
||||
#print(response)
|
||||
# print(response)
|
||||
temp1 = response.split('<ObtainUserTicketResult>')
|
||||
temp2 = temp1[1].split('</ObtainUserTicketResult>')
|
||||
ticket = temp2[0]
|
||||
#print("got ticket: " + ticket)
|
||||
print("got ticket: " + ticket)
|
||||
return ticket
|
||||
|
||||
def Release_Ticket(ticket, URL, HOST):
|
||||
@@ -43,10 +41,10 @@ def Release_Ticket(ticket, URL, HOST):
|
||||
</soap12:Envelope>"""
|
||||
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length'}
|
||||
response = requests.post(url=URL, data=ReleaseTicket, headers=headers).text
|
||||
#("released ticket "+ticket)
|
||||
print("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, client):
|
||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader):
|
||||
|
||||
ExternalID = []
|
||||
id = []
|
||||
@@ -207,7 +205,6 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
</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>')
|
||||
@@ -241,53 +238,43 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
ws3['A1'] = "Product Name"
|
||||
ws3['B1'] = "Quantity"
|
||||
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
|
||||
for x in ws3:
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + PrintQuantityColumn + ":" + PrintQuantityColumn + ")"
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!G:G)"
|
||||
if count != 1:
|
||||
ws3.cell(column = 2, row = count, value = value)
|
||||
count += 1
|
||||
|
||||
count = 1
|
||||
for x in ws3:
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + ItemPriceColumn + ":" + ItemPriceColumn + ")"
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!H:H)"
|
||||
if count != 1:
|
||||
ws3.cell(column = 3, row = count, value = value)
|
||||
count += 1
|
||||
|
||||
|
||||
client_Specific_Tabs(client, wb, ticket, HOST, URL)
|
||||
# Finalize Spreadsheet and save
|
||||
Format_Report(ws, summary_SSheader, summary_columnFormat)
|
||||
Format_Report(ws2, detail_SSheader, detail_columnFormat)
|
||||
Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat)
|
||||
|
||||
def loadMenu():
|
||||
|
||||
|
||||
def loadClients():
|
||||
|
||||
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||
ConfigFile = "StorefrontUtilitiesConfig.xml"
|
||||
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
|
||||
with open(ConfigFile) as f:
|
||||
@@ -295,64 +282,26 @@ def loadClients():
|
||||
|
||||
y = bs(r, "lxml")
|
||||
|
||||
# Get list of clients
|
||||
# Get list of clients
|
||||
for x in y.find_all('name'):
|
||||
# print(x.text)
|
||||
ClientName.append(x.text)
|
||||
|
||||
return ClientName
|
||||
# Get Storefront API URls
|
||||
for x in y.find_all('storefrontapiurl'):
|
||||
# print(x)
|
||||
SF_URL.append(x.text)
|
||||
|
||||
def GetClientConfig(Client):
|
||||
|
||||
SF_URL = ""
|
||||
CLIENT_SUMMARY_TAB = []
|
||||
client_headers = []
|
||||
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('://')
|
||||
# Get Storefront Host URLs
|
||||
for x in SF_URL:
|
||||
temp1 = x.split('://')
|
||||
temp2 = temp1[1].split('/')
|
||||
SF_HOST = (temp2[0])
|
||||
|
||||
# Get Storefront Host URL
|
||||
HOST = (temp2[0])
|
||||
SF_HOST.append(HOST)
|
||||
|
||||
|
||||
# Get Monthly Report Summary 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('summarytab'):
|
||||
for z in g.find_all('columnname'):
|
||||
@@ -366,8 +315,6 @@ def GetClientConfig(Client):
|
||||
|
||||
# Get Monthly Report Column Format
|
||||
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'):
|
||||
@@ -377,8 +324,6 @@ def GetClientConfig(Client):
|
||||
|
||||
# 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'):
|
||||
@@ -390,23 +335,25 @@ def GetClientConfig(Client):
|
||||
CLIENT_DETAIL_TAB = []
|
||||
client_detail_headers = []
|
||||
|
||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||
choice = 0
|
||||
for x in ClientName:
|
||||
print(choice, x)
|
||||
choice = choice + 1
|
||||
|
||||
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_TAB))
|
||||
DETAIL_REPORT_FIELDS = '\n'.join(map(str, DETAIL_TAB))
|
||||
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 x in w.find_all('name'):
|
||||
if x.text == Client:
|
||||
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)
|
||||
|
||||
|
||||
summary_columnformat = dict.fromkeys(headers[0])
|
||||
# set Summary Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in summary_columnformat:
|
||||
@@ -417,31 +364,52 @@ def GetClientConfig(Client):
|
||||
# Get specific Detail Column Types for chosen client
|
||||
for w in y.find_all('client'):
|
||||
for x in w.find_all('name'):
|
||||
if x.text == Client:
|
||||
if x.text == ClientName[option]:
|
||||
for x in w.find_all('monthlyreport'):
|
||||
for g in x.find_all('detailtab'):
|
||||
for z in g.find_all('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
|
||||
|
||||
|
||||
detail_columnformat = dict.fromkeys(detail_headers[0])
|
||||
# set Detail Column Types Header Dictionary
|
||||
detail_columnformat = dict.fromkeys(detail_headers[option])
|
||||
# set Detail Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in detail_columnformat:
|
||||
detail_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
|
||||
|
||||
# create new report file and add headers based on config file
|
||||
wb = workbook.Workbook()
|
||||
ws = wb.active
|
||||
ws.title = "Order Summary"
|
||||
ws.append(headers[0])
|
||||
ws.append(headers[option])
|
||||
|
||||
ws2 = wb.create_sheet("Item Detail")
|
||||
ws2.append(detail_headers[0])
|
||||
ws2.append(detail_headers[option])
|
||||
|
||||
ClientConfig = [SF_URL, SF_HOST, REPORT_FIELDS, DETAIL_REPORT_FIELDS, summary_columnformat, headers, detail_columnformat, detail_headers, wb, ws, ws2]
|
||||
# converts summary_tab values to a string, adds everything to the URL_HOST array and returns it
|
||||
|
||||
return ClientConfig
|
||||
REPORT_FIELDS = '\n'.join(map(str, SUMMARY_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, 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