What am I getting wrong?

25 views
Skip to first unread message

Marcelo Muñoz

unread,
Jul 27, 2025, 4:17:52 PMJul 27
to Ledger
While reading the manual '4.5.3 Fixing Lot Prices', I came across this example.

     2009/01/01 Shell
         Expenses:Gasoline             11 GAL {=$2.299} @ $2.30
         Assets:Checking

 When I calculate the balance for this example, the Cash account balances at $-25 and not $-25.29. Is this correct, or am I misunderstanding something?


I would also appreciate it if someone could explain this paragraph to me. As I understand it, capital gains or losses are generated at the moment of sale, not at the moment of purchase:

This transaction says that you bought 11 gallons priced at $2.299 per
gallon at a _cost to you_ of $2.30 per gallon.  Ledger auto-generates a
balance posting in this case to Equity:Capital Losses to reflect the 1.1
cent difference, which is then balanced by Assets:Checking because its
amount is null.


my ledger version is: Ledger 3.3.2-20230330

Thank you in advance!!
Marcelo



John Wiegley

unread,
Jul 27, 2025, 4:20:17 PMJul 27
to Marcelo Muñoz, Ledger
>>>>> "MM" == Marcelo Muñoz <ma.muno...@gmail.com> writes:

MM> While reading the manual '4.5.3 Fixing Lot Prices', I came across this
MM> example.

MM>      2009/01/01 Shell
MM>          Expenses:Gasoline             11 GAL {=$2.299} @ $2.30
MM>          Assets:Checking

MM>  When I calculate the balance for this example, the Cash account balances
MM> at $-25 and not $-25.29. Is this correct, or am I misunderstanding
MM> something?

Hi Marcelo, can you please include the command you used to “calculate the
balance”?

Thanks, John

Igbanam Ogbuluijah

unread,
Jul 27, 2025, 4:35:20 PMJul 27
to ledge...@googlegroups.com, Marcelo Muñoz
I think it's a rounding problem.

The command to calculate the balance is the default ledger balance.

The fixed version of this specifies a commodity with decimal places.

commodity $
  format $1,234.56

2009/01/01 Shell

  Expenses:Gasoline         11 GAL {=$2.299} @ $2.30
  Assets:Checking

Without the commodity specification, ledger seems to round the amounts to the nearest whole.



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/m2freho079.fsf%40gmail.com.

John Wiegley

unread,
Jul 27, 2025, 4:47:02 PMJul 27
to Igbanam Ogbuluijah, ledge...@googlegroups.com, Marcelo Muñoz
>>>>> "IO" == Igbanam Ogbuluijah <xigb...@gmail.com> writes:

IO> The fixed version of this specifies a commodity with decimal places.

I see, this is simply a display matter. You can see the “real” value using the
--unround switch, even without the commodity setting:

$-25.289 Assets:Checking
11 GAL Expenses:Gasoline
--------------------
$-25.289
11 GAL

John

Marcelo Muñoz

unread,
Jul 28, 2025, 12:21:11 PMJul 28
to John Wiegley, Igbanam Ogbuluijah, ledge...@googlegroups.com
Thanks for your answers! Do you think I should open an issue with this? 
 I remember reading in the doc that Ledger should display
 the commodity using the same format in the  reports  as it's used in the journal file.

Marcelo

John Wiegley

unread,
Jul 28, 2025, 12:56:33 PMJul 28
to Marcelo Muñoz, Igbanam Ogbuluijah, ledge...@googlegroups.com
>>>>> Marcelo Muñoz <ma.muno...@gmail.com> writes:

> Thanks for your answers! Do you think I should open an issue with this?   I
> remember reading in the doc that Ledger should display  the commodity using
> the same format in the  reports  as it's used in the journal file.

True, but it never “observes” the precision used in pricing amounts, since
those are so often of very high precision when the ordinary amounts are not.
The commodity directive was created to solve this very problem, so I would
recommend that route as the best solution in this case!

John
Reply all
Reply to author
Forward
0 new messages