egh / ledger-autosync

Synchronize your ledger-cli files with your bank.
GNU General Public License v3.0
273 stars 42 forks source link

Error when working with non-empty ledger file #21

Closed phil-mitchell closed 7 years ago

phil-mitchell commented 7 years ago

Using master, the following command:

ledger-autosync -l test.ledger

Where test.ledger contains any transactions, e.g.:

2016/01/02 Transfer
    Assets:Checquing:T:J       CAD400.00
    Assets:Savings:T:T:J  -CAD400.00

Yields the following error if there were downloaded transactions that need to be processed:

Caught exception processing Assets:Checquing:T:JTraceback (most recent call last):
  File "/home/phil/ledger-autosync/ledgerautosync/cli.py", line 97, in sync
    print_results(converter, ofx, ledger, txns, args)
  File "/home/phil/ledger-autosync/ledgerautosync/cli.py", line 73, in print_results
    print converter.convert(txn).format(args.indent)
  File "/home/phil/ledger-autosync/ledgerautosync/converter.py", line 310, in convert
    self.mk_dynamic_account(self.format_payee(txn), exclude=self.name),
  File "/home/phil/ledger-autosync/ledgerautosync/converter.py", line 183, in mk_dynamic_account
    account = self.lgr.get_account_by_payee(payee, exclude)
  File "/home/phil/ledger-autosync/ledgerautosync/ledgerwrap.py", line 81, in get_account_by_payee
    self.load_payees()
  File "/home/phil/ledger-autosync/ledgerautosync/ledgerwrap.py", line 210, in load_payees
    self.add_payee(xact.payee, xact.account)
AttributeError: 'Transaction' object has no attribute 'account'
egh commented 7 years ago

It looks like there is a problem with the ledger-python interface. ledger-autosync can interact with ledger, hledger, or the ledger python bindings. It will prefer python if available.

I myself don't often use the python bindings because I have found them to be buggy. I can reproduce this with my debian testing machine and will attempt to fix.

It will also add an option to disable using the python bindings so a user can at least work around these situations.

In the meantime, another workaround would be to remove the python ledger bindings or create a virtualenv that does not use them. If the bindings are not available ledger-autosync will not use them

phil-mitchell commented 7 years ago

Thanks for the quick reply. Removing ledger-python package resolves the issue for me. Glad to hear you can reproduce locally.

egh commented 7 years ago

I have fixed the python binding tests and disabled their use by default.