Fixing references.
This commit is contained in:
@@ -9,19 +9,30 @@ from email.MIMEText import MIMEText
|
|||||||
from email.MIMEBase import MIMEBase
|
from email.MIMEBase import MIMEBase
|
||||||
from email import Encoders
|
from email import Encoders
|
||||||
|
|
||||||
|
|
||||||
|
def getPaymentHistory(datastore, loan, asOfDate):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def getAmortization(datastore, loan, paymentHistory):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def loadLoanInformation(filename):
|
def loadLoanInformation(filename):
|
||||||
|
datastore = getDatastore(filename)
|
||||||
|
loanModel = {}
|
||||||
|
|
||||||
datastore = getDataStore(filename)
|
loanModel['loan'] = getLoan(datastore)
|
||||||
|
|
||||||
loanModel['loan'] = getLoan(dataStore)
|
|
||||||
loanModel['lender'] = getLender(datastore)
|
loanModel['lender'] = getLender(datastore)
|
||||||
loanModel['borrower'] = getBorrower(datastore)
|
loanModel['borrower'] = getBorrower(datastore)
|
||||||
loanModel['paymentHistory'] = getPaymentHistory(datastore, loan, asOfDate)
|
loanModel['paymentHistory'] = getPaymentHistory(datastore, loan, asOfDate)
|
||||||
loanModel['futureAmortization'] = getAmortization(datastore, loan, paymentHistory)
|
loanModel['futureAmortization'] = getAmortization(datastore, loan, loanModel.paymentHistory)
|
||||||
return loanModel
|
return loanModel
|
||||||
|
|
||||||
|
|
||||||
def getLoan(datastore):
|
def getLoan(datastore):
|
||||||
# read in the loan profile information
|
# read in the loan profile information
|
||||||
|
loan = {}
|
||||||
|
|
||||||
annual_rate = Decimal(datastore['loan.interest rate']) / 100
|
annual_rate = Decimal(datastore['loan.interest rate']) / 100
|
||||||
daily_interest_rate = annual_rate / 360
|
daily_interest_rate = annual_rate / 360
|
||||||
@@ -49,8 +60,10 @@ def getLoan(datastore):
|
|||||||
loan['next_payment_date'] = '12/12/12'
|
loan['next_payment_date'] = '12/12/12'
|
||||||
return loan
|
return loan
|
||||||
|
|
||||||
|
|
||||||
def getLender(datastore):
|
def getLender(datastore):
|
||||||
#to be replaced with real loading code
|
lender = {}
|
||||||
|
# to be replaced with real loading code
|
||||||
lender['name'] = 'Rivanna Graphite Investments, LLC'
|
lender['name'] = 'Rivanna Graphite Investments, LLC'
|
||||||
lender['phone'] = '703.343.0782'
|
lender['phone'] = '703.343.0782'
|
||||||
lender['address'] = '743 Madison St NW'
|
lender['address'] = '743 Madison St NW'
|
||||||
@@ -59,8 +72,10 @@ def getLender(datastore):
|
|||||||
lender['zip'] = '20011'
|
lender['zip'] = '20011'
|
||||||
return getLender
|
return getLender
|
||||||
|
|
||||||
|
|
||||||
def getBorrower(datastore):
|
def getBorrower(datastore):
|
||||||
#to be replaced with real loading code
|
borrower = {}
|
||||||
|
# to be replaced with real loading code
|
||||||
borrower['name'] = 'Bear Houses, LLC'
|
borrower['name'] = 'Bear Houses, LLC'
|
||||||
borrower['address'] = '123 Any Street'
|
borrower['address'] = '123 Any Street'
|
||||||
borrower['city'] = 'Alltown'
|
borrower['city'] = 'Alltown'
|
||||||
@@ -68,7 +83,8 @@ def getBorrower(datastore):
|
|||||||
borrower['zip'] = '11111'
|
borrower['zip'] = '11111'
|
||||||
return borrower
|
return borrower
|
||||||
|
|
||||||
def getDataStore(filename=None):
|
|
||||||
|
def getDatastore(filename=None):
|
||||||
try:
|
try:
|
||||||
if filename:
|
if filename:
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
@@ -84,31 +100,34 @@ def getDataStore(filename=None):
|
|||||||
|
|
||||||
|
|
||||||
def calculateLoanAmortization(loanModel):
|
def calculateLoanAmortization(loanModel):
|
||||||
|
|
||||||
|
|
||||||
return loanModel
|
return loanModel
|
||||||
|
|
||||||
|
|
||||||
def transformTemplate(template_fileName, loanModel):
|
def transformTemplate(template_fileName, loanModel):
|
||||||
# template_filename = "statement.txt.jinja"
|
# template_filename = "statement.txt.jinja"
|
||||||
# setup jinja for creating the statement
|
# setup jinja for creating the statement
|
||||||
env = Environment(loader=FileSystemLoader('.'))
|
env = Environment(loader=FileSystemLoader('.'))
|
||||||
template = env.get_template(template_fileName)
|
template = env.get_template(template_fileName)
|
||||||
|
|
||||||
report = template.render(original_principal_balance=principal, future_payments=future_payments, \
|
report = template.render(original_principal_balance=loanModel.principal, future_payments=loanModel.future_payments,
|
||||||
past_payments=past_payments, balloon_payment=remaining_principal, \
|
past_payments=loanModel.past_payments, balloon_payment=loanModel.remaining_principal,
|
||||||
total_interest_paid_to_date=total_interest, statement=statement)
|
total_interest_paid_to_date=loanModel.total_interest, statement=loanModel.statement)
|
||||||
return report
|
return report
|
||||||
|
|
||||||
|
|
||||||
def generatePDFStatement():
|
def generatePDFStatement():
|
||||||
template_filename = "statement.pdf.jinja"
|
template_filename = "statement.pdf.jinja"
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def generateHTMLStatement():
|
def generateHTMLStatement():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def generateTextStatement():
|
def generateTextStatement():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def generateEmail(from_address, to_address, subject, body, attachment):
|
def generateEmail(from_address, to_address, subject, body, attachment):
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
@@ -126,6 +145,7 @@ def generateEmail(from_address, to_address, subject, body, attachment):
|
|||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# this program reads the json file describing a mortgage and calculate the actual and projected amortization
|
# this program reads the json file describing a mortgage and calculate the actual and projected amortization
|
||||||
# the first payment in the file should be the interest paid at closing
|
# the first payment in the file should be the interest paid at closing
|
||||||
@@ -156,7 +176,7 @@ def main():
|
|||||||
statement, lender, borrower, loan = {}, {}, {}, {}
|
statement, lender, borrower, loan = {}, {}, {}, {}
|
||||||
lender = loanModel.lender
|
lender = loanModel.lender
|
||||||
borrower = loanModel.borrower
|
borrower = loanModel.borrower
|
||||||
past_payments = loadModel.past_payments
|
past_payments = loanModel.past_payments
|
||||||
future_payments = loanModel.future_payments
|
future_payments = loanModel.future_payments
|
||||||
|
|
||||||
statement['title'] = "Mortgage Statement - 185 James River Rd"
|
statement['title'] = "Mortgage Statement - 185 James River Rd"
|
||||||
@@ -168,7 +188,10 @@ def main():
|
|||||||
# loop over the payments and calculate the actual amortization
|
# loop over the payments and calculate the actual amortization
|
||||||
actual_payments = loanModel["payments"]
|
actual_payments = loanModel["payments"]
|
||||||
|
|
||||||
remaining_principal = principal
|
remaining_principal = loanModel.principal
|
||||||
|
payment_day_of_month = loanInformation.payment_day_of_month
|
||||||
|
daily_interest_rate = loanInformation.daily_interest_rate
|
||||||
|
total_periods = loanInformation.total_periods
|
||||||
annual_interest = 0
|
annual_interest = 0
|
||||||
total_interest = 0
|
total_interest = 0
|
||||||
|
|
||||||
@@ -209,20 +232,6 @@ def main():
|
|||||||
|
|
||||||
if old_bill_date.month < 12:
|
if old_bill_date.month < 12:
|
||||||
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:
|
|
||||||
annual_interest_record['year'] = old_bill_date.year
|
|
||||||
annual_interest_record['interest'] = annual_interest
|
|
||||||
past_interest.append(annual_interest_record)
|
|
||||||
next_bill_date = date(year=old_bill_date.year + 1, month=1, day=payment_day_of_month)
|
|
||||||
payment_record['print_interest_total'] = True
|
|
||||||
payment_record[
|
|
||||||
'interest_total_message'] = "Total interest for " + old_bill_date.year.__str__() + " was $" + annual_interest.__str__()
|
|
||||||
annual_interest = 0
|
|
||||||
|
|
||||||
if old_bill_date.month < 12:
|
|
||||||
payment_record['print_interest_total'] = True
|
|
||||||
payment_record[
|
|
||||||
'interest_total_message'] = "Total interest to date for " + old_bill_date.year.__str__() + " is $" + annual_interest.__str__()
|
|
||||||
|
|
||||||
# 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):
|
||||||
@@ -257,7 +266,7 @@ def main():
|
|||||||
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)
|
||||||
|
|
||||||
report = transformTemplate('',loanModel)
|
report = transformTemplate('', loanModel)
|
||||||
|
|
||||||
# create pdf
|
# create pdf
|
||||||
class MyFPDF(FPDF, HTMLMixin):
|
class MyFPDF(FPDF, HTMLMixin):
|
||||||
|
|||||||
Reference in New Issue
Block a user