hpdeifel / hledger-iadd

A terminal UI as drop-in replacement for hledger add.
BSD 3-Clause "New" or "Revised" License
77 stars 8 forks source link

Default year directive is not taken into account #59

Open ShrykeWindgrace opened 3 years ago

ShrykeWindgrace commented 3 years ago

Hi!

My muscle memory prefers dates in the 2021-12-31 or 12-31 format, and I am running hledger-iadd as follows:

$ hledger-iadd --completion-engine fuzzy --date-format '[%Y-]%m-%d'

The journal file (pointed by $LEDGER_FILE) contains a default year directive: Y2021.

Yet when I enter the transaction date without the year (e.g. "11-03"), but in the future (because reasons), the year suggestion is 2020; the heuristics for year suggestion goes astray. Is there a an additional configuration step for default year - to bypass that heuristics - that I missed?

Cheers!

$ hledger-iadd --version                                            
This is hledger-iadd version 1.3.14
hpdeifel commented 2 years ago

Yes, iadd currently ignores the default year set in the journal. The year that's suggested is based on the current date and the (incomplete) entered date. The assumption is that iadd is mostly used to record past transactions and so it will helpfully suggest the most recent matching date from the past.

I don't know how to best accommodate your use-case without breaking mine, as I exclusively enter past transactions and the current behavior is quite helpful for that. Maybe the default year could indeed be used if set, but I have a feeling that this would somewhat conflate two concepts that ought to be separate: The in-journal date format and the completion mechanism.

ShrykeWindgrace commented 2 years ago

Thanks for clarifications! Indeed, current heuristics works perfectly well if we input only past transactions.

I wonder if we could a separate directive - something like {%Y}, for example - that would force current year or default year in the date suggestion. Admittedly, that's a non-zero effort for a minor gain, I will not insist on implementing this feature=)