Banking API: Using bank transactions in Google Sheets

At mobfish, in 2017 we switched to doing our financial planning on a weekly basis and reconciling it weekly with the actual transactions. The advantage of this approach is that you can quickly identify recurring transactions and predict their booking to the exact week. This is especially important for startups, because you often head towards a liquidity bottleneck and can see to the week when action is needed. In this short post I show how I automated the reconciliation using spreadsheet formulas and a banking API.

Reconciling bookings week by week is annoying, and if you want a monthly view, you have to create it separately, because unfortunately months don’t always start on a Monday and end on a Sunday. In the worst case, if you roughly summarize your monthly report from the individual weeks with Excel formulas, you end up with the salary payments of 2 months in one month. 

As a computer scientist, you can’t tolerate a situation like that for long, so I wondered whether it wouldn’t be handy to automate the reconciliation with the bank account, or checking incoming payments, via an Excel/spreadsheet function.

I had the following function in mind:

=banksum(Startdatum; Enddatum; Suchwort)

This would make it possible to assign employees’ salaries to the correct week:

=banksum(“29.10.2018”; “04.10.2018”; “Gehalt”)

So much for the idea…

Now for the implementation. To implement the search quickly, I decided to keep all transactions in an SQL database. That way more complex queries are possible if needed, and I can extend my feature set quickly. On top of that, Google Apps Script comes with a ready-made JDBC implementation that makes accessing a database from within a spreadsheet child’s play:

 var connection=Jdbc.getConnection('jdbc:mysql://dbserver:3306/dbname', 'user', 'passwort');
  var statement=connection.createStatement();

But now the question: how do I get my bank data? ? My first idea was: “Just use the bank’s CSV export!” The annoying thing is that you always have to import it manually… 

After briefly reading up on HBCI, I came to the conclusion that someone must have already built all this and that you could simply use it. 

My first thought was to use figo.io. After all, our bank data was already there, since our company ERP system also uses their API. After a bit of back and forth with figo support, it became clear that the folks from Hamburg wouldn’t support my tinkering project.

So I kept googling. My next attempt was “fintecsystems”. Their support was super fast, and after a short time I had a test account and could at least connect our bank transactions via the website. Unfortunately, within the sandbox API I couldn’t access the transactions. And I didn’t want to buy a full license just for tinkering.

In the end I stuck with finapi.io. A test account was set up quickly. The API was self-explanatory, and just a few minutes later my transactions were tumbling into the database. FinAPI has a more than fair pricing model, especially for small applications.

Optimized functions

My first prototype was done and I could start using my newly developed function in the financial planning. Pretty quickly I hit my first limit… myself. My salary in the financial plan didn’t match my real salary at all. Why? The bank statements also include VISA payments, and they always contain my name. So my function also needed a way to support multiple search terms:

=banksum("29.10.2018"; "04.10.2018"; "Gehalt&Tobias Sell")

This extension was useful in other places in the plan, too. For example, to separate the costs of “Google Cloud” from “Google Apps”. 

I got stuck once more with the item “fuel”. In this case, several different providers are combined in one item, since we don’t all fill up at the same gas station and don’t use a fuel card either. So my function also needed an “OR” condition:

=banksum("29.10.2018"; "04.10.2018"; "Aral|Shell|Total&Tanken")

To show the whole thing in action, I made a short video:

Demo sheet with sample financial planning and the function in action.

If you want the code, you can find it here. More about Google Apps Script can be found here.

Title-Photo by rawpixel on Unsplash