|
@ -25,6 +25,7 @@ import { |
|
|
Tooltip |
|
|
Tooltip |
|
|
} from 'chart.js'; |
|
|
} from 'chart.js'; |
|
|
import * as Color from 'color'; |
|
|
import * as Color from 'color'; |
|
|
|
|
|
import { getMonth } from 'date-fns'; |
|
|
import { isNumber } from 'lodash'; |
|
|
import { isNumber } from 'lodash'; |
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
import { Subject, takeUntil } from 'rxjs'; |
|
|
|
|
|
|
|
@ -50,6 +51,8 @@ export class FireCalculatorComponent |
|
|
|
|
|
|
|
|
@ViewChild('chartCanvas') chartCanvas; |
|
|
@ViewChild('chartCanvas') chartCanvas; |
|
|
|
|
|
|
|
|
|
|
|
private readonly CONTRIBUTION_PERIOD = 12; |
|
|
|
|
|
|
|
|
public calculatorForm = this.formBuilder.group({ |
|
|
public calculatorForm = this.formBuilder.group({ |
|
|
annualInterestRate: new FormControl<number>(undefined), |
|
|
annualInterestRate: new FormControl<number>(undefined), |
|
|
paymentPerPeriod: new FormControl<number>(undefined), |
|
|
paymentPerPeriod: new FormControl<number>(undefined), |
|
@ -296,11 +299,15 @@ export class FireCalculatorComponent |
|
|
label: $localize`Savings` |
|
|
label: $localize`Savings` |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const monthsPassedInCurrentYear = getMonth(new Date()); |
|
|
|
|
|
|
|
|
for (let period = 1; period <= t; period++) { |
|
|
for (let period = 1; period <= t; period++) { |
|
|
|
|
|
const periodInMonths = |
|
|
|
|
|
period * this.CONTRIBUTION_PERIOD - monthsPassedInCurrentYear; |
|
|
const { interest, principal, totalAmount } = |
|
|
const { interest, principal, totalAmount } = |
|
|
this.fireCalculatorService.calculateCompoundInterest({ |
|
|
this.fireCalculatorService.calculateCompoundInterest({ |
|
|
P, |
|
|
P, |
|
|
period, |
|
|
periodInMonths, |
|
|
PMT, |
|
|
PMT, |
|
|
r |
|
|
r |
|
|
}); |
|
|
}); |
|
|