I am trying to use the ledger 3.1 `balance` command to produce output for another script. I am using `--balance-format "%A=%(display_total)\n"` for this purpose. Unfortunately, I have found that though I have declared all accounts with the `account` command, it is impossible to get values for any accounts that have not had transactions during the period selected, including parent accounts with non-zero balances.

For example, consider the following journal.

~~~
account Assets
account Expenses
account Expenses:Clothing
account Expenses:Food
account Income

2017-03-15 Employer
   Income             $-100
   Assets              $100

2017-03-15 Restaurant
   Assets              $-20
   Expenses:Food        $20
~~~

The balance of the Expenses (parent) account is $20. The balance of the Expenses:Clothing account is 0. But the balance command shows neither.

~~~
$ ledger --no-total --balance-format "%A=%(display_total)\n" balance
Assets=$80
Expenses:Food=$20
Income=$-100
~~~

I would like to get balances of all accounts, including empty/zero accounts (Expenses:Clothing) and parent accounts (Expenses) that do not have transactions of their own.

I can make ledger provide values for parent accounts if I add a dummy automated transaction like this with a line for every account.

~~~
= expr true
   Assets                 0
   Expenses               0
   Expenses:Clothing      0
   Expenses:Food          0
   Income                 0
~~~

Now I at least get the parent accounts (Expenses), but still not empty/zero accounts (Expenses:Clothing).

~~~
$ ledger --no-total --balance-format "%A=%(display_total)\n" balance
Assets=$80
Expenses=$20
Expenses:Food=$20
Income=$-100
~~~

Note that this is not resolved by simply adding more transactions, because a selected `--period` for a report may or may not contain transactions that touch a specific account.

Am I missing something?

Thanks for your help!

--

--- You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to