Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_budget fails with some split transactions in the budget #83

Closed
lndnbrg opened this issue Mar 5, 2021 · 4 comments
Closed

get_budget fails with some split transactions in the budget #83

lndnbrg opened this issue Mar 5, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@lndnbrg
Copy link

lndnbrg commented Mar 5, 2021

Hi!
I have some issue with the sdk and my budget.

Calling this code will raise an error:

from ynab_sdk import YNAB

try:
    api_key = "12312123.....123123"
    apicheck = YNAB(api_key)
    data = apicheck.budgets.get_budget("12345678-f349-410e-8ae8-d35672845374")
    print(repr(data.data.budget))
except Exception:
    raise

The response:

Traceback (most recent call last):
  File "/Users/andreas/Downloads/apitest.py", line 21, in <module>
    data = apicheck.budgets.get_budget("12345678-f349-410e-8ae8-d35672845374")
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/budgets.py", line 17, in get_budget
    return BudgetDetailResponse.from_dict(response)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 505, in from_dict
    data = Data.from_dict(obj.get("data"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 493, in from_dict
    budget = Budget.from_dict(obj.get("budget"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 455, in from_dict
    subtransactions = parsers.from_list(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 47, in from_list
    return [f(y) for y in x]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 47, in <listcomp>
    return [f(y) for y in x]
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/api/models/responses/budget_detail.py", line 276, in from_dict
    category_id = parsers.from_str(obj.get("category_id"))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 16, in from_str
    raise ex
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ynab_sdk/utils/parsers.py", line 11, in from_str
    assert isinstance(x, str)

I have a certain type of split transaction (mix of category and account) that is causing this issue (image attached):

Transaction: Payee TEST / Outflow: 100€
Split 1: Category RENT / Outflow: 50€
Split 2: Account CREDITCARD / Outflow: 50€

When I create this kind of transaction in a test budget, that is working otherwise, it fails. As soon as I delete it, the call is working fine.

Could you make your api handle this case? I am no programmer, so I cannot figure it myself and provide you with a pull request.

Thank you!
Andreas
Screenshot_2021-03-05 bla test YNAB

@andreroggeri andreroggeri added the bug Something isn't working label Mar 8, 2021
@andreroggeri
Copy link
Owner

Hi @lndnbrg thanks for the report.

I'll look into it !

@andreroggeri
Copy link
Owner

Hey @lndnbrg I released a new version (0.2.4) that handles your case. Let me know if something doesn't work for you

@lndnbrg
Copy link
Author

lndnbrg commented Mar 9, 2021

Hi @andreroggeri Thank you very much! I can’t find release 2.4, so that I can use it as a dependency and test it with my other software. Could you publish the release or is it somewhere already?

@andreroggeri
Copy link
Owner

I forgot to create a new tag 🤦 .

It should be released in a few minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants