stenjo / SbankenToYNAB

Importing data from Sbanken to YNAB using Sbanken API and python 3
25 stars 5 forks source link

Split Transaction: Invalid value for `payee_id`, must not be `None` #10

Closed laien closed 4 years ago

laien commented 4 years ago

Hi.

First of all, thanks for sharing SbankenToYNAB!

When using a split transaction, I get this error:
Traceback (most recent call last): File "SyncAccounts.py", line 78, in <module> api_response = api_instance.get_transactions_by_account(api_settings.budget_id, account_map['account'], since_date=startDate) File "/Users/Documents/Projects/SbankenToYNAB/ynab/ynab/transactions_api.py", line 366, in get_transactions_by_account (data) = self.get_transactions_by_account_with_http_info(budget_id, account_id, **kwargs) # noqa: E501 File "/Users/Documents/Projects/SbankenToYNAB/ynab/ynab/transactions_api.py", line 450, in get_transactions_by_account_with_http_info collection_formats=collection_formats) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 322, in call_api _preload_content, _request_timeout) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 161, in __call_api return_data = self.deserialize(response_data, response_type) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 233, in deserialize return self.__deserialize(data, response_type) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 272, in __deserialize return self.__deserialize_model(data, klass) File "/Users/nikolai/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 613, in __deserialize_model kwargs[attr] = self.__deserialize(value, attr_type) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 272, in __deserialize return self.__deserialize_model(data, klass) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 613, in __deserialize_model kwargs[attr] = self.__deserialize(value, attr_type) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 250, in __deserialize for sub_data in data] File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 250, in <listcomp> for sub_data in data] File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 272, in __deserialize return self.__deserialize_model(data, klass) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 613, in __deserialize_model kwargs[attr] = self.__deserialize(value, attr_type) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 250, in __deserialize for sub_data in data] File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 250, in <listcomp> for sub_data in data] File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 272, in __deserialize return self.__deserialize_model(data, klass) File "/Users/Documents/Projects/SbankenToYNAB/ynab/api_client.py", line 615, in __deserialize_model instance = klass(**kwargs) File "/Users/Documents/Projects/SbankenToYNAB/ynab/models/sub_transaction.py", line 69, in __init__ self.payee_id = payee_id File "/Users/Documents/Projects/SbankenToYNAB/ynab/models/sub_transaction.py", line 186, in payee_id raise ValueError("Invalid value forpayee_id, must not beNone") # noqa: E501 ValueError: Invalid value forpayee_id, must not beNone

It seems like SbankenToYNAB doesn't handle split transactions. Maybe something you can consider?

yonyonson commented 4 years ago

Hei,

issue is that some of your split transactions (subtransactions) lack payee info. ORM used in this script is based on Swagger description of YNAB API, and Swagger definition states that sub_transaction must have a payee.

At the same time YNAB webapp doesn't requires it, since YNAB interprents Swagges specification in a well... more free way that I would have.

Here is reference to discussion at YNABs forum on the topic: https://support.youneedabudget.com/t/80a4gk/subtransactions-returned-from-api-appear-not-to-follow-swagger-definition

Long story short: I would recommend you to workaround this issue by making sure that you define payee on all of your subtransactions.

Regards, Petr