Updated files to produce current daily interest accrual information.
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</p>
|
<p></p>
|
||||||
<div id="tabs">
|
<div id="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#loan_information">Loan Information</a></li>
|
<li><a href="#loan_information">Loan Information</a></li>
|
||||||
@@ -68,9 +68,10 @@
|
|||||||
<tr><td><b>Term: </b></td><td>{{model.parameters.periods }} months </td></tr>
|
<tr><td><b>Term: </b></td><td>{{model.parameters.periods }} months </td></tr>
|
||||||
<tr><td><b>Next Payment Due Date:</b></td><td> {{model.parameters.next_due_date}} </td></tr>
|
<tr><td><b>Next Payment Due Date:</b></td><td> {{model.parameters.next_due_date}} </td></tr>
|
||||||
<tr><td><b>Payment Due:</b></td><td> {{ "$%.2f"|format(model.parameters.next_payment_amt) }} </td></tr>
|
<tr><td><b>Payment Due:</b></td><td> {{ "$%.2f"|format(model.parameters.next_payment_amt) }} </td></tr>
|
||||||
|
<tr><td><b>Daily Interest Accrual:</b></td><td> {{ "$%.2f"|format(model.current_daily_interest_accrual) }}</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p/>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="loan_history">
|
<div id="loan_history">
|
||||||
<table border="1px" align="center">
|
<table border="1px" align="center">
|
||||||
@@ -79,7 +80,7 @@
|
|||||||
<th colspan="9">Loan History</th>
|
<th colspan="9">Loan History</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th width='5%'>#</td>
|
<th width='5%'>#</th>
|
||||||
<th width='10%'>Due Date</th>
|
<th width='10%'>Due Date</th>
|
||||||
<th width='10%'>Date Paid</th>
|
<th width='10%'>Date Paid</th>
|
||||||
<th width='10%'>Days Interest</th>
|
<th width='10%'>Days Interest</th>
|
||||||
@@ -104,18 +105,18 @@
|
|||||||
<td align='right'> {{ "$%.2f"|format(item.new_balance) }} </td>
|
<td align='right'> {{ "$%.2f"|format(item.new_balance) }} </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if item.month == 12 or loop.last %}
|
{% if item.month == 12 or loop.last %}
|
||||||
<tr><td colspan='9'"> Total interest paid in {{item.year}} is {{ "$%.2f"|format(item.annual_interest_to_date) }}.</td></tr>
|
<tr><td colspan='9'> Total interest paid in {{item.year}} is {{ "$%.2f"|format(item.annual_interest_to_date) }}.</td></tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<tr><td colspan='9'"> Total interest paid to date is {{ "$%.2f"|format(model.total_interest_paid_to_date) }}.</td></tr>
|
<tr><td colspan='9'> Total interest paid to date is {{ "$%.2f"|format(model.total_interest_paid_to_date) }}.</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="loan_accounting">
|
<div id="loan_accounting">
|
||||||
<h3>Loan Accounting</h3>
|
<h3>Loan Accounting</h3>
|
||||||
<textarea border="1px" width="70%" cols="120" rows="25">
|
<textarea border="1px" width="70%" cols="120" rows="25">
|
||||||
{% for item in model.past_payments %}
|
{% for item in model.past_payments | reverse %}
|
||||||
{{item.payment_date }} * "{{item.payee}}" "{{item.payee}} Mortgage Payment {{ item.payment_number}}"
|
{{item.payment_date }} * "{{item.payee}}" "{{item.payee}} Mortgage Payment {{ item.payment_number}}"
|
||||||
{{item.payment_account}} {{ "%.2f"|format(item.payment_amount * -1) }} USD
|
{{item.payment_account}} {{ "%.2f"|format(item.payment_amount * -1) }} USD
|
||||||
{{item.loan_account}} {{ "%.2f"|format(item.principal_payment) }} USD
|
{{item.loan_account}} {{ "%.2f"|format(item.principal_payment) }} USD
|
||||||
{{item.interest_account}} {{ "%.2f"|format(item.interest_payment) }} USD
|
{{item.interest_account}} {{ "%.2f"|format(item.interest_payment) }} USD
|
||||||
@@ -162,7 +163,7 @@
|
|||||||
<tr><td align="center" bgcolor="darkgrey">Generate and Send Statement</td></tr>
|
<tr><td align="center" bgcolor="darkgrey">Generate and Send Statement</td></tr>
|
||||||
<tr><td>Send From: {{model.email.from_address}}<br/>Send To: {{model.email.to_address}}</td></tr>
|
<tr><td>Send From: {{model.email.from_address}}<br/>Send To: {{model.email.to_address}}</td></tr>
|
||||||
<tr><td bgcolor="beige">Subject:</td></tr>
|
<tr><td bgcolor="beige">Subject:</td></tr>
|
||||||
<tr><td align="center"><textarea type="text" cols="120" name="subject">{{model.email.subject}}</textarea></td></tr>
|
<tr><td align="center"><textarea cols="120" name="subject">{{model.email.subject}}</textarea></td></tr>
|
||||||
<tr><td bgcolor="beige">Message:</td></tr>
|
<tr><td bgcolor="beige">Message:</td></tr>
|
||||||
<tr><td align="center"><textarea rows="8" cols="120" name="message">{{model.email.body}}</textarea></td></tr>
|
<tr><td align="center"><textarea rows="8" cols="120" name="message">{{model.email.body}}</textarea></td></tr>
|
||||||
<tr><td bgcolor="beige">Send Statement As:</td></tr>
|
<tr><td bgcolor="beige">Send Statement As:</td></tr>
|
||||||
@@ -187,7 +188,7 @@
|
|||||||
<table align="center" border="1px" width="75%">
|
<table align="center" border="1px" width="75%">
|
||||||
<tr><td align="center" bgcolor="darkgrey">Record a Payment</td></tr>
|
<tr><td align="center" bgcolor="darkgrey">Record a Payment</td></tr>
|
||||||
<tr><td bgcolor="beige">Payment Date:</td></tr>
|
<tr><td bgcolor="beige">Payment Date:</td></tr>
|
||||||
<tr><td><input type="date" name="date"</td></tr>
|
<tr><td><input type="date" name="date"></td></tr>
|
||||||
<tr><td bgcolor="beige">Payment Amount:</td></tr>
|
<tr><td bgcolor="beige">Payment Amount:</td></tr>
|
||||||
<tr><td><input type="text" name="amount"></td></tr>
|
<tr><td><input type="text" name="amount"></td></tr>
|
||||||
<tr><td bgcolor="beige">Late Fee Amount:</td></tr>
|
<tr><td bgcolor="beige">Late Fee Amount:</td></tr>
|
||||||
@@ -203,7 +204,7 @@
|
|||||||
<table align="center" border="1px" width="75%">
|
<table align="center" border="1px" width="75%">
|
||||||
<tr><td align="center" bgcolor="darkgrey">Record an Extra Payment</td></tr>
|
<tr><td align="center" bgcolor="darkgrey">Record an Extra Payment</td></tr>
|
||||||
<tr><td bgcolor="beige">Payment Date:</td></tr>
|
<tr><td bgcolor="beige">Payment Date:</td></tr>
|
||||||
<tr><td><input type="date" name="date"</td></tr>
|
<tr><td><input type="date" name="date"></td></tr>
|
||||||
<tr><td bgcolor="beige">Payment Amount:</td></tr>
|
<tr><td bgcolor="beige">Payment Amount:</td></tr>
|
||||||
<tr><td><input type="text" name="amount"></td></tr>
|
<tr><td><input type="text" name="amount"></td></tr>
|
||||||
<tr><td><input name="notify" type="checkbox" value="notify"/>Send Payment Recorded Notification</td></tr>
|
<tr><td><input name="notify" type="checkbox" value="notify"/>Send Payment Recorded Notification</td></tr>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import json
|
|
||||||
import jinja2
|
import jinja2
|
||||||
import smtplib
|
import smtplib
|
||||||
import os
|
import os
|
||||||
@@ -13,19 +12,19 @@ from email import encoders
|
|||||||
import couchdb
|
import couchdb
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dbUserName = os.environ['COUCHDB_USERNAME']
|
dbUserName = os.environ['COUCHDB_USERNAME']
|
||||||
except:
|
except:
|
||||||
dbUserName = 'admin'
|
dbUserName = 'admin'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dbPassword = os.environ['COUCHDB_PW']
|
dbPassword = os.environ['COUCHDB_PW']
|
||||||
except:
|
except:
|
||||||
dbPassword = 'ams19230'
|
dbPassword = 'ams19230'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dbHost = os.environ['COUCHDB_HOST']
|
dbHost = os.environ['COUCHDB_HOST']
|
||||||
except:
|
except:
|
||||||
dbHost = 'couch.jkent.org'
|
dbHost = 'couch.jkent.org'
|
||||||
|
|
||||||
connectString = f'https://{dbUserName}:{dbPassword}@{dbHost}/'
|
connectString = f'https://{dbUserName}:{dbPassword}@{dbHost}/'
|
||||||
print(connectString)
|
print(connectString)
|
||||||
@@ -50,7 +49,7 @@ app = Flask(__name__)
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello():
|
def hello():
|
||||||
loans = getLoanFiles(database)
|
loans = getLoanFiles()
|
||||||
|
|
||||||
#if a loan was not specified, choose the first loan and reload page with it
|
#if a loan was not specified, choose the first loan and reload page with it
|
||||||
if 'loan' in request.args:
|
if 'loan' in request.args:
|
||||||
@@ -117,7 +116,7 @@ def update_file():
|
|||||||
|
|
||||||
if proceed_flag is True:
|
if proceed_flag is True:
|
||||||
payment_history.append([payment_date, str(payment_amount), str(late_fee), str(extra_payment)])
|
payment_history.append([payment_date, str(payment_amount), str(late_fee), str(extra_payment)])
|
||||||
database[document_id]=document
|
database[document_id] = document
|
||||||
messages.append("The payment was successfully written. ")
|
messages.append("The payment was successfully written. ")
|
||||||
|
|
||||||
# see if an email notification was requested, if not, exit now
|
# see if an email notification was requested, if not, exit now
|
||||||
@@ -189,7 +188,7 @@ def send_statement():
|
|||||||
######
|
######
|
||||||
|
|
||||||
|
|
||||||
def getLoanFiles(directory):
|
def getLoanFiles():
|
||||||
#iterate over each of the documents found in the mortgage couchdb
|
#iterate over each of the documents found in the mortgage couchdb
|
||||||
#database and pull their display name
|
#database and pull their display name
|
||||||
loans = []
|
loans = []
|
||||||
@@ -201,25 +200,26 @@ def getLoanFiles(directory):
|
|||||||
|
|
||||||
return loans
|
return loans
|
||||||
|
|
||||||
|
|
||||||
def createLoanEntryMenuItem(loanName, document_id):
|
def createLoanEntryMenuItem(loanName, document_id):
|
||||||
x = {}
|
x = {}
|
||||||
x['name'] = loanName
|
x['name'] = loanName
|
||||||
x['document_id'] = document_id
|
x['document_id'] = document_id
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
######
|
######
|
||||||
# Datastore Manipulation Functions
|
# Datastore Manipulation Functions
|
||||||
######
|
######
|
||||||
|
|
||||||
def getStatementHeader(datastore):
|
def getStatementHeader(datastore):
|
||||||
return datastore['header']
|
return datastore['header']
|
||||||
|
|
||||||
|
|
||||||
def getAccounting(datastore):
|
def getAccounting(datastore):
|
||||||
try:
|
try:
|
||||||
return datastore['accounting']
|
return datastore['accounting']
|
||||||
except:
|
except:
|
||||||
return {"payment_account":"", "loan_account":"", "interest_account": ""}
|
return {"payment_account": "", "loan_account": "", "interest_account": ""}
|
||||||
|
|
||||||
|
|
||||||
def getEmailInformation(datastore):
|
def getEmailInformation(datastore):
|
||||||
@@ -281,17 +281,16 @@ def getBorrower(datastore):
|
|||||||
|
|
||||||
|
|
||||||
def getDatastore(document_id=None):
|
def getDatastore(document_id=None):
|
||||||
if document_id == None:
|
if document_id is None:
|
||||||
quit("Invalid document.")
|
quit("Invalid document.")
|
||||||
|
|
||||||
datastore = database[document_id]
|
datastore = database[document_id]
|
||||||
return datastore
|
return datastore
|
||||||
|
|
||||||
|
|
||||||
######
|
######
|
||||||
# Loan Calculation Functions
|
# Loan Calculation Functions
|
||||||
######
|
######
|
||||||
|
|
||||||
|
|
||||||
def amortizeLoan(loan):
|
def amortizeLoan(loan):
|
||||||
# loop over the payments and calculate the actual amortization
|
# loop over the payments and calculate the actual amortization
|
||||||
monthly_payment = loan["parameters"]["monthly_payment"]
|
monthly_payment = loan["parameters"]["monthly_payment"]
|
||||||
@@ -331,7 +330,8 @@ def amortizeLoan(loan):
|
|||||||
% (payment_number, payment_date, interest_paid_through_date))
|
% (payment_number, payment_date, interest_paid_through_date))
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
new_interest = (days_since_last_payment * remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
new_daily_interest = (remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
||||||
|
new_interest = (days_since_last_payment * new_daily_interest).quantize(Decimal("0.00"))
|
||||||
new_principal = payment_amount - new_interest - late_fee
|
new_principal = payment_amount - new_interest - late_fee
|
||||||
interest_paid_through_date = payment_date
|
interest_paid_through_date = payment_date
|
||||||
total_interest = total_interest + new_interest
|
total_interest = total_interest + new_interest
|
||||||
@@ -346,8 +346,8 @@ def amortizeLoan(loan):
|
|||||||
payment_record['bill_date'] = next_bill_date
|
payment_record['bill_date'] = next_bill_date
|
||||||
payment_record['payment_date'] = payment_date
|
payment_record['payment_date'] = payment_date
|
||||||
payment_record['days_of_interest'] = days_since_last_payment
|
payment_record['days_of_interest'] = days_since_last_payment
|
||||||
|
payment_record['daily_interest'] = new_daily_interest
|
||||||
payment_record['payment_amount'] = payment_amount
|
payment_record['payment_amount'] = payment_amount
|
||||||
principal_payment = payment_amount - new_interest - late_fee
|
|
||||||
payment_record['principal_payment'] = payment_amount - new_interest - late_fee
|
payment_record['principal_payment'] = payment_amount - new_interest - late_fee
|
||||||
payment_record['interest_payment'] = new_interest
|
payment_record['interest_payment'] = new_interest
|
||||||
payment_record['new_balance'] = remaining_principal
|
payment_record['new_balance'] = remaining_principal
|
||||||
@@ -388,6 +388,7 @@ def amortizeLoan(loan):
|
|||||||
# loop over remaining scheduled payments and present estimated amortization
|
# loop over remaining scheduled payments and present estimated amortization
|
||||||
while (payment_number <= total_periods) and (remaining_principal > 0):
|
while (payment_number <= total_periods) and (remaining_principal > 0):
|
||||||
days_since_last_payment = (next_bill_date - interest_paid_through_date).days
|
days_since_last_payment = (next_bill_date - interest_paid_through_date).days
|
||||||
|
new_daily_interest = (remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
||||||
new_interest = (days_since_last_payment * remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
new_interest = (days_since_last_payment * remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
||||||
|
|
||||||
# make sure the last payment isn't too much
|
# make sure the last payment isn't too much
|
||||||
@@ -405,6 +406,7 @@ def amortizeLoan(loan):
|
|||||||
future_payment_record['payment_number'] = payment_number
|
future_payment_record['payment_number'] = payment_number
|
||||||
future_payment_record['payment_date'] = next_bill_date
|
future_payment_record['payment_date'] = next_bill_date
|
||||||
future_payment_record['days_of_interest'] = days_since_last_payment
|
future_payment_record['days_of_interest'] = days_since_last_payment
|
||||||
|
future_payment_record['daily_interest'] = new_daily_interest
|
||||||
future_payment_record['payment_amount'] = monthly_payment
|
future_payment_record['payment_amount'] = monthly_payment
|
||||||
future_payment_record['principal_payment'] = new_principal
|
future_payment_record['principal_payment'] = new_principal
|
||||||
future_payment_record['interest_payment'] = new_interest
|
future_payment_record['interest_payment'] = new_interest
|
||||||
@@ -417,7 +419,7 @@ def amortizeLoan(loan):
|
|||||||
next_bill_date = date(year=old_bill_date.year, month=old_bill_date.month + 1, day=payment_day_of_month)
|
next_bill_date = date(year=old_bill_date.year, month=old_bill_date.month + 1, day=payment_day_of_month)
|
||||||
else:
|
else:
|
||||||
next_bill_date = date(year=old_bill_date.year + 1, month=1, day=payment_day_of_month)
|
next_bill_date = date(year=old_bill_date.year + 1, month=1, day=payment_day_of_month)
|
||||||
|
loan["current_daily_interest_accrual"] = (remaining_principal * daily_interest_rate).quantize(Decimal("0.00"))
|
||||||
loan["balloon_payment"] = remaining_principal
|
loan["balloon_payment"] = remaining_principal
|
||||||
loan["past_payments"] = past_payments
|
loan["past_payments"] = past_payments
|
||||||
loan["future_payments"] = future_payments
|
loan["future_payments"] = future_payments
|
||||||
@@ -529,7 +531,7 @@ def selectTemplate(formatType):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
app.debug = True
|
app.debug = True
|
||||||
app.run(host = '0.0.0.0', port='8000')
|
app.run(host='0.0.0.0', port=8000)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user