Skip to content

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

6.5 KB
Raw Blame
<div class="container">
  <div class="row mb-5">
    <div class="col-lg">
      <h2 class="d-none d-sm-block h3 mb-3 text-center" i18n>FIRE</h2>
      <div>
        <h4 class="align-items-center d-flex mb-3">
          <span i18n>Calculator</span>
          @if (user?.subscription?.type === 'Basic') {
            <gf-premium-indicator class="ms-1" />
          }
        </h4>
        <gf-fire-calculator
          [annualInterestRate]="user?.settings?.annualInterestRate"
          [colorScheme]="user?.settings?.colorScheme"
          [currency]="user?.settings?.baseCurrency"
          [deviceType]="deviceType()"
          [fireWealth]="fireWealth?.today.valueInBaseCurrency"
          [hasPermissionToUpdateUserSettings]="
            !hasImpersonationId && hasPermissionToUpdateUserSettings
          "
          [locale]="user?.settings?.locale"
          [projectedTotalAmount]="user?.settings?.projectedTotalAmount"
          [retirementDate]="user?.settings?.retirementDate"
          [savingsRate]="user?.settings?.savingsRate"
          [style.opacity]="
            user?.subscription?.type === 'Basic' ? '0.67' : 'initial'
          "
          [style.pointer-events]="
            user?.subscription?.type === 'Basic' ? 'none' : 'initial'
          "
          (annualInterestRateChanged)="onAnnualInterestRateChange($event)"
          (calculationCompleted)="onCalculationComplete($event)"
          (projectedTotalAmountChanged)="onProjectedTotalAmountChange($event)"
          (retirementDateChanged)="onRetirementDateChange($event)"
          (savingsRateChanged)="onSavingsRateChange($event)"
        />
      </div>
    </div>
  </div>
  <div>
    <h4 class="align-items-center d-flex">
      <span i18n>Sustainable retirement income</span>
      @if (user?.subscription?.type === 'Basic') {
        <gf-premium-indicator class="ms-1" />
      }
    </h4>
    @if (isLoading) {
      <div>
        <ngx-skeleton-loader
          animation="pulse"
          class="my-1"
          [theme]="{
            height: '1rem',
            width: '100%'
          }"
        />
        <ngx-skeleton-loader
          animation="pulse"
          [theme]="{
            height: '1rem',
            width: '10rem'
          }"
        />
      </div>
    } @else {
      <div [class.text-body-secondary]="user?.subscription?.type === 'Basic'">
        <div class="mb-2">
          <ng-container i18n
            >If you retire today, you would be able to withdraw
            <span class="fw-bold"
              ><gf-value
                class="d-inline-block"
                [isCurrency]="true"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="
                  hasPermissionToShowValues
                    ? withdrawalRatePerYear?.toNumber()
                    : null
                "
              />
              per year</span
            >
            or
            <span class="fw-bold"
              ><gf-value
                class="d-inline-block"
                [isCurrency]="true"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="
                  hasPermissionToShowValues
                    ? withdrawalRatePerMonth?.toNumber()
                    : null
                "
              />
              per month</span
            >, based on your total assets of
            <span class="fw-bold"
              ><gf-value
                class="d-inline-block"
                [isCurrency]="true"
                [locale]="user?.settings?.locale"
                [unit]="user?.settings?.baseCurrency"
                [value]="
                  hasPermissionToShowValues
                    ? fireWealth?.today.valueInBaseCurrency
                    : null
                "
            /></span>
            and a safe withdrawal rate (SWR) of</ng-container
          >
          @if (
            !hasImpersonationId &&
            hasPermissionToUpdateUserSettings &&
            user?.settings?.isExperimentalFeatures
          ) {
            <select
              class="border-0 cursor-pointer d-inline-block fw-bold safe-withdrawal-rate-select"
              [formControl]="safeWithdrawalRateControl"
            >
              @for (rate of safeWithdrawalRateOptions; track rate) {
                <option [value]="rate">
                  {{ rate * 100 | number: '1.1-1' }} %
                </option>
              }</select
            >.
          } @else {
            <ng-container>&nbsp;</ng-container>
            <span class="fw-bold"
              ><gf-value
                class="d-inline-block"
                [isPercent]="true"
                [locale]="user?.settings?.locale"
                [precision]="1"
                [value]="user?.settings?.safeWithdrawalRate" /></span
            >.
          }
        </div>

        @if (user?.settings?.isExperimentalFeatures) {
          <div>
            <ng-container i18n
              >By <span class="fw-bold">{{ retirementDateLabel }}</span
              >, this is projected to increase to
              <span class="fw-bold"
                ><gf-value
                  class="d-inline-block"
                  [isCurrency]="true"
                  [locale]="user?.settings?.locale"
                  [unit]="user?.settings?.baseCurrency"
                  [value]="
                    hasPermissionToShowValues
                      ? withdrawalRatePerYearProjected?.toNumber()
                      : null
                  "
                />
                per year</span
              >
              or
              <span class="fw-bold"
                ><gf-value
                  class="d-inline-block"
                  [isCurrency]="true"
                  [locale]="user?.settings?.locale"
                  [unit]="user?.settings?.baseCurrency"
                  [value]="
                    hasPermissionToShowValues
                      ? withdrawalRatePerMonthProjected?.toNumber()
                      : null
                  "
                />
                per month</span
              >, assuming a
              <span class="fw-bold"
                ><gf-value
                  class="d-inline-block"
                  [isPercent]="true"
                  [locale]="user?.settings?.locale"
                  [precision]="2"
                  [value]="(user?.settings?.annualInterestRate ?? 0) / 100"
              /></span>
              annual interest rate.</ng-container
            >
          </div>
        }
      </div>
    }
  </div>
</div>