Skip to content
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

Fixing the conversion for the "new" ing CSV format. #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: python

python:
- "3.5"
- "3.6"

install:
- pip install -e .[test]

script:
- pytest src/ofxstatement
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
20 changes: 0 additions & 20 deletions README.rst

This file was deleted.

22 changes: 15 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -35,6 +42,7 @@
['ingbe = ofxstatement.plugins.ingbe:IngBePlugin']
},
install_requires=['ofxstatement'],
extras_require={'test': ["freezegun", "pytest"]},
include_package_data=True,
zip_safe=True
)
25 changes: 14 additions & 11 deletions src/ofxstatement/plugins/ingbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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

Expand All @@ -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'
Expand Down