|
@ -201,16 +201,16 @@ export class FireCalculatorComponent |
|
|
|
|
|
|
|
|
if (this.hasPermissionToUpdateUserSettings === true) { |
|
|
if (this.hasPermissionToUpdateUserSettings === true) { |
|
|
this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false }); |
|
|
this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false }); |
|
|
this.calculatorForm.get('retirementDate').enable({ emitEvent: false }); |
|
|
|
|
|
this.calculatorForm |
|
|
this.calculatorForm |
|
|
.get('projectedTotalAmount') |
|
|
.get('projectedTotalAmount') |
|
|
.enable({ emitEvent: false }); |
|
|
.enable({ emitEvent: false }); |
|
|
|
|
|
this.calculatorForm.get('retirementDate').enable({ emitEvent: false }); |
|
|
} else { |
|
|
} else { |
|
|
this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false }); |
|
|
this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false }); |
|
|
this.calculatorForm.get('retirementDate').disable({ emitEvent: false }); |
|
|
|
|
|
this.calculatorForm |
|
|
this.calculatorForm |
|
|
.get('projectedTotalAmount') |
|
|
.get('projectedTotalAmount') |
|
|
.disable({ emitEvent: false }); |
|
|
.disable({ emitEvent: false }); |
|
|
|
|
|
this.calculatorForm.get('retirementDate').disable({ emitEvent: false }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -218,12 +218,12 @@ export class FireCalculatorComponent |
|
|
normalizedMonthAndYear: Date, |
|
|
normalizedMonthAndYear: Date, |
|
|
datepicker: MatDatepicker<Date> |
|
|
datepicker: MatDatepicker<Date> |
|
|
) { |
|
|
) { |
|
|
const ctrlValue = this.calculatorForm.get('retirementDate').value; |
|
|
const retirementDate = this.calculatorForm.get('retirementDate').value; |
|
|
const newDate = setMonth( |
|
|
const newRetirementDate = setMonth( |
|
|
setYear(ctrlValue, normalizedMonthAndYear.getFullYear()), |
|
|
setYear(retirementDate, normalizedMonthAndYear.getFullYear()), |
|
|
normalizedMonthAndYear.getMonth() |
|
|
normalizedMonthAndYear.getMonth() |
|
|
); |
|
|
); |
|
|
this.calculatorForm.get('retirementDate').setValue(newDate); |
|
|
this.calculatorForm.get('retirementDate').setValue(newRetirementDate); |
|
|
datepicker.close(); |
|
|
datepicker.close(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -381,7 +381,7 @@ export class FireCalculatorComponent |
|
|
for (let period = 1; period <= t; period++) { |
|
|
for (let period = 1; period <= t; period++) { |
|
|
const periodInMonths = |
|
|
const periodInMonths = |
|
|
period * this.CONTRIBUTION_PERIOD - monthsPassedInCurrentYear; |
|
|
period * this.CONTRIBUTION_PERIOD - monthsPassedInCurrentYear; |
|
|
const { interest, principal, totalAmount } = |
|
|
const { interest, principal } = |
|
|
this.fireCalculatorService.calculateCompoundInterest({ |
|
|
this.fireCalculatorService.calculateCompoundInterest({ |
|
|
P, |
|
|
P, |
|
|
periodInMonths, |
|
|
periodInMonths, |
|
@ -404,14 +404,6 @@ export class FireCalculatorComponent |
|
|
return this.fireWealth || 0; |
|
|
return this.fireWealth || 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getPMT() { |
|
|
|
|
|
return this.savingsRate ?? 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getR() { |
|
|
|
|
|
return this.calculatorForm.get('annualInterestRate').value / 100; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getPeriodsToRetire(): number { |
|
|
private getPeriodsToRetire(): number { |
|
|
if (this.projectedTotalAmount) { |
|
|
if (this.projectedTotalAmount) { |
|
|
const periods = this.fireCalculatorService.calculatePeriodsToRetire({ |
|
|
const periods = this.fireCalculatorService.calculatePeriodsToRetire({ |
|
@ -435,6 +427,10 @@ export class FireCalculatorComponent |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getPMT() { |
|
|
|
|
|
return this.savingsRate ?? 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private getProjectedTotalAmount() { |
|
|
private getProjectedTotalAmount() { |
|
|
if (this.projectedTotalAmount) { |
|
|
if (this.projectedTotalAmount) { |
|
|
return this.projectedTotalAmount || 0; |
|
|
return this.projectedTotalAmount || 0; |
|
@ -451,6 +447,10 @@ export class FireCalculatorComponent |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getR() { |
|
|
|
|
|
return this.calculatorForm.get('annualInterestRate').value / 100; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private getRetirementDate(): Date { |
|
|
private getRetirementDate(): Date { |
|
|
const monthsToRetire = this.periodsToRetire % 12; |
|
|
const monthsToRetire = this.periodsToRetire % 12; |
|
|
const yearsToRetire = Math.floor(this.periodsToRetire / 12); |
|
|
const yearsToRetire = Math.floor(this.periodsToRetire / 12); |
|
|