Tag for automatic multi-currency posting

25 views
Skip to first unread message

Vladimir Parfinenko

unread,
Oct 10, 2024, 4:20:55 PMOct 10
to Ledger
Hi all,

My ledger file looks like this:

2024-10-10 foo
    expenses  ; :bar:
    assets:first   -5 USD
    assets:second  -3 USD
    assets:third  -10 EUR


And I expect that `balance %bar` would be 8 USD and 10 EUR. However, only the USD posting was tagged by ledger and balance shows only 8 USD. Is it a bug or a feature?

// Ledger 3.3.2-20230330

Regards,
Vladimir Parfinenko

John Wiegley

unread,
Oct 10, 2024, 5:48:30 PMOct 10
to Vladimir Parfinenko, Ledger
>>>>> "VP" == Vladimir Parfinenko <vladimir....@gmail.com> writes:

VP> My ledger file looks like this:

VP> 2024-10-10 foo
VP>     expenses  ; :bar:
VP>     assets:first   -5 USD
VP>     assets:second  -3 USD
VP>     assets:third  -10 EUR

VP> And I expect that `balance %bar` would be 8 USD and 10 EUR. However, only
VP> the USD posting was tagged by ledger and balance shows only 8 USD. Is it a
VP> bug or a feature?

This sounds like a bug to me. You are tagging a posting with an associated
balance. My guess is that oafter this line:

https://github.com/ledger/ledger/blob/johnw%2Fhashes/src/xact.cc#L149

We will need to duplicate the null_post’s metadata. Otherwise, only the first
commodity in the balance_t structure that we are balancing against will be
associated with the full metadata (such as your tag), while the balancing
postings created for all of the other commodity will be without any metadata
(and other details, it would seem).

Thank you for finding this!

John

John Wiegley

unread,
Nov 6, 2024, 2:45:08 PMNov 6
to Vladimir Parfinenko, Ledger
>>>>> "VP" == Vladimir Parfinenko <vladimir....@gmail.com> writes:

VP> And I expect that `balance %bar` would be 8 USD and 10 EUR. However, only
VP> the USD posting was tagged by ledger and balance shows only 8 USD. Is it a
VP> bug or a feature?

Hi Vladimir, this is now fixed in https://github.com/ledger/ledger/pull/2394

John

Vladimir Parfinenko

unread,
Nov 6, 2024, 4:31:13 PMNov 6
to John Wiegley, Ledger
Thank you!

ср, 6 нояб. 2024 г. в 20:45, John Wiegley <jwie...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages