Destination accounts in reg report

Is there a way to show the destination account in a register report? I'm working with ledger, so a ledger answer is preferred. But if there's a way to do this in hledger, I'd appreciaate that too.

The base register report shows up like so

$ hledger register checking
2008/01/01 income               assets:bank:checking            $1           $1
2008/06/01 gift                 assets:bank:checking            $1           $2
2008/06/02 save                 assets:bank:checking           $-1           $1
2008/12/31 pay off              assets:bank:checking           $-1            0

What I am interested in is the account the commodity flows towards from assets:bank:checking. i.e. something like this

$ hledger register checking
2008/01/01 shopping    assets:bank:checking    expenses:somewhere   $-1    $-1

Now I know there's the -r flag which shows the related account instead of the account in the filter. Something like this

$ ledger register -r checking
2008/01/01 shopping               expenses:somewhere            $1           $-1

The problem with this is it lumps all the balances of the related accounts in the running balance. I would like to keep the running balance as the balance of the account in the filter, but also show which related account is concerned in a transaction

Doesn’t hledger’s -r flag do that ? If not maybe you could show a small mock-up.

Consider this

2024-12-01 * Opening Balances
  Assets:Checking        50 EUR
  Assets:Cash            13 EUR
  Equity

2024-12-01 * A Payee
  Expenses:Projects:A    10 EUR
  Assets:Checking

2024-12-01 * B Payee
  Expenses:Projects:B    14 EUR
  Assets:Checking

with r, the reg report looks like so

|| 2024-12-01 Opening Balances     Assets:Cash                 13 EUR        13 EUR
||                                 Equity                     -63 EUR       -50 EUR
|| 2024-12-01 A Payee              Expenses:Projects:A         10 EUR       -40 EUR
|| 2024-12-01 B Payee              Expenses:Projects:B         14 EUR       -26 EUR

(ignore the || in front; that's Vim's quickfix list quirk)

In this reg report, nothing flows from Assets:Cash to Assets:Checking. The only "relation" is cos they're part of the same posting for opening balances.

Writing this up though, I realize if I break up the opening balances posting, like below, it plays more nicely with the -r flag

2024-12-01 * Opening Balances
  Assets:Checking        50 EUR
  Equity

2024-12-01 * Opening Balances
  Assets:Cash            13 EUR
  Equity

2024-12-01 * A Payee
  Expenses:Projects:A    10 EUR
  Assets:Checking

2024-12-01 * B Payee
  Expenses:Projects:B    14 EUR
  Assets:Checking

Tackler does that by default (if you select multiple accounts for the register reports). However the journal format is not 1:1 compatible with ledger / hledger.

REGISTER
--------
2019-01-04 'Strawberry ice cream
            Assets:Cash                            -2.00         -2.00
            Expenses:Ice_cream                      2.00          2.00
----------------------------------------------------------------------
2019-02-03 'Ginger bear
            Assets:Cash                            -1.50         -3.50
            Expenses:Lemonade                       1.50          1.50
----------------------------------------------------------------------

I didn’t understand this, could you break down your thinking for me ?

Oh I see. You are running hledger register checking -r and you're not expecting to see Assets:Cash mentioned, because we humans know that the flow wasn't between cash and checking. But hledger and ledger don''t know that, they're just performing a symmetric mathematical operation.

So yes, being part of the same journal entry/transaction is the relation understood by -r/--related. I think you found the right solution: use separate entries to represent the situation more precisely.

1 Like