Hi there,

This might be an ultra-classic use-case of ledger here I am facing.

Let's plot the scene:


- They have their own bank account (Alice and Bob) and a Join account

- Alice and Bob rent a flat ($1500/mo), which for some reasons is paid
  by Bob from his own account (not for the Join one).
  
- Every month Alice wires half the rent ($750) to Bob's checking account
- Every month wire the rent to the owner


For clean readability I always use the following scheme:
  (Assets|Income|Expenses|Liabilities|Equity):(Alice|Bob|Join):Account


I assume the following opening balances:

  2016/01/01 * Opening balance
      Assets:Bob:Bank:Checking            $12345
      Equity:Bob:Bank:Checking      
  
  2016/01/01 * Opening balance
      Assets:Join:Bank:Checking             $123
      Equity:Join:Bank:Checking        


This can be written as follow:


  2016/01/01 Alice
      Assets:Bob:Bank:Checking              $750
      Income:Bob:Alice:Rent
  
  2016/01/01 Owner
      Assets:Bob:Bank:Checking  
      Expenses:Bob:Rent                    $1500

The balance is then:

  $ ./test.ledger bal
                $11718  Assets
                $11595    Bob:Bank:Checking
                  $123    Join:Bank:Checking
               $-12468  Equity
               $-12345    Bob:Bank:Checking
                 $-123    Join:Bank:Checking
                 $1500  Expenses:Bob:Rent
                 $-750  Income:Bob:Alice:Rent
  --------------------
                     0

This is good and works fine but hides a few things:

a) Who pays the rent
b) If Alice made a mistake in the wire there is no way to check it
c) An extra income is shown for Bob which should disappear after bob
   paid the rent

I thus add a few automatic rules such as:

  =/^Expenses:Bob:Rent$/
      $account  -1
      Expenses:Join:Alice:Rent               0.5
      Expenses:Join:Bob:Rent                 0.5
      ;
      Income:Bob:Alice:Rent                  0.5
      Income:Join:Alice:Rent                -0.5


The goal here is to split Bob's rent expense into 2 Expenses for the
Join accounting and transfers the Bob's income to the Join account.

Now the result is better:

  $ ./test.ledger bal
                $11718  Assets
                $11595    Bob:Bank:Checking
                  $123    Join:Bank:Checking
               $-12468  Equity
               $-12345    Bob:Bank:Checking
                 $-123    Join:Bank:Checking
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
                 $-750  Income:Join:Alice:Rent
  --------------------
                     0

We can see who paid what (From Expenses:Join):

  $ ./test.ledger bal '/^(expenses):join/'
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
  --------------------
                 $1500

and Bob does not have the extra income:

  $ ./test.ledger bal '/^(expenses|income):bob/'  -E
                     0  Expenses:Bob:Rent
                     0  Income:Bob:Alice:Rent
  --------------------
                     0


But the Join seems to be false then:

  $ ./test.ledger bal '/^(expenses|income):join/'  -E
                 $1500  Expenses:Join
                  $750    Alice:Rent
                  $750    Bob:Rent
                 $-750  Income:Join:Alice:Rent
  --------------------
                  $750

If I understand correctly this means that the Join has more expenses
than income which is logical since there is no Income:Join:Bob:Rent.

Is it correct to add this line to the automatic rule?
    (Income:Join:John:Rent)              -0.5
If I do so, The balance is not 0 unless I query with "-R" switch.

Thus is there a way to display wanted information without using a
virtual transaction? Or from where should I take the amount to balance
"Income:Join:John:Rent"?


extra question: Is there a way to use regexp backrefs to write something
like:

=/^Expenses:Bob:(Rent)$/
    $account  -1
    Expenses:Join:Alice:$1               0.5
    Expenses:Join:Bob:$1                 0.5
    Income:Bob:Alice:$1                  0.5
    Income:Join:Alice:$1                -0.5
    (Income:Join:John:$1)               -0.5


Thanks in advance.

Seb.

-- 

--- 
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