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

This commit is contained in:
Dan Dembinski
2021-05-28 16:26:05 -04:00
parent 64d913572c
commit b83e181c47
4 changed files with 23 additions and 4 deletions

View File

@@ -1,2 +1,2 @@
@echo off @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" 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"

View File

@@ -145,3 +145,14 @@ def mark_sent(InvoiceID, InvoiceDate):
session.query(Invoice).filter(Invoice.InvoiceID == InvoiceID).update({Invoice.InvoiceSent: 1}) session.query(Invoice).filter(Invoice.InvoiceID == InvoiceID).update({Invoice.InvoiceSent: 1})
session.commit() 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()

View File

@@ -10,7 +10,7 @@ except:
fileName = '' fileName = ''
while running is True: 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()) option = int(input())
if option == 1: if option == 1:
print('Enter invoice number') print('Enter invoice number')
@@ -21,6 +21,12 @@ while running is True:
elif option == 3: elif option == 3:
sendEmail.send_email(False, 'ALL') sendEmail.send_email(False, 'ALL')
elif option == 4: 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 running = False
else: else:
print('not an option') print('not an option')

View File

@@ -44,6 +44,7 @@ def send_email(test, record):
# if ShippingCompany != 'None' and ShippingAddress2 == 'None': # if ShippingCompany != 'None' and ShippingAddress2 == 'None':
block = ''' block = '''
<br>{ShippingCompany}
<br>{name} <br>{name}
<br>{ShippingAddress1} <br>{ShippingAddress1}
<br>{ShippingCity}, {ShippingState} {ShippingZip} <br>{ShippingCity}, {ShippingState} {ShippingZip}
@@ -51,7 +52,7 @@ def send_email(test, record):
</p> </p>
</td> </td>
''' '''
addressBlock = block.format(name=Name, ShippingAddress1=ShippingAddress1, ShippingCity=ShippingCity, addressBlock = block.format(ShippingCompany=ShippingCompany, name=Name, ShippingAddress1=ShippingAddress1, ShippingCity=ShippingCity,
ShippingState=ShippingState, ShippingZip=ShippingPostalCode) ShippingState=ShippingState, ShippingZip=ShippingPostalCode)
@@ -179,7 +180,7 @@ def send_email(test, record):
f.close() f.close()
msg = MIMEMultipart() msg = MIMEMultipart()
msg['Subject'] = 'INVOICE ' + InvoiceNumber msg['Subject'] = 'Payment Due: Invoice for CFF Portal Order ' + OrderNumber
if test is True: if test is True:
msg['To'] = 'ddembinski@gll.com' msg['To'] = 'ddembinski@gll.com'
# msg['Cc'] = 'ddembinski@gll.com' # msg['Cc'] = 'ddembinski@gll.com'
@@ -202,3 +203,4 @@ def send_email(test, record):
sent_orders.append(OrderNumber) sent_orders.append(OrderNumber)
print(sent_orders) print(sent_orders)