Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/fix initial annual interest rate in fire calculator (#3437)

Thomas Kaul4355c96ab6c1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d26ab416e2..9ad4dd2fcc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Fixed
+
+- Fixed an issue with the initial annual interest rate in the _FIRE_ calculator
+
## 2.83.0 - 2024-05-30
### Changed
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 4f6c8dc089..bd52d8b796 100644
--- a/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts
+++ b/libs/ui/src/lib/fire-calculator/fire-calculator.component.ts
@@ -123,19 +123,6 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
Tooltip
);
- this.calculatorForm.setValue(
- {
- annualInterestRate: this.annualInterestRate,
- paymentPerPeriod: this.savingsRate,
- principalInvestmentAmount: 0,
- projectedTotalAmount: this.projectedTotalAmount,
- retirementDate: this.retirementDate ?? this.DEFAULT_RETIREMENT_DATE
- },
- {
- emitEvent: false
- }
- );
-
this.calculatorForm.valueChanges
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(() => {
@@ -169,9 +156,22 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
}
public ngOnChanges() {
- this.periodsToRetire = this.getPeriodsToRetire();
-
if (isNumber(this.fireWealth) && this.fireWealth >= 0) {
+ this.calculatorForm.setValue(
+ {
+ annualInterestRate: this.annualInterestRate,
+ paymentPerPeriod: this.savingsRate,
+ principalInvestmentAmount: 0,
+ projectedTotalAmount: this.projectedTotalAmount,
+ retirementDate: this.retirementDate ?? this.DEFAULT_RETIREMENT_DATE
+ },
+ {
+ emitEvent: false
+ }
+ );
+
+ this.periodsToRetire = this.getPeriodsToRetire();
+
setTimeout(() => {
// Wait for the chartCanvas
this.calculatorForm.patchValue(
@@ -409,9 +409,9 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
if (this.projectedTotalAmount) {
const periods = this.fireCalculatorService.calculatePeriodsToRetire({
P: this.getP(),
- totalAmount: this.projectedTotalAmount,
PMT: this.getPMT(),
- r: this.getR()
+ r: this.getR(),
+ totalAmount: this.projectedTotalAmount
});
return periods;