Posting Costs with --exchange --historical

25 views
Skip to first unread message

Henry Mitchell

unread,
Aug 15, 2025, 8:23:59 PMAug 15
to ledge...@googlegroups.com
Hi,

When recording expenses in a foreign currency, I want to see how much I had spent in my base currency (USD) as of the date of the transaction. If I record the price at which I want the foreign currency valued and use `--historical --exchange USD`, it gets what I want for the most part. However, credit cards have their own rate and I would like to have the ledger reflect that, but I can't seem to figure out how to do so correctly.

Consider:
P 2025-01-01 00:00:00 USD 150.00 JPY

2025-01-01 Should be 10.00 USD
  Assets:Cash    -1500 JPY
  Expenses:Food   1500 JPY

2025-01-01 Credit Cards Use One-Off Exchange Rate
  Liabilities:Credit     -11.00 USD
  Expenses:Food           1500 JPY @@ 11.00 USD

2025-01-01 Should still be 10.00 USD
  Assets:Cash       -1500 JPY
  Expenses:Food      1500 JPY

$ ledger --file /tmp/test.ledger --price-db /dev/null register Food --exchange USD --historical
2025-01-01 Should be 10.00 USD                        Expenses:Food  11.00 USD  11.00 USD
2025-01-01 Credit Cards Use One-Off Exchange Rate     Expenses:Food  11.00 USD  22.00 USD
2025-01-01 Should still be 10.00 USD                  Expenses:Food  11.00 USD  33.00 USD

If I set the posting cost as above, it creates a pricedb entry that affects the cash purchases. If I use a virtual posting cost using (@@), the pricedb entry doesn't get created, but `--historical --exchange USD` seems to ignore the explicit posting cost, so all 3 postings get valued at 10.00 USD. Is this intended behavior? If so, how can I have it show the Cash transactions as 10.00 USD and the Credit transaction as 11.00 USD?

Thanks,
Henry

Igbanam Ogbuluijah

unread,
Aug 17, 2025, 4:53:54 PMAug 17
to Ledger
The way I've done this in the past is to see the 11 rate as 10 + 1. Now, I can record the 1 as cost of the transaction somewhat, and the 10 continues as the normal rate. Could this work for your case?


Igbanam

--

---
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 ledger-cli+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ledger-cli/CACTkciO%3DM0_O6a8M8ggQqYmHhSzwBM2QDECFCrVTBMaophoZ6g%40mail.gmail.com.

Henry Mitchell

unread,
Aug 17, 2025, 10:37:30 PMAug 17
to ledge...@googlegroups.com
I can workaround this or not even bother (I just leave the foreign currency as a comment). But what I'd like to know is if this is even possible with ledger or if I misunderstood what virtual posting cost and --historical were supposed to do here.

Tavis Ormandy

unread,
Aug 27, 2025, 5:53:36 PMAug 27
to ledge...@googlegroups.com
On 2025-08-16, Henry Mitchell wrote:
> If I set the posting cost as above, it creates a pricedb entry that affects
> the cash purchases. If I use a virtual posting cost using (@@), the pricedb
> entry doesn't get created, but `--historical --exchange USD` seems to
> ignore the explicit posting cost, so all 3 postings get valued at 10.00
> USD. Is this intended behavior?

I think it does makes sense, because you're effectively just ignoring it.

> If so, how can I have it show the Cash
> transactions as 10.00 USD and the Credit transaction as 11.00 USD?
>

I *think* you don't want the historical value (the fair market value of
the commodity at the time you purchased it), you want what you *actually*
paid (regardless of any discounts or fees to the fmv)... so you want the
basis, no? So just --basis instead of --historical?

Tavis.

--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger tav...@sdf.org
_\_V _( ) _( ) @taviso

Henry Mitchell

unread,
Aug 28, 2025, 1:35:11 AMAug 28
to ledge...@googlegroups.com
On Wed, Aug 27, 2025 at 2:53 PM Tavis Ormandy <tav...@gmail.com> wrote:
On 2025-08-16, Henry Mitchell wrote:
> If I set the posting cost as above, it creates a pricedb entry that affects
> the cash purchases. If I use a virtual posting cost using (@@), the pricedb
> entry doesn't get created, but `--historical --exchange USD` seems to
> ignore the explicit posting cost, so all 3 postings get valued at 10.00
> USD. Is this intended behavior?

I think it does makes sense, because you're effectively just ignoring it.

> If so, how can I have it show the Cash
> transactions as 10.00 USD and the Credit transaction as 11.00 USD?
>

I *think* you don't want the historical value (the fair market value of
the commodity at the time you purchased it), you want what you *actually*
paid (regardless of any discounts or fees to the fmv)... so you want the
basis, no? So just --basis instead of --historical?

Thanks Tavis. I think --basis does what I expected. I kinda sorta understand why. Maybe it'll become clearer to me as I try to make use of this flag for what I would like to do.

 
Tavis.

--
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger tav...@sdf.org
_\_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 ledger-cli+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages