Hello!

(Fri, Mar 03, 2023 at 04:25:06AM -0000) Tavis Ormandy :
> Hello! I've managed to break my ledger file again :(
> 
> $ ledger bal
> Error: Divide by zero
> 
> I minimized it down to this transaction (numbers changed for privacy):
> 
> commodity FOO
>     format  1,000.00 FOO
> 
> 2022/12/31 * Opening Balances
>     Assets:Brokerage  1.208 FOO @ $8.87
>     Equity:Opening Balances
> 
> 2023/01/03 * Transaction
>     Assets:Brokerage  -1.211 FOO @ $16.79
>     Assets:Brokerage  -0.003 FOO @ $16.79 ; Fractional shares liquidated
>     Assets:Checking  $20.38
>     Income:Capital Gains

You said that commodity FOO had a precision of 2 decimal digits, but in
your entry you have 3, and the second one evaluates to 0 due to that
precision.

If you replace your format with
commodity FOO
  format  1,000.000 FOO
it starts working fine again.

Although formally correct with that change, on the spirit you prbably
wanted that instead in your second transaction:

2023/01/03 * Transaction
    Assets:Brokerage  -1.211 FOO {$8.87} @ $16.79
    Assets:Brokerage  -0.003 FOO {$8.87} @ $16.79 ; Fractional shares liquidated
    Assets:Checking  $20.38
    Income:Capital Gains

(check with the ledger bal command to see the difference)
-- 
Ismael

-- 

--- 
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/20230303131410.d3xydq6vff4o7hw4%40dilion.

Reply via email to