Beancount on Android?

754 views
Skip to first unread message

Alen Šiljak

unread,
Apr 21, 2019, 2:55:43 PM4/21/19
to Beancount
One of the reasons Beancount was the first on my list for exploring, was that it was written in Python and I'm quite keen on using Python for mobile development lately.
So it really looked like a perfect candidate that should run the same on all platforms I use currently (Linux, Windows, Android). Unfortunately, that's not the case.
Even ledger, which is written in c++, can run natively on all these platforms, which is really convenient. But I managed to package a minimal Docker image anyway.

Nonetheless, just off-the-hip shot - what would be required to remove dependency on C/C++ compilation during install? Also, keeping PyPi versions up-to-date would really be helpful in that respect as Python is available in Termux and installing with pip is a piece of cake on Android.
This hopefully includes Fava, as well, in which case the whole system would be able to run on a mobile device (at least Android).
How useful would something like this be to the community, anyway? I know for me it's almost a must, in order to be able to see some reports, at least.

On the other hand, I'm also thinking about expanding MoneyManagerEx for Android to support data export to plain text so that it can be used as a data entry tool on a phone. I have a decent QIF implementation, which was used to transfer entries to GnuCash. There is some CSV code that I would need to revisit, which would be good enough to support (H)Ledger and Beancount as there seems to be a fair amount of tools available for parsing CSV records.

Martin Blais

unread,
Apr 21, 2019, 4:04:53 PM4/21/19
to Beancount
On Sun, Apr 21, 2019 at 2:55 PM Alen Šiljak <alen....@gmx.com> wrote:
One of the reasons Beancount was the first on my list for exploring, was that it was written in Python and I'm quite keen on using Python for mobile development lately.
So it really looked like a perfect candidate that should run the same on all platforms I use currently (Linux, Windows, Android). Unfortunately, that's not the case.
Even ledger, which is written in c++, can run natively on all these platforms, which is really convenient. But I managed to package a minimal Docker image anyway.

Nonetheless, just off-the-hip shot - what would be required to remove dependency on C/C++ compilation during install?

Converting the three files of C from this repo:

Two of them are auto-generated from a Flex (lexer.l) and Bison (grammar.y)  configuration.
The third is very simple.
I think it would be possible to convert all of those to a PLY parser in pure-Python, but it would run too slow to be useful (unless you have a small input file).

 
Also, keeping PyPi versions up-to-date would really be helpful in that respect as Python is available in Termux and installing with pip is a piece of cake on Android.

This tends to need just a bit of a nudge in my direction.
I can do this quickly when needed though.

 
This hopefully includes Fava, as well, in which case the whole system would be able to run on a mobile device (at least Android).
How useful would something like this be to the community, anyway? I know for me it's almost a must, in order to be able to see some reports, at least.

What I'd find useful for myself is not so much having Beancount itself on the device, but a simple app that allows me to enter transactions easily and quickly on-the-go and to make it possible to extract and convert its database to partially booked Beancount syntax like an importer. I track some (few) cash transactions manually, but when I do they tend to end up in a Google Keep note which I'll transcribe by hand much later on; generally speaking this is rare. When I travel, however, I tend to enjoy tracking every little bit of expenses for fun and comparison with other trips, and I do the same thing, Google Keep on my phone. I just transcribe those after every couple of days to my small travel laptop, copy-pasting from Keep on web (this drives my wife crazy when I'm transcribing because I'll be asking something like "do you remember when we got the ice cream at the temple two days ago, did I pay or did you pay? How much was it?" or "did we use the credit card at the Oyster place last week?" Anyhow.). It would be much nicer if it was a bit structured, i.e., those are the fields I'd use: date, amount, category (I then translate into account), cash or cc (I also translate to account), who paid. Basically a partial data entry for double-entry accounting. This could also be useful for HLedger and Ledger, no doubt.



On the other hand, I'm also thinking about expanding MoneyManagerEx for Android to support data export to plain text so that it can be used as a data entry tool on a phone. I have a decent QIF implementation, which was used to transfer entries to GnuCash. There is some CSV code that I would need to revisit, which would be good enough to support (H)Ledger and Beancount as there seems to be a fair amount of tools available for parsing CSV records.

SGTM

 

--
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/638b10a5-1e93-44d5-9fd1-6bdb4249de5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alen Šiljak

unread,
Apr 21, 2019, 4:34:32 PM4/21/19
to Beancount


On Sunday, 21 April 2019 22:04:53 UTC+2, Martin Blais wrote:

What I'd find useful for myself is not so much having Beancount itself on the device, but a simple app that allows me to enter transactions easily and quickly on-the-go and to make it possible to extract and convert its database to partially booked Beancount syntax like an importer.

Great! Well, that's exactly what I'm doing (and others who ask this sort of questions on the forums are interested in).Do check-out MMEx for Android (http://android.moneymanagerex.org/) and see if you like it.
It is extremely convenient for quickly entering transactions through a Single Account widget or a New Transaction shortcut that can be placed on the home screen. It uses Money Manager Ex database, which is based on categories (like Quicken) and supports only two levels of them.
So far this has not been a problem for me, as I had the same structure of Expense accounts in GnuCash and I could map them in the import configuration.
So, this would allow you to enter transactions right after they happen. The app uses content providers so you can use any (cloud?) storage provider as a safety file backup mechanism or for synchronization.
So that part is more-or-less taken care of. The data transfer happens from a Search screen, where transactions can be queried and filtered, then shared through the Share button in the toolbar. Currently there is only QIF export because that's what I've been using for Quicken, then GnuCash. It should not take too much effort to either add a new CSV formatter or reactivate the existing one.
I guess the CSV would fit all of the plain-text-accounting (PTA) tools and that part can be done on the desktop once the file is shared.

Since I'm not so keen on Java Android development lately, I wrote a Python library - https://gitlab.com/alensiljak/moneymanagerexlib - which reads the MMEx SQLite database directly (through SQLAlchemy) and, oh wait!, exports to CSV. I already forgot that I completed this but the process never worked due to bugs in GnuCash's CSV importer when multiple currencies are used.
Anyways, well, the whole chain can obviously be tested already, then!
This is exposed as a library, check it out, and it can then write any data you like but, as you already listed, there are typical fields available: status, date, account (from/to in case of transfer), category, payee, notes, transaction number, transaction type (+, -, txfer). This is just off the transaction screen so, if any fields are missing, they can be added.

I guess this could be enough for now, and it's already available on F-Droid.

Alen Šiljak

unread,
Apr 21, 2019, 6:21:30 PM4/21/19
to Beancount
Trying to install via pip in Termux. The installation of lxml fails.
During the process, I installed the following libraries:

- libxml2
- libxml2-dev
- clang
- libclang
- libclang-dev

but the compilation still fails with

Alen Šiljak

unread,
Apr 27, 2019, 11:12:28 AM4/27/19
to Beancount
Adding libxml2-util, python-dev, libxslt-dev

Ref: https://github.com/termux/termux-app/issues/8

Alen Šiljak

unread,
Apr 27, 2019, 11:15:26 AM4/27/19
to Beancount
Wow, so the problem was lxml the whole time, not beancount. No issues installing from PyPi after lxml was sorted.
I can now run it in Termux. Hopefully fava goes through without any issues either.

Alen Šiljak

unread,
May 5, 2019, 4:59:40 PM5/5/19
to Beancount
One more dependency is clang package. The listed ones are all installed via pkg manager, not pip.

Manuel Amador (Rudd-O)

unread,
Feb 18, 2021, 12:17:34 AM2/18/21
to bean...@googlegroups.com
I do this using Simpletask plus a bit of Lua in it.  If I input any transaction, the add task filter will look for numbers and the magic words chf, usd or eur, and add an +accounting tag to the post.  The Lua code in the Simpletask settings goes so:

function onAdd(t,f,e)
  currs = {'chf', 'usd', 'eur'}
  for currC = 1, #currs do
    if t:lower():match(currs[currC]) then
      return t.. " +accounting"
    end
  end
  return t
end

Entering transactions this way is /incredible/.  Tap on checkmark icon, write "beer 8 chf", push save.  It's done, and when I get home, it's imported!

That todo.txt file syncs with my desktop via Syncthing.  You can also use Dropbox if you want.  No biggie.  It's transport-agnostic.

Once I'm home I fire up my beancount todo importer, which is a very dumb importer I will attach to this e-mail.  The program produces beancount transactions (to be returned to the importer) then annuls the ingested tasks in the todo.txt on disk.  The updated todo.txt file gets synced back to my phone, and bingo, I no longer carry around my cash expenses!

Naturally as you'll see the cashtodo.py program attached uses the smart_importer module which gets the contra account right 99% of the time.  That's the other part — rarely do I have to change the final accounts that enter my cash beancount file.

I also manually enter the tag +accounting for when I make an expense that isn't cash (I am careful not to type usd, chf or eur into the task) and I want to remember what that expense was without a receipt.  That way, I can remember when and how much I spent in so-and-so, and conciliate my credit card using the normal process and importer I already have, safe in the knowledge that I won't be asking myself "so what the hell were these 82.99 dollars the other day?  what's this company again?"

Useful.
--
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.

For more options, visit https://groups.google.com/d/optout.
cashtodo.py
OpenPGP_signature

Jim Austria

unread,
Dec 6, 2024, 12:33:19 AM12/6/24
to Beancount
hi, can someone clearly state how to set up fava/beancount on termux? have been trying for hours
I get errors when installing, and also when trying to install dependcies and libraries
Reply all
Reply to author
Forward
0 new messages