rienafairefr / pynYNAB

a python client for the new YNAB
MIT License
138 stars 12 forks source link

Can't create a new payee and add a transaction #35

Closed rossdargan closed 7 years ago

rossdargan commented 7 years ago

(started a new issue as I think the other one is probably solved)

The issue is ynab_client.add_transactions(transactions) only works if you are not adding a new payee.

I can only add a transaction and a new payee with the following code:

 payee=Payee(name='test5')
 ynab_client.budget.be_payees.append(payee)
 transaction = Transaction(entities_account_id=account.id, amount=2, date=datetime.now(), entities_payee_id=payee.id, imported_date=datetime.now().date(),   imported_payee="test5", memo="test 2", source="Imported"  )
 ynab_client.budget.be_transactions.append(transaction)
 ynab_client.push(2)

I'm guessing this isn't the correct way, but it is a work around for now.

rienafairefr commented 7 years ago

It's actually the right way :-) I've added some helper methods on the Client object for simple actions like add_transaction, but the way you demonstrated here is actually what should be done in the general case! The library needs documentation I think! Cheers,

On Mar 18, 2017 1:18 PM, "Ross Dargan" notifications@github.com wrote:

(started a new issue as I think the other one is probably solved)

The issue is ynab_client.add_transactions(transactions) only works if you are not adding a new payee.

I can only add a transaction and a new payee with the following code:

payee=Payee(name='test5') ynab_client.budget.be_payees.append(payee) transaction = Transaction(entities_account_id=account.id, amount=2, date=datetime.now(), entities_payee_id=payee.id, imported_date=datetime.now().date(), imported_payee="test5", memo="test 2", source="Imported" ) ynab_client.budget.be_transactions.append(transaction) ynab_client.push(2)

I'm guessing this isn't the correct way, but it is a work around for now.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rienafairefr/pynYNAB/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/AAuS9arj3-SkrkeDtUI2UztYFAvh5gVHks5rm8t4gaJpZM4MhZeS .

rossdargan commented 7 years ago

Ha ha, fantastic! I'll close this issue then :)