egh / ledger-autosync

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

Intended way of handling transactions without date in plugin / skipping transactions? #139

Closed fapdash closed 4 months ago

fapdash commented 5 months ago

Since their latest update my bank includes entries in their csv that haven't cleared yet. Some of those transactions have neither a date nor aux_date associated with them.

ledger-autosync doesn't seem to like Transactions without a date:

TypeError: __init__() missing 1 required positional argument: 'date'

I'm fine with just ignoring / skipping those lines as I don't really care about entries that haven't cleared yet. First I tried returning None for the entries that I want to skip, but ledger-autosync doesn't seem to expect that:

AttributeError: 'NoneType' object has no attribute 'format'

Currently I handle it something like that:

class NoneTransaction:
    def format(self, _indent, _assertions):
        return ""

class MyConverter(CsvConverter):

    def convert(self, row):
        # more code..
        if not date or not cleared:
            # Ignore unsettled transactions and transactions without any dates
            return NoneTransaction()

This works fine but adds a blank line for each ignored entry. Am I missing a better / intended way to do this?

fapdash commented 5 months ago

Full plugin code can be found here: https://github.com/fapdash/dotfiles/blob/145e2d0a6ed7b0a2c95ae7a6c5399863494a7d18/ledger-autosync/plugins/dkb.py

egh commented 4 months ago

I can't think of a better way. I think returning None should skip, it would be a very small change to add.

fapdash commented 4 months ago

@egh Cool, unless you want to work on that I'd prepare a PR in the next days?

egh commented 4 months ago

Please do! Thank you