simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
2.91k stars 315 forks source link

Solve Ledger file reading #1962

Open simonmichael opened 1 year ago

simonmichael commented 1 year ago

Capturing this from chat:

Despite all the work on supporting Ledger syntax, the vast majority of Ledger users who try to read their file with hledger, fail and move on. Including the folks who don't use value expressions, and the folks who have been told the ledger print | hledger -f- ... trick.

you'd think that last would work - ledger print is always valid h/ledger syntax, right ? I think now there are two main snags:

needing to set LANG, because everyone has non-ascii and haskell programs throw up their hands if they see that without proper LANG

needing to add commodity directives or -c options, because ledger print adds decimal zeros forcing hledger to check transaction-balancedness more precisely than ledger does

definitely time we had a better strategy here

Wishes

Actions

Related

simonmichael commented 1 year ago

Documented the transaction-balancing precision issue for users at https://hledger.org/ledger.html#incompatible-balancing

simonmichael commented 1 year ago

https://github.com/simonmichael/hledger/tree/master/hledger/test/ledger-compat is the start of a test suite for Ledger file compatibility. It uses Ledger's functional tests as a source of diverse sample Ledger files, and others collected manually can be added over time. Let me know if you can think of another good source.

https://gist.github.com/simonmichael/052703b1641669bfe067c68b81f707cc is the categorised results of a test run.. easier to read in Emacs, but to summarise, we currently read about 80% of Ledger's tests' sample data files. The most frequent causes of read failure were amount expressions and lot notation. There was ~20 other distinct causes of failure as well.

simonmichael commented 1 year ago

https://hledger.org/ledger.html#journal-format is a new status table.

alensiljak commented 1 year ago

design and implement some kind of Ledger file detection

What do you think of https://github.com/ledger-rs/incubator/discussions/2? The main suggestion is the data format specified in the header, similar to shebangs. The program handling becomes easier with semantic versioning.

simonmichael commented 1 year ago

@alensiljak seems a good idea. hledger uses file extension as a hint for input/output format also - .csv/.tsv/.ssv/.timeclock/.timedot/.journal/.hledger (/.ledger/.beancount/...)