Report format: ordering accounts and printing metadata along with records?

358 views
Skip to first unread message

Roman Grazhdan

unread,
Mar 2, 2015, 2:10:37 AM3/2/15
to ledge...@googlegroups.com
Hi all, I'd like to ask if I can tweak the reports Ledger generates in a couple of ways.

It would be nice to have control over the order in which accounts appear (for quick checks, I'd like assets to be listed the last). I've read the manual on format strings but there's no obvious way to do that.

Another question is on the register: is there a way to make Ledger print metadata from tags? Haven't noticed it covered.

Thanks in advance!

John Wiegley

unread,
Mar 2, 2015, 1:10:28 PM3/2/15
to ledge...@googlegroups.com
>>>>> Roman Grazhdan <sehnsuch...@gmail.com> writes:

> It would be nice to have control over the order in which accounts appear
> (for quick checks, I'd like assets to be listed the last). I've read the
> manual on format strings but there's no obvious way to do that.

Can you give a quick example? Have you tried "--sort account"?

> Another question is on the register: is there a way to make Ledger print
> metadata from tags? Haven't noticed it covered.

Try --prepend tag("Foo").

John

Roman Grazhdan

unread,
Mar 3, 2015, 4:45:14 PM3/3/15
to ledge...@googlegroups.com, jo...@newartisans.com

Can you give a quick example?  Have you tried "--sort account"?

Let's say I have Assets:Debit card and Assets:Cash and then some Income:Job and Expenses:Many accounts here. I'd like to get assets listed the last in the balance report, without relying on alphabet if possible.

--sort account looks like default behavior in this respect.

But it's not a big deal. I've started to figure out the format strings, so I'll make them stand out in some other way.
 
> Another question is on the register: is there a way to make Ledger print
> metadata from tags? Haven't noticed it covered.
 
Try --prepend tag("Foo").


[hoodoo@x230 ledger]$ ledger --strict -f main.ledger reg --prepend tag foo
Error: Illegal option --prepend

[hoodoo@x230 ledger]$ ledger -v
    0ms  [INFO]  Ledger starting
Ledger 3.1.0-20141005, the command-line accounting tool

Copyright (c) 2003-2014, John Wiegley.  All rights reserved.

This program is made available under the terms of the BSD Public License.
See LICENSE file included with the distribution for details and disclaimer.
Error: No journal file was specified (please use -f)
    2ms  [INFO]  Ledger ended

[hoodoo@x230 ledger]$ yum info ledger
Installed Packages
Name        : ledger
Arch        : x86_64
Version     : 3.1
Release     : 1.fc21
Size        : 23 M
Repo        : installed
From repo   : fedora

Searching for 'prepend' in the man page, I've got this:

     --meta EXPR
              In the register report, prepend the transaction with the value of the given TAG.

It sort of does the trick, but it only allows to add one tag. Speaking of man pages, the one which ships with Fedora package lacks the FORMATS section. I've found the information in PDF anyway.

So, as I've said, I've figured out the format string, a powerful tool indeed, and I'm now playing with the register form. Here's what does what I want:

%(has_tag("nm") ? tag("nm") : " ")

That way metadata gets printed if available and the template does not break.

John
Reply all
Reply to author
Forward
0 new messages