hledger icon indicating copy to clipboard operation
hledger copied to clipboard

`bal -X USD` doesn't show multicurrency account balance in the one currency (USD)

Open notxvilka opened this issue 6 months ago • 3 comments

bal -X <CURRENCY> doesn't seem to work as manuall suggests - it still not recalculates everything in this one <CURRENCY>.

For example, this is what hledger bal assets -X USD -f test.journal returns:

           $2345.000  assets:bank1:cur1
             456 CHF  assets:bank1:cur2
             100 CHF  assets:bank2:cur2
             200 GBP  assets:bank2:cur3
             400 CAN  assets:bank2:cur4
             300 NGN  assets:bank3:cur5
--------------------
           $2345.000
             400 CAN
             556 CHF
             200 GBP
             300 NGN

hledger --version: hledger 1.43.1, mac-aarch64

test.journal:

2025-01-01 Opening balance
	assets:bank1:cur1		$2345
	assets:bank1:cur2		456 CHF @ $0.5
	assets:bank2:cur2		100 CHF @ $0.5
	assets:bank2:cur3		200 GBP @ $0.01
	assets:bank2:cur4		400 CAN @ $10
	assets:bank3:cur5		300 NGN @ $0.005
	equity

I assume it should show the summary in just USD rather than showing the same as without -X USD.

notxvilka avatar Jun 09 '25 20:06 notxvilka

Several problems:

  1. Your journal uses $ but you've requested value in USD; hledger doesn't know these are the same. Use -X \$ instead. Or, you could declare that $ and USD are equivalent:

    P 0000-01-01 USD $1
    
  2. hledger doesn't infer market prices from costs by default. Either add some P directives, or add --infer-market-prices to the command to infer them.

$ hledger bal assets -X \$ --infer-market-prices
           $2345.000  assets:bank1:cur1
            $228.000  assets:bank1:cur2
             $50.000  assets:bank2:cur2
              $2.000  assets:bank2:cur3
           $4000.000  assets:bank2:cur4
              $1.500  assets:bank3:cur5
--------------------
           $6626.500  

simonmichael avatar Jun 09 '25 21:06 simonmichael

PS, I am open to suggestions to improve the docs. https://hledger.org/dev/hledger.html#value-reporting mentions P and --infer-market-prices.

You might be coming from Ledger, where inferring market prices from costs is done by default ?

simonmichael avatar Jun 09 '25 21:06 simonmichael

PS, I am open to suggestions to improve the docs. https://hledger.org/dev/hledger.html#value-reporting mentions P and --infer-market-prices.

You might be coming from Ledger, where inferring market prices from costs is done by default ?

Good point. Now I can understand it from the documentation but before you mentioned it wasn't immediately clear, indeed. I will send a PR trying to clarify it better in the documentation.

notxvilka avatar Jun 10 '25 03:06 notxvilka