On Mon, 9 Oct 2017, at 02:14, Richard Lawrence wrote:
> Is there a reason you need to use a virtual transaction for this? 
> Why not just use a subaccount, like
> 
> 2017-10-01 * Opening Balance 
>      Assets:CurrentAccount:Savings  $100 Assets:CurrentAccount 
>      $900 Equity:OpeningBalances 
>  
> Then, the balance of Assets:CurrentAccount reflects what you are 
> currently tracking as the "real" balance, while the balance of 
> Assets:CurrentAccount:Savings reflects what you are currently 
> tracking as the "virtual" balance.  You don't have to mess with 
> virtual transactions (or the flags for dealing with them) at all.

Thanks -- honestly I'd entirely forgotten about subaccounts while
thinking about this!

Trying this out makes me realize I really didn't understand subaccounts,
and in fact I'm pretty sure I still don't understand how best to use
them for this purpose.

One thing against using subaccounts in this way is that you can't move
money from multiple real accounts into one virtual account (says
Funds:Savings).  It's true that for purposes of reports I guess I should
still be able pull those out by name as long as I name them
consistently, because of ledger's use of regexps.  However, I guess I
can't do this:

2017-10-01 * Opening Balance
    Assets:CurrentAccount   $1000
    Equity:OpeningBalances

2017-10-02 * Savings
    Assets:CurrentAccount:Savings   $100
    Assets:CurrentAccount

Because then if I go on to do this:

2017-10-03 * Adjustment
    Assets:CurrentAccount   = $1005
    Equity:Adjustments

then this balance command tells me I have made $100 out of thin air
($1105 total):

ledger b Assets:CurrentAccount

That's because in that final txn I'm actually setting not the summed-up
total of everything in *or under* Assets:CurrentAccount, as appears in
the balance output, but the amount that lives in that *exact* location
(which you might write in a balance command as
'^Assets:CurrentAccount$').  I'm not sure there's any way to fix that
final txn to say that it's actually the *total* "descendant-or-self"
value I want to set equal to $1005?

Exactly the same problem crops up if I try splitting out, starting from
the start of the journal, the non-savings amount into an
Assets:CurrentAccount:Unallocated (only this time I end up with an extra
$1000 out of thin air -- so obviously this is the better method :-).

If I instead try creating a new Antisavings subaccount just when I
balance the savings:

2017-10-01 * Opening Balance
    Assets:CurrentAccount   $1000
    Equity:OpeningBalances

2017-10-02 * Savings
    Assets:CurrentAccount:Savings   $100
    Assets:CurrentAccount:Antisavings

2017-10-03 * Adjustment
    Assets:CurrentAccount   = $1005
    Equity:Adjustments

Then balance commands like these print what I expected:

ledger b Assets:CurrentAccount

ledger b Assets:CurrentAccount and not Assets:CurrentAccount:Savings

But this seems like a horrible abuse: I'm still not declaring what I
want to declare, which is that I have $1005 dollars total in that real
current account.  Plus I then have a mysterious -$100 in AntiSavings and
a feeling that I don't know what I'm doing and probably shouldn't be
allowed to use ledger.

Can anybody unconfuse me?

-- 

--- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to