From b5645e2492fb7babe154771b5f8c18112494c431 Mon Sep 17 00:00:00 2001 From: john Date: Mon, 20 May 2024 18:15:36 -0400 Subject: [PATCH] Updated files to produce current daily interest accrual information. Fixed calculation bug. Added current balance to loan information screen. --- mortgage/templates/main.html | 1 + mortgage/web.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mortgage/templates/main.html b/mortgage/templates/main.html index 72e004e..0e457da 100644 --- a/mortgage/templates/main.html +++ b/mortgage/templates/main.html @@ -68,6 +68,7 @@ Term: {{model.parameters.periods }} months Next Payment Due Date: {{model.parameters.next_due_date}} Payment Due: {{ "$%.2f"|format(model.parameters.next_payment_amt) }} + Current Balance {{ "$%.2f"|format(model.current_balance) }} Daily Interest Accrual: {{ "$%.2f"|format(model.current_daily_interest_accrual) }} diff --git a/mortgage/web.py b/mortgage/web.py index d737b22..e040033 100644 --- a/mortgage/web.py +++ b/mortgage/web.py @@ -385,6 +385,9 @@ def amortizeLoan(loan): else: loan["parameters"]["next_payment_amt"] = monthly_payment + loan["current_balance"] = remaining_principal + loan["current_daily_interest_accrual"] = (remaining_principal * daily_interest_rate).quantize(Decimal("0.00")) + # loop over remaining scheduled payments and present estimated amortization while (payment_number <= total_periods) and (remaining_principal > 0): days_since_last_payment = (next_bill_date - interest_paid_through_date).days @@ -419,7 +422,7 @@ def amortizeLoan(loan): next_bill_date = date(year=old_bill_date.year, month=old_bill_date.month + 1, day=payment_day_of_month) else: 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["past_payments"] = past_payments loan["future_payments"] = future_payments