From b83e181c4778258c9024c781dd758f325a0e3699 Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Fri, 28 May 2021 16:26:05 -0400 Subject: [PATCH] Fix bat file argument. Adding Company Name to address block. Add option to "un-send" an email. This marks the InvoiceSent column as False. You can then re-test and re-send the mail. This doesn't remove the original email history from the SentInvoice table, and resending the email will add a new record to the table. Orders can be un-sent via the Invoice Number or Order Number --- CFFInvoice.bat | 2 +- InvoiceDatabase.py | 11 +++++++++++ main.py | 8 +++++++- sendEmail.py | 6 ++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CFFInvoice.bat b/CFFInvoice.bat index b597fa2..36f35f3 100644 --- a/CFFInvoice.bat +++ b/CFFInvoice.bat @@ -1,2 +1,2 @@ @echo off -cmd /k "cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice\Scripts & activate & cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice & python main.py &1" \ No newline at end of file +cmd /k "cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice\Scripts & activate & cd /d C:\Program Files (x86)\AKSESS\Storefront\CFFInvoice & python main.py %1" \ No newline at end of file diff --git a/InvoiceDatabase.py b/InvoiceDatabase.py index 603e66f..b20de42 100644 --- a/InvoiceDatabase.py +++ b/InvoiceDatabase.py @@ -145,3 +145,14 @@ def mark_sent(InvoiceID, InvoiceDate): session.query(Invoice).filter(Invoice.InvoiceID == InvoiceID).update({Invoice.InvoiceSent: 1}) session.commit() + +def unsend(option, number): + option = option + number = number + # Invoice Number + if option == 1: + session.query(Invoice).filter(Invoice.InvoiceNumber == number).update({Invoice.InvoiceSent: 0}) + #Order Number + elif option == 2: + session.query(Invoice).filter(Invoice.OrderID == number).update({Invoice.InvoiceSent: 0}) + session.commit() \ No newline at end of file diff --git a/main.py b/main.py index a0e5704..c87b63b 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ except: fileName = '' while running is True: - print('1. load new excel file\n2. Send Test emails\n3. Send Invoices\n4. Quit') + print('1. load new excel file\n2. Send Test emails\n3. Send Invoices\n4. Un-send Invoce\n5. Quit') option = int(input()) if option == 1: print('Enter invoice number') @@ -21,6 +21,12 @@ while running is True: elif option == 3: sendEmail.send_email(False, 'ALL') elif option == 4: + print('1. Invoice Number\n2. Order Number') + option = int(input()) + print('Enter Number: ') + number = str(input()) + InvoiceDatabase.unsend(option, number) + elif option == 5: running = False else: print('not an option') diff --git a/sendEmail.py b/sendEmail.py index ac14011..df60be8 100644 --- a/sendEmail.py +++ b/sendEmail.py @@ -44,6 +44,7 @@ def send_email(test, record): # if ShippingCompany != 'None' and ShippingAddress2 == 'None': block = ''' +
{ShippingCompany}
{name}
{ShippingAddress1}
{ShippingCity}, {ShippingState} {ShippingZip} @@ -51,7 +52,7 @@ def send_email(test, record):

''' - addressBlock = block.format(name=Name, ShippingAddress1=ShippingAddress1, ShippingCity=ShippingCity, + addressBlock = block.format(ShippingCompany=ShippingCompany, name=Name, ShippingAddress1=ShippingAddress1, ShippingCity=ShippingCity, ShippingState=ShippingState, ShippingZip=ShippingPostalCode) @@ -179,7 +180,7 @@ def send_email(test, record): f.close() msg = MIMEMultipart() - msg['Subject'] = 'INVOICE ' + InvoiceNumber + msg['Subject'] = 'Payment Due: Invoice for CFF Portal Order ' + OrderNumber if test is True: msg['To'] = 'ddembinski@gll.com' # msg['Cc'] = 'ddembinski@gll.com' @@ -202,3 +203,4 @@ def send_email(test, record): sent_orders.append(OrderNumber) print(sent_orders) +