Column Format is now working for both summary and item details. Load function passes client name to the client_Specific_Tabs function in ClientSpecific.py. This will allow any client customization to be done outside of the main program (in theory. I haven't actually tested this yet).
This commit is contained in:
16
ClientSpecific.py
Normal file
16
ClientSpecific.py
Normal file
@@ -0,0 +1,16 @@
|
||||
def client_Specific_Tabs(option):
|
||||
if option == "Westfield":
|
||||
Westfield()
|
||||
elif option == " CCM":
|
||||
CCM()
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
def Westfield():
|
||||
print("Neat westfield stuff will go here")
|
||||
exit()
|
||||
|
||||
def CCM():
|
||||
print("Neat CCM stuff will go here")
|
||||
exit()
|
||||
2320
Config_ORIG.xml
2320
Config_ORIG.xml
File diff suppressed because it is too large
Load Diff
@@ -98,7 +98,6 @@
|
||||
<ColumnName>Date/Time Order Created</ColumnName>
|
||||
<ColumnFormat>DateTime</ColumnFormat>
|
||||
<RangeName>DetailDateTime</RangeName>
|
||||
<ColumnFormat>None</ColumnFormat>
|
||||
</Column>
|
||||
<Column>
|
||||
<ColumnName>Item Status</ColumnName>
|
||||
@@ -119,7 +118,7 @@
|
||||
<ColumnName>Printing Option: PrintingQuantity</ColumnName>
|
||||
<ColumnHeader>Quantity</ColumnHeader>
|
||||
<RangeName>DetailQuantity</RangeName>
|
||||
<ColumnFormat>None</ColumnFormat>
|
||||
<ColumnFormat>Integer</ColumnFormat>
|
||||
</Column>
|
||||
<Column>
|
||||
<ColumnName>Item Price</ColumnName>
|
||||
@@ -129,13 +128,13 @@
|
||||
<Column>
|
||||
<ColumnName>Data List Record Count</ColumnName>
|
||||
<RangeName>DetailDataListRecordCount</RangeName>
|
||||
<ColumnFormat>None</ColumnFormat>
|
||||
<ColumnFormat>Integer</ColumnFormat>
|
||||
</Column>
|
||||
<Column>
|
||||
<ColumnName>Printing Option: OverrunQuantity</ColumnName>
|
||||
<ColumnHeader>OverrunQuantity</ColumnHeader>
|
||||
<RangeName>DetailOverrunQuantity</RangeName>
|
||||
<ColumnFormat>None</ColumnFormat>
|
||||
<ColumnFormat>Integer</ColumnFormat>
|
||||
</Column>
|
||||
<Column>
|
||||
<ColumnName>Printing Option: OptionalDataList</ColumnName>
|
||||
|
||||
@@ -1,31 +1,48 @@
|
||||
def Write_Report(y, ws, columnFormat, SSheader):
|
||||
def Write_Report(y, columnFormat, SSheader, sheet):
|
||||
results = []
|
||||
|
||||
count = 0
|
||||
for child in y.report:
|
||||
for childs in child:
|
||||
print(columnFormat[SSheader[count]])
|
||||
count = count + 1
|
||||
if '$' in childs.text:
|
||||
convert = childs.text
|
||||
apply = convert[1:]
|
||||
results.append(float(apply.replace(',', '')))
|
||||
if childs.text is not "":
|
||||
asdf = Format_Check(columnFormat, SSheader, childs, count)
|
||||
else:
|
||||
results.append(childs.text)
|
||||
ws.append(results)
|
||||
results = []
|
||||
asdf = childs.text
|
||||
results.append(asdf)
|
||||
count = count + 1
|
||||
count = 0
|
||||
sheet.append(results)
|
||||
results = []
|
||||
|
||||
def Detail_Write_Report(y, ws):
|
||||
# def Detail_Write_Report(y, sheet):
|
||||
# results = []
|
||||
#
|
||||
# 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)
|
||||
# sheet.append(results)
|
||||
# results = []
|
||||
|
||||
def Format_Check(columnFormat, SSheader, childs, count):
|
||||
check = columnFormat[SSheader[count]]
|
||||
results = []
|
||||
|
||||
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)
|
||||
ws.append(results)
|
||||
results = []
|
||||
if check == "None":
|
||||
return childs.text
|
||||
elif check == "Currency":
|
||||
if '$' in childs.text:
|
||||
convert = childs.text
|
||||
apply = convert[1:]
|
||||
results.append(float(apply.replace(',', '')))
|
||||
return results[0]
|
||||
else:
|
||||
return float(childs.text)
|
||||
elif check == "Integer":
|
||||
return int(childs.text)
|
||||
else:
|
||||
return childs.text
|
||||
|
||||
56
main.py
56
main.py
@@ -1,10 +1,9 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
# import csv
|
||||
from openpyxl import workbook
|
||||
from openpyxl.styles import Font
|
||||
|
||||
from WriteReport import *
|
||||
from ClientSpecific import *
|
||||
|
||||
bold = Font(bold=True)
|
||||
|
||||
@@ -42,11 +41,8 @@ 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, columnFormat, SSheader):
|
||||
def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIELDS, summary_columnFormat, summary_SSheader, detail_columnFormat, detail_SSheader):
|
||||
|
||||
ExternalID = []
|
||||
id = []
|
||||
@@ -82,7 +78,8 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
y = bs(report, "lxml")
|
||||
|
||||
# Opens report file and writes each row
|
||||
Write_Report(y, ws, columnFormat, SSheader)
|
||||
sheet = ws
|
||||
Write_Report(y, summary_columnFormat, summary_SSheader, sheet)
|
||||
|
||||
# Grabs all the Order IDs from Column A
|
||||
for cell in ws['A']:
|
||||
@@ -197,7 +194,8 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
|
||||
|
||||
|
||||
# Opens report file and writes each row
|
||||
Detail_Write_Report(y, ws)
|
||||
sheet = ws2
|
||||
Write_Report(y, detail_columnFormat, detail_SSheader, sheet)
|
||||
|
||||
# Finalize Spreadsheet and save
|
||||
|
||||
@@ -225,6 +223,7 @@ def loadMenu():
|
||||
detail_headers = []
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
COLUMN_FORMAT = []
|
||||
detail_columnformat = []
|
||||
|
||||
# Open the config file
|
||||
with open(ConfigFile) as f:
|
||||
@@ -292,12 +291,11 @@ def loadMenu():
|
||||
|
||||
option = int(input())
|
||||
|
||||
if ClientName[option] == "Westfield":
|
||||
Westfield()
|
||||
client_Specific_Tabs(ClientName[option])
|
||||
|
||||
columnformat = dict.fromkeys(headers[option])
|
||||
summary_columnformat = dict.fromkeys(headers[option])
|
||||
|
||||
# Get specific Column Types for chosen client
|
||||
# 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 == ClientName[option]:
|
||||
@@ -305,10 +303,27 @@ def loadMenu():
|
||||
for g in x.find_all('summarytab'):
|
||||
for z in g.find_all('columnformat'):
|
||||
CLIENT_COLUMN_FORMAT.append(z.text)
|
||||
# set Column Types Header Dictionary
|
||||
# set Summary Column Types Header Dictionary
|
||||
count = 0
|
||||
for key in columnformat:
|
||||
columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
for key in summary_columnformat:
|
||||
summary_columnformat[key] = CLIENT_COLUMN_FORMAT[count]
|
||||
count = count + 1
|
||||
|
||||
CLIENT_COLUMN_FORMAT = []
|
||||
# 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 == 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[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
|
||||
@@ -322,10 +337,9 @@ def loadMenu():
|
||||
|
||||
# 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]))
|
||||
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, columnformat, headers[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():
|
||||
@@ -337,12 +351,14 @@ def main():
|
||||
ws = URL_HOST[4]
|
||||
ws2 = URL_HOST[5]
|
||||
DETAIL_REPORT_FIELDS = URL_HOST[6]
|
||||
columnFormat = URL_HOST[7]
|
||||
summary_columnFormat = URL_HOST[7]
|
||||
|
||||
SSheader = URL_HOST[8]
|
||||
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, columnFormat, SSheader)
|
||||
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