diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts index 2562db8a7..f1b316df7 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.component.ts @@ -91,9 +91,12 @@ export class FirePageComponent implements OnDestroy, OnInit { }); } - public onSavingsRateChange(savingsRate: number) { + public onRetirementDateChange(retirementDate: Date) { this.dataService - .putUserSetting({ savingsRate }) + .putUserSetting({ + retirementDate: retirementDate.toISOString(), + projectedTotalAmount: null + }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { this.userService.remove(); @@ -109,12 +112,9 @@ export class FirePageComponent implements OnDestroy, OnInit { }); } - public onRetirementDateChange(retirementDate: Date) { + public onSavingsRateChange(savingsRate: number) { this.dataService - .putUserSetting({ - retirementDate: retirementDate.toISOString(), - projectedTotalAmount: null - }) + .putUserSetting({ savingsRate }) .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(() => { this.userService.remove(); diff --git a/apps/client/src/locales/messages.nl.xlf b/apps/client/src/locales/messages.nl.xlf index b3dbcff38..8bf46aa05 100644 --- a/apps/client/src/locales/messages.nl.xlf +++ b/apps/client/src/locales/messages.nl.xlf @@ -3507,7 +3507,7 @@ Target Net Worth - Beoogd Netto Vermogen + Beoogd Netto Vermogen libs/ui/src/lib/fire-calculator/fire-calculator.component.html 38 diff --git a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts index d8d2e3adf..53a382ae3 100644 --- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts +++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts @@ -201,16 +201,16 @@ export class FireCalculatorComponent if (this.hasPermissionToUpdateUserSettings === true) { this.calculatorForm.get('paymentPerPeriod').enable({ emitEvent: false }); - this.calculatorForm.get('retirementDate').enable({ emitEvent: false }); this.calculatorForm .get('projectedTotalAmount') .enable({ emitEvent: false }); + this.calculatorForm.get('retirementDate').enable({ emitEvent: false }); } else { this.calculatorForm.get('paymentPerPeriod').disable({ emitEvent: false }); - this.calculatorForm.get('retirementDate').disable({ emitEvent: false }); this.calculatorForm .get('projectedTotalAmount') .disable({ emitEvent: false }); + this.calculatorForm.get('retirementDate').disable({ emitEvent: false }); } } @@ -218,12 +218,12 @@ export class FireCalculatorComponent normalizedMonthAndYear: Date, datepicker: MatDatepicker ) { - const ctrlValue = this.calculatorForm.get('retirementDate').value; - const newDate = setMonth( - setYear(ctrlValue, normalizedMonthAndYear.getFullYear()), + const retirementDate = this.calculatorForm.get('retirementDate').value; + const newRetirementDate = setMonth( + setYear(retirementDate, normalizedMonthAndYear.getFullYear()), normalizedMonthAndYear.getMonth() ); - this.calculatorForm.get('retirementDate').setValue(newDate); + this.calculatorForm.get('retirementDate').setValue(newRetirementDate); datepicker.close(); } @@ -381,7 +381,7 @@ export class FireCalculatorComponent for (let period = 1; period <= t; period++) { const periodInMonths = period * this.CONTRIBUTION_PERIOD - monthsPassedInCurrentYear; - const { interest, principal, totalAmount } = + const { interest, principal } = this.fireCalculatorService.calculateCompoundInterest({ P, periodInMonths, @@ -404,14 +404,6 @@ export class FireCalculatorComponent return this.fireWealth || 0; } - private getPMT() { - return this.savingsRate ?? 0; - } - - private getR() { - return this.calculatorForm.get('annualInterestRate').value / 100; - } - private getPeriodsToRetire(): number { if (this.projectedTotalAmount) { const periods = this.fireCalculatorService.calculatePeriodsToRetire({ @@ -435,6 +427,10 @@ export class FireCalculatorComponent } } + private getPMT() { + return this.savingsRate ?? 0; + } + private getProjectedTotalAmount() { if (this.projectedTotalAmount) { return this.projectedTotalAmount || 0; @@ -451,6 +447,10 @@ export class FireCalculatorComponent } } + private getR() { + return this.calculatorForm.get('annualInterestRate').value / 100; + } + private getRetirementDate(): Date { const monthsToRetire = this.periodsToRetire % 12; const yearsToRetire = Math.floor(this.periodsToRetire / 12);