Skip to content

Commit

Permalink
feat: add totalInterest prop to Mortgage class
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Oct 15, 2024
1 parent 282add5 commit 8ec8813
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/Mortgage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Mortgage {
monthlyPayment: number;
totalMortgageCost: number;
yearlyPaymentBreakdown: MortgageBreakdown;
totalInterest: number;

constructor(params: MortgageParams) {
this.propertyValue = params.propertyValue;
Expand All @@ -51,6 +52,7 @@ export class Mortgage {
this.totalMortgageCost = totalMortgageCost;

this.yearlyPaymentBreakdown = this.calculateYearlyPaymentBreakdown();
this.totalInterest = this.calculateTotalInterest();
}

private calculateMortgagePrinciple() {
Expand Down Expand Up @@ -110,4 +112,9 @@ export class Mortgage {

return yearlyPaymentBreakdown;
}
private calculateTotalInterest() {
const totalInterest = parseFloat((this.principal * this.interestRate * this.termYears).toFixed(2))
console.log("Total interest: ", totalInterest)
return totalInterest
}
}

0 comments on commit 8ec8813

Please sign in to comment.