Beancount Importer for DKB CSV exports
Project description
Beancount DKB Importer
beancount-dkb provides importers 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.
Beancount 3.x
Beancount 3.x has replaced the config.py file based workflow in favor of having a
script based workflow, as per the changes documented here. The beangulp examples
suggest using a Python script based on beangulp.Ingest. Here's an example of how that
might work:
Add an import.py script in your project root with the following contents:
from beancount_dkb import ECImporter, CreditImporter
from beangulp import Ingest
importers = (
ECImporter(
"DE99 9999 9999 9999 9999 99",
'Assets:DKB:EC',
currency='EUR',
),
CreditImporter(
"9999 9999 9999 9999",
'Assets:DKB:Credit',
currency='EUR',
),
)
if __name__ == "__main__":
ingest = Ingest(importers)
ingest()
... and run it directly using python import.py extract.
Beancount 2.x
Adjust your config file to include ECImporter and CreditImporter
(depending on what account you're trying to import).
Add the following to your config.py.
from beancount_dkb import ECImporter, CreditImporter
CONFIG = [
ECImporter(
"DE99 9999 9999 9999 9999 99",
"Assets:DKB:EC",
currency='EUR',
),
CreditImporter(
"9999 9999 9999 9999",
"Assets:DKB:Credit",
currency='EUR',
),
]
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.
Add the meta_code parameter when instantiating an ECImporter.
Beancount 3.x
from beancount_dkb import ECImporter
from beangulp import Ingest
importers = (
ECImporter(
"DE99 9999 9999 9999 9999 99",
"Assets:DKB:EC",
meta_code="code',
),
)
if __name__ == "__main__":
ingest = Ingest(importers)
ingest()
Beancount 2.x
...
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 payee_patterns and description_patterns arguments, which should
be a list of (pattern, account) tuples. The pattern is compiled using re.compile,
so feel free to use regular expressions there.
Beancount 3.x
from beancount_dkb import ECImporter
from beangulp import Ingest
importers = (
ECImporter(
"DE99 9999 9999 9999 9999 99",
"Assets:DKB:EC",
payee_patterns=[
("REWE", "Expenses:Supermarket:REWE"),
(r"N*TFL*X", "Expenses:Online:Netflix"),
],
),
)
if __name__ == "__main__":
ingest = Ingest(importers)
ingest()
Beancount 2.x
CONFIG = [
ECImporter(
IBAN_NUMBER,
"Assets:DKB:EC",
currency='EUR',
payee_patterns=[
("REWE", "Expenses:Supermarket:REWE"),
("NETFLIX", "Expenses:Online:Netflix"),
],
),
CreditImporter
CreditImporter accepts a description_patterns argument, which should be a list of
(pattern, account) tuples.
Beancount 3.x
from beancount_dkb import CreditImporter
from beangulp import Ingest
importers = (
ECImporter(
"9999 9999 9999 9999",
"Assets:DKB:EC",
currency="EUR",
payee_patterns=[
("REWE", "Expenses:Supermarket:REWE"),
("NETFLIX", "Expenses:Online:Netflix"),
],
),
)
if __name__ == "__main__":
ingest = Ingest(importers)
ingest()
Beancount 2.x
CONFIG = [
CreditImporter(
CARD_NUMBER,
'Assets:DKB:Credit',
currency='EUR',
description_patterns=[
('REWE', 'Expenses:Supermarket:REWE'),
('NETFLIX', 'Expenses:Online:Netflix'),
],
)
Contributing
Contributions are most welcome!
Please make sure you have Python 3.10+ and Poetry installed.
- Clone the repository:
git clone https://github.com/siddhantgoel/beancount-dkb - Install the packages required for development:
poetry install - That's basically it. You should now be able to run the test suite:
poetry run task test.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file beancount_dkb-1.8.0.tar.gz.
File metadata
- Download URL: beancount_dkb-1.8.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2716d79b3b0bff5b7cc75c80c8792da7c988e3b3af8d5e3add24bc56b53875f5
|
|
| MD5 |
a905b1ddc90093a4289648cd3e7ae83f
|
|
| BLAKE2b-256 |
6578db689929e9f0bce9e21b38ba5ef61570ffeb53c328117d865accd273b6aa
|
Provenance
The following attestation bundles were made for beancount_dkb-1.8.0.tar.gz:
Publisher:
release.yml on siddhantgoel/beancount-dkb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beancount_dkb-1.8.0.tar.gz -
Subject digest:
2716d79b3b0bff5b7cc75c80c8792da7c988e3b3af8d5e3add24bc56b53875f5 - Sigstore transparency entry: 719592875
- Sigstore integration time:
-
Permalink:
siddhantgoel/beancount-dkb@a8c3de925b469d2855560be280127d48b972249a -
Branch / Tag:
refs/tags/v1.8.0 - Owner: https://github.com/siddhantgoel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8c3de925b469d2855560be280127d48b972249a -
Trigger Event:
push
-
Statement type:
File details
Details for the file beancount_dkb-1.8.0-py3-none-any.whl.
File metadata
- Download URL: beancount_dkb-1.8.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfaa4acaac97a33444329d8fedd88783becdb53d3621ef60bd7009a27c50f0bf
|
|
| MD5 |
89d1464f473f1dea7ee92c112d4de515
|
|
| BLAKE2b-256 |
e8393542453e4d5e609f71dd45ba84b49fa559a8fbd4711ce8e184f12c609bed
|
Provenance
The following attestation bundles were made for beancount_dkb-1.8.0-py3-none-any.whl:
Publisher:
release.yml on siddhantgoel/beancount-dkb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beancount_dkb-1.8.0-py3-none-any.whl -
Subject digest:
bfaa4acaac97a33444329d8fedd88783becdb53d3621ef60bd7009a27c50f0bf - Sigstore transparency entry: 719592877
- Sigstore integration time:
-
Permalink:
siddhantgoel/beancount-dkb@a8c3de925b469d2855560be280127d48b972249a -
Branch / Tag:
refs/tags/v1.8.0 - Owner: https://github.com/siddhantgoel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a8c3de925b469d2855560be280127d48b972249a -
Trigger Event:
push
-
Statement type: