Skip to main content

Beancount Importer for DKB CSV exports

Project description

Beancount DKB Importer

image

image

image

image

beancount-dkb provides an Importer for converting CSV exports of DKB (Deutsche Kreditbank) account summaries to the Beancount format.

Installation

$ pip install beancount-dkb

In case you prefer installing from the Github repository, please note that main is the development branch so stable is what you should be installing from.

Usage

If you're not familiar with how to import external data into Beancount, please read this guide first.

Adjust your config file to include ECImporter and CreditImporter (depending on what account you're trying to import).

A sample configuration might look like the following:

from beancount_dkb import ECImporter, CreditImporter

IBAN_NUMBER = 'DE99 9999 9999 9999 9999 99' # your real IBAN number

CARD_NUMBER = '9999 9999 9999 9999'         # your real Credit Card number

CONFIG = [
    ECImporter(
        IBAN_NUMBER,
        'Assets:DKB:EC',
        currency='EUR',
        file_encoding='utf-8',
    ),

    CreditImporter(
        CARD_NUMBER,
        'Assets:DKB:Credit',
        currency='EUR',
        file_encoding='utf-8',
    )
]

Once this is in place, you should be able to run bean-extract on the command line to extract the transactions and pipe all of them into your Beancount file.

$ bean-extract /path/to/config.py transaction.csv >> you.beancount

Transaction Codes as Meta Tags

By default, the ECImporter prepends the transaction code ("Buchungstext") to the transaction description. To achieve shorter descriptions and use meta tags to query for certain transaction codes, the importer may be configured to store the transaction code in a user provided meta tag.

The following configuration instructs the importer to use a meta tag code to store transaction codes:

...
CONFIG = [
    ECImporter(
        IBAN_NUMBER,
        'Assets:DKB:EC',
        currency='EUR',
        meta_code='code',
    ),
...

This is how an example transaction looks without the option:

2021-03-01 * "Kartenzahlung" "XY Supermarket"
    Assets:DKB:EC                        -133.72 EUR

And this is the resulting transaction using meta_code='code'

2021-03-01 * "XY Supermarket"
    code: Kartenzahlung
    Assets:DKB:EC                        -133.72 EUR

Pattern-matching Transactions

It's possible to give the importer classes hints if you'd like them to include a second posting based on specific characteristics of the original transaction.

For instance, if the payee or the description in a transaction always matches a certain value, it's possible to tell the ECImporter or CreditImporter to automatically place a second posting in the returned lits of transactions.

ECImporter

ECImporter accepts a payee_patterns argument, which should be a list of (pattern, account) tuples.

CONFIG = [
    ECImporter(
        IBAN_NUMBER,
        'Assets:DKB:EC',
        currency='EUR',
        file_encoding='utf-8',
        payee_patterns=[
            ('REWE Filialen', 'Expenses:Supermarket:REWE'),
            ('NETFLIX', 'Expenses:Online:Netflix'),
        ],
    ),

CreditImporter

CreditImporter accepts a description_patterns argument, which should be a list of (pattern, account) tuples.

CONFIG = [
    CreditImporter(
        CARD_NUMBER,
        'Assets:DKB:Credit',
        currency='EUR',
        file_encoding='utf-8',
        description_patterns=[
            ('REWE sagt Danke', 'Expenses:Supermarket:REWE'),
            ('NETFLIX', 'Expenses:Online:Netflix'),
        ],
    )

FAQ

ERROR:root:Importer beancount_dkb.ec.ECImporter.identify() raised an unexpected error: 'utf-8' codec can't decode byte 0xf6 in position 17: invalid start byte

Change the file_encoding parameter. It seems like the CSV exports are ISO-8859-1 encoded, but utf-8 seems like a useful default.

Contributing

Contributions are most welcome!

Please make sure you have Python 3.6+ and Poetry installed.

  1. Clone the repository: git clone https://github.com/siddhantgoel/beancount-dkb
  2. Install the packages required for development: poetry install
  3. That's basically it. You should now be able to run the test suite: poetry run py.test.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beancount-dkb-0.14.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

beancount_dkb-0.14.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file beancount-dkb-0.14.0.tar.gz.

File metadata

  • Download URL: beancount-dkb-0.14.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Linux/5.15.0-43-generic

File hashes

Hashes for beancount-dkb-0.14.0.tar.gz
Algorithm Hash digest
SHA256 14282042aaff26b8734b1e060f8b0b65aa523a662b27e2969899c363bbb95a5e
MD5 a34b00dcac4fe1c853e1ba361bf337bc
BLAKE2b-256 afb838f1c999bf2ce06a73791ed3189ee9a08a8995f1b0806a44fa8ef74648e5

See more details on using hashes here.

File details

Details for the file beancount_dkb-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: beancount_dkb-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Linux/5.15.0-43-generic

File hashes

Hashes for beancount_dkb-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee63e4f6650553ed8f60ae0f56b17072a474017920858676ca5e74854b56fa60
MD5 14641059f9bb7ae0d2b1581b0be8e150
BLAKE2b-256 ed31e1e849b43c6051e6c8ca24cfe92b80fae6d5d6057d3406ef88270b863980

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page