hledger icon indicating copy to clipboard operation
hledger copied to clipboard

allow "safe" reports even with unbalanced transactions in the journal

Open simonmichael opened this issue 2 years ago • 0 comments

When you are trying to troubleshoot a broken journal, you can't run useful queries like hledger accounts unless you first remove or comment out all unbalanced transactions. This feels awkward. We discussed on chat, here are some excerpts:

I'm a little unclear on where you draw the line, generally or for each specific command, on how much error to try to ignore by default. Because in the worst case, someone is choosing to launch missiles or not based on the report output (maybe even an accounts report), and quietly ignoring some serious problem in the input might not be desirable

--ignore-balanced to ignore unbalanced transactions sounds possible

--ignore-parseable to ignore invalid journal entries (syntax errors, broken include directives, wrong file formats..) sounds a bit more complicated

Some help mockups:

1: --ignore-balanced - any unbalanced transactions in the journal will

(for commands which don't require them, like accounts, commodities, tags): be parsed normally, without raising an error (for commands which require them, like print, register, balance): be omitted and excluded from reports, without raising an error but with a warning printed on stderr

no that sounds a bit suspect

2: --ignore-balanced - causes commands which don't calculate amounts - like accounts, commodities, payees, tags; also the print command - to process unbalanced transactions without raising an error. This can be useful when troubleshooting, or in scripts. Commands which do calculate amounts - like register and balance reports - are not affected by this flag.

--ignore-balanced also implies --ignore-assertions. Or not.

3: simpler if we allowed all commands to ignore unbalanced transactions, even balance and register reports (either including or excluding those txns). Should we allow such balance/register reports ? I don't think so

4: Commands which don't calculate amounts - like accounts, commodities, payees, tags - will process unbalanced transactions without raising an error (always).

Overall it seems like it would be harmless enough, and more useful, if reports which don't calculate with amounts, can run even when there are unbalanced transactions (option 4 above).

simonmichael avatar Aug 24 '23 17:08 simonmichael