simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
3.06k stars 320 forks source link

Can the register report produce a per-account running total? #1787

Open PSLLSP opened 2 years ago

PSLLSP commented 2 years ago

I am not sure but I think that register command is broken. Example journal:

$ cat demo-reg.journal
2019/01/01 Google home hub
    expenses:personal:electronics          $90.00
    liabilities                           $-90.00

2019/01/02 Phone screen protector
    expenses:personal:electronics:upgrades          $10.00
    liabilities

2019/01/02 Weekly train ticket
    expenses:personal:train tickets       $153.00
    liabilities

2019/01/03 Flowers
    expenses:personal          $30.00
    liabilities

2019/01/10 Weekly train ticket
    expenses:personal:train tickets       $123.00
    liabilities

I do not like this output, is it correct? The last column, those should be balances??

$ hledger -f demo-reg.journal reg
2019-01-01 Google home hub                expenses:personal:electronics         $90.00        $90.00
                                          liabilities                          $-90.00             0
2019-01-02 Phone screen protector         ex:pe:electronics:upgrades            $10.00        $10.00
                                          liabilities                          $-10.00             0
2019-01-02 Weekly train ticket            ex:personal:train tickets            $153.00       $153.00
                                          liabilities                         $-153.00             0
2019-01-03 Flowers                        expenses:personal                     $30.00        $30.00
                                          liabilities                          $-30.00             0
2019-01-10 Weekly train ticket            ex:personal:train tickets            $123.00       $123.00
                                          liabilities                         $-123.00             0

Compare with output, when I filter for liabilities, this is better, isn't it?

$ hledger -f demo-reg.journal reg liabilities
2019-01-01 Google home hub                liabilities                          $-90.00       $-90.00
2019-01-02 Phone screen protector         liabilities                          $-10.00      $-100.00
2019-01-02 Weekly train ticket            liabilities                         $-153.00      $-253.00
2019-01-03 Flowers                        liabilities                          $-30.00      $-283.00
2019-01-10 Weekly train ticket            liabilities                         $-123.00      $-406.00

The same, with grep, balance is not updated, it is always 0:

$ hledger -f demo-reg.journal reg | grep "liabilities"
                                          liabilities                          $-90.00             0
                                          liabilities                          $-10.00             0
                                          liabilities                         $-153.00             0
                                          liabilities                          $-30.00             0
                                          liabilities                         $-123.00             0

And again, for "tickets":

$ hledger -f demo-reg.journal reg tickets
2019-01-02 Weekly train ticket            ex:personal:train tickets            $153.00       $153.00
2019-01-10 Weekly train ticket            ex:personal:train tickets            $123.00       $276.00
$ hledger -f demo-reg.journal reg | grep "tickets"
2019-01-02 Weekly train ticket            ex:personal:train tickets            $153.00       $153.00
2019-01-10 Weekly train ticket            ex:personal:train tickets            $123.00       $123.00
Xitian9 commented 2 years ago

This looks correct to me. The numbers on the right are the running total, and since you're not doing any filtering every transaction will balance out, and the running total will be 0 at the end of every transaction.

Perhaps you want to filter, as you did in the second example. Or perhaps you want to use the aregister command. If you let us know what you're trying to do, it might be more helpful. You might have more luck with these sorts of problems asking in the discussion areas https://hledger.org/support.html.

PSLLSP commented 2 years ago

I would expect to see this (in that case I can use grep to have the same output like when I filter output in hledger):

2019-01-01 Google home hub                expenses:personal:electronics         $90.00        $90.00
                                          liabilities                          $-90.00       $-90.00
2019-01-02 Phone screen protector         ex:pe:electronics:upgrades            $10.00        $10.00
                                          liabilities                          $-10.00      $-100.00
2019-01-02 Weekly train ticket            ex:personal:train tickets            $153.00       $153.00
                                          liabilities                         $-153.00      $-253.00
2019-01-03 Flowers                        expenses:personal                     $30.00        $30.00
                                          liabilities                          $-30.00      $-283.00
2019-01-10 Weekly train ticket            ex:personal:train tickets            $123.00       $276.00
                                          liabilities                         $-123.00      $-406.00

I am not an accountant and I accept I can miss something important. I checked output of ledger -f demo-reg.journal register and it produces the same output as hledger -f demo-reg.journal register.

Xitian9 commented 2 years ago

I see, you want a per-account running total rather than an overall running total, is that correct? I don't think there's a way to do that currently, but a balance report will give you the overall per-account total. Is there a specific reason you need these numbers, or were you just surprised by the current behaviour?

PSLLSP commented 2 years ago

I know I can use balance command... I do not need this register output. I just noticed this behavior, I was confused/surprised with the output and I reported it as I assumed it must be a bug...

simonmichael commented 2 years ago

It's the way PTA register reports have always worked. I understand your alternative mockup, but I must say I think it would be quite a bit more confusing to most people.

the-solipsist commented 2 years ago

I can imagine a 3-columnar running totals including account-level balance as well as transaction-level totals. But I'm not very sure how intuitive it is.

2019-01-01 Google     expenses:personal:electronics      $90.00    $90.00     $90.00
                      liabilities                       $-90.00         0    $-90.00
2019-01-02 Phone      ex:pe:electronics:upgrades         $10.00    $10.00     $10.00
                      liabilities                       $-10.00         0   $-100.00
2019-01-02 Train      ex:personal:train tickets         $153.00   $154.00    $153.00
                      liabilities                      $-153.00         0   $-253.00
2019-01-03 Flowers    expenses:personal                  $30.00    $30.00     $30.00
                      liabilities                       $-30.00         0   $-283.00
2019-01-10 Train      ex:personal:train tickets         $123.00   $276.00    $276.00
                      liabilities                      $-123.00         0   $-406.00

or even:

2019-01-01 Google     expenses:personal:electronics         $90.00        $90.00    $90.00
                      liabilities                          $-90.00       $-90.00         0
2019-01-02 Phone      ex:pe:electronics:upgrades            $10.00        $10.00    $10.00
                      liabilities                          $-10.00      $-100.00         0
2019-01-02 Train      ex:personal:train tickets            $153.00       $153.00   $154.00
                      liabilities                         $-153.00      $-253.00         0
2019-01-03 Flowers    expenses:personal                     $30.00        $30.00    $30.00
                      liabilities                          $-30.00      $-283.00         0
2019-01-10 Train      ex:personal:train tickets            $123.00       $276.00   $276.00
                      liabilities                         $-123.00      $-406.00         0

or:

2019-01-01 Google     expenses:personal:electronics       $90.00     $90.00    $90.00
                      liabilities                        $-90.00    $-90.00         0
2019-01-02 Phone      ex:pe:electronics:upgrades          $10.00     $10.00    $10.00
                      liabilities                       $-100.00    $-10.00         0
2019-01-02 Train      ex:personal:train tickets          $153.00    $153.00   $154.00
                      liabilities                       $-253.00   $-153.00         0
2019-01-03 Flowers    expenses:personal                   $30.00     $30.00    $30.00
                      liabilities                       $-283.00    $-30.00         0
2019-01-10 Train      ex:personal:train tickets          $276.00    $123.00   $276.00
                      liabilities                       $-406.00   $-123.00         0