redstreet / beancount_reds_plugins

Miscellaneous plugins for Beancount double entry accounting
GNU General Public License v3.0
95 stars 18 forks source link

Allow processing with missing balances for OFX #23

Closed chase-dwelle closed 1 year ago

chase-dwelle commented 1 year ago

I'm using Fidelity for most of my financial life. Part of that includes using their cash management account and a brokerage account that acts like a checking account.

I'm using the importers for the investment brokerage accounts just fine, but when I try to apply a banking.Importer for the more "bank"-like brokerage accounts I get the error that InvestmentStatement object has no attribute 'balance'. Traceback at the bottom.

I tried creating a custom importer for the "banking" accounts with self.include_balances = False to skip adding balances, but still get the same error.

class Importer(banking.Importer, ofxreader.Importer):
    IMPORTER_NAME = "Fidelity Banking Accounts"

    def custom_init(self):
        if not self.custom_init_run:
            self.max_rounding_error = 0.04
            self.filename_pattern_def = "fidelity_banking*"
            self.includes_balances = False
            self.custom_init_run = True

oft-summarize works, but seems to leave the balance as None:

Statement info: 2022-12-01 00:00:00 -- 2022-12-29 00:00:00. Bal: []

I don't mind not having balance info for these accounts. Would it be acceptable to try and warn for this behavior, or is there something likely wrong with OFX file?

ERROR:root:Importer personal_finance.ingestors.beancount_reds_importers.fidelity_banking.Importer.extract() raised an unexpected error: 'InvestmentStatement' object has no attribute 'balance'
Traceback (most recent call last):
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/beancount/ingest/extract.py", line 182, in extract
    new_entries = extract_from_file(
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/beancount/ingest/extract.py", line 67, in extract_from_file
    new_entries = importer.extract(file, **kwargs)
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/smart_importer/hooks.py", line 40, in patched_extract_method
    imported_entries = unpatched_extract(
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/beancount_reds_importers/libtransactionbuilder/banking.py", line 119, in extract
    new_entries += self.extract_balance(file, counter)
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/beancount_reds_importers/libtransactionbuilder/banking.py", line 67, in extract_balance
    for bal in self.get_balance_statement():
  File "~/pypoetry/virtualenvs/personal-finance-Iy5H7pvA-py3.9/lib/python3.9/site-packages/beancount_reds_importers/libreader/ofxreader.py", line 56, in get_balance_statement
    yield Balance(date, self.ofx_account.statement.balance)
AttributeError: 'InvestmentStatement' object has no attribute 'balance'
chase-dwelle commented 1 year ago

Closing because posted in the wrong repo. Correct issue is here: https://github.com/redstreet/beancount_reds_importers/issues/40