Cleaned some sections up a bit to make format checking and column styling better.

This commit is contained in:
Dan Dembinski
2019-06-25 16:42:47 -04:00
parent 28fce7e10f
commit 988159af7e
2 changed files with 76 additions and 35 deletions

41
main.py
View File

@@ -1,11 +1,11 @@
import requests
from bs4 import BeautifulSoup as bs
from openpyxl import workbook
from openpyxl.styles import Font
from WriteReport import *
from ClientSpecific import *
bold = Font(bold=True)
def Obtain_Ticket(URL, HOST):
GetTicket = """<?xml version="1.0" encoding="utf-8"?>
@@ -85,6 +85,10 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
for cell in ws['A']:
ExternalID.append(cell.value)
ExternalID.pop(0)
# weird = len(ExternalID)
# ExternalID.pop(weird-1)
# print(ExternalID)
# exit()
# Reset the header SOAPAction to FindOrderID. This is needed to get the OrderID needed for Shipping Charges
headers = {'Host': HOST, 'Content-Type': 'application/soap+xml; charset=utf-8', 'Content-Length': 'length', 'SOAPAction': 'http://www.pageflex.com/XmlWebServices/2004/StorefrontAPI/20041111/FindOrderID'}
@@ -135,7 +139,9 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
for w in y.find_all('fval'):
shippingcost.append(float(w.text))
# Add columns to Summary Tab
### THIS IS WHERE THE EXTRA SUMMARY TAB SECTION WAS ###
# Add columns to Summary Tab
ws.insert_cols(2)
ws['B1'] = "Match"
@@ -146,23 +152,21 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
ws.insert_cols(7)
ws['G1'] = "Adjustments"
# Load Shipping Charges into the sheet
# Load Shipping Charges into the sheet
count = 2
for x in shippingcost:
ws.cell(column=6, row=count, value=x)
count = count + 1
# Compute Production Charges and write to spreadsheet
count = 2
# Compute Production Charges and write to spreadsheet
count = 1
for row in ws:
value = "=H"+str(count)+"-G"+str(count)+"-F"+str(count)
ws.cell(column=5, row=count, value=value)
if count != 1:
value = "=H" + str(count) + "-G" + str(count) + "-F" + str(count)
ws.cell(column=5, row=count, value=value)
count += 1
############# Order Details tab #############
############# Order Details tab #############
print("Getting Item Detail")
@@ -189,23 +193,16 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL
temp2 = temp1[1].split('<error />')
report = (temp2[0])
y = bs(report, "lxml")
# Opens report file and writes each row
sheet = ws2
Write_Report(y, detail_columnFormat, detail_SSheader, sheet)
# Finalize Spreadsheet and save
for cell in ws["1:1"]:
cell.font = bold
for cell in ws2["1:1"]:
cell.font = bold
print("Enter a filename for the report: ")
filename = input()
wb.save('report.xlsx')
Format_Report(ws, summary_SSheader, summary_columnFormat)
Format_Report(ws2, detail_SSheader, detail_columnFormat)
Save_Report(wb, ws, ws2, summary_SSheader, summary_columnFormat)
def loadMenu():