Re: Transaction balances as unbalanced virtual but doesn't when real

2022-01-04 Thread Muke Tever
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.


Re: Transaction balances as unbalanced virtual but doesn't when real

2022-01-04 Thread Martin Michlmayr
* 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
B10 EUR

You need the @ on the first posting.

BTW, given 1 OBJ {$5.00} I once argued that the cost should set the
price (i.e. @ $5.00 should be implicit if no other @ is given).
I still think that makes sense but it's not how ledger works.
I think it's this one: https://github.com/ledger/ledger/issues/630

-- 
Martin Michlmayr
https://www.cyrius.com/

-- 

--- 
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/YdQiLXsNrRjk9Tmy%40jirafa.cyrius.com.


Re: Transaction balances as unbalanced virtual but doesn't when real

2022-01-03 Thread Muke Tever
On Monday, January 3, 2022 at 3:12:39 PM UTC-8 Martin Michlmayr wrote:

> * Muke Tever  [2022-01-02 21:45]: 
> > = %/inventory/ 
> > Equity:$account (-amount) 
> > Equity:USD (market(amount)) 
>
> I initially thought it's a bug but after looking at it some more I 
> think it's not a bug. 
>
> amount and market(amount) are not the same. The amount is $5.00. 
> market(amount) is 1 OBJ {$5.00} [2022-01-02].
>

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
   
1 OBJ {$5.00} [2022/01/02]  Assets:OBJ
  $-5.00  Income:OBJs

  $-5.00
1 OBJ {$5.00} [2022/01/02]

So the interesting thing is that it complains when it's an automated 
transaction, even when it both would balance as a normal transaction and 
would balance the original transaction to zero.  

= %/inventory/
Equity:$account -1 OBJ {$5.00} [2022/01/02]
Equity:USD  $5.00

2022/01/02 Interest
Assets:OBJ 1 OBJ {$5.00} [2022/01/02] ; 
:inventory:
Income:OBJs   $-5.00
 
While parsing file "/Users/[...]/Documents/2022/Ledger/testfile.ledger", 
line 7:
While balancing transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 5-7:
> 2022/01/02 Interest
> Assets:OBJ 1 OBJ {$5.00} [2022/01/02] 
; :inventory:
> Income:OBJs   $-5.00
Unbalanced remainder is:
   $5.00
-1 OBJ {$5.00} [2022/01/02]
Amount to balance against:
  $10.00
While applying automated transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 1-3:
> = %/inventory/
> Equity:$account -1 OBJ {$5.00} [2022/01/02]
> Equity:USD  $5.00
While extending transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 5-7:
> 2022/01/02 Interest
> Assets:OBJ 1 OBJ {$5.00} [2022/01/02] 
; :inventory:
> Income:OBJs   $-5.00
Error: Transaction does not balance

So I think you need to use either: 
>
> = %/inventory/ 
> Equity:$account (-amount) 
> Equity:USD (amount) 
>
> or: 
>
> = %/inventory/ 
> Equity:$account (market(-amount)) 
> Equity:USD (market(amount)) 
>
> You can run this command to see the difference: 
> ledger -f d bal --lots equity
>

Indeed these do not throw errors, but they don't get me balanced to zero as 
I'm intending.
Thank you for your time and response.

-- 

--- 
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/ff9aebef-b91b-4bde-ad42-0152f2772844n%40googlegroups.com.


Re: Transaction balances as unbalanced virtual but doesn't when real

2022-01-03 Thread Martin Michlmayr
* Muke Tever  [2022-01-02 21:45]:
> = %/inventory/
> Equity:$account (-amount)
> Equity:USD  (market(amount))

I initially thought it's a bug but after looking at it some more I
think it's not a bug.

amount and market(amount) are not the same.  The amount is $5.00.
market(amount) is 1 OBJ {$5.00} [2022-01-02].

So I think you need to use either:

= %/inventory/
Equity:$account (-amount)
Equity:USD  (amount)

or:

= %/inventory/
Equity:$account (market(-amount))
Equity:USD  (market(amount))

You can run this command to see the difference:
ledger -f d bal --lots equity

-- 
Martin Michlmayr
https://www.cyrius.com/

-- 

--- 
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/YdOC4Dd28KN731X%2B%40jirafa.cyrius.com.


Transaction balances as unbalanced virtual but doesn't when real

2022-01-03 Thread Muke Tever
Howdy!

I'm trying to automate a transaction.  The below gives the expected 
outcome, and it appears to balance as expected:

= %/inventory/
(Equity:$account) (-amount)
(Equity:USD)  (market(amount))

2022/01/02 Interest
Assets:OBJ 1 OBJ @ $5.00 ; :inventory:
Income:OBJs  $-5.00

   1 OBJ  Assets:OBJ
  -1 OBJ  Equity:Assets:OBJ
   $5.00  Equity:USD
  $-5.00  Income:OBJs

   0

But I need this to be a real transaction.  However if I make it real, or 
even if I use [balanced virtual accounts], I get an error that it doesn't 
balance anymore:

= %/inventory/
Equity:$account (-amount)
Equity:USD  (market(amount))

2022/01/02 Interest
Assets:OBJ 1 OBJ @ $5.00 ; :inventory:
Income:OBJs  $-5.00

While parsing file "/Users/[...]/Documents/2022/Ledger/testfile.ledger", 
line 7:
While balancing transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 5-7:
> 2022/01/02 Interest
> Assets:OBJ 1 OBJ @ $5.00 ; :inventory:
> Income:OBJs  $-5.00
Unbalanced remainder is:
   $5.00
-1 OBJ {$5.00} [2022/01/02]
Amount to balance against:
  $10.00
While applying automated transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 1-3:
> = %/inventory/
> Equity:$account (-amount)
> Equity:USD  (market(amount))
While extending transaction from 
"/Users/[...]/Documents/2022/Ledger/testfile.ledger", lines 5-7:
> 2022/01/02 Interest
> Assets:OBJ 1 OBJ @ $5.00 ; :inventory:
> Income:OBJs  $-5.00
Error: Transaction does not balance

This looks like a bug, but it's also possible I'm doing something broken 
that shouldn't work.

Any suggestions on how this should be done? 


-- 

--- 
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/24ce40bf-32d7-441a-8762-2d0cc8a1fe34n%40googlegroups.com.