Hi,

> Hi,
> a couple of things, I am not sure I can bring it into a well structured
> message ;-)

You most certainly do! 😃, I appreciate your answer
> First,


> Well, it does *something*, it prints a lot of error messages about
> unbalanced transactions. I don't know why, but it seems you need a
> currency here. If I just add "JPY" after every number in your example,
> `ledger bal` shows

> ```
>          -170.00 JPY  Liabilities
>          -110.00 JPY    User1
>           -55.00 JPY      from User1
>           -55.00 JPY      from User2
>           -60.00 JPY    User2
>           -30.00 JPY      from User1
>           -30.00 JPY      from User2
>           170.00 JPY  expenses
>            40.00 JPY    ChristmasTree
>            20.00 JPY    Flowers
>            80.00 JPY    Jacket
>            30.00 JPY    Pajama
> --------------------
>                    0
> ```

Aha, thanks out of ignorance what currency is JPY supposed to be?


> Consider

> ```
> = expr account =~ /Liabilities:User1$/
>    $account    -1.0
>    Income:User1    1.0
>    Liabilities:User1-from-User2    (-(amount-roundto(0.5*amount, 0)))
>    Income:User2    (amount-roundto(0.5*amount, 0))

> = expr account =~ /Liabilities:User2$/
>    $account    -1.0
>    Income:User2    (amount-roundto(0.5*amount, 0))
>    Liabilities:User1-from-User2    (roundto(0.5*amount, 0))
> ```

> then your example transactions leave you with a balance (before
> clearing) of

> ```
>          -195.00 JPY  Income
>          -110.00 JPY    User1
>           -85.00 JPY    User2
>            25.00 JPY  Liabilities:User1-from-User2
>           170.00 JPY  expenses
>            40.00 JPY    ChristmasTree
>            20.00 JPY    Flowers
>            80.00 JPY    Jacket
>            30.00 JPY    Pajama
> --------------------
>                    0
> ```

Great, I think this is already enough, the payback time is nice, but I
think this solution is already good and clear enough. 
Out of personal taste I prefer, though:

#+begin_src ledger   
= expr account =~ /Liabilities:User1$/
   $account    -1.0
   Income:User1    1.0
   Liabilities:User1-from-User2    (-(amount-roundto(0.5*amount, 0)))
   Income:User2    (amount-roundto(0.5*amount, 0))
= expr account =~ /Liabilities:User2$/
   $account    -1.0
   Income:User2    (amount-roundto(0.5*amount, 0))
   Liabilities:User1-from-User2    (roundto(0.5*amount, 0))
2021-12-05=2021-12-07 User1
  expenses:User1:Jacket  80 EUR
  Liabilities:User1
2021-12-05=2021-12-07 User1
  expenses:User1:Pajama  30 EUR
  Liabilities:User1
2021-12-05=2021-12-07 User2
  expenses:User2:Flowers  20 EUR
  Liabilities:User2
2021-12-05=2021-12-07 User2
  expenses:User2:ChristmasTree  40.00 EUR
  Liabilities:User2
#+end_src

#+RESULTS:
#+begin_example
         -195.00 EUR  Income
         -110.00 EUR    User1
          -85.00 EUR    User2
           25.00 EUR  Liabilities:User1-from-User2
          170.00 EUR  expenses
          110.00 EUR    User1
           80.00 EUR      Jacket
           30.00 EUR      Pajama
           60.00 EUR    User2
           40.00 EUR      ChristmasTree
           20.00 EUR      Flowers
--------------------
                   0
#+end_example

The advantage is that I can control who spent money on what

In any case this is very nice thanks

Uwe  

-- 

--- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/87bl0vfiea.fsf%40mat.ucm.es.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to