Hi,

Am Mittwoch, den 29.12.2021, 17:41 +0100 schrieb Uwe Brauer:
> The question is can this be done automatically?
> 
> By this I mean
> can
> 2010/07/23 User2:User1-Compensation
>   expenses:User2:User1-Compensation  25.00
>   expenses:User1:User1-Compensation
> 
> Somehow be generated automatically?

For a similar use case I use automated transactions
 https://www.ledger-cli.org/3.0/doc/ledger3.html#Automated-Transactions
that split every transaction in two parts, like

```
= expr account =~ /Liabilities:[a-zA-z0-9]*$/ and aux_date >= [2020/05]
  $account    -1.0
  $account:from User1    (roundto(0.6*amount, 0))
  $account:from User2    (amount-roundto(0.6*amount, 0))
```

where the 0.6 means that User1 should cover 60% of the costs and User2
only 40%. If the two should pay the same then just use 0.5. Also, if
your currency uses fractional parts (as in your example) then the
second parameter to `roundto()` should not be 0, probably 2.

Then if all your transactions look like

```
2021-12-03=2021-12-05 Amazon
  Expenses:Presents    2000 JPY
  Liabilities:User1

2021-12-05=2021-12-07 eBay
  Expenses:Presents    3000 JPY
  Liabilities:User2
```

then you get a balance such as

```
            5000 JPY  Expenses:Presents
           -5000 JPY  Liabilities
           -2000 JPY    User1
           -1200 JPY      from User1
            -800 JPY      from User2
           -3000 JPY    User2
           -1800 JPY      from User1
           -1200 JPY      from User2
--------------------
                   0
```

and then you can look at the minimum of "User1:from User2" and
"User2:from User1" and compute the reimbursement account.

I guess this is more complicated than what you need for your use case,
but it served me well because it generalizes well to non-equal
contributions, and also I can have a User3 make some purchases that
will then be reimbursed by User1 and User2 in the same ratio as
everything else.

Hope it helps
Tobias

-- 

--- 
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/55691047f01e58c2784854ec6ccba70001fc5ff3.camel%40web.de.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to