Browse Source

Feature/add safe withdrawal rate to user settings (#5629)

* Add safe withdrawal rate to user settings

* Update changelog
pull/5630/head
Thomas Kaul 3 weeks ago
committed by GitHub
parent
commit
6ff1d65a70
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 10
      CHANGELOG.md
  2. 4
      apps/api/src/app/user/update-user-setting.dto.ts
  3. 5
      apps/api/src/app/user/user.service.ts
  4. 5
      apps/client/src/app/pages/portfolio/fire/fire-page.component.ts
  5. 12
      apps/client/src/app/pages/portfolio/fire/fire-page.html
  6. 1
      libs/common/src/lib/interfaces/user-settings.interface.ts

10
CHANGELOG.md

@ -5,6 +5,16 @@ 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
### Added
- Added the safe withdrawal rate to the user settings (experimental)
### Changed
- Improved the wording of the 4% rule in the _FIRE_ section
## 2.203.0 - 2025-09-27
### Added

4
apps/api/src/app/user/update-user-setting.dto.ts

@ -104,6 +104,10 @@ export class UpdateUserSettingDto {
@IsOptional()
retirementDate?: string;
@IsNumber()
@IsOptional()
safeWithdrawalRate?: number;
@IsNumber()
@IsOptional()
savingsRate?: number;

5
apps/api/src/app/user/user.service.ts

@ -265,6 +265,11 @@ export class UserService {
PerformanceCalculationType.ROAI;
}
// Set default value for safe withdrawal rate
if (!(user.settings.settings as UserSettings)?.safeWithdrawalRate) {
(user.settings.settings as UserSettings).safeWithdrawalRate = 0.04;
}
// Set default value for view mode
if (!(user.settings.settings as UserSettings).viewMode) {
(user.settings.settings as UserSettings).viewMode = 'DEFAULT';

5
apps/client/src/app/pages/portfolio/fire/fire-page.component.ts

@ -63,7 +63,10 @@ export class GfFirePageComponent implements OnDestroy, OnInit {
this.fireWealth = new Big(10000);
}
this.withdrawalRatePerYear = this.fireWealth.mul(4).div(100);
this.withdrawalRatePerYear = this.fireWealth.mul(
this.user.settings.safeWithdrawalRate
);
this.withdrawalRatePerMonth = this.withdrawalRatePerYear.div(12);
this.isLoading = false;

12
apps/client/src/app/pages/portfolio/fire/fire-page.html

@ -37,7 +37,7 @@
</div>
<div>
<h4 class="align-items-center d-flex">
<span i18n>4% Rule</span>
<span i18n>Sustainable retirement income</span>
@if (user?.subscription?.type === 'Basic') {
<gf-premium-indicator class="ml-1" />
}
@ -96,7 +96,15 @@
[value]="fireWealth?.toNumber()"
/>
</span>
and a withdrawal rate of 4%.
and a safe withdrawal rate (SWR) of
<span class="font-weight-bold"
><gf-value
class="d-inline-block"
[isPercent]="true"
[locale]="user?.settings?.locale"
[precision]="1"
[value]="user?.settings?.safeWithdrawalRate" /></span
>.
</div>
}
</div>

1
libs/common/src/lib/interfaces/user-settings.interface.ts

@ -29,6 +29,7 @@ export interface UserSettings {
performanceCalculationType?: PerformanceCalculationType;
projectedTotalAmount?: number;
retirementDate?: string;
safeWithdrawalRate?: number;
savingsRate?: number;
viewMode?: ViewMode;
xRayRules?: XRayRulesSettings;

Loading…
Cancel
Save