How can i distribute amounts between several accounts based on set % or ratio?

91 views
Skip to first unread message

mpl...@gmail.com

unread,
Nov 29, 2018, 7:27:11 PM11/29/18
to Beancount
Guys hi,

Let say i have transactions going into account Expenses:Rent, and i would like 60% of total go to Expenses:Rent:Personal and 40% to Expenses:Rent:Business,
what's the best way to do it?

Justus Pendleton

unread,
Nov 30, 2018, 12:38:57 AM11/30/18
to Beancount
On Friday, November 30, 2018 at 7:27:11 AM UTC+7, mpl...@gmail.com wrote:
Let say i have transactions going into account Expenses:Rent, and i would like 60% of total go to Expenses:Rent:Personal and 40% to Expenses:Rent:Business,
what's the best way to do it?

I think the best way is to just be explicit and write: $600 to one and $400 to the other. 

If you really want to though, beancount supports simple math expressions so you can write:

Expenses:Rent:Personal (1,000 * 0.6) USD
Expenses:Rent:Business (1,000 * 0.4) USD


Zhuoyun Wei

unread,
Dec 1, 2018, 11:23:32 AM12/1/18
to bean...@googlegroups.com
2018-11-29 21:38:57 Justus Pendleton <just...@gmail.com>:
TIL Beancount supports basic math expressions!

I have quite a lot of transactions that need to be split by ratio
(shared expenses with roommates). Each time I have to calculate the
shares myself and fill in the result. This is lifesaver!
>
>
> --
> You received this message because you are subscribed to the Google Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> beancount+...@googlegroups.com.
> To post to this group, send email to bean...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/
> 6b3aedf9-1da8-4983-94f1-4cb3b502f7f8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
Zhuoyun Wei
signature.asc

Martin Blais

unread,
Dec 1, 2018, 8:43:54 PM12/1/18
to bean...@googlegroups.com
On Sat, Dec 1, 2018 at 11:23 AM Zhuoyun Wei <wzy...@wzyboy.org> wrote:
2018-11-29 21:38:57 Justus Pendleton <just...@gmail.com>:
> On Friday, November 30, 2018 at 7:27:11 AM UTC+7, mpl...@gmail.com wrote:
>
>     Let say i have transactions going into account Expenses:Rent, and i would like 60% of total go to
>     Expenses:Rent:Personal and 40% to Expenses:Rent:Business,
>     what's the best way to do it?
>
>
> I think the best way is to just be explicit and write: $600 to one and $400 to the other. 
>
> If you really want to though, beancount supports simple math expressions so you can write:
>
> Expenses:Rent:Personal (1,000 * 0.6) USD
> Expenses:Rent:Business (1,000 * 0.4) USD
>
TIL Beancount supports basic math expressions!

I have quite a lot of transactions that need to be split by ratio
(shared expenses with roommates). Each time I have to calculate the
shares myself and fill in the result. This is lifesaver!

If you have a really specific need you could also write a plugin.
I do that for sharing expenses, e.g. I trigger filling off of a tag.
IIRC Ledger supports % as amounts, but I've never looked at how it actually works.
One way it could make sense would be to sum up the postings with non-% amounts, and fill in - like when you omit the amount - with the % of the remainder. We'd have to also check that the amounts sum up to 100% (or rely on the balance to fail).
Anyhow, I don't think it's a super common usage, and using ratios as you suggested works well.


 
>
>
> --
> You received this message because you are subscribed to the Google Groups "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> beancount+...@googlegroups.com.
> To post to this group, send email to bean...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/
> 6b3aedf9-1da8-4983-94f1-4cb3b502f7f8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
Zhuoyun Wei

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.

Zhuoyun Wei

unread,
Dec 1, 2018, 9:50:51 PM12/1/18
to bean...@googlegroups.com
2018-12-01 20:43:39 Martin Blais <bl...@furius.ca>:
> On Sat, Dec 1, 2018 at 11:23 AM Zhuoyun Wei <wzy...@wzyboy.org> wrote:
>
> 2018-11-29 21:38:57 Justus Pendleton <just...@gmail.com>:
> > On Friday, November 30, 2018 at 7:27:11 AM UTC+7, mpl...@gmail.com wrote:
> >
> >     Let say i have transactions going into account Expenses:Rent, and i would like 60% of total go to
> >     Expenses:Rent:Personal and 40% to Expenses:Rent:Business,
> >     what's the best way to do it?
> >
> >
> > I think the best way is to just be explicit and write: $600 to one and $400 to the other. 
> >
> > If you really want to though, beancount supports simple math expressions so you can write:
> >
> > Expenses:Rent:Personal (1,000 * 0.6) USD
> > Expenses:Rent:Business (1,000 * 0.4) USD
> >
> TIL Beancount supports basic math expressions!
>
> I have quite a lot of transactions that need to be split by ratio
> (shared expenses with roommates). Each time I have to calculate the
> shares myself and fill in the result. This is lifesaver!
>
>
> If you have a really specific need you could also write a plugin.
> I do that for sharing expenses, e.g. I trigger filling off of a tag.
> IIRC Ledger supports % as amounts, but I've never looked at how it actually works.
> One way it could make sense would be to sum up the postings with non-% amounts, and fill in - like when you omit the
> amount - with the % of the remainder. We'd have to also check that the amounts sum up to 100% (or rely on the balance
> to fail).
> Anyhow, I don't think it's a super common usage, and using ratios as you suggested works well.
>

I had always thinking about writing my own plugins. But I prefer to
keep my repo in a self-contained way. That is to say, I do not want to
modify PYTHONPATH each time I run bean-* commands / fava, nor do I want
to put my plugin outside the repo. So I am counting on this issue to be
resolved: https://bitbucket.org/blais/beancount/issues/214/add-top-level-directory-to-syspath
(I may try to be helpful if possible).

Currently the new discovery of math expressions in Amount helps a lot. I
can now just append "/ 2" to those expenses that shared with my
roommate, instead of caculating the shares myself.
>
>  
>

--
Zhuoyun Wei
signature.asc

Martin Blais

unread,
Dec 18, 2018, 11:12:54 PM12/18/18
to Beancount
You got it.

Insert 
  option "insert_pythonpath" "TRUE"
in any file you want to have the parent directory inserted for.


Currently the new discovery of math expressions in Amount helps a lot. I
can now just append "/ 2" to those expenses that shared with my
roommate, instead of caculating the shares myself.

The expression arithmetic is still pretty basic, but I use it a lot too.
I think the new version of that shell - the only that should be rewritten as a separate project - should have much more.


 
>
>  
>

--
Zhuoyun Wei

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages