hledger icon indicating copy to clipboard operation
hledger copied to clipboard

hledger add doesn't work when combining @@ and conversion equity accounts

Open javalasers opened this issue 2 years ago • 1 comments

Version: hledger 1.30, mac-x86_64

I'm recording commodity conversions using both the @@ mechanism and also the equity conversion accounts, as mentioned here. ("Conversion with equity postings and explicit cost"). However, "hledger add" doesn't see this as balanced, even though if I manually input in the journal, it is seen as balanced and works exactly as expected.

Small example:

Date [2023-07-04]:
Description: Test 2
Using this similar transaction for defaults:
2023-07-04 Test
    assets:eth                            1 ETH
    equity:conversion:$-ETH:ETH          -1 ETH
    equity:conversion:$-ETH:$             $2000
    revenue:staking                      $-2000

Account 1 [assets:eth]:
Amount  1 [1 ETH]: 1 ETH @@ $2000
Account 2 [equity:conversion:$-ETH:ETH]:
Amount  2 [-1 ETH @@ $2000]: -1 ETH
Account 3 [equity:conversion:$-ETH:$]:
Amount  3 [1 ETH]: $2000
Account 4 [revenue:staking]:
Amount  4 [$-2000]:
Account 5: .
Please enter more postings to balance the transaction.

If I continue adding accounts to the hledger add entry to try to determine what it is looking for to accept that the transaction is balanced, it is clear that it wants an entry that literally says "-1 ETH @@ $2000". However, if I try to use such an entry for the Amount 2 above, then hledger itself rejects that journal entry when I try to run "bse" or similar afterward.

Basically there is a divergence in what hledger sees as a balanced journal entry vs. what "hledger add" sees as a balanced journal entry, when both the @@ syntax and the conversion equity account methods are in use.

javalasers avatar Jul 05 '23 04:07 javalasers

Thanks for the report. I agree add should accept this, as the journal reader does.

simonmichael avatar Jul 10 '23 04:07 simonmichael