|
|
|
@ -1,7 +1,11 @@ |
|
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
|
import { ImpersonationStorageService } from '@ghostfolio/client/services/impersonation-storage.service'; |
|
|
|
import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
|
import { FireWealth, User } from '@ghostfolio/common/interfaces'; |
|
|
|
import { |
|
|
|
FireWealth, |
|
|
|
User, |
|
|
|
FireCalculation |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
import { GfFireCalculatorComponent } from '@ghostfolio/ui/fire-calculator'; |
|
|
|
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; |
|
|
|
@ -44,6 +48,10 @@ export class GfFirePageComponent implements OnDestroy, OnInit { |
|
|
|
public withdrawalRatePerMonth: Big; |
|
|
|
public withdrawalRatePerYear: Big; |
|
|
|
|
|
|
|
public projectedWithdrawalRatePerMonth: Big; |
|
|
|
public projectedWithdrawalRatePerYear: Big; |
|
|
|
public fireCalculation: FireCalculation; |
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
public constructor( |
|
|
|
@ -170,6 +178,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit { |
|
|
|
this.user = user; |
|
|
|
|
|
|
|
this.calculateWithdrawalRates(); |
|
|
|
this.calculateProjectedWithdrawalRates(); |
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
|
}); |
|
|
|
@ -211,6 +220,11 @@ export class GfFirePageComponent implements OnDestroy, OnInit { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public onCalculationComplete(calculation: FireCalculation) { |
|
|
|
this.fireCalculation = calculation; |
|
|
|
this.calculateProjectedWithdrawalRates(); |
|
|
|
} |
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
@ -225,4 +239,19 @@ export class GfFirePageComponent implements OnDestroy, OnInit { |
|
|
|
this.withdrawalRatePerMonth = this.withdrawalRatePerYear.div(12); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private calculateProjectedWithdrawalRates() { |
|
|
|
if ( |
|
|
|
this.fireWealth && |
|
|
|
this.user?.settings?.safeWithdrawalRate && |
|
|
|
this.fireCalculation.projectedTotalAmount |
|
|
|
) { |
|
|
|
this.projectedWithdrawalRatePerYear = new Big( |
|
|
|
this.fireCalculation.projectedTotalAmount |
|
|
|
).mul(this.user.settings.safeWithdrawalRate); |
|
|
|
|
|
|
|
this.projectedWithdrawalRatePerMonth = |
|
|
|
this.projectedWithdrawalRatePerYear.div(12); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|