Quick Budget Underfunded & API goal_under_funded don't match

I've noticed that for some categories the value in the UI shown in Quick Budget > Underfunded doesn't match the value returned in  goal_under_funded in the API.

Example 1

The current amount in the category ($4056) was budgeted in 2021-03-01 and this goal was created in 2021-04-01. The UI excludes funds budgeted to the category before the goal period started but the API does not.

API: $222.19 from goal_overall_left / goal_months_to_budget

UI: $590.91 from goal_target / goal_months_to_budget

 

 

GET /v1/budgets/<budget_id>/months/2021-04-01
{
  "data": {
    "month": {
      "categories": [
        {
          "goal_type": "NEED",
          "goal_target_month": "2022-02-01",
          "goal_target": 6500000,
          "goal_months_to_budget": 11,
          "goal_creation_month": "2021-04-01",
          "budgeted": 0,
          "balance": 4056000,
          "goal_overall_funded": 4056000,
          "goal_overall_left": 2444000,
          "activity": 0,
          "goal_under_funded": 222190,
          "goal_percentage_complete": 62
        }
      ]
    }
  }
}

Example 2

Monthly goals also show the same thing. The UI only factors in funds budgeted within the current goal period. The API uses goal_overall_left / goal_months_to_budget looking at all the funds allocated to the category.

 

 

GET /v1/budgets/<budget_id>/months/2021-04-01
{
  "data": {
    "month": {
      "categories": [
        {
          "goal_type": "NEED",
          "goal_target_month": null,
          "goal_target": 3500000,
          "goal_months_to_budget": 1,
          "goal_creation_month": "2021-03-01",
          "budgeted": 0,
          "balance": 3500000,
          "goal_overall_funded": 3500000,
          "goal_overall_left": 0,
          "activity": 0,
          "goal_under_funded": 0,
          "goal_percentage_complete": 100
        }
      ]
    }
  }
}
7replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi, there! Looks like you're chatting with our Support Team about this via email, as well, and they can loop in our developers. :)  That's the best way to figure this one out!

    Like 1
  • Thanks for the question and detailed info!

    The goal_under_funded generally corresponds to the "Underfunded" amount in the web and mobile clients but it is not exactly the same in some cases.

    The difference is that the web and mobile clients do some additional handling.  When viewing a category with a "Needed for Spending" goal in a future month, any funding from a prior goal period is not considered as progress towards the goal.  The goal_under_funded field in the API does not do this.

    So, although named similarly, they are not quite the same thing.

    I'll work to get this information updated in the API documentation so it's clear.

    Like 1
  • That makes sense, I appreciate your response!

    It would be very useful to have values for goal_overall_funded, goal_overall_left, goal_percentage_complete and goal_under_funded that are scoped to the current goal period (excluding funds budgeted in past goal periods) available via the API.

    Would this be something you'd entertain in a feature request?

    Like
    • 18059521-5301-4da6-9ab7-869db2 To help with understanding - can you give me some more information on how you are using these fields, especially in a future month?

      Like
    • Brady I'm looking for the total underfunded value for a given month so I can fail validation if it's more than my monthly income or if I'll end up with funds remaining. I tune the goals for all categories until the numbers hit that sweet spot. Typically the current month and next month are fully funded so I'll query the first month with nothing budgeted. If a goal period starts/wraps between the current month and the next month yet to be budgeted the numbers with the current implementation aren't right.

      After I make changes in YNAB I run a CLI utility that collects API responses from YNAB and other providers to ensure everything looks good and archive the data. After confirming no validation issues are found I review the API responses line by line and commit them to a git repo. I am new to YNAB so I've been reviewing the API responses carefully to ensure I understand how everything works under the hood.

      The goal_under_funded description made it sound like it was exactly what I was looking for. It seems like "within the current goal period" means that funds budgeted in past goal periods would be excluded, especially since that's the way it's handled in the web app. I also interpreted current as the current month you're querying for vs the current calendar month.

      The amount of funding still needed in the current month to stay on track towards completing the goal within the current goal period.

      While I would be absolutely thrilled, I am not sure my use case merits making a change to the API. However, I wonder if some adjustments could help the values of the goal_overall_funded, goal_overall_left, goal_percentage_complete and goal_under_funded keys live up to the spirit of their descriptions.

      Like
    • 18059521-5301-4da6-9ab7-869db2 That's helpful - thanks for the usage information.  I'll pass this request, along with the context,  to the team.  Hopefully, knowing how it works a bit more you might be able to make some adjustments in your scripts to account for the difference.

      Like
Like Follow
  • 1 mth agoLast active
  • 7Replies
  • 66Views
  • 3 Following