On Tuesday, January 4, 2022 at 2:32:20 AM UTC-8 Martin Michlmayr wrote:

> * Muke Tever  [2022-01-03 18:54]: 
> > Oh, I see the problem, and I guess it's a little different than I 
> > thought. So amount and market(amount) doesn't 'balance' to zero, 
> > but they do 'balance' in the sense that ledger doesn't complain 
> > about it being unbalanced, if they exist as a regular transaction: 
>
> > 2022/01/02 Interest 
> > Assets:OBJ 1 OBJ {$5.00} [2022/01/02] 
> > Income:OBJs $-5.00 
>
> Yes and no. 
>
> The example you give only works because ledger assumes that a 
> transaction with two commodities balances. (It does an implicit 
> conversion. There was some discussion about this recently, in which I 
> argued that ledger should not do this.) 
>
> If you introduce a third commodity in your example it will not 
> balance: 
>
> 2022/01/02 Interest 
> Assets:OBJ 1 OBJ {$5.00} [2022/01/02] 
> Income:OBJs $-5.00 
> A -10 EUR 
> B 10 EUR 
>
> You need the @ on the first posting.
>

Indeed— I constructed it with @ in my initial failed example. 

But this helps me out.  My goal was to fix the redundancy of having four 
lines in the transaction when two were predictable.  If it's a matter of 
commodities, I can just put a different line in the automated transaction 
so it's only working with the one commodity.  

The below builds on your first suggestion to me and produces the intended 
result, balancing without errors (though I'll certainly rename the tag to 
something more applicable):

= %/inventory/
    Income:OBJs                  (market(-amount))
    Equity:USD                    (market(amount))

2022/01/02 Interest
    Assets:OBJ                       1 OBJ [2022/01/02] @ $5.00 ; 
:inventory:
    Equity:OBJ                      -1 OBJ [2022/01/02] @ $5.00

1 OBJ {$5} [2022/01/02]  Assets:OBJ
-1 OBJ {$5} [2022/01/02]  Equity:OBJ
                  $5  Equity:USD
                 $-5  Income:OBJs
--------------------
                   0

 Thank you!
 

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/b93d8945-325c-4796-a163-b14d5c66759dn%40googlegroups.com.

Reply via email to