diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..461be9b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python + +python: + - "3.5" + - "3.6" + +install: + - pip install -e .[test] + +script: + - pytest src/ofxstatement diff --git a/README.md b/README.md new file mode 100644 index 0000000..64f477f --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# ofxstatement-be-ing + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ING Belgium plugin for ofxstatement +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This project provides a custom plugin for [ofxstatement](https://github.com/kedder/ofxstatement) for ING (BE). It is based +on the work done by TheoMarescaux (https://github.com/TheoMarescaux/ofxstatement-be-ing) +and corrected for INGs latest changes to the csv files generated by their homebanking. + +`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format, +suitable for importing to GnuCash. Plugin for ofxstatement parses a +particular proprietary bank statement format and produces common data +structure, that is then formatted into an OFX file. + +Users of ofxstatement have developed several plugins for their banks. They are +listed on main [`ofxstatement`](https://github.com/kedder/ofxstatement) site. If your bank is missing, you can develop +your own plugin. + +## Installation + +### From PyPI repositories +``` +pip3 install ofxstatement-be-ing +``` + +### From source +``` +git clone https://github.com/jbbandos/ofxstatement-be-ing.git +python3 setup.py install +``` + +## Usage +``` +$ ofxstatement convert -t ingbe input.csv output.ofx +``` diff --git a/README.rst b/README.rst deleted file mode 100644 index 306eb53..0000000 --- a/README.rst +++ /dev/null @@ -1,20 +0,0 @@ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ING Belgium plugin for ofxstatement -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -`ofxstatement`_ is a tool to convert proprietary bank statement to OFX format, -suitable for importing to GnuCash. Plugin for ofxstatement parses a -particular proprietary bank statement format and produces common data -structure, that is then formatted into an OFX file. - -.. _ofxstatement: https://github.com/kedder/ofxstatement - - -Users of ofxstatement have developed several plugins for their banks. They are -listed on main `ofxstatement`_ site. If your bank is missing, you can develop -your own plugin. - -Usage -===== - - $ ofxstatement convert -t ingbe input.csv output.ofx diff --git a/setup.py b/setup.py index a3aa771..1b6d98e 100755 --- a/setup.py +++ b/setup.py @@ -1,25 +1,32 @@ #!/usr/bin/python3 """Setup """ + +import os + from setuptools import find_packages +from setuptools.command.test import test as TestCommand from distutils.core import setup -version = "0.0.1" +import unittest + +version = "0.1.1" -with open('README.rst') as f: +with open('README.md') as f: long_description = f.read() setup(name='ofxstatement-be-ing', version=version, - author="Theodore Marescaux", - author_email="theo.public@gmail.com", - url="https://github.com/TheoMarescaux/ofxstatement-be-ing", + author="Bernardo Bandos", + author_email="@hotmail.com", + url="https://github.com/jbbandos/ofxstatement-be-ing", description=("OFXStatement plugin for ING (Belgium)"), - long_description=long_description, + long_description=open("README.md").read(), + long_description_content_type='text/markdown', license="GPLv3", keywords=["ofx", "banking", "statement"], classifiers=[ - 'Development Status :: 3 - Alpha', + 'Development Status :: 4 - Beta', 'Programming Language :: Python :: 3', 'Natural Language :: English', 'Topic :: Office/Business :: Financial :: Accounting', @@ -35,6 +42,7 @@ ['ingbe = ofxstatement.plugins.ingbe:IngBePlugin'] }, install_requires=['ofxstatement'], + extras_require={'test': ["freezegun", "pytest"]}, include_package_data=True, zip_safe=True ) diff --git a/src/ofxstatement/plugins/ingbe.py b/src/ofxstatement/plugins/ingbe.py index a601b2f..788c9fa 100644 --- a/src/ofxstatement/plugins/ingbe.py +++ b/src/ofxstatement/plugins/ingbe.py @@ -20,9 +20,9 @@ class IngBeParser(CsvStatementParser): date_format = "%d/%m/%Y" mappings = { 'check_no': 3, - 'date': 4, + 'date': 5, 'payee': 2, - 'memo': 9, + 'memo': 8, 'amount': 6 } @@ -40,7 +40,7 @@ def split_records(self): """Return iterable object consisting of a line per transaction """ - reader = csv.reader(self.fin) + reader = csv.reader(self.fin, delimiter=';') next(reader, None) return reader @@ -49,20 +49,23 @@ def parse_record(self, line): """ # Remove non CSV cr*p and zero-value notifications - if(line[5] and not (line[6]=="0" and line[7]=="0")): + if(line[5] and not (line[6]=="0")): transaction_id = line[3] date = line[4] date_value = line[5] - account_to = line[2] - currency = line[8] - - # fix amount - Well done ING, mixing the comma as decimal separator and as CSV delimiter. Way to go... - line[6] = line[6]+"."+line[7] + if(line[2]): + account_to = line[2] + else: + account_to = ' '.join(line[8].split()) + + currency = line[7] + line[6] = line[6].replace(",", ".") amount = line[6] + # Pack info in description - line[9] = line[9]+"-"+line[10]+"-"+line[11] - description = line[9] + line[8] = ' '.join(line[8].split())+"-"+' '.join(line[9].split())+"-"+' '.join(line[10].split()) + description = line[8] stmtline = super(IngBeParser, self).parse_record(line) stmtline.trntype = 'DEBIT' if stmtline.amount < 0 else 'CREDIT'