Basic LibreOffice invoice in Finland


I have no responsibility if this guide and the linked examples are bogus and cause you any harm. The purpose of this post is solely as a personal note for myself. Follow and use it at your own risk.

Through this post we’ll see how to create an invoice with LibreOffice which would include the Finnish Reference Number (Viitenumero) or the RF Creditor Reference generated from that Finnish Reference Number and the Finnish Bank Bar Code (Pankkiviivakoodi).

The Finnish Reference Number

The Finnish Reference Number (viitenumero) identifies a specific bank transfer. In practice, it is used in invoices sent to a customer by a company or similar entity.

When we create an invoice in Finland, we want to include such number so its payment is following a standard set by the Finnish banks. For example, some banks may charge a commission if, when setting a payment, this number is not included.

The generation of this number follows a simple algorithm and I’ve compiled several implementations in different programming languages. Since we want to use it in LibreOffice Calc, the most suitable way would be through a (Basic) macro. It’s usage is as follows:


Which number to pass you say? Well, it is pretty much whatever you want to pass (check the algorithm for the restrictions) but I basically pass the incremental invoice number. In my case, I just number my invoices like YYYY### meaning the 4 digits of the current year plus 3 digits for the incremental number of that invoice along the year (not in my wildest dreams I would generate more than 999 invoices in a single year). For example 2021023 would indicated the 23rd invoice generated in 2021. The result in the cell will show 202 10236, which is the provided number plus a check digit calculated by the algorithm and returned in a proper formatting (groups of 5 numbers).

The RF Creditor Reference

The RF Creditor Reference is an international business standard for an number preceded by the “RF” letters which serves a similar purpose than the Finnish Reference Number: identifying a specific payment.

The generation of this number also follows a simple algorithm and it was first implemented within the SEPA rulebook 3.2. Since having both numbers in the same invoice would be redundant and the RF Creditor Reference is international, we could just use this number and it should be accepted by the Finnish banks and some other banks, particularly some of those accepting SEPA transfers.

If we use the Finnish Reference Number, the calculation of the RF Creditor Reference check digits is pretty simple. We can just use the following formula in a cell:

=TEXT(98-MOD(SUBSTITUTE(LASKEVIITE(number)," ","")*1000000+271500,97),"00")

Following the example above, for the generated Finnish Reference Number 202 10236, the result in the cell will show 42. Then, we only have to concatenate everything together to get the full RF Creditor Reference: RF42 2021 0236.

Bar codes

Finnish banks have jointly developed the (Finnish) Bank Bar Code (Pankkiviivakoodi) in order to accelerate payments and to prevent erroneous data from being keyed in. The Bank Bar Code is a Code 128 bar code explicitly developed to be used with reference numbers in invoicing.

Hence, we want to add support to our Calc spreadsheet for generating bar codes. Fortunately, some Jiří Gabriel created a sophisticated (basic) macro for generating a whole set of 1D and 2D bar codes. This macro is able to generate the bar codes as graphical objects or as text which will be shown as the proper bar code when the companion BarsAndSpaces.ttf font is applied to the text. In my examples, I use the latter but you may prefer the former since that would allow you not to have that font installed.

This formula will show as cell result a Code 128 bar code containing the passed number if we apply the BarsAndSpaces.ttf font to its content:


The Finnish Bank Bar Code

The Bank Bar Code is a form of presenting payment transaction data, approved by Finance
Finland (FFI). As commented above, it was jointly developed by Finnish banks and needs a reference number.

The Bank Bar Code has 2 versions currently in active use: version 4 uses the Finnish Reference Number while version 5 uses the RF Creditor Reference. Below, you can see how the 54 length structure of this bar code is divided depending on the version:

The numeric part of the payee’s bank
account number (IBAN)
Finnish Reference Number20N
(Finnish) Bank Bar Code v.4
The numeric part of the payee’s bank
account number (IBAN)
The numeric part of the RF
Creditor Reference
(Finnish) Bank Bar Code v.5

As you see, the algorithm is simple enough that can be easily implemented in a spreadsheet.

The full documentation for the Bank Bar Code is provided by Finance Finland.

Invoice examples

After all the blabbering above we get to the part that is, probably, the most interesting for you: the ODS examples.

I hope it helps you! 😀️

Appendix: QR Codes

Finance Finland also provides Guidelines for the use of QR code in credit transfer forms. Additionally, our bar codes macro also supports QR code generation. In other words, it would be possible to create an invoice with LibreOffice Calc featuring this QR code (QR-koodi).

However, I’ll leave this for another day … 😉️

Leave a Reply

Your email address will not be published. Required fields are marked *