Hi Fred
I use a solution similar to yours for sharing expenses with my partner in
ledger-cli. For beancount I have made a (very simple) plugin that does pretty
much the same. I have attached the plugin which you might find useful. It is
used like this:
plugin "bc_plugins.split_expenses" "Assets:Receivable"
2019/05/22 * Bakery
Expenses:Food 10.00 EUR
split: "Susa"
Assets:Cash
The plugin transforms the transaction into the following:
2019/05/22 * Bakery
Expenses:Food 5.00 EUR
Assets:Receivable:Susa 5.00 EUR
Assets:Cash
Regards,
Michael
On Wed, May 22, 2019, at 17:44, [email protected] wrote:
>
> Hi,
>
> I'm new to beancount and currently assessing whether I can switch from
> ledger-cli in order to make use of the web interface fava.
>
> I'm interested in ways on how to split expenses in beancount: I share a
> household with my partner and for many expenses I'd like to register only
> half the debit as a personal expense whereas the other half should be
> registered as an asset (something that my partner owes me).
>
> I currently use ledger-cli and make heavy of the following automatic
> transaction to split transactions with my partner:
> = tag("With") =~ "Susa"
> $account -0.5
> Assets:Receivable:Susa 0.5
>
> Shared expenses are then recorded like this:
> 2019/05/22 * Bakery
> Expenses:Food 10.00 EUR ; With: Susa
> Assets:Cash
>
> This results in a credit of 5.00 EUR to Expenses:Food and
> Assets:Receivable:Susa each. I find this quite comfortable and want to know
> if there is something similar in beancount. (I've already learned that there
> are no automatic transactions in beancount)
>
> I skimmed the documentation of beancount for sharing expenses and what I
> found <http://furius.ca/beancount/doc/shared> seems to involve "special"
> accounts (e.g. Expenses:Food:Fred & Expenses:Food:Susa) in order to split
> transactions using a plugin ("beancount.plugins.split_expenses") -- is this
> correct?
>
> Does the mentioned plugin work in way like the automatic transaction in
> ledger-cli does, i.e. does running beancount automatically split the written
> amount in the journal file or does the workflow involve running a command
> that results in hard-coded input text that replaces the original input data?
>
> More generally: How do beancount users normally record regular shared
> expenses?
>
> Thanks and regards,
> Fred
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/e413816b-57be-439b-ae24-fd33efbbaf8a%40googlegroups.com
>
> <https://groups.google.com/d/msgid/beancount/e413816b-57be-439b-ae24-fd33efbbaf8a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/65aeda05-d024-4143-8e91-3b0c4b1cd362%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.
"""
Share expenses by splitting postings with a metadata tag.
"""
__copyright__ = "Copyright (C) 2019 Michael Budde"
__license__ = "GNU GPLv2"
import collections
from beancount.core import amount
from beancount.core import account
from beancount.core import convert
from beancount.core import data
from beancount.core import getters
from beancount.core import interpolate
__plugins__ = ('split_expenses',)
def split_expenses(entries, unused_options_map, debitor_account):
"""Split posting.
Args:
debitor_account: An account prefix the debitor name
unused_options_map: A parser options dict.
Returns:
A list of entries and a list of errors.
"""
new_entries = []
for entry in entries:
if isinstance(entry, data.Transaction):
new_postings = []
for posting in entry.postings:
if posting.meta and 'split' in posting.meta:
split_units = amount.Amount(posting.units.number / 2,
posting.units.currency)
remaining = amount.Amount(posting.units.number - split_units.number,
posting.units.currency)
meta = posting.meta.copy()
meta[interpolate.AUTOMATIC_META] = True
del meta['split']
new_postings.append(posting._replace(units=remaining))
new_postings.append(
posting._replace(
meta=meta,
account=account.join(debitor_account, posting.meta['split']),
units=split_units,
cost=posting.cost))
else:
new_postings.append(posting)
entry = entry._replace(postings=new_postings)
new_entries.append(entry)
return new_entries, []