Merge lp:~igor-cota/banking-addons/banking-addons into lp:banking-addons/6.0

Proposed by Igor Cota
Status: Merged
Merged at revision: 78
Proposed branch: lp:~igor-cota/banking-addons/banking-addons
Merge into: lp:banking-addons/6.0
Diff against target: 215 lines (+199/-0)
3 files modified
account_banking_hr_rba/__init__.py (+31/-0)
account_banking_hr_rba/__terp__.py (+43/-0)
account_banking_hr_rba/rba.py (+125/-0)
To merge this branch: bzr merge lp:~igor-cota/banking-addons/banking-addons
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Approve
Review via email: mp+114666@code.launchpad.net

Description of the change

Initial support for Raiffeisenbank Croatia. Statements import works nicely. First time using Python / bzr as dev so please be gentle. :)

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Igor,

thank you for contributing your import module! Looks great, especially if this is your first work with these specific tools.

If you are interested in conjuring up a 6.1 version of this module, this little API change should do the trick:

http://bazaar.launchpad.net/~therp-nl/banking-addons/6.0-interactive-matching-and-debit-orders/revision/103/account_banking_fi_patu/patu.py

Best regards,
Stefan.

review: Approve
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

While merging, I renamed __terp__.py to __openerp__.py. The former is deprecated, although it still works.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_banking_hr_rba'
2=== added file 'account_banking_hr_rba/__init__.py'
3--- account_banking_hr_rba/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_banking_hr_rba/__init__.py 2012-07-12 15:42:47 +0000
5@@ -0,0 +1,31 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (C) 2012 Igor Cota (<http://www.codexapertus.hr>).
10+# Copyright (C) 2010 Sami Haahtinen (<http://ressukka.net>).
11+# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
12+# All Rights Reserved
13+#
14+# WARNING: This program as such is intended to be used by professional
15+# programmers who take the whole responsability of assessing all potential
16+# consequences resulting from its eventual inadequacies and bugs
17+# End users who are looking for a ready-to-use solution with commercial
18+# garantees and support are strongly adviced to contract EduSense BV
19+#
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU General Public License as published by
22+# the Free Software Foundation, either version 3 of the License, or
23+# (at your option) any later version.
24+#
25+# This program is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+# GNU General Public License for more details.
29+#
30+# You should have received a copy of the GNU General Public License
31+# along with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+##############################################################################
34+import rba
35+
36+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
37
38=== added file 'account_banking_hr_rba/__terp__.py'
39--- account_banking_hr_rba/__terp__.py 1970-01-01 00:00:00 +0000
40+++ account_banking_hr_rba/__terp__.py 2012-07-12 15:42:47 +0000
41@@ -0,0 +1,43 @@
42+##############################################################################
43+#
44+# Copyright (C) 2012 Igor Cota (<http://www.codexapertus.hr>).
45+# Copyright (C) 2010 Sami Haahtinen (<http://ressukka.net>).
46+# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
47+# All Rights Reserved
48+#
49+# WARNING: This program as such is intended to be used by professional
50+# programmers who take the whole responsability of assessing all potential
51+# consequences resulting from its eventual inadequacies and bugs
52+# End users who are looking for a ready-to-use solution with commercial
53+# garantees and support are strongly adviced to contract EduSense BV
54+#
55+# This program is free software: you can redistribute it and/or modify
56+# it under the terms of the GNU General Public License as published by
57+# the Free Software Foundation, either version 3 of the License, or
58+# (at your option) any later version.
59+#
60+# This program is distributed in the hope that it will be useful,
61+# but WITHOUT ANY WARRANTY; without even the implied warranty of
62+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63+# GNU General Public License for more details.
64+#
65+# You should have received a copy of the GNU General Public License
66+# along with this program. If not, see <http://www.gnu.org/licenses/>.
67+#
68+##############################################################################
69+{
70+ 'name': 'Account Banking RBA Croatia module',
71+ 'version': '0.1',
72+ 'license': 'GPL-3',
73+ 'author': 'Igor Cota',
74+ 'website': 'http://www.codexapertus.hr',
75+ 'category': 'Account Banking',
76+ 'depends': ['account_banking'],
77+ 'description': '''
78+ Module for importing Raiffeisen Bank Croatia XML bank statements.
79+
80+ This modules contains no logic, just an import filter for account_banking.
81+ ''',
82+ 'active': False,
83+ 'installable': True,
84+}
85
86=== added directory 'account_banking_hr_rba/i18n'
87=== added file 'account_banking_hr_rba/rba.py'
88--- account_banking_hr_rba/rba.py 1970-01-01 00:00:00 +0000
89+++ account_banking_hr_rba/rba.py 2012-07-12 15:42:47 +0000
90@@ -0,0 +1,125 @@
91+# -*- encoding: utf-8 -*-
92+##############################################################################
93+#
94+# Copyright (C) 2012 Igor Cota (<http://www.codexapertus.hr>).
95+# Special thanks to Pythonic code stylist Thomas Perl (<http://thp.io>)
96+#
97+# Copyright (C) 2010 Sami Haahtinen (<http://ressukka.net>).
98+# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
99+# All Rights Reserved
100+#
101+# This program is free software: you can redistribute it and/or modify
102+# it under the terms of the GNU General Public License as published by
103+# the Free Software Foundation, either version 3 of the License, or
104+# (at your option) any later version.
105+#
106+# This program is distributed in the hope that it will be useful,
107+# but WITHOUT ANY WARRANTY; without even the implied warranty of
108+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109+# GNU General Public License for more details.
110+#
111+# You should have received a copy of the GNU General Public License
112+# along with this program. If not, see <http://www.gnu.org/licenses/>.
113+#
114+##############################################################################
115+
116+'''
117+This parser implements the Raiffeisenbank Croatia XML format support.
118+'''
119+from account_banking.parsers import models
120+from tools.translate import _
121+import xml, datetime, time
122+from xml.dom.minidom import parseString
123+
124+__all__ = ['parser']
125+
126+def get_first_node(dom, *args):
127+ '''
128+ Function to go down DOM hierarchy. Made for brevity.
129+ '''
130+ node = None
131+ for arg in args:
132+ if node == None:
133+ node = dom.getElementsByTagName(args[0])[0]
134+ else:
135+ node = node.getElementsByTagName(arg)[0]
136+
137+ return node
138+
139+class transaction(models.mem_bank_transaction):
140+ '''
141+ Implementation of transaction communication class for account_banking.
142+ '''
143+ def __init__(self, transaction_dom, *args, **kwargs):
144+ '''
145+ Parse specific transaction DOM and set attributes.
146+ '''
147+ iidd = get_first_node(transaction_dom, "BrojTransakcije").firstChild.nodeValue
148+ execution_date = datetime.datetime.strptime(get_first_node(transaction_dom, "DatumValute").firstChild.nodeValue, '%d.%m.%Y')
149+ effective_date = datetime.datetime.strptime(get_first_node(transaction_dom, "DatumKnjizenja").firstChild.nodeValue, '%d.%m.%Y')
150+
151+ owner_string = get_first_node(transaction_dom, "DuznikPrimatelj_1").firstChild.nodeValue
152+ remote_owner = ' '.join(owner_string.split()) # Way too much random whitespace
153+
154+ transferred_amount = 0. # Assume float
155+
156+ if get_first_node(transaction_dom, 'Promet', 'Tip').firstChild.nodeValue == 'P':
157+ transferred_amount = float(get_first_node(transaction_dom, 'Promet', 'Iznos').firstChild.nodeValue.replace(',',''))
158+ else:
159+ transferred_amount = -float(get_first_node(transaction_dom, 'Promet', 'Iznos').firstChild.nodeValue.replace(',',''))
160+
161+ super(transaction, self).__init__(*args, **kwargs)
162+
163+ self.id = iidd
164+ self.execution_date = execution_date
165+ self.effective_date = effective_date
166+ self.remote_owner = remote_owner
167+ self.transferred_amount = transferred_amount
168+
169+ def is_valid(self):
170+ return True # Everything is fine. Trust me.
171+
172+class statement(models.mem_bank_statement):
173+ '''
174+ Implementation of bank_statement communication class of account_banking
175+ '''
176+ def __init__(self, dom, *args, **kwargs):
177+ '''
178+ Parse DOM and set general statement attributes
179+ '''
180+ super(statement, self).__init__(*args, **kwargs)
181+
182+ year = get_first_node(dom, "GodinaIzvoda").firstChild.nodeValue
183+ serial = get_first_node(dom, "BrojIzvoda").firstChild.nodeValue
184+
185+ self.id = 'BNK/' + year + '/' + serial[1:]
186+
187+ self.local_account = '2484008-' + get_first_node(dom, "Racun").firstChild.nodeValue # Prepend RBA VDBI
188+ self.local_currency = 'HRK' # Hardcoded HRK
189+
190+ self.start_balance = float(get_first_node(dom, "Grupe", "Grupa", "ZaglavljeGrupe", "PocetnoStanje").firstChild.nodeValue.replace(',',''))
191+ self.end_balance = float(get_first_node(dom, "Grupe", "Grupa", "ProknjizenoStanje", "Iznos").firstChild.nodeValue.replace(',',''))
192+
193+ self.date = datetime.datetime.strptime(get_first_node(dom, "DatumIzvoda").firstChild.nodeValue, '%d.%m.%Y')
194+
195+class parser(models.parser):
196+ code = 'HRRBA'
197+ country_code = 'hr'
198+ name = _('RBA statement format')
199+ doc = _('''RBA XML format defines one statement per file. This parser
200+will parse the file and import to OpenERP
201+''')
202+
203+ def parse(self, data):
204+ result = []
205+ stmnt = None
206+ dom = xml.dom.minidom.parseString(data)
207+
208+ stmnt = statement(dom) # We have just the one statement per file
209+
210+ for i in get_first_node(dom, 'Grupa', 'Stavke').getElementsByTagName('Stavka'):
211+ trnsact = transaction(i)
212+ stmnt.transactions.append(trnsact)
213+
214+ result.append(stmnt)
215+ return result

Subscribers

People subscribed via source and target branches