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

I have the same issue, in transitioning to ledger from a similar system that includes this information in the format, and came to the same conclusion. However, I would like to support some of my own tools that expect to have this information for multiple postings within a single transaction. I have come up with two other options to try:

  1. Redefine posting order, pairing the first debits with the first credits in order, with the elided or bucket account paired with whatever is left at the end. I could optionally group postings into individual subtransactions in the main transaction, instead of separated into debit and credit groups. Ledger would ignore this context, but my tools could use it.

1a. Another redefinition would be to share all debits e venly with each credit, or vice versa. This could make amounts more complicated, but if only listing accounts, you would have all those on the other side of the T instead of only one pairing.

  1. I can specifically mark the information for my tools in the ledger file, either preprocessing before piping to ledger or using comments.

A good thing about ledger is that if the pure format doesn't include something you need, there are ways to add it.