From 17894e82eac29e38cfbacbd07bc9e6817356622b Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Fri, 28 Jun 2019 13:24:25 -0400 Subject: [PATCH] Since there was some varience between clients on the order of the headers, I reworked some sections to work off header names instead of hardcoded column letter/numbers --- StorefrontUtilitiesConfig.xml | 505 +++++++++++++++++----------------- WriteReport.py | 35 ++- main.py | 24 +- 3 files changed, 298 insertions(+), 266 deletions(-) diff --git a/StorefrontUtilitiesConfig.xml b/StorefrontUtilitiesConfig.xml index 1dd6815..47e664b 100644 --- a/StorefrontUtilitiesConfig.xml +++ b/StorefrontUtilitiesConfig.xml @@ -268,6 +268,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -276,6 +277,7 @@ Order Status + None Balance Due @@ -294,34 +296,42 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -335,10 +345,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -347,25 +359,30 @@ Item Status + None Printing Option: HagenJobID GLI Job # DetailGLIJobID + None Product Name DetailProductName + None Product Metadata Field: PRODUCT_SKU CCM Item # DetailCCMItem + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -384,42 +401,52 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfilePhoneNumber UserProfilePhone + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -483,6 +510,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -491,6 +519,7 @@ Order Status + None Balance Due @@ -509,42 +538,52 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingEmailAddress InvoiceEmailAddress + None Shipping Field: ShippingCompany ShippingCompany + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -558,10 +597,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -570,20 +611,24 @@ Item Status + None Printing Option: HagenJobID GLI Job # DetailGLIJobID + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -593,16 +638,19 @@ Data List Record Count DetailDataListRecordCount + None Printing Option: OverrunQuantity OverrunQuantity DetailOverrunQuantity + None Printing Option: OptionalDataList OptionalDataList DetailOptionalDataList + None Checkout Field: PaymentChargeCode @@ -616,42 +664,52 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfilePhone UserProfilePhone + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -671,6 +729,7 @@ Printing Option: AppealCode_1_Quantity Appeal Code 1 Quantity + None Printing Option: AppealCode_2 @@ -680,6 +739,7 @@ Printing Option: AppealCode_2_Quantity Appeal Code 2 Quantity + None Printing Option: AppealCode_3 @@ -689,6 +749,7 @@ Printing Option: AppealCode_3_Quantity Appeal Code 3 Quantity + None Printing Option: AppealCode_4 @@ -697,7 +758,8 @@ Printing Option: AppealCode_4_Quantity - Appeal Code 4 Quantity + Appeal Code 4 Quantity + None Printing Option: AppealCode_5 @@ -707,6 +769,7 @@ Printing Option: AppealCode_5_Quantity Appeal Code 5 Quantity + None Printing Option: AppealCode_6 @@ -716,6 +779,7 @@ Printing Option: AppealCode_7_Quantity Appeal Code 7 Quantity + None Printing Option: AppealCode_8 @@ -725,6 +789,7 @@ Printing Option: AppealCode_9_Quantity Appeal Code 9 Quantity + None Printing Option: AppealCode_10 @@ -734,6 +799,7 @@ Printing Option: AppealCode_10_Quantity Appeal Code 10 Quantity + None Printing Option: AppealCode_11 @@ -743,6 +809,7 @@ Printing Option: AppealCode_11_Quantity Appeal Code 11 Quantity + None Printing Option: AppealCode_12 @@ -752,6 +819,7 @@ Printing Option: AppealCode_12_Quantity Appeal Code 12 Quantity + None @@ -805,6 +873,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -813,6 +882,7 @@ Order Status + None Balance Due @@ -826,34 +896,42 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -867,10 +945,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -879,20 +959,24 @@ Item Status + None Printing Option: HagenJobID GLI Job # DetailGLIJobID + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -902,16 +986,19 @@ Data List Record Count DetailDataListRecordCount + None Printing Option: OverrunQuantity OverrunQuantity DetailOverrunQuantity + None Printing Option: OptionalDataList OptionalDataList DetailOptionalDataList + None User Logon @@ -920,38 +1007,47 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1010,6 +1106,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -1018,6 +1115,7 @@ Order Status + None Balance Due @@ -1036,34 +1134,42 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1077,10 +1183,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -1089,20 +1197,24 @@ Item Status + None Printing Option: HagenJobID GLI Job # DetailGLIJobID + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -1112,21 +1224,25 @@ Data List Record Count DetailDataListRecordCount + None Printing Option: OverrunQuantity OverrunQuantity DetailOverrunQuantity + None Printing Option: OptionalDataList OptionalDataList DetailOptionalDataList + None Printing Option: OptionalDownload OptionalDownload DetailOptionalDownload + None Checkout Field: PaymentChargeCode @@ -1136,10 +1252,12 @@ Printing Option: BusinessUnits Business Unit + None Printing Option: Subledger Subledger + None User Logon @@ -1148,42 +1266,52 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfilePhoneNumber UserProfilePhone + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1242,6 +1370,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -1250,6 +1379,7 @@ Order Status + None Balance Due @@ -1263,34 +1393,42 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1304,10 +1442,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -1316,20 +1456,24 @@ Item Status + None Printing Option: HagenJobID GLI Job # DetailGLIJobID + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -1339,11 +1483,13 @@ Data List Record Count DetailDataListRecordCount + None Printing Option: OptionalDownload OptionalDownload DetailOptionalDownload + None User Logon @@ -1352,38 +1498,47 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1442,6 +1597,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -1450,6 +1606,7 @@ Order Status + None Order Price @@ -1459,6 +1616,7 @@ Checkout Field: PaymentMethodOfPayment Payment Method + None User Logon @@ -1467,38 +1625,47 @@ Owner Profile: UserProfileCompany UserProfileCompanyName + None Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1512,10 +1679,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -1524,15 +1693,18 @@ Item Status + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -1542,16 +1714,19 @@ Data List Record Count DetailDatalistRecordCount + None Printing Option: OverrunQuantity OverrunQuantity DetailOverrunQuantity + None Printing Option: OptionalDataList OptionalDataList DetailOptionalDataList + None User Logon @@ -1560,38 +1735,47 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1650,6 +1834,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -1658,6 +1843,7 @@ Order Status + None Order Price @@ -1671,6 +1857,7 @@ Checkout Field: PaymentMethodOfPayment Payment Method + None Checkout Field: PaymentChargeCode @@ -1680,6 +1867,7 @@ Checkout Field: PaymentCreditCardType Credit Card Type + None User Logon @@ -1689,38 +1877,47 @@ Owner Profile: UserProfileCompany UserProfileCompanyName + None Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1734,10 +1931,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -1750,19 +1949,23 @@ Item Status + None Printing Option: HagenJobID GLI Job # + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -1772,6 +1975,7 @@ Printing Option: OptionalDownload OptionalDownload + None User Logon @@ -1780,38 +1984,47 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -1861,259 +2074,9 @@ - - Westfield - http://westfield.gli.us.com/store/storefrontapi.asmx - - - - - Order ID - SummaryOrderID - - - Date/Time Created - DateTime - SummaryDateTime - - - Order Status - - - Balance Due - Currency - SummaryBalanceDue - - - Order Price - Currency - - - Checkout Field: PaymentMethodOfPayment - Payment Method - - - Shipping Field: DepartmentCode - DepartmentCode - Text - - - User Logon - Text - - - Owner Profile: UserProfileFirstName - UserProfileFirstName - - - Owner Profile: UserProfileLastName - UserProfileLastName - - - Shipping Field: ShippingFirstName - ShippingFirstName - - - Shipping Field: ShippingLastName - ShippingLastName - - - Shipping Field: ShippingAddress1 - ShippingAddress1 - - - Shipping Field: ShippingAddress2 - ShippingAddress2 - - - Shipping Field: ShippingCity - ShippingCity - - - Shipping Field: ShippingState - ShippingState - - - Shipping Field: ShippingPostalCode - ShippingPostalCode - Text - - - - - - - Order ID - DetailOrderID - - - Document ID - DetailDocumentID - - - Date/Time Order Created - DateTime - DetailDateTime - - - Item Status - - - Printing Option: HagenJobID - GLI Job # - DetailGLIJobID - - - Product Name - DetailProductName - - - Printing Option: PrintingQuantity - Quantity - DetailQuantity - - - Item Price - Currency - DetailItemPrice - - - Printing Option: ReasonCodes - Reason Codes - - - Product Metadata Field: PromailProductID - PromailProductID - - - Shipping Field: DepartmentCode - ShippingDepartmentCode - - - Shipping Field: AgencyCode - ShippingAgencyCode - - - Checkout Field: DepartmentCode - DepartmentCode - Text - - - User Logon - Text - - - Owner Profile: UserProfileFirstName - UserProfileFirstName - - - Owner Profile: UserProfileLastName - UserProfileLastName - - - Owner Profile: UserProfilePhoneNumber - UserProfilePhone - - - Owner Profile: UserProfileEmailAddress - UserProfileEmailAddress - - - Shipping Field: ShippingFirstName - ShippingFirstName - - - Shipping Field: ShippingLastName - ShippingLastName - - - Shipping Field: ShippingAddress1 - ShippingAddress1 - - - Shipping Field: ShippingAddress2 - ShippingAddress2 - - - Shipping Field: ShippingCity - ShippingCity - - - Shipping Field: ShippingState - ShippingState - - - Shipping Field: ShippingPostalCode - ShippingPostalCode - Text - - - Shipping Field: ShippingPhone - ShippingPhoneNumber - Text - - - Document's Description - Document's Description - Text - - - - - - - - - Login - Text - UserAccounts - - - Status - - - First Name - - - Last Name - - - User Profile: UserProfileEmailAddress - Email - Text - - - Date/Time Last Logged In - DateTime - - - Date/Time Created - DateTime - - - User Profile: AgencyQuestion - Agency Question - - - User Profile: AgencyCode - Agency Code - Text - - - User Profile: DepartmentCode - Department Code - Text - - - Is Admin - - - Is User - - - - - + + Westfield + Soprema http://soprema.gli.us.com/Store/storefrontapi.asmx @@ -2123,6 +2086,7 @@ Order ID SummaryOrderID + None Date/Time Created @@ -2131,6 +2095,7 @@ Order Status + None Order Price @@ -2144,11 +2109,13 @@ Checkout Field: PaymentMethodOfPayment Payment Method + None Checkout Field: PaymentCreditCardType Credit Card Type + None User Logon @@ -2159,34 +2126,42 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -2200,10 +2175,12 @@ Order ID DetailOrderID + None Document ID DetailDocumentID + None Date/Time Order Created @@ -2216,19 +2193,23 @@ Item Status + None Printing Option: HagenJobID GLI Job # + None Product Name DetailProductName + None Printing Option: PrintingQuantity Quantity DetailQuantity + Integer Item Price @@ -2238,6 +2219,7 @@ Printing Option: OptionalDownload OptionalDownload + None User Logon @@ -2246,38 +2228,47 @@ Owner Profile: UserProfileFirstName UserProfileFirstName + None Owner Profile: UserProfileLastName UserProfileLastName + None Owner Profile: UserProfileEmailAddress UserProfileEmailAddress + None Shipping Field: ShippingFirstName ShippingFirstName + None Shipping Field: ShippingLastName ShippingLastName + None Shipping Field: ShippingAddress1 ShippingAddress1 + None Shipping Field: ShippingAddress2 ShippingAddress2 + None Shipping Field: ShippingCity ShippingCity + None Shipping Field: ShippingState ShippingState + None Shipping Field: ShippingPostalCode @@ -2287,7 +2278,7 @@ - + @@ -2298,9 +2289,11 @@ First Name + None Last Name + None User Profile: UserProfileEmailAddress @@ -2317,9 +2310,11 @@ Is Admin + None Is User + None diff --git a/WriteReport.py b/WriteReport.py index d9542b7..91fab7b 100644 --- a/WriteReport.py +++ b/WriteReport.py @@ -1,7 +1,7 @@ from openpyxl.styles import Font from openpyxl.styles import PatternFill # from openpyxl.styles import numbers - +from openpyxl.utils import get_column_letter bold = Font(bold=True) @@ -65,13 +65,32 @@ def Format_Report(sheet, SSheader, columnFormat): count += 1 rowcount = 1 -def Save_Report(wb, sheet, sheet2, sheet3, SSheader, columnFormat): +def Save_Report(wb, sheet, sheet2, sheet3, SSheader, detail_header, columnFormat): # adds total fields at bottom of report summarylength = sheet.max_row itemlength = sheet2.max_row productlength = sheet3.max_row + PrintQuantity = 0 + for x in detail_header: + if x != "Printing Option: PrintingQuantity": + PrintQuantity += 1 + else: + break + PrintQuantity += 1 + + ItemPrice = 0 + for x in detail_header: + if x != "Item Price": + ItemPrice += 1 + else: + break + ItemPrice += 1 + + PrintQuantityColumn = get_column_letter(PrintQuantity) + ItemPriceColumn = get_column_letter(ItemPrice) + lightGreen = 'ADFF2F' darkGreen = '006400' @@ -82,8 +101,15 @@ def Save_Report(wb, sheet, sheet2, sheet3, SSheader, columnFormat): sheet.cell(column = 8, row = summarylength+1).fill = PatternFill(start_color=lightGreen, end_color=darkGreen, fill_type='solid') sheet.cell(column = 8, row= summarylength+1).font = Font(color=darkGreen) - sheet2.cell(column=7, row=itemlength + 1, value="=SUM(G2:G" + str(itemlength)+")") - sheet2.cell(column=8, row=itemlength + 1, value="=SUM(H2:H" + str(itemlength)+")") + sheet2.cell(column=PrintQuantity, row=itemlength + 1, value="=SUM(" + PrintQuantityColumn + "2:" + PrintQuantityColumn + str(itemlength) + ")") + sheet2.cell(column=ItemPrice, row=itemlength + 1, value="=SUM(" + ItemPriceColumn + "2:" + ItemPriceColumn + str(itemlength) + ")") + + + + + # sheet2.cell(column=PrintQuantity, row=itemlength + 1, value="=SUM(G2:G" + str(itemlength)+")") + # sheet2.cell(column=ItemPrice, row=itemlength + 1, value="=SUM(H2:H" + str(itemlength)+")") + # Format_Report misses this one. Whoops sheet2.cell(column=8, row=itemlength + 1).number_format = '$#,##0.00_);($#,##0.00)' @@ -109,6 +135,7 @@ def Save_Report(wb, sheet, sheet2, sheet3, SSheader, columnFormat): sheet.cell(column=5, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)' sheet.cell(column=6, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)' sheet.cell(column=7, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)' + sheet.cell(column=8, row=rowcount).number_format = '$#,##0.00_);($#,##0.00)' if rowcount < sheet.max_row: rowcount += 1 count += 1 diff --git a/main.py b/main.py index dc28e58..f0173ff 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,7 @@ import requests from bs4 import BeautifulSoup as bs from openpyxl import workbook - +from openpyxl.utils import get_column_letter from WriteReport import * from ClientSpecific import * @@ -140,8 +140,6 @@ 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)) - - ### THIS IS WHERE THE EXTRA SUMMARY TAB SECTION WAS ### # Add columns to Summary Tab ws.insert_cols(2) @@ -160,12 +158,21 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL count = count + 1 # Production and Adjustment Charges + + ItemPrice = 0 + for x in detail_SSheader: + if x != "Item Price": + ItemPrice += 1 + else: + break + ItemPrice += 1 + ItemPriceColumn = get_column_letter(ItemPrice) + count = 1 for row in ws: if count != 1: - # value = "=SUMIF(A:A,'Item Detail'!A:A,'Item Detail'!H:H)" - value = "=SUMIF('item Detail'!A:A,A" + str(count) + ",'Item Detail'!H:H)" + value = "=SUMIF('item Detail'!A:A,A" + str(count) + ",'Item Detail'!" + ItemPriceColumn + ":" + ItemPriceColumn + ")" ws.cell(column=5, row=count, value=value) value = "=H" + str(count) + "-E" + str(count) + "-F" + str(count) ws.cell(column=7, row=count, value = value) @@ -178,7 +185,9 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL print("Getting Item Detail") for z in ExternalID: - report_filter = """<?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue=\"""" + z + """\" maxValue="" /> </PFWebFilter:UserFilter>""" + # report_filter = """<?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue=\"""" + z + """\" maxValue="" /> </PFWebFilter:UserFilter>""" + report_filter = """<?xml version="1.0"?> <PFWebFilter:UserFilter xmlns:PFWebFilter="http://www.pageflex.com/schemas/2004/Storefront/UserFilters/20040817" filterClass="Items"> <PFWebFilter:Step publicFieldName="Order ID" query="ExactEquals" minValue=\"""" + z + """\" maxValue="" /> <PFWebFilter:Step publicFieldName="Item Status" query="ExactEquals" minValue=\"Shipped" maxValue="" /> </PFWebFilter:UserFilter>""" + send = """ @@ -223,6 +232,7 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL count += 1 # Add Quantity and Item Price columns. Populate both based using SUMIF off of the Item Detail Tab + ws3['A1'] = "Product Name" ws3['B1'] = "Quantity" ws3['C1'] = "Item Price" @@ -244,7 +254,7 @@ def Run_Report(ticket, URL, HOST, REPORT_FIELDS, wb, ws, ws2, DETAIL_REPORT_FIEL # 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, summary_columnFormat) + Save_Report(wb, ws, ws2, ws3, summary_SSheader, detail_SSheader, summary_columnFormat) def loadMenu():