-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New plugin: Fidor Bank AG #1
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
ofxstatement-1822direkt | ||
ofxstatement-fidorbank UPDATE THIS README | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`ofxstatement`_ plugin to support 1822direkt.com bank statements | ||
`ofxstatement`_ plugin to support banking.fidor.de CSV bank statements | ||
|
||
`ofxstatement`_ is a tool | ||
to convert proprietary bank statement to OFX format, suitable for | ||
importing into account programms like GnuCash or YNAB classic. | ||
to convert proprietary bank statements to OFX format, suitable for | ||
importing into account programs like GnuCash or YNAB. | ||
|
||
Plugins for `ofxstatement`_ parses a particular | ||
proprietary bank statement format and produces common data structure, | ||
Plugins for `ofxstatement`_ parse a particular | ||
proprietary bank statement format and produce common data structure, | ||
that is then formatted into an OFX file. | ||
|
||
This project provides an `ofxstatement`_ plugin for the German bank | ||
1822direkt.com | ||
|
||
1822direkt used to provide OFX downloads but have removed this | ||
useful format and now only have a propriatay CSV (German version). | ||
Shame on them. | ||
Fidor Bank. | ||
|
||
Using `ofxstatement`_ and this plugin, I successfully converted | ||
CSV bank statements to OFX and import this into my accounting software. | ||
I'm using YNAB classic for now. But GnuCash should also work fine. | ||
CSV bank statements to OFX and imported this into YNAB. Any software | ||
supporting the OFX format should work fine. | ||
|
||
|
||
Requirements | ||
============ | ||
|
||
You need python 3.x to run this as ofxstament seems to requires python3 | ||
You need python 3.x to run this as ofxstament requires python3 | ||
|
||
|
||
Installation | ||
|
@@ -40,38 +36,40 @@ example: | |
|
||
pip3 install --user ofxstatement | ||
git clone https://github.com/MirkoDziadzka/ofxstatement-germany | ||
cd ofxstatement-germany/germany_1822direkt | ||
cd ofxstatement-germany/germany_fidorbank | ||
pip3 install --user . | ||
|
||
Check the Python documentation on instructions for you operating system and | ||
setup. Remember you must use Python 3. | ||
Check the Python documentation on instructions for your operating system and | ||
setup. Remember, you must use Python 3. | ||
|
||
|
||
Setup | ||
===== | ||
|
||
Check if plugin is installed: | ||
Check if the plugin is installed: | ||
|
||
.. code:: bash | ||
|
||
ofxstatement list-plugins | ||
|
||
Expected output:: | ||
|
||
germany_1822direkt | ||
germany_fidorbank | ||
|
||
Edit config. The *account* is the ID used by your accounting program to | ||
associate the transactions with a certain account. Probably you want to use | ||
your bank account number (Kontonummer) i.e. the last 10 digits of your IBAN. | ||
(Note: YNAB does not seem to care about this field, since you import directly | ||
to the account screen anyway.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least in classic YNAB, you can import a file by starting YNAB with this file as an argument. This is what my import process is doing. It then uses the account data to find out into which of the YNAB accounts it should import this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm using this with the web version of YNAB, so less relevant. It might still do this from the All Accounts screen, but I haven't tried. |
||
|
||
.. code:: bash | ||
|
||
ofxstatement edit-config | ||
|
||
A text editor will open. Configure something like this:: | ||
|
||
[1822direkt] | ||
plugin = germany_1822direkt | ||
[fidorbank] | ||
plugin = germany_fidorbank | ||
account = 0123456789 | ||
|
||
Some other config options you may set are: | ||
|
@@ -85,8 +83,7 @@ Usage | |
===== | ||
|
||
.. code:: bash | ||
|
||
ofxstatement convert -t 1822direkt umsaetze-0123456789-03.02.2018_15_05.csv test.ofx | ||
ofxstatement convert -t fidorbank umsaetze-0123456789-03.02.2018_15_05.csv test.ofx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this is default filename for CSV files downloaded from Fidor? I would like to keep the names of the files realistic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's e.g. |
||
|
||
You may then import *test.ofx* into any accounting program which | ||
accepts OFX, for example YNAB-classix or gnuCash. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import csv | ||
import hashlib | ||
import re | ||
|
||
from ofxstatement.plugin import Plugin | ||
from ofxstatement.parser import CsvStatementParser | ||
from ofxstatement.statement import StatementLine | ||
|
||
|
||
class FidorBankAGPlugin(Plugin): | ||
def get_parser(self, filename): | ||
encoding = self.settings.get('charset', 'utf-8') | ||
with open(filename, 'r', encoding=encoding) as f: | ||
lines = f.readlines() | ||
parser = FidorBankAGParser(lines) | ||
parser.statement.account_id = self.settings['account'] | ||
parser.statement.bank_id = self.settings.get('bank', '50050201') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Fidor, looks like it is |
||
parser.statement.currency = self.settings.get('currency', 'EUR') | ||
return parser | ||
|
||
|
||
class FidorBankAGParser(CsvStatementParser): | ||
""" | ||
This plugin tries to parse the provided CSV data into OFX format. | ||
""" | ||
date_format = "%d.%m.%Y" | ||
|
||
def split_records(self): | ||
return csv.reader(self.fin, delimiter=';') | ||
|
||
def parse_float(self, f): | ||
""" convert a number in german localization (e.g. 1.234,56) to float """ | ||
return float(f.replace('.', '').replace(',', '.')) | ||
|
||
def parse_record(self, line): | ||
if self.cur_record < 2: | ||
return None | ||
sl = StatementLine() | ||
# Build an ID based on an MD5 of the whole line. | ||
original_line = ";".join(line) | ||
hl = hashlib.new('md5'); | ||
hl.update(original_line.encode('utf-8')) | ||
sl.id = hl.hexdigest() | ||
sl.date = self.parse_datetime(line[0]) | ||
sl.amount = self.parse_float(line[3]) | ||
sl.trntype = 'DEBIT' if sl.amount < 0 else 'CREDIT' | ||
# Payees generally follow a few formats. | ||
# Variations in Beschreibung: | ||
# MasterCard Onlinekauf bei <PAYEE> | ||
# MasterCard Gutschrift in Höhe von <AMOUNT> bei <PAYEE> | ||
# Variations in Beschreibung2: | ||
# Empfänger: <PAYEE>, IBAN: <IBAN>, BIC: <BIC> | ||
# Absender: <PAYEE>, IBAN: <IBAN>, BIC: <BIC> | ||
# Beschreibung2 is empty when the payee is in Beschreibung. | ||
# Default to blank for unknown patterns. | ||
sl.payee = '' | ||
|
||
beschreibung2 = "" + line[2] | ||
if (beschreibung2).strip() != '': | ||
# Split the Beschreibung2 value by comma, then each list element by comma. Use the second value of the | ||
# first element for the Payee. | ||
desc_parts = beschreibung2.split(",") | ||
desc1_parts = ("" + desc_parts[0]).split(":") | ||
sl.payee = ("" + desc1_parts[1]).strip() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why adding the empty string here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not that experienced in Python, and I wanted PyCharm's code hints to work properly. So type coercion, basically. |
||
else: | ||
pattern = re.compile('.+ bei (.+)$') | ||
match = pattern.match(line[1]) | ||
if match: | ||
sl.payee = match.group(1) | ||
|
||
# Use Beschreibung as the memo. | ||
sl.memo = line[1] | ||
|
||
return sl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove/update this "UPDATE THIS README"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already been updated so this is safe to remove