print removes commodity directive

40 views
Skip to first unread message

Colin Dean

unread,
Jun 15, 2020, 5:23:12 PM6/15/20
to Ledger

I’m updating my finances for the first time in a while starting afresh: a whole new transaction record.

Something I’ve somehow never hit before: My workflow is to append the output of ledger-autosync to my tx record, make adjustments, categorize, commit, then sort and format using ledger print. What I’m noticing is that my commodity directive is getting stripped.

$ cat test.ledger
commodity USD
  alias $
  format 1,000.00

2020/06/16 Test
  Expenses    $56
  Assets      -56 USD


$ ledger -f test.ledger bal
             -56 USD  Assets
              56 USD  Expenses
--------------------
                   0

$ ledger -f test.ledger print
2020/06/16 Test
    Expenses                                  56 USD
    Assets

This is making is hard to intermix $ and USD, as ledger-autosync mixes the two outputs depending on the converter in use and I tend to use USD when I do things manually.

Is there a way to disable removing the commodity? I understand that ‘print’ is supposed to output the most space-efficient representation of the tx log, but it’s annoying to have to re-add the commodity directive every time I sort.




-- 
Colin Dean

Martin Michlmayr

unread,
Jun 15, 2020, 7:52:35 PM6/15/20
to ledge...@googlegroups.com
* Colin Dean <coli...@gmail.com> [2020-06-15 14:23]:
> Is there a way to disable removing the commodity? I understand that
> ‘print’ is supposed to output the most space-efficient
> representation of the tx log, but it’s annoying to have to re-add
> the commodity directive every time I sort.

I'm not sure why $ is removed, but
print --raw
works.
--
Martin Michlmayr
https://www.cyrius.com/

Robin H. Johnson

unread,
Jun 16, 2020, 2:59:14 AM6/16/20
to ledge...@googlegroups.com
On Mon, Jun 15, 2020 at 02:23:09PM -0700, Colin Dean wrote:
> I’m updating my finances for the first time in a while starting afresh: a
> whole new transaction record.
>
> Something I’ve somehow never hit before: My workflow is to append the
> output of ledger-autosync to my tx record, make adjustments, categorize,
> commit, then sort and format using ledger print. What I’m noticing is that
> my commodity directive is getting stripped.
>
> $ cat test.ledger
> commodity USD
> alias $
> format 1,000.00
>
> 2020/06/16 Test
> Expenses $56
> Assets -56 USD
'alias' provides an alternate way to INPUT entries.
It is converted and printed in the canonical format.

There's a note in the infodoc that the 'format' directive:
"In the future, using this directive will disable Ledger's observation
of other ways that commodity is used, and will provide the “canonical”
representation."

These two examples will produce different output:
===
commodity USD
alias $
format 1,000.00

2020/06/16 Test
Expenses $56
Assets -56 USD
===
commodity $
alias USD
format 1,000.00

2020/06/16 Test
Expenses $56
Assets -56 USD
====


>
>
> $ ledger -f test.ledger bal
> -56 USD Assets
> 56 USD Expenses
> --------------------
> 0
>
> $ ledger -f test.ledger print
> 2020/06/16 Test
> Expenses 56 USD
> Assets
>
> This is making is hard to intermix $ and USD, as ledger-autosync mixes the
> two outputs depending on the converter in use and I tend to use USD when I
> do things manually.
I think ledger-autosync should probably gain options to convert
consistently, and then it would match your USD manual inputs.

>
> Is there a way to disable removing the commodity? I understand that ‘print’
> is supposed to output the most space-efficient representation of the tx
> log, but it’s annoying to have to re-add the commodity directive every time
> I sort.
It converts to the canonical format, which other than the --raw option,
doesn't help you.


--
Robin Hugh Johnson
Gentoo Linux: Dev, Infra Lead, Foundation Treasurer
E-Mail : rob...@gentoo.org
GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85
GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136
signature.asc

Colin Dean

unread,
Jun 16, 2020, 1:32:14 PM6/16/20
to Ledger
Thanks, it looks like --raw is what I want.

Colin Dean

unread,
Jun 16, 2020, 3:03:49 PM6/16/20
to Ledger
Second thought, it's not. Using 

ledger -f 2020.ledger print -S d --raw > 2020-s.ledger

still dropped the commodity directive.
Reply all
Reply to author
Forward
0 new messages