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.86k stars 307 forks source link

--infer-costs does not understand postings with blank amounts #1954

Open ag-eitilt opened 1 year ago

ag-eitilt commented 1 year ago

I'm using a variant of the equity-postings method of recording currency conversions/securities trading, where I leave the equity account unfilled to catch both commodities; using the example in the manual, my transaction would be:

2021-01-01
    assets:cash        -100 EUR
    assets:cash         120 USD
    equity:conversion

This works well for most reports, but does not introduce a basis when using the -B flag. (I'm using the {$0.00} syntax for lots, in the hopes that's eventually made functional, but that's a separate issue.) So far no surprises since that's exactly what the docs describe, but when I try adding the --infer-cost flag as used in the manual hledger throws an error complaining that "Conversion postings must occur in adjacent pairs". I agree that being explicit with your conversion account is a good thing, but I feel like the case where there's a posting with a blank amount and multiple commodities which don't balance without it is very nearly as explicit.

simonmichael commented 1 year ago

I think it's functioning as documented, as you say, but I agree it would be nice if this form could also be supported. Maybe there are ambiguities, any thoughts @Xitian9 ?