Your Plan


Contents

Introduction

The Your Plan page is where a user can view their goals and make changes to them. The user can view the total monthly contributions they are expected to make, and how much of this will be invested in their different goals. The user can also edit or delete, activate or deactivate any of their goals.

Overview

The Your Plan page shows get data from the endpoint /api:J8MNGPq:v1/auth/loadGoals1 which actions App\Http\Controllers\Goals\GoalsController@loadGoals1. The controller method runs App\Actions\loadGoals1::make()->handle(Auth::id()); and displays the user's goals.

API Response Example

{
    "goals_ef": {
        "target": "420,000.00",
        "principle": "418400.0000000000",
        "value": 454884.99084922095,
        "status": "completed",
        "active": true,
        "name": "Emergency Fund",
        "target_int": 420000,
        "principle_growth": 1,
        "allocation": 0.8,
        "goal_id": 0000,
        "saved_int": 454884.99084922095,
        "saved": "454,884.99",
        "time_to_goal": "-1 year and 12 months",
        "allocation_int": 50000,
        "allocation_percent": 80,
        "allocation_int_desc": "50,000.00",
        "parent_goal": false,
        "category": {
            "id": 78,
            "goal_name": "Emergency Fund",
            "goal_type": "Fixed",
            "created_at": "2023-08-03T08:20:25.000000Z",
            "updated_at": "2023-08-03T08:20:25.000000Z"
        },
        "achieve_date": "02/2025",
        "target_date": "Feb 2025",
        "date_text": "Achieved",
        "form_target_date": "02/2025",
        "ef": "yes"
    },
    "goals_ff": {
        "target": "60,000,000.00",
        "principle": "630000.0000000000",
        "value": 683867.4944472861,
        "status": "pending",
        "active": false,
        "name": "Financial Freedom",
        "target_int": 60000000,
        "principle_growth": 0.01,
        "allocation": 1.03,
        "goal_id": 0001,
        "saved_int": 683867.4944472861,
        "saved": "683,867.49",
        "time_to_goal": "17 years and 9 months",
        "allocation_int": 65000,
        "allocation_percent": 103,
        "allocation_int_desc": "65,000.00",
        "parent_goal": false,
        "category": {
            "id": 82,
            "goal_name": "Financial Freedom",
            "goal_type": "Fixed",
            "created_at": "2023-08-03T08:20:25.000000Z",
            "updated_at": "2023-08-03T08:20:25.000000Z"
        },
        "achieve_date": "11/2042",
        "target_date": "Nov 2042",
        "date_text": "Inactive",
        "form_target_date": "11/2042"
    },
    "goals_cf_long": [
        {
            "target": "3,000,000.00",
            "principle": "288083.0000000000",
            "value": 318000.64791159454,
            "status": "pending",
            "active": true,
            "name": "Real estate",
            "target_int": 3000000,
            "principle_growth": 0.1,
            "allocation": 0.21,
            "goal_id": 0002,
            "saved_int": 318000.64791159454,
            "saved": "318,000.65",
            "time_to_goal": "7 years and 10 months",
            "allocation_int": 13200,
            "allocation_percent": 21,
            "allocation_int_desc": "13,200.00",
            "parent_goal": false,
            "category": {
                "id": 80,
                "goal_name": "Sinking Fund",
                "goal_type": "Optional",
                "created_at": "2023-08-03T08:20:25.000000Z",
                "updated_at": "2023-08-03T08:20:25.000000Z"
            },
            "achieve_date": "12/2032",
            "target_date": "Dec 2032",
            "date_text": "Dec 2032",
            "form_target_date": "12/2032"
        }
    ],
    "savings": 30000,
    "available_desc": "63,200.00",
    "available": 63200,
    "income": "100,000.00",
    "savings_desc": "30,000.00",
    "rate": 30,
    "goals_wl_array": [],
    "goals_cf_short": []
}

Monthly Contributions

The user can view the total monthly contributions they are expected to make. This is the sum of the monthly allocations for all the goals the user is investing in. It is calculated by running App\Actions\Goals\GetUserMonthlyGoalsAllocationAction::make()->handle(Auth::id()); which sums the savings for all the user's active goals. If the user has no active goals, the total monthly contribution is set to the savings value for the user's App\Models\FinancialFreedom model.

Goals

The user's goals are split into three categories: Financial Freedom, Emergency Fund, and Custom Goals.

Financial Freedom

The user's financial freedom goal is a long-term goal that the user is investing in. The user can view the target amount, the monthly investment, and the target date for the goal. From the API response, the Financial Freedom goal is displayed by the goals_ff key. It is retrieved by the following code:

public function loadGoals1(int $userId): array
{
    $user_goals = Goal::query()->with('category')->where('users_id', $userId)->get();
    #
    #
    $goals_ff = $user_goals
        ->where('sys_goal_type_id', GoalTypesEnum::FINANCIAL_FREEDOM->value)
        ->first();

Emergency Fund

The user's emergency fund goal is a short-term goal that the user is investing in. The user can view the target amount, the monthly investment, and the target date for the goal. From the API response, the Emergency Fund goal is displayed by the goals_ef key. It is retrieved by the following code:

public function loadGoals1(int $userId): array
{
    $user_goals = Goal::query()->with('category')->where('users_id', $userId)->get();
    #
    #
    $goals_ef = $user_goals
        ->where('sys_goal_type_id', GoalTypesEnum::EMERGENCY_FUND->value)
        ->first();

Custom Goals (Long)

The user's long-term custom goals are goals that the user has created and is investing in. The user can view the target amount, the monthly investment, and the target date for the goal. From the API response, the long-term custom goals are displayed by the goals_cf_long key. It is retrieved by the following code:

public function loadGoals1(int $userId): array
{
    $user_goals = Goal::query()->with('category')->where('users_id', $userId)->get();
    #
    #
    $goals_cf_array_long = collect();
    #
    #
    $user_goals
        ->whereNotIn('sys_goal_type_id', [GoalTypesEnum::EMERGENCY_FUND->value, GoalTypesEnum::FINANCIAL_FREEDOM->value])
        ->where('is_wishlist', false)
        ->each(function (Goal $goals_cf) use ($goals_cf_array_short, $goals_cf_array_long) {
            $goals_cf_data = GoalUserViewAction::run($goals_cf);
            if ($goals_cf->isLongTerm()) {
                $goals_cf_array_long->push($goals_cf_data);

Custom Goals (Short)

The user's short-term custom goals are goals that the user has created and is investing in. The user can view the target amount, the monthly investment, and the target date for the goal. From the API response, the short-term custom goals are displayed by the goals_cf_short key. It is retrieved by the following code:

public function loadGoals1(int $userId): array
{
    $user_goals = Goal::query()->with('category')->where('users_id', $userId)->get();
    #
    #
    $goals_cf_array_short = collect();
    #
    #
    $user_goals
        ->whereNotIn('sys_goal_type_id', [GoalTypesEnum::EMERGENCY_FUND->value, GoalTypesEnum::FINANCIAL_FREEDOM->value])
        ->where('is_wishlist', false)
        ->each(function (Goal $goals_cf) use ($goals_cf_array_short, $goals_cf_array_long) {
            $goals_cf_data = GoalUserViewAction::run($goals_cf);
            #
            #
            } else {
                    $goals_cf_array_short->push($goals_cf_data);
            }

Goal Actions

The user can perform various actions on their goals, such as editing, deleting, activating, or deactivating them.

Edit Goal

The user can edit a goal by clicking on the Pencil icon next to the goal. This will open a modal where the user can edit the goal's details. For the Financial Freedom and Emergency Fund goals, the user can edit only how much they'd like to save monthly. For custom goals, the user can edit the goal's title, category, target amount, monthly investment, and target date.

Edit Financial Freedom Goal

The user can edit the Financial Freedom goal by clicking on the Pencil icon next to the goal. This will open a modal where the user can edit the goal's monthly investment.

Clicking the Next button will hit /api:IaYS-M9j/financial_freedom/update_allocation which is handled by App\Http\Controllers\Onboarding\OnboardingController@updateFinancialFreedomAllocation. This endpoint validates the data, and runs App\Actions\FinancialFreedom\UpdateFinancialFreedomAllocationAction::make()->handle(); to update the goal's monthly investment.

Edit Emergency Fund Goal

The user can edit the Emergency Fund goal by clicking on the Pencil icon next to the goal. This will open a modal where the user can edit the goal's monthly investment.

Clicking the Next button will hit /api:IaYS-M9j/emergency_fund/update which is handled by App\Http\Controllers\Goals\GoalsController@emergencyFundUpdate. This endpoint validates the data, and runs App\Actions\EmergencyFund\UpdateEmergencyFundAllocationAction::make()->handle(); to update the goal's monthly investment.

Edit Custom Goal

The user can edit a custom goal by clicking on the Pencil icon next to the goal. This will open a modal where the user can edit the goal's details. The user can edit the goal's title, category, target amount, monthly investment, and target date.

Clicking the Next button will hit /api:IaYS-M9j/get_suggested_monthly_savings which is handled by App\Http\Controllers\Goals\GoalsController@getSuggestedMonthlySavings. This endpoint validates the data and runs the App\Actions\Calculators\CalculatePMT action to calculate the monthly investment for the goal. More on the PMT calculation can be found here. The endpoint returns the suggested monthly investment amount. The user will then click the Update Goal button to update the goal's details, which will hit /api:IaYS-M9j/goal_calculator/update which is handled by App\Http\Controllers\Goals\GoalsController@goalCalculatorUpdate. This endpoint validates the data and updates the goal's details.

Note: To get the goal's category, the endpoint /api:IaYS-M9j/goal_types is hit which is handled by App\Http\Controllers\Goals\GoalsController@getGoalTypes. This endpoint returns the goal categories.

[
    {
        "id": 7,
        "goal_name": "House"
    },
    {
        "id": 8,
        "goal_name": "Travel"
    },
    {
        "id": 9,
        "goal_name": "Car"
    },
    {
        "id": 10,
        "goal_name": "Family"
    },
    {
        "id": 11,
        "goal_name": "Education"
    },
    {
        "id": 12,
        "goal_name": "Baby"
    },
    {
        "id": 14,
        "goal_name": "Other"
    }
]

Delete Goal

Still on the Edit Goal modal, the user can delete a goal by clicking on the Delete button. This will open a confirmation modal where the user can confirm the deletion of the goal. Clicking the Delete button will hit /api:IaYS-M9j/delete/goal which is handled by App\Http\Controllers\Goals\GoalsController@deleteGoal. This endpoint validates the data and deletes the goal.

Note that the user cannot delete a goal with transactions. If the goal has transactions, the user will not be able to see the Delete button.

Goal Activity

Each goal has an activity Toggle button that the user can use to activate or deactivate the goal. The user can activate or deactivate a goal by clicking on the Toggle button. This will hit /api:IaYS-M9j/activate/goal which is handled by App\Http\Controllers\Goals\GoalsController@activateGoal. This endpoint validates the data and activates or deactivates the goal. A goal is said to be active if the deactivated_at field is null.

    if ($goal->deactivated_at) {
        $goal->update(['deactivated_at' => null]);
        $message = "Goal activated!";
    } else {
        $goal->update(['deactivated_at' => now()]);
        $message = "Goal deactivated!";
    }

Reset Financial Freedom Goal

Back to the Edit Goal Modal for the Financial Freedom goal, the user can reset the goal by clicking on the Reset Goal button. This will redirect the user to the onboarding page where they can reset the goal. More of this can be found here.