|
|
|
@ -4,7 +4,7 @@ import { |
|
|
|
} from '@ghostfolio/common/chart-helper'; |
|
|
|
import { primaryColorRgb } from '@ghostfolio/common/config'; |
|
|
|
import { getLocale } from '@ghostfolio/common/helper'; |
|
|
|
import { FireCalculation } from '@ghostfolio/common/interfaces'; |
|
|
|
import { FireCalculationCompleteEvent } from '@ghostfolio/common/interfaces'; |
|
|
|
import { ColorScheme } from '@ghostfolio/common/types'; |
|
|
|
|
|
|
|
import { CommonModule } from '@angular/common'; |
|
|
|
@ -89,10 +89,11 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
|
@Input() savingsRate: number; |
|
|
|
|
|
|
|
@Output() annualInterestRateChanged = new EventEmitter<number>(); |
|
|
|
@Output() calculationCompleted = |
|
|
|
new EventEmitter<FireCalculationCompleteEvent>(); |
|
|
|
@Output() projectedTotalAmountChanged = new EventEmitter<number>(); |
|
|
|
@Output() retirementDateChanged = new EventEmitter<Date>(); |
|
|
|
@Output() savingsRateChanged = new EventEmitter<number>(); |
|
|
|
@Output() calculationComplete = new EventEmitter<FireCalculation>(); |
|
|
|
|
|
|
|
@ViewChild('chartCanvas') chartCanvas: ElementRef<HTMLCanvasElement>; |
|
|
|
|
|
|
|
@ -136,12 +137,12 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
|
this.calculatorForm.valueChanges |
|
|
|
.pipe(debounceTime(500), takeUntil(this.unsubscribeSubject)) |
|
|
|
.subscribe(() => { |
|
|
|
const { retirementDate, projectedTotalAmount } = |
|
|
|
const { projectedTotalAmount, retirementDate } = |
|
|
|
this.calculatorForm.getRawValue(); |
|
|
|
this.calculationComplete.emit({ |
|
|
|
retirementDate, |
|
|
|
|
|
|
|
this.calculationCompleted.emit({ |
|
|
|
projectedTotalAmount, |
|
|
|
annualInterestRate: this.getR() |
|
|
|
retirementDate |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -175,10 +176,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy { |
|
|
|
if (isNumber(this.fireWealth) && this.fireWealth >= 0) { |
|
|
|
this.calculatorForm.setValue( |
|
|
|
{ |
|
|
|
annualInterestRate: this.annualInterestRate ?? 5, |
|
|
|
paymentPerPeriod: this.savingsRate ?? 0, |
|
|
|
annualInterestRate: this.annualInterestRate, |
|
|
|
paymentPerPeriod: this.savingsRate, |
|
|
|
principalInvestmentAmount: this.fireWealth, |
|
|
|
projectedTotalAmount: this.projectedTotalAmount ?? 0, |
|
|
|
projectedTotalAmount: this.projectedTotalAmount, |
|
|
|
retirementDate: this.retirementDate ?? this.DEFAULT_RETIREMENT_DATE |
|
|
|
}, |
|
|
|
{ |
|
|
|
|