From 717210636d35ee357023b9daadb77745caf11815 Mon Sep 17 00:00:00 2001 From: JohnKent Date: Wed, 10 Jul 2019 22:57:23 -0400 Subject: [PATCH] The tool can now update the payment history. --- mortgage_template.py | 26 ++++++- templates/add.html | 6 +- templates/main.html | 14 +++- testloan.json | 167 ++++++++++++++++++++++++++++--------------- 4 files changed, 150 insertions(+), 63 deletions(-) diff --git a/mortgage_template.py b/mortgage_template.py index f31ae5d..dfa8260 100644 --- a/mortgage_template.py +++ b/mortgage_template.py @@ -203,7 +203,7 @@ def amortizeLoan(loan): def transformTemplate(template_fileName, loanModel): - # template_filename = "statement.txt.jinja" + # template_filename = "statement.text.jinja" # setup jinja for creating the statement env = Environment(loader=FileSystemLoader('.')) template = env.get_template(template_fileName) @@ -242,6 +242,30 @@ def generateEmail(from_address, to_address, subject, body, pdfAttachment, txtAtt return msg +def generateEmailWithAttachments(from_address, to_address, subject, body, pdfAttachment, htmlAttachment, txtAttachment): + msg = MIMEMultipart() + msg['Subject'] = subject + msg['From'] = from_address + msg['To'] = to_address + + msg.attach(MIMEText(body)) + + if (pdfAttachment != None): + part = MIMEBase("application", "octet-stream") + part.set_payload(pdfAttachment) + Encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="statement.pdf"') + msg.attach(part) + + if (txtAttachment != None): + part = MIMEBase("text", "html") + part.set_payload(txtAttachment) + Encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="statement.html"') + msg.attach(part) + + return msg + def sendEmail(msg, from_address, to_address, passwd): try: diff --git a/templates/add.html b/templates/add.html index 7e68337..78323fd 100644 --- a/templates/add.html +++ b/templates/add.html @@ -12,7 +12,11 @@ - + +{% for message in messages %} + +{% endfor %} +
{{message}}
Return to Main Screen. \ No newline at end of file diff --git a/templates/main.html b/templates/main.html index b311656..9bc9409 100644 --- a/templates/main.html +++ b/templates/main.html @@ -151,11 +151,21 @@ - +
-

Add Loan Payment Tab

+
+ + + + + + + + +
Record a Payment
Payment Date:
Payment Amount:
+
diff --git a/testloan.json b/testloan.json index 8a7331b..731c04d 100644 --- a/testloan.json +++ b/testloan.json @@ -1,65 +1,114 @@ { -"htmlTemplate": "statement.pdf.jinja", -"txtTemplate": "statement.txt.jinja", -"format": "html", -"email": { - "from_address": "jkent3rd@gmail.com", - "to_address": "jkent3rd@gmail.com", - "server": "smtp.gmail.com", - "password": "pvyrbcnzrjoizprn", - "template": "./template.txt", - "send_pdf": "true", - "send_text": "true", - "subject": "Your loan statement...", - "body": "Your loan statement is attached.", - "text": "Please see your most recent account statement." + "htmlTemplate": "statement.pdf.jinja", + "parameters": { + "monthly_payment": 589.0, + "interest_rate": 6.5, + "start_interest_date": "2017-12-05", + "payment_day_of_month": "15", + "first_payment_month": "2018-01-15", + "account_number": "100100", + "principal": 10020.0, + "start_date": "2017-12-05", + "periods_per_year": 12, + "periods": 18 }, -"parameters": { - "account_number": "100100", - "principal": 10020.00, - "interest_rate": 6.5, - "periods_per_year": 12, - "periods": 18, - "start_date": "2017-12-05", - "start_interest_date": "2017-12-05", - "first_payment_month": "2018-01-15", - "monthly_payment": 589.00, - "payment_day_of_month": "15" + "format": "html", + "txtTemplate": "statement.txt.jinja", + "lender": { + "city": "Washington", + "name": "Test Lender", + "zip": "20011", + "phone": "703.343.0782", + "state": "DC", + "address": "743 Madison St NW" }, -"payments": [ - ["2018-01-16", "589.00"], - ["2018-03-30", "589.00"], - ["2018-04-06", "589.00"], - ["2018-04-12", "589.00"], - ["2018-05-28", "589.00"], - ["2018-06-12", "589.00"], - ["2018-07-13", "589.00"], - ["2018-08-14", "589.00"], - ["2018-09-26", "589.00"], - ["2018-10-15", "0"], - ["2018-11-29", "589.00"], - ["2018-12-31", "589.00"], - ["2019-01-28", "589.00"], - ["2019-03-15", "589.00"] - ], -"borrower": { - "name": "Bear Houses, LLC", - "address": "301 N Beauregard St Apt 203", - "city": "Alexandria", - "state": "VA", - "zip": "22312" + "header": { + "date": "Today", + "title": "Installment Loan Test Statement" }, -"lender": { - "name": "John Kent", - "phone": "703.343.0782", - "address": "743 Madison St NW", - "city": "Washington", - "state": "DC", - "zip": "20011" + "payments": [ + [ + "2018-01-16", + "589.00" + ], + [ + "2018-03-30", + "589.00" + ], + [ + "2018-04-06", + "589.00" + ], + [ + "2018-04-12", + "589.00" + ], + [ + "2018-05-28", + "589.00" + ], + [ + "2018-06-12", + "589.00" + ], + [ + "2018-07-13", + "589.00" + ], + [ + "2018-08-14", + "589.00" + ], + [ + "2018-09-26", + "589.00" + ], + [ + "2018-10-15", + "0" + ], + [ + "2018-11-29", + "589.00" + ], + [ + "2018-12-31", + "589.00" + ], + [ + "2019-01-28", + "589.00" + ], + [ + "2019-03-15", + "589.00" + ], + [ + "2019-07-10", + "123.12" + ], + [ + "2019-07-10", + "120" + ] + ], + "borrower": { + "city": "Alexandria", + "state": "VA", + "name": "Test Borrower Houses, LLC", + "zip": "22312", + "address": "301 N Beauregard St Apt 203" }, -"header": { - "title": "Installment Loan Statement", - "date": "Today" + "email": { + "body": "Your test loan statement is attached.", + "to_address": "jkent3rd@gmail.com", + "from_address": "jkent3rd@gmail.com", + "text": "Please see your most recent test account statement.", + "server": "smtp.gmail.com", + "send_text": "true", + "template": "./template.txt", + "send_pdf": "true", + "password": "pvyrbcnzrjoizprn", + "subject": "Your test loan statement..." } -} - +} \ No newline at end of file