Created a source directly for purposes of deployment as zip file.
Updated to Python 3.
This commit is contained in:
52
9Kloan.json
52
9Kloan.json
@@ -1,51 +1 @@
|
||||
{
|
||||
"htmlTemplate": "statement.pdf.jinja",
|
||||
"txtTemplate": "statement.txt.jinja",
|
||||
"format": "html",
|
||||
"email": {
|
||||
"from_address": "jkent3rd@gmail.com",
|
||||
"to_address": "grady@gradystreet.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."
|
||||
},
|
||||
"parameters": {
|
||||
"account_number": "100002",
|
||||
"principal": 9000.00,
|
||||
"interest_rate": 6.5,
|
||||
"periods_per_year": 12,
|
||||
"periods": 20,
|
||||
"start_date": "2019-06-15",
|
||||
"start_interest_date": "2019-06-17",
|
||||
"first_payment_month": "2019-07-15",
|
||||
"monthly_payment": 475.00,
|
||||
"payment_day_of_month": "15"
|
||||
},
|
||||
"payments": [
|
||||
],
|
||||
"borrower": {
|
||||
"name": "Bear Houses, LLC",
|
||||
"address": "301 N Beauregard St Apt 203",
|
||||
"city": "Alexandria",
|
||||
"state": "VA",
|
||||
"zip": "22312"
|
||||
},
|
||||
"lender": {
|
||||
"name": "Rivanna Graphite Investments, LLC",
|
||||
"phone": "703.343.0782",
|
||||
"address": "743 Madison St NW",
|
||||
"city": "Washington",
|
||||
"state": "DC",
|
||||
"zip": "20011"
|
||||
},
|
||||
"header": {
|
||||
"title": "Installment Loan Statement",
|
||||
"date": "Today"
|
||||
}
|
||||
}
|
||||
|
||||
{"htmlTemplate": "statement.pdf.jinja", "parameters": {"monthly_payment": 475.0, "interest_rate": 6.5, "start_interest_date": "2019-06-17", "payment_day_of_month": "15", "first_payment_month": "2019-07-15", "account_number": "100002", "periods": 20, "start_date": "2019-06-15", "periods_per_year": 12, "principal": 9000.0}, "format": "html", "email": {"body": "Your loan statement is attached.", "to_address": "grady@gradystreet.com", "from_address": "jkent3rd@gmail.com", "text": "Please see your most recent account statement.", "server": "smtp.gmail.com", "send_text": "true", "template": "./template.txt", "send_pdf": "true", "password": "pvyrbcnzrjoizprn", "subject": "Your loan statement..."}, "lender": {"city": "Washington", "name": "Rivanna Graphite Investments, LLC", "zip": "20011", "phone": "703.343.0782", "state": "DC", "address": "743 Madison St NW"}, "header": {"date": "Today", "title": "Installment Loan Statement"}, "payments": [["2019-07-15", "475.00"], ["2019-08-14", "475.00"], ["2019-09-17", "475"], ["2019-10-15", "0"], ["2019-11-15", "0"], ["2019-12-5", "475"]], "borrower": {"city": "Alexandria", "state": "VA", "name": "Bear Houses, LLC", "zip": "22312", "address": "301 N Beauregard St Apt 203"}, "txtTemplate": "statement.txt.jinja"}
|
||||
@@ -1,62 +1 @@
|
||||
{
|
||||
"htmlTemplate": "statement.pdf.jinja",
|
||||
"txtTemplate": "statement.txt.jinja",
|
||||
"format": "html",
|
||||
"email": {
|
||||
"from_address": "jkent3rd@gmail.com",
|
||||
"to_address": "bck@virginia.edu",
|
||||
"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."
|
||||
},
|
||||
"parameters": {
|
||||
"account_number": "100001",
|
||||
"principal": 35000.00,
|
||||
"interest_rate": 5.0,
|
||||
"periods_per_year": 12,
|
||||
"periods": 180,
|
||||
"start_date": "2018-06-25",
|
||||
"start_interest_date": "2018-07-01",
|
||||
"first_payment_month": "2018-08-01",
|
||||
"monthly_payment": 278.15,
|
||||
"payment_day_of_month": "01"
|
||||
},
|
||||
"borrower": {
|
||||
"name": "Grandma Tina's Properties, LLC",
|
||||
"address": "743 Madison St NW",
|
||||
"city": "Washington",
|
||||
"state": "DC",
|
||||
"zip": "20011"
|
||||
},
|
||||
"lender": {
|
||||
"name": "Brenda Kelly",
|
||||
"phone": "434-286-2110",
|
||||
"address": "150 Confederate Street",
|
||||
"city": "Scottsville",
|
||||
"state": "VA",
|
||||
"zip": "24590"
|
||||
},
|
||||
"header": {
|
||||
"title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA",
|
||||
"date": "Today"
|
||||
},
|
||||
"payments": [
|
||||
["2018-08-01", "278.15"],
|
||||
["2018-09-01", "278.15"],
|
||||
["2018-10-01", "278.15"],
|
||||
["2018-11-01", "278.15"],
|
||||
["2018-12-01", "278.15"],
|
||||
["2019-01-01", "278.15"],
|
||||
["2019-02-01", "278.15"],
|
||||
["2019-03-01", "278.15"],
|
||||
["2019-04-01", "278.15"],
|
||||
["2019-05-01", "278.15"],
|
||||
["2019-05-31", "278.15"],
|
||||
["2019-07-01", "278.15"]
|
||||
]
|
||||
}
|
||||
{"htmlTemplate": "statement.pdf.jinja", "parameters": {"monthly_payment": 278.15, "interest_rate": 5.0, "start_interest_date": "2018-07-01", "payment_day_of_month": "01", "first_payment_month": "2018-08-01", "account_number": "100001", "periods": 180, "start_date": "2018-06-25", "periods_per_year": 12, "principal": 35000.0}, "format": "html", "email": {"body": "Your loan statement is attached.", "to_address": "bck@virginia.edu", "from_address": "jkent3rd@gmail.com", "text": "Please see your most recent account statement.", "server": "smtp.gmail.com", "send_text": "true", "template": "./template.txt", "send_pdf": "true", "password": "pvyrbcnzrjoizprn", "subject": "Your loan statement..."}, "lender": {"city": "Scottsville", "name": "Brenda Kelly", "zip": "24590", "phone": "434-286-2110", "state": "VA", "address": "150 Confederate Street"}, "header": {"date": "Today", "title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA"}, "payments": [["2018-08-01", "278.15"], ["2018-09-01", "278.15"], ["2018-10-01", "278.15"], ["2018-11-01", "278.15"], ["2018-12-01", "278.15"], ["2019-01-01", "278.15"], ["2019-02-01", "278.15"], ["2019-03-01", "278.15"], ["2019-04-01", "278.15"], ["2019-05-01", "278.15"], ["2019-05-31", "278.15"], ["2019-07-01", "278.15"], ["2019-08-01", "278.15"], ["2019-09-02", "278.15"], ["2019-10-01", "278.15"], ["2019-11-01", "278.15"], ["2019-12-02", "278.15"], ["2020-01-02", "278.15"]], "borrower": {"city": "Washington", "state": "DC", "name": "Grandma Tina's Properties, LLC", "zip": "20011", "address": "743 Madison St NW"}, "txtTemplate": "statement.txt.jinja"}
|
||||
@@ -1,62 +1 @@
|
||||
{
|
||||
"htmlTemplate": "statement.pdf.jinja",
|
||||
"txtTemplate": "statement.txt.jinja",
|
||||
"format": "html",
|
||||
"email": {
|
||||
"from_address": "jkent3rd@gmail.com",
|
||||
"to_address": "johnkent49@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."
|
||||
},
|
||||
"parameters": {
|
||||
"account_number": "100001",
|
||||
"principal": 35000.00,
|
||||
"interest_rate": 5.0,
|
||||
"periods_per_year": 12,
|
||||
"periods": 180,
|
||||
"start_date": "2018-06-25",
|
||||
"start_interest_date": "2018-07-01",
|
||||
"first_payment_month": "2018-08-01",
|
||||
"monthly_payment": 278.15,
|
||||
"payment_day_of_month": "01"
|
||||
},
|
||||
"borrower": {
|
||||
"name": "Grandma Tina's Properties, LLC",
|
||||
"address": "743 Madison St NW",
|
||||
"city": "Washington",
|
||||
"state": "DC",
|
||||
"zip": "20011"
|
||||
},
|
||||
"lender": {
|
||||
"name": "John Kent",
|
||||
"phone": "434-510-7272",
|
||||
"address": "109 Shores Rd",
|
||||
"city": "Palmyra",
|
||||
"state": "VA",
|
||||
"zip": "22963"
|
||||
},
|
||||
"header": {
|
||||
"title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA",
|
||||
"date": "Today"
|
||||
},
|
||||
"payments": [
|
||||
["2018-08-01", "278.15"],
|
||||
["2018-09-01", "278.15"],
|
||||
["2018-10-01", "278.15"],
|
||||
["2018-11-01", "278.15"],
|
||||
["2018-12-01", "278.15"],
|
||||
["2019-01-01", "278.15"],
|
||||
["2019-02-01", "278.15"],
|
||||
["2019-03-01", "278.15"],
|
||||
["2019-04-01", "278.15"],
|
||||
["2019-05-01", "278.15"],
|
||||
["2019-05-31", "278.15"],
|
||||
["2019-07-01", "278.15"]
|
||||
]
|
||||
}
|
||||
{"htmlTemplate": "statement.pdf.jinja", "parameters": {"monthly_payment": 278.15, "interest_rate": 5.0, "start_interest_date": "2018-07-01", "payment_day_of_month": "01", "first_payment_month": "2018-08-01", "account_number": "100001", "periods": 180, "start_date": "2018-06-25", "periods_per_year": 12, "principal": 35000.0}, "format": "html", "email": {"body": "Your loan statement is attached.", "to_address": "johnkent49@gmail.com", "from_address": "jkent3rd@gmail.com", "text": "Please see your most recent account statement.", "server": "smtp.gmail.com", "send_text": "true", "template": "./template.txt", "send_pdf": "true", "password": "pvyrbcnzrjoizprn", "subject": "Your loan statement..."}, "lender": {"city": "Palmyra", "name": "John Kent", "zip": "22963", "phone": "434-510-7272", "state": "VA", "address": "109 Shores Rd"}, "header": {"date": "Today", "title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA"}, "payments": [["2018-08-01", "278.15"], ["2018-09-01", "278.15"], ["2018-10-01", "278.15"], ["2018-11-01", "278.15"], ["2018-12-01", "278.15"], ["2019-01-01", "278.15"], ["2019-02-01", "278.15"], ["2019-03-01", "278.15"], ["2019-04-01", "278.15"], ["2019-05-01", "278.15"], ["2019-05-31", "278.15"], ["2019-07-01", "278.15"], ["2019-08-01", "278.15"], ["2019-09-02", "278.15"], ["2019-10-01", "278.15"], ["2019-11-01", "278.15"], ["2019-12-02", "278.15"], ["2020-01-02", "278.15"]], "borrower": {"city": "Washington", "state": "DC", "name": "Grandma Tina's Properties, LLC", "zip": "20011", "address": "743 Madison St NW"}, "txtTemplate": "statement.txt.jinja"}
|
||||
@@ -1,69 +1 @@
|
||||
{
|
||||
"htmlTemplate": "statement.pdf.jinja",
|
||||
"txtTemplate": "statement.txt.jinja",
|
||||
"format": "html",
|
||||
"email": {
|
||||
"from_address": "jkent3rd@gmail.com",
|
||||
"to_address": "grady@gradystreet.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."
|
||||
},
|
||||
"parameters": {
|
||||
"account_number": "100001",
|
||||
"principal": 97750.00,
|
||||
"interest_rate": 5.5,
|
||||
"periods_per_year": 12,
|
||||
"periods": 185,
|
||||
"start_date": "2017-11-07",
|
||||
"start_interest_date": "2017-11-11",
|
||||
"first_payment_month": "2017-12-15",
|
||||
"monthly_payment": 803.00,
|
||||
"payment_day_of_month": "15"
|
||||
},
|
||||
"payments": [
|
||||
["2017-12-11", "803.00"],
|
||||
["2018-01-23", "803.00"],
|
||||
["2018-03-23", "803.00"],
|
||||
["2018-04-18", "803.00"],
|
||||
["2018-04-26", "803.00"],
|
||||
["2018-05-15", "0.00"],
|
||||
["2018-06-15", "0.00"],
|
||||
["2018-07-12", "803.00"],
|
||||
["2018-08-07", "803.00"],
|
||||
["2018-09-06", "803.00"],
|
||||
["2018-10-11", "803.00"],
|
||||
["2018-11-13", "803.00"],
|
||||
["2018-12-13", "803.00"],
|
||||
["2019-01-14", "803.00"],
|
||||
["2019-02-05", "803.00"],
|
||||
["2019-03-05", "803.00"],
|
||||
["2019-04-15", "803.00"],
|
||||
["2019-05-15", "0.00"],
|
||||
["2019-06-13", "803.00"]
|
||||
],
|
||||
"borrower": {
|
||||
"name": "Bear Houses, LLC",
|
||||
"address": "301 N Beauregard St Apt 203",
|
||||
"city": "Alexandria",
|
||||
"state": "VA",
|
||||
"zip": "22312"
|
||||
},
|
||||
"lender": {
|
||||
"name": "Rivanna Graphite Investments, LLC",
|
||||
"phone": "703.343.0782",
|
||||
"address": "743 Madison St NW",
|
||||
"city": "Washington",
|
||||
"state": "DC",
|
||||
"zip": "20011"
|
||||
},
|
||||
"header": {
|
||||
"title": "Mortgage Loan Statement - 195 Greenfield Lane, Pearl MS",
|
||||
"date": "Today"
|
||||
}
|
||||
}
|
||||
{"htmlTemplate": "statement.pdf.jinja", "parameters": {"monthly_payment": 803.0, "interest_rate": 5.5, "start_interest_date": "2017-11-11", "payment_day_of_month": "15", "first_payment_month": "2017-12-15", "account_number": "100001", "periods": 185, "start_date": "2017-11-07", "periods_per_year": 12, "principal": 97750.0}, "format": "html", "email": {"body": "Your loan statement is attached.", "to_address": "grady@gradystreet.com", "from_address": "jkent3rd@gmail.com", "text": "Please see your most recent account statement.", "server": "smtp.gmail.com", "send_text": "true", "template": "./template.txt", "send_pdf": "true", "password": "pvyrbcnzrjoizprn", "subject": "Your loan statement..."}, "lender": {"city": "Washington", "name": "Rivanna Graphite Investments, LLC", "zip": "20011", "phone": "703.343.0782", "state": "DC", "address": "743 Madison St NW"}, "header": {"date": "Today", "title": "Mortgage Loan Statement - 195 Greenfield Lane, Pearl MS"}, "payments": [["2017-12-11", "803.00"], ["2018-01-23", "803.00"], ["2018-03-23", "803.00"], ["2018-04-18", "803.00"], ["2018-04-26", "803.00"], ["2018-05-15", "0.00"], ["2018-06-15", "0.00"], ["2018-07-12", "803.00"], ["2018-08-07", "803.00"], ["2018-09-06", "803.00"], ["2018-10-11", "803.00"], ["2018-11-13", "803.00"], ["2018-12-13", "803.00"], ["2019-01-14", "803.00"], ["2019-02-05", "803.00"], ["2019-03-05", "803.00"], ["2019-04-15", "803.00"], ["2019-05-15", "0.00"], ["2019-06-13", "803.00"], ["2019-07-25", "803.00"], ["2019-08-14", "803.00"], ["2019-09-13", "803.00"], ["2019-10-21", "803.00"], ["2019-11-29", "803.00"], ["2019-12-19", "803.00"], ["2020-01-15", "803"]], "borrower": {"city": "Alexandria", "state": "VA", "name": "Bear Houses, LLC", "zip": "22312", "address": "301 N Beauregard St Apt 203"}, "txtTemplate": "statement.txt.jinja"}
|
||||
@@ -15,7 +15,7 @@
|
||||
<table><tr>
|
||||
<td>Loan:</td>
|
||||
<td>
|
||||
<select name="loan">
|
||||
<select name="loan" id="loan">
|
||||
{% for loan in loans %}
|
||||
{% if loan.filename==filename %}
|
||||
<option value="{{loan.filename}}" selected>{{loan.name}}</option>
|
||||
@@ -28,6 +28,15 @@
|
||||
</td>
|
||||
</table>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(
|
||||
function() {
|
||||
$("#loan").change(
|
||||
function() {
|
||||
this.form.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</p>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
@@ -10,11 +10,10 @@ import os
|
||||
loader=jinja2.FileSystemLoader([os.path.join(os.path.dirname(__file__),"templates")])
|
||||
environment = jinja2.Environment(loader=loader)
|
||||
|
||||
from email.MIMEMultipart import MIMEMultipart
|
||||
from email.MIMEText import MIMEText
|
||||
from email.MIMEBase import MIMEBase
|
||||
from email import Encoders
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
@@ -218,9 +217,9 @@ def getDatastore(filename=None):
|
||||
datastore = json.load(f)
|
||||
|
||||
except Exception as e:
|
||||
print "An error occurred opening your loan file '%s'. " % filename
|
||||
print "The Exception:"
|
||||
print e.__repr__()
|
||||
print("An error occurred opening your loan file '%s'. " % filename)
|
||||
print("The Exception:")
|
||||
print(e.__repr__())
|
||||
quit()
|
||||
|
||||
return datastore
|
||||
@@ -256,8 +255,8 @@ def amortizeLoan(loan):
|
||||
|
||||
#check for out of order payments, generally a sign of a data entry problem, especially years
|
||||
if days_since_last_payment < 0:
|
||||
print "Payment Number %s appears out of order. The payment date '%s' is before the previous payment on '%s'." \
|
||||
% (payment_number, payment_date, interest_paid_through_date)
|
||||
print("Payment Number %s appears out of order. The payment date '%s' is before the previous payment on '%s'." \
|
||||
% (payment_number, payment_date, interest_paid_through_date))
|
||||
quit()
|
||||
|
||||
new_interest = (days_since_last_payment * remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
||||
@@ -345,7 +344,7 @@ def transformTemplate(template_fileName, loanModel):
|
||||
# setup jinja for creating the statement
|
||||
template = environment.get_template(template_fileName)
|
||||
|
||||
print loanModel
|
||||
print(loanModel)
|
||||
report = template.render(model=loanModel)
|
||||
return report
|
||||
|
||||
@@ -361,21 +360,21 @@ def generateEmail(from_address, to_address, subject, body, pdf, html, txt):
|
||||
if (pdf != None):
|
||||
part = MIMEBase("application", "octet-stream")
|
||||
part.set_payload(pdf)
|
||||
Encoders.encode_base64(part)
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="statement.pdf"')
|
||||
msg.attach(part)
|
||||
|
||||
if (html != None):
|
||||
part = MIMEBase("text", "html")
|
||||
part.set_payload(html)
|
||||
Encoders.encode_base64(part)
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="statement.html"')
|
||||
msg.attach(part)
|
||||
|
||||
if (txt != None):
|
||||
part = MIMEBase("text", "plain")
|
||||
part.set_payload(txt)
|
||||
Encoders.encode_base64(part)
|
||||
encoders.encode_base64(part)
|
||||
part.add_header('Content-Disposition', 'attachment; filename="statement.txt"')
|
||||
msg.attach(part)
|
||||
|
||||
@@ -392,7 +391,7 @@ def sendEmail(msg, from_address, to_address, passwd):
|
||||
server.sendmail(from_address, to_address, msg.as_string())
|
||||
server.close()
|
||||
except:
|
||||
print "Couldn't send email."
|
||||
print("Couldn't send email.")
|
||||
|
||||
|
||||
def createPDF(report):
|
||||
@@ -420,6 +419,9 @@ def selectTemplate(format):
|
||||
|
||||
return 'statement.html.jinja'
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
app.debug = True
|
||||
app.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user