On 2023-04-02, Tavis Ormandy wrote:
> Hello! I sometimes spend money in two different currencies, $ and £.
> This usually works fine, but it breaks a few reports. For example, now I
> can't do this:
>
> $ ledger reg --monthly -j ^Expenses:
> While evaluating value expression:
> quantity(scrub(display_amount))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> While converting $20.00
> £15.00 to an amount:
> While calling function 'quantity $20.00
> £15.00':
> Error: Cannot convert a balance with multiple commodities to an amount
>
Answering my own question, I think I was nearly there, you need:
= expr (account =~ /^Expenses:/ and commodity == '£')
; VALUE:: market(amount, date, exchange)
To lock the value in to the exchange rate on the date of the
transaction, and then add -X '$' to force the conversion.
If you don't want to automate it, you can also manually add something
like this to each transaction:
; VALUE:: $100
This seems (?) to give reasonable output, although I wonder if -X "$"
should just do this by default?
Tavis.
--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger [email protected]
_\_V _( ) _( ) @taviso
--
---
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ledger-cli/u0cg6f%24ndq%241%40ciao.gmane.io.