Updating to most recent
This commit is contained in:
71
main.py
71
main.py
@@ -1,3 +1,6 @@
|
||||
## SET FLASK_APP=SFU.py
|
||||
##Flask Run
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
from openpyxl import workbook
|
||||
@@ -22,7 +25,7 @@ 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]
|
||||
@@ -43,7 +46,7 @@ def Release_Ticket(ticket, URL, HOST):
|
||||
#("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 = []
|
||||
id = []
|
||||
@@ -204,6 +207,7 @@ 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>')
|
||||
@@ -237,26 +241,49 @@ 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'!G:G)"
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + PrintQuantityColumn + ":" + PrintQuantityColumn + ")"
|
||||
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'!H:H)"
|
||||
value = "=SUMIF('Item Detail'!F:F,A"+str(count)+",'Item Detail'!" + ItemPriceColumn + ":" + ItemPriceColumn + ")"
|
||||
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 loadClients():
|
||||
|
||||
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||
@@ -293,6 +320,10 @@ def GetClientConfig(Client):
|
||||
summary_columnformat = []
|
||||
detail_columnformat = []
|
||||
|
||||
if Client == 'Westfield':
|
||||
Westfield()
|
||||
return
|
||||
|
||||
# Loads config file and reads in XML
|
||||
ConfigFile = "../StorefrontUtilitiesConfig.xml"
|
||||
|
||||
@@ -364,6 +395,7 @@ def GetClientConfig(Client):
|
||||
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'):
|
||||
@@ -412,33 +444,4 @@ def GetClientConfig(Client):
|
||||
|
||||
ClientConfig = [SF_URL, SF_HOST, REPORT_FIELDS, DETAIL_REPORT_FIELDS, summary_columnformat, headers, detail_columnformat, detail_headers, wb, ws, ws2]
|
||||
|
||||
return ClientConfig
|
||||
|
||||
|
||||
# def loadMenu():
|
||||
#
|
||||
# Since I forgot what this is...It passes ClientName over to ClientSpecific.py to see if they have any custom tabs.
|
||||
# client_Specific_Tabs(ClientName[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()
|
||||
return ClientConfig
|
||||
Reference in New Issue
Block a user