Skip to content

Commit

Permalink
Merge branch 'release/2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed May 24, 2015
2 parents 9cfe5ff + 67b98cf commit db06728
Show file tree
Hide file tree
Showing 36 changed files with 4,882 additions and 3,647 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ env:
install:
- pip install -r requirements.txt
- pip install tox
- pip install coveralls
script:
- tox -e $TOX_ENV
- py.test

after_success:
- coveralls
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,31 @@ Introduction
:alt: Test Status
:target: https://travis-ci.org/WoLpH/mt940

.. image:: https://coveralls.io/repos/WoLpH/mt940/badge.png?branch=master
:alt: Coverage Status
:target: https://coveralls.io/r/WoLpH/mt940?branch=master

.. image:: https://landscape.io/github/WoLpH/mt940/master/landscape.png
:target: https://landscape.io/github/WoLpH/mt940/master
:alt: Code Health

A library to parse MT940 files and returns smart Python collections for
statistics and manipulation.

Links
-----

* Documentation
- http://mt940.readthedocs.org/en/latest/
* Source
- https://github.com/WoLpH/mt940
* Bug reports
- https://github.com/WoLpH/mt940/issues
* Package homepage
- https://pypi.python.org/pypi/mt-940
* My blog
- http://w.wol.ph/

Install
------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion mt940/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__package_name__ = 'mt-940'
__version__ = '2.0'
__version__ = '2.1'
__author__ = 'Rick van Hattem'
__author_email__ = 'Wolph@Wol.ph'
__description__ = '''
Expand Down
40 changes: 26 additions & 14 deletions mt940/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,37 @@
import mt940


class Date(datetime.date):
class Model(object):
pass


class Date(datetime.date, Model):
'''Just a regular date object which supports dates given as strings
Args:
year (str): The year (0-100), will automatically add 2000 when needed
month (str): The month
day (str): The day
'''
def __new__(cls, year, month, day, **kwargs):
year = int(year, 10)
if year < 1000:
year += 2000

month = int(month, 10)
day = int(day, 10)
return datetime.date.__new__(cls, year, month, day)


class Amount(object):
def __new__(cls, *args, **kwargs):
if kwargs:
year = kwargs.get('year')
month = kwargs.get('month')
day = kwargs.get('day')
year = int(year, 10)
if year < 1000:
year += 2000

month = int(month, 10)
day = int(day, 10)
return datetime.date.__new__(cls, year, month, day)
else:
# For pickling the date object uses it's own binary format
# No need to do anything special there :)
return datetime.date.__new__(cls, *args, **kwargs)


class Amount(Model):
'''Amount object containing currency and amount
Args:
Expand Down Expand Up @@ -52,7 +64,7 @@ def __repr__(self):
)


class Balance(object):
class Balance(Model):
'''Parse balance statement
Args:
Expand Down Expand Up @@ -213,7 +225,7 @@ def __repr__(self):
)


class Transaction(object):
class Transaction(Model):
def __init__(self, transactions, data=None):
self.transactions = transactions
self.data = {}
Expand Down
2 changes: 1 addition & 1 deletion mt940/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

try:
import enum
except ImportError:
except ImportError: # pragma: no cover
import sys
print >> sys.stderr, 'MT940 requires the `enum34` package'

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
enum34
pytest
pytest-pep8
pytest-flakes
pytest-cov
flake8
sphinx
sphinxcontrib-napoleon
pyyaml
34 changes: 27 additions & 7 deletions tests/betterplace/currency_in_25.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
---
- - !ruby/object:MT940::Account
modifier:
content: 51210600/9223382012EUR
bank_code: '51210600'
account_number: '9223382012'
account_currency: EUR
&id001 !!python/object:mt940.models.Transactions
data: {account_identification: 51210600/9223382012EUR}
processors:
post_account_identification: []
post_available_balance: []
post_closing_balance: []
post_forward_available_balance: []
post_opening_balance: []
post_related_reference: []
post_statement: [!!python/name:mt940.processors.date_cleanup_post_processor '']
post_statement_number: []
post_transaction_details: []
post_transaction_reference_number: []
pre_account_identification: []
pre_available_balance: []
pre_closing_balance: []
pre_forward_available_balance: []
pre_opening_balance: []
pre_related_reference: []
pre_statement: []
pre_statement_number: []
pre_transaction_details: []
pre_transaction_reference_number: []
transactions:
- !!python/object:mt940.models.Transaction
data: {}
transactions: *id001
36 changes: 29 additions & 7 deletions tests/betterplace/empty_86.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
---
- - !ruby/object:MT940::StatementLineInformation
modifier:
content: 091
code: 0
details: ''
account_holder: ''
&id001 !!python/object:mt940.models.Transactions
data: {}
processors:
post_account_identification: []
post_available_balance: []
post_closing_balance: []
post_forward_available_balance: []
post_opening_balance: []
post_related_reference: []
post_statement: [!!python/name:mt940.processors.date_cleanup_post_processor '']
post_statement_number: []
post_transaction_details: []
post_transaction_reference_number: []
pre_account_identification: []
pre_available_balance: []
pre_closing_balance: []
pre_forward_available_balance: []
pre_opening_balance: []
pre_related_reference: []
pre_statement: []
pre_statement_number: []
pre_transaction_details: []
pre_transaction_reference_number: []
transactions:
- !!python/object:mt940.models.Transaction
data: {transaction_details: '091

-'}
transactions: *id001
50 changes: 40 additions & 10 deletions tests/betterplace/empty_entry_date.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
---
- - !ruby/object:MT940::StatementLine
modifier:
content: 110701CN50,00NZ10NONREF
funds_code: :credit
amount: 5000
swift_code: NZ10
reference: NONREF
transaction_description: ''
date: 2011-07-01
&id001 !!python/object:mt940.models.Transactions
data: {}
processors:
post_account_identification: []
post_available_balance: []
post_closing_balance: []
post_forward_available_balance: []
post_opening_balance: []
post_related_reference: []
post_statement: [!!python/name:mt940.processors.date_cleanup_post_processor '']
post_statement_number: []
post_transaction_details: []
post_transaction_reference_number: []
pre_account_identification: []
pre_available_balance: []
pre_closing_balance: []
pre_forward_available_balance: []
pre_opening_balance: []
pre_related_reference: []
pre_statement: []
pre_statement_number: []
pre_transaction_details: []
pre_transaction_reference_number: []
transactions:
- !!python/object:mt940.models.Transaction
data:
amount: !!python/object:mt940.models.Amount
amount: !!python/object/apply:decimal.Decimal ['50.00']
currency: null
bank_reference: null
currency: null
customer_reference: NONREF
date: !!python/object/apply:mt940.models.Date
- !!binary |
B9sHAQ==
extra_details: ''
funds_code: N
id: NZ10
status: C
transactions: *id001
32 changes: 27 additions & 5 deletions tests/betterplace/empty_line.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
---
- - !ruby/object:MT940::Job
modifier:
content: TELEREPORTING
reference: TELEREPORTING
&id001 !!python/object:mt940.models.Transactions
data: {transaction_reference: TELEREPORTING}
processors:
post_account_identification: []
post_available_balance: []
post_closing_balance: []
post_forward_available_balance: []
post_opening_balance: []
post_related_reference: []
post_statement: [!!python/name:mt940.processors.date_cleanup_post_processor '']
post_statement_number: []
post_transaction_details: []
post_transaction_reference_number: []
pre_account_identification: []
pre_available_balance: []
pre_closing_balance: []
pre_forward_available_balance: []
pre_opening_balance: []
pre_related_reference: []
pre_statement: []
pre_statement_number: []
pre_transaction_details: []
pre_transaction_reference_number: []
transactions:
- !!python/object:mt940.models.Transaction
data: {}
transactions: *id001
44 changes: 35 additions & 9 deletions tests/betterplace/missing_crlf_at_end.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
---
- - !ruby/object:MT940::ClosingBalance
modifier: F
content: C100323EUR42570,04
balance_type: :start
sign: :credit
currency: EUR
amount: 4257004
date: 2010-03-23
&id001 !!python/object:mt940.models.Transactions
data:
closing_balance: !!python/object:mt940.models.Balance
amount: !!python/object:mt940.models.Amount
amount: !!python/object/apply:decimal.Decimal ['42570.04']
currency: EUR
date: !!python/object/apply:mt940.models.Date
- !!binary |
B9oDFw==
status: C
processors:
post_account_identification: []
post_available_balance: []
post_closing_balance: []
post_forward_available_balance: []
post_opening_balance: []
post_related_reference: []
post_statement: [!!python/name:mt940.processors.date_cleanup_post_processor '']
post_statement_number: []
post_transaction_details: []
post_transaction_reference_number: []
pre_account_identification: []
pre_available_balance: []
pre_closing_balance: []
pre_forward_available_balance: []
pre_opening_balance: []
pre_related_reference: []
pre_statement: []
pre_statement_number: []
pre_transaction_details: []
pre_transaction_reference_number: []
transactions:
- !!python/object:mt940.models.Transaction
data: {}
transactions: *id001

0 comments on commit db06728

Please sign in to comment.