Importing transactions in foreign currency

81 views
Skip to first unread message

Daniele Nicolodi

unread,
Sep 13, 2020, 3:49:44 AM9/13/20
to Beancount
Hello,

I deal very often with transactions in foreign currency (currency
different from the account currency) and I am looking for improving my
workflow to handle them.

My importers, usually, import transactions writing only one posting
recording the expense, like this:

2020-08-26 ! "RESTAURANT GAMBIT BRAUNSCHWEIG"
Liabilities:Nexi -16.30 EUR

and then I complete transaction writing the other postings, either
manually or through a machine learning classifier.

For foreign currency transactions, I like to record the fact that the
expense was in a currency different from the account currency and that
part of the expense was for transaction handling fees. This results in
the importers writing something like:

2020-08-25 ! "AVIS RENT-A-CAR 1 BOULDER"
Liabilities:Nexi -224.18 EUR
Expenses:Unknown 258.94 USD @ 0.8487523 EUR
Expenses:Fees:Nexi 4.40 EUR

using the Expenses:Unknown account as a placeholder. However, this makes
posting the expense to the right account a bit harder, both manually and
programmatically: the posting needs to be modified instead than simply
added and it gets even more complicated if I want to split the expense
over multiple Expenses accounts.

Does anyone have a better way of dealing with this?

Cheers,
Dan

Martin Blais

unread,
Sep 13, 2020, 8:13:59 AM9/13/20
to Beancount
I don't fully understand.
Can you write down how you would modify this transaction manually, both to just one account, and also if you were to split to multiple expenses accounts?
Do you want to record the expense in foreign (usd) currency to local (eur)?

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/beancount/35a34d40-1f19-6434-b23b-b6c4df973fb4%40grinta.net.

Daniele Nicolodi

unread,
Sep 13, 2020, 1:52:47 PM9/13/20
to bean...@googlegroups.com
On 13/09/2020 14:13, Martin Blais wrote:
> I don't fully understand.
> Can you write down how you would modify this transaction manually, both
> to just one account, and also if you were to split to multiple expenses
> accounts?
> Do you want to record the expense in foreign (usd) currency to local (eur)?

In the simple case, the importer emits

2020-08-26 ! "RESTAURANT GAMBIT BRAUNSCHWEIG"
Liabilities:Nexi -16.30 EUR

and I complete it as

2020-08-26 ! "RESTAURANT GAMBIT BRAUNSCHWEIG"
Liabilities:Nexi -16.30 EUR
Expenses:Restaurant

In the case of foreign currency, the importer emits

2020-08-25 ! "AVIS RENT-A-CAR 1 BOULDER"
Liabilities:Nexi -224.18 EUR
Expenses:Unknown 258.94 USD @ 0.8487523 EUR
Expenses:Fees:Nexi 4.40 EUR

needs to be rewritten as

2020-08-25 ! "AVIS RENT-A-CAR 1 BOULDER"
Liabilities:Nexi -224.18 EUR
Expenses:Transportation:Rental 258.94 USD @ 0.8487523 EUR
Expenses:Fees:Nexi 4.40 EUR

which is many more key strokes in my editor (or some more complex code
in the automatic in the case of automatic categorization).

In a more complex example involving multiple expenses accounts, the
importer generates:

2020-08-25 ! "AMAZON.COM"
Liabilities:Nexi -224.18 EUR
Expenses:Unknown 258.94 USD @ 0.8487523 EUR
Expenses:Fees:Nexi 4.40 EUR

which must be rewritten as

2020-08-25 ! "AMAZON.COM"
Liabilities:Nexi -224.18 EUR
Expenses:Electronics 158.94 USD @ 0.8487523 EUR
Expenses:Toys 100.00 USD @ 0.8487523 EUR
Expenses:Fees:Nexi 4.40 EUR

involving even more keystrokes.

The nuisance is to have to delete "Unknown" and replace it with
something else (and to have to copy the price in the latest example).

It is a small nuisance, but recently I had to deal with enough of these
transactions that looking for a smoother solution became interesting.

Cheers,
Dan
> <mailto:beancount%2Bunsu...@googlegroups.com>.
> --
> 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
> <mailto:beancount+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/CAK21%2BhNg9StFJ3cdn86ZBU_W37eNR36ges0sw566utC0gWp%2BtQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/beancount/CAK21%2BhNg9StFJ3cdn86ZBU_W37eNR36ges0sw566utC0gWp%2BtQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

redst...@gmail.com

unread,
Sep 15, 2020, 1:53:27 PM9/15/20
to Beancount
There are a few approaches I can think of:

A) The simplest would be to really get comfortable with your editor. vim/emacs and other editors have macros and autocomplete that should make this a breeze, and really, no different in terms of keystrokes and complexity from editing transactions without conversions

B) Hide the conversion by booking it into a holding account:
2020-01-01 * "Furniture"
Liabilities:CreditCard -30 EUR
Liabilities:Hold -35 USD @ 0.75 EUR
Liabilities:Hold 30 EUR
Expenses:Table 25 USD
Expenses:Chair 15 USD

C) (fully automatic) Rewrite your importer so it emits what you want, even when filtered through smart_importer. Might involve modifying smart_importer or whatever machine learning importer you use

Does that help?

Daniele Nicolodi

unread,
Sep 16, 2020, 7:36:52 AM9/16/20
to bean...@googlegroups.com
On 15/09/2020 19:53, redst...@gmail.com wrote:
> There are a few approaches I can think of:
>
> A) The simplest would be to really get comfortable with your editor.
> vim/emacs and other editors have macros and autocomplete that should
> make this a breeze, and really, no different in terms of keystrokes and
> complexity from editing transactions without conversions

I assure you that I am more than comfortable with my editor. Still,
there are more keystrokes involved in editing an entry than in simply
appending a posting to a transaction.

> B) Hide the conversion by booking it into a holding account:
> 2020-01-01 * "Furniture"
> Liabilities:CreditCard -30 EUR
> Liabilities:Hold -35 USD @ 0.75 EUR
> Liabilities:Hold 30 EUR
> Expenses:Table 25 USD
> Expenses:Chair 15 USD

Your example does not balance, but even after fixing the math, I am not
sure it would owrk as intended: a transaction like

2020-09-16 * "Test"
Liabilities:Hold -20 USD @ 0.75 EUR
Liabilities:Hold 15 EUR

balances, but is not zero sum.

> C) (fully automatic) Rewrite your importer so it emits what you want,
> even when filtered through smart_importer. Might involve modifying
> smart_importer or whatever machine learning importer you use

This kind of transactions are rare enough for them to do not be reliably
identified, but sometimes common enough to try to optimize the workflow
to handle them.

> Does that help?

Not really.

Cheers,
Daniele

redst...@gmail.com

unread,
Sep 16, 2020, 12:27:27 PM9/16/20
to Beancount
 

> B) Hide the conversion by booking it into a holding account:
> 2020-01-01 * "Furniture"
> Liabilities:CreditCard -30 EUR
> Liabilities:Hold -35 USD @ 0.75 EUR
> Liabilities:Hold 30 EUR
> Expenses:Table 25 USD
> Expenses:Chair 15 USD

Your example does not balance, but even after fixing the math, I am not
sure it would owrk as intended: a transaction like

2020-09-16 * "Test"
Liabilities:Hold -20 USD @ 0.75 EUR
Liabilities:Hold 15 EUR

balances, but is not zero sum.

What do you mean by "not zero sum"? How does this affect you?

Daniele Nicolodi

unread,
Sep 16, 2020, 2:15:28 PM9/16/20
to bean...@googlegroups.com
This transactions balances to:

Assets
Equity
Expenses
Income
Liabilities:Hold 15.00 EUR
Liabilities:Hold -20.00 USD

because a cost and not a price is (correctly) used to convert from USD
to EUR. This makes it very difficult to define an invariant on the
Liabilities:Hold account and thus check that no mistakes have been made
in the booking.

Cheers,
Dan

Martin Blais

unread,
Sep 16, 2020, 9:33:37 PM9/16/20
to Beancount
Note that when the  currency trading accounts method is there by default, the balance will actually always be zero:

It'll be:

Assets
Equity:Currency:USD   20.00 ESD
Equity:Currency:EUR  -15.00 EUR

Expenses
Income
Liabilities:Hold    15.00 EUR
Liabilities:Hold   -20.00 USD


 
Cheers,

Dan

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/beancount/f2cbf080-4e73-347b-d2ac-0e7444825cda%40grinta.net.
Reply all
Reply to author
Forward
0 new messages