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

Can't sync transactions back #66

Open
steffen-lorenz opened this issue Apr 22, 2018 · 1 comment
Open

Can't sync transactions back #66

steffen-lorenz opened this issue Apr 22, 2018 · 1 comment

Comments

@steffen-lorenz
Copy link

Hi

unfortunately I'm not able to add a transaction and return it back to YNAB
what I did:
First try:

client = nYnabClientFactory().create_client(email=email, password=password, budget_name=budget)
session = client.session
transaction = Transaction(accepted= True,
         amount= -30.0,
         cash_amount= -30.0,
         check_number= None,
         cleared= 'Uncleared',
         credit_amount= 0.0,
         credit_amount_adjusted= 0.0,
         date= datetime.date(2018, 4, 19),
         date_entered_from_schedule= None,
         entities_account_id= 'fdcf0f38-8779-44d8-aaba-98b2989e7d71',
         entities_payee_id= None,
         entities_scheduled_transaction_id= None,
         entities_subcategory_id= None,
         flag= None,
         imported_date= None,
         imported_payee= None,
         is_tombstone= False,
         matched_transaction_id= None,
         memo= '',
         source= None,
         subcategory_credit_amount_preceding= 0.0,
         transfer_account_id= None,
         transfer_subtransaction_id= None,
         transfer_transaction_id= None,
         ynab_id= None)
client.add_transaction(transaction)

==> "WrongPushException: tried to push a changed_entities with 0 entities while we expected 1 entities"
Second try:

transaction = Transaction(amount=123.0,
                              cash_amount = 123.0,
                              credit_amount = 0.0,
                              credit_amount_adjusted = 0.0,
                              date=datetime.datetime.today().date(),
                              entities_account_id='fdcf0f38-8779-44d8-aaba-98b2989e7d71')
client.budget.transactions.append(transaction)
client.push(1)

==>

NYnabConnectionError: Unknown API Error "server_error" was returned from the API when sending request ({'operation_name': 'syncBudgetData', 'request_data': '{"starting_device_knowledge": 0, "ending_device_knowledge": 1, "device_knowledge_of_server": 72, "changed_entities": {"be_transaction_groups": [{"id": "ab9d2a2b-15f5-4a84-a2e5-e8fe733de090", "transaction": {"id": "ab9d2a2b-15f5-4a84-a2e5-e8fe733de090", "is_tombstone": false, "accepted": true, "amount": 123000, "cash_amount": 123000, "check_number": null, "cleared": "Uncleared", "credit_amount": 0, "credit_amount_adjusted": 0, "date": "2018-04-22", "date_entered_from_schedule": null, "entities_account_id": "fdcf0f38-8779-44d8-aaba-98b2989e7d71", "entities_payee_id": null, "entities_scheduled_transaction_id": null, "entities_subcategory_id": null, "flag": null, "imported_date": null, "imported_payee": null, "matched_transaction_id": null, "memo": null, "source": null, "subcategory_credit_amount_preceding": 0, "transfer_account_id": null, "transfer_subtransaction_id": null, "transfer_transaction_id": null, "ynab_id": null}, "subtransactions": null, "matched_transaction": null}]}, "calculated_entities_included": false, "budget_version_id": "97d50cc0-be8a-4d74-a171-8865ce655ddb"}'})

I tried several combinations for the transaction, this one I copied from an existing one, none of it worked
Pulling data from YNAB works.
I also checked that the account exist by pulling the accounts for that budget.
Did I miss something?

@rienafairefr
Copy link
Owner

Normally the first should have worked.
I have no idea how the second went to the push, because there is no transactions attribute on the budget object, its name is be_transactions, I wanted to remove the be_ and ce_ prefixes at some point but I thought this didnt make it to master/pypi. How did you install ?

Most of the arguments in the Transaction(*kwargs) arguments are not needed, by default they are None already ^^

Are you trying to modify an existing transaction ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants