Merge lp:~openerp-dev/openobject-addons/trunk-import-bank-statements into lp:openobject-addons
- trunk-import-bank-statements
- Merge into trunk
Proposed by
DJ Patel (OpenERP)
Status: | Needs review |
---|---|
Proposed branch: | lp:~openerp-dev/openobject-addons/trunk-import-bank-statements |
Merge into: | lp:openobject-addons |
Diff against target: |
817 lines (+520/-103) 19 files modified
account/__init__.py (+1/-0) account/__openerp__.py (+1/-1) account/account_bank_statement_import.py (+118/-0) account/account_bank_statement_import_view.xml (+47/-0) account/tests/__init__.py (+4/-0) account/tests/test_import_bank_statement.py (+73/-0) account/wizard/account_financial_report.py (+1/-1) account_qif/__init__.py (+24/-0) account_qif/__openerp__.py (+49/-0) account_qif/account_qif.py (+96/-0) account_qif/tests/__init__.py (+4/-0) account_qif/tests/test_import_bank_statement.py (+30/-0) l10n_be_coda/__openerp__.py (+0/-1) l10n_be_coda/l10n_be_coda_view.xml (+1/-2) l10n_be_coda/l10n_be_coda_wizard.xml (+0/-35) l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt (+11/-11) l10n_be_coda/tests/__init__.py (+4/-0) l10n_be_coda/tests/test_import_bank_statement.py (+39/-0) l10n_be_coda/wizard/account_coda_import.py (+17/-52) |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/trunk-import-bank-statements |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+212993@code.launchpad.net |
Commit message
Description of the change
Hello,
I have created a generic wizard for ofx, qif and coda file format.
It is used to import these types of bank statements into openerp.
Thanks,
Divyesh
To post a comment you must log in.
- 9257. By DJ Patel (OpenERP)
-
[IMP] account : Improved the code to return an action.
- 9258. By DJ Patel (OpenERP)
-
[FIX] account, account_qif, l10n_be_coda : Fixed the test cases.
- 9259. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9260. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9261. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9262. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
Unmerged revisions
- 9262. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9261. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9260. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9259. By DJ Patel (OpenERP)
-
[Merge] Merged with trunk.
- 9258. By DJ Patel (OpenERP)
-
[FIX] account, account_qif, l10n_be_coda : Fixed the test cases.
- 9257. By DJ Patel (OpenERP)
-
[IMP] account : Improved the code to return an action.
- 9256. By DJ Patel (OpenERP)
-
[Merge] Merged the branch: lp:~openerp-dev/openobject-addons/trunk-import-bank-statement with improvements.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account/__init__.py' | |||
2 | --- account/__init__.py 2012-11-29 22:26:45 +0000 | |||
3 | +++ account/__init__.py 2014-04-02 04:28:41 +0000 | |||
4 | @@ -38,5 +38,6 @@ | |||
5 | 38 | import res_currency | 38 | import res_currency |
6 | 39 | import edi | 39 | import edi |
7 | 40 | import res_config | 40 | import res_config |
8 | 41 | import account_bank_statement_import | ||
9 | 41 | 42 | ||
10 | 42 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 43 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
11 | 43 | 44 | ||
12 | === modified file 'account/__openerp__.py' | |||
13 | --- account/__openerp__.py 2014-02-13 17:39:10 +0000 | |||
14 | +++ account/__openerp__.py 2014-04-02 04:28:41 +0000 | |||
15 | @@ -124,7 +124,7 @@ | |||
16 | 124 | 'account_bank_view.xml', | 124 | 'account_bank_view.xml', |
17 | 125 | 'res_config_view.xml', | 125 | 'res_config_view.xml', |
18 | 126 | 'account_pre_install.yml', | 126 | 'account_pre_install.yml', |
20 | 127 | 127 | 'account_bank_statement_import_view.xml', | |
21 | 128 | 'views/report_vat.xml', | 128 | 'views/report_vat.xml', |
22 | 129 | ], | 129 | ], |
23 | 130 | 'js': [ | 130 | 'js': [ |
24 | 131 | 131 | ||
25 | === added file 'account/account_bank_statement_import.py' | |||
26 | --- account/account_bank_statement_import.py 1970-01-01 00:00:00 +0000 | |||
27 | +++ account/account_bank_statement_import.py 2014-04-02 04:28:41 +0000 | |||
28 | @@ -0,0 +1,118 @@ | |||
29 | 1 | # -*- coding: utf-8 -*- | ||
30 | 2 | ############################################################################## | ||
31 | 3 | # | ||
32 | 4 | # OpenERP, Open Source Management Solution | ||
33 | 5 | # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>). | ||
34 | 6 | # | ||
35 | 7 | # This program is free software: you can redistribute it and/or modify | ||
36 | 8 | # it under the terms of the GNU Affero General Public License as | ||
37 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
38 | 10 | # License, or (at your option) any later version. | ||
39 | 11 | # | ||
40 | 12 | # This program is distributed in the hope that it will be useful, | ||
41 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | 15 | # GNU Affero General Public License for more details. | ||
44 | 16 | # | ||
45 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
46 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | 19 | # | ||
48 | 20 | ############################################################################## | ||
49 | 21 | |||
50 | 22 | import logging | ||
51 | 23 | import base64 | ||
52 | 24 | import os | ||
53 | 25 | import time | ||
54 | 26 | |||
55 | 27 | from openerp.osv import fields, osv | ||
56 | 28 | from openerp.tools.translate import _ | ||
57 | 29 | from openerp import tools | ||
58 | 30 | |||
59 | 31 | _logger = logging.getLogger(__name__) | ||
60 | 32 | |||
61 | 33 | try: | ||
62 | 34 | from ofxparse import OfxParser as ofxparser | ||
63 | 35 | except ImportError: | ||
64 | 36 | _logger.warning("OFX parser partially unavailable because the `ofxparse` Python library cannot be found. " | ||
65 | 37 | "It can be easily download and install from this `https://pypi.python.org/pypi/ofxparse`.") | ||
66 | 38 | ofxparser = None | ||
67 | 39 | |||
68 | 40 | _IMPORT_FILE_TYPE = [('ofx', 'OFX')] | ||
69 | 41 | |||
70 | 42 | class account_bank_statement_import(osv.TransientModel): | ||
71 | 43 | _name = 'account.bank.statement.import' | ||
72 | 44 | _description = 'Import Bank Statement' | ||
73 | 45 | _columns = { | ||
74 | 46 | 'data_file': fields.binary('Bank Statement File', required=True, help='Select bank statement file to import in OpenERP. .OFX, .QIF or CODA are accepted.'), | ||
75 | 47 | 'file_type': fields.selection(_IMPORT_FILE_TYPE, 'File Type'), | ||
76 | 48 | 'journal_id': fields.many2one('account.journal', 'Journal', required=True), | ||
77 | 49 | 'account_id': fields.many2one('account.account', 'Account', domain="[('type', '!=', 'view')]", help=" Choose the account to be credited/debited for the entries of the statement.", required=True), | ||
78 | 50 | } | ||
79 | 51 | |||
80 | 52 | def _get_default_journal(self, cr, uid, context=None): | ||
81 | 53 | company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.bank.statement', context=context) | ||
82 | 54 | journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'bank'), ('company_id', '=', company_id)], context=context) | ||
83 | 55 | return journal_ids and journal_ids[0] or False | ||
84 | 56 | |||
85 | 57 | _defaults = { | ||
86 | 58 | 'file_type': 'ofx', | ||
87 | 59 | 'journal_id': _get_default_journal, | ||
88 | 60 | } | ||
89 | 61 | |||
90 | 62 | def import_bank_statement(self, cr, uid, bank_statement_vals=False, context=None): | ||
91 | 63 | statement_id = self.pool.get('account.bank.statement').create(cr, uid, bank_statement_vals, context=context) | ||
92 | 64 | return statement_id | ||
93 | 65 | |||
94 | 66 | def process_ofx(self, cr, uid, data_file, journal_id=False, account_id=False, context=None): | ||
95 | 67 | try: | ||
96 | 68 | tempfile = open( "temp.ofx", "w+" ) | ||
97 | 69 | tempfile.write(base64.decodestring(data_file)) | ||
98 | 70 | tempfile.read() | ||
99 | 71 | pathname = os.path.dirname('temp.ofx') | ||
100 | 72 | path = os.path.join(os.path.abspath(pathname), 'temp.ofx') | ||
101 | 73 | ofx = ofxparser.parse(file(path)) | ||
102 | 74 | except: | ||
103 | 75 | raise osv.except_osv(_('Import Error!'), _('Please check OFX file format is proper or not.')) | ||
104 | 76 | line_ids = [] | ||
105 | 77 | total_amt = 0.00 | ||
106 | 78 | try: | ||
107 | 79 | for transaction in ofx.account.statement.transactions: | ||
108 | 80 | vals_line = { | ||
109 | 81 | 'date' : transaction.date, | ||
110 | 82 | 'name' : transaction.memo, | ||
111 | 83 | 'ref': transaction.id, | ||
112 | 84 | 'amount' : transaction.amount, | ||
113 | 85 | 'account_id': account_id | ||
114 | 86 | } | ||
115 | 87 | total_amt += float(transaction.amount) | ||
116 | 88 | line_ids.append((0, 0, vals_line)) | ||
117 | 89 | except Exception,e: | ||
118 | 90 | raise osv.except_osv(_('Error!'), _("Following problem has been occurred while importing your file, Please verify the file is proper or not.\n\n %s" % e.message)) | ||
119 | 91 | st_start_date = ofx.account.statement.start_date or False | ||
120 | 92 | st_end_date = ofx.account.statement.end_date or False | ||
121 | 93 | period_obj = self.pool.get('account.period') | ||
122 | 94 | if st_end_date: | ||
123 | 95 | period_ids = period_obj.find(cr, uid, st_end_date, context=context) | ||
124 | 96 | else: | ||
125 | 97 | period_ids = period_obj.find(cr, uid, st_start_date, context=context) | ||
126 | 98 | vals_bank_statement = { | ||
127 | 99 | 'name': ofx.account.routing_number, | ||
128 | 100 | 'balance_start': ofx.account.statement.balance, | ||
129 | 101 | 'balance_end_real': float(ofx.account.statement.balance) + total_amt, | ||
130 | 102 | 'period_id': period_ids and period_ids[0] or False, | ||
131 | 103 | 'journal_id': journal_id | ||
132 | 104 | } | ||
133 | 105 | vals_bank_statement.update({'line_ids': line_ids}) | ||
134 | 106 | os.remove(path) | ||
135 | 107 | return vals_bank_statement | ||
136 | 108 | |||
137 | 109 | def parse_file(self, cr, uid, ids, context=None): | ||
138 | 110 | data = self.browse(cr, uid, ids[0], context=context) | ||
139 | 111 | vals = getattr(self, "process_%s" % data.file_type)(cr, uid, data.data_file, data.journal_id.id, data.account_id.id, context=context) | ||
140 | 112 | statement_id = self.import_bank_statement(cr, uid, vals, context=context) | ||
141 | 113 | model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_bank_statement_tree') | ||
142 | 114 | action = self.pool[model].read(cr, uid, action_id, context=context) | ||
143 | 115 | action['domain'] = "[('id', 'in', ["+', '.join(map(str, [statement_id]))+"])]" | ||
144 | 116 | return action | ||
145 | 117 | |||
146 | 118 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
147 | 0 | 119 | ||
148 | === added file 'account/account_bank_statement_import_view.xml' | |||
149 | --- account/account_bank_statement_import_view.xml 1970-01-01 00:00:00 +0000 | |||
150 | +++ account/account_bank_statement_import_view.xml 2014-04-02 04:28:41 +0000 | |||
151 | @@ -0,0 +1,47 @@ | |||
152 | 1 | <?xml version="1.0" ?> | ||
153 | 2 | <openerp> | ||
154 | 3 | <data> | ||
155 | 4 | |||
156 | 5 | <record id="account_bank_statement_import_view" model="ir.ui.view"> | ||
157 | 6 | <field name="name">Import Bank Statements</field> | ||
158 | 7 | <field name="model">account.bank.statement.import</field> | ||
159 | 8 | <field name="priority">1</field> | ||
160 | 9 | <field name="arch" type="xml"> | ||
161 | 10 | <form string="Import Bank Statements" version="7.0"> | ||
162 | 11 | <group> | ||
163 | 12 | <group> | ||
164 | 13 | <field name="file_type" required="1"/> | ||
165 | 14 | <field name="data_file" attrs="{'invisible':[('file_type','=',False)]}"/> | ||
166 | 15 | <field name="journal_id" domain="[('type', '=', 'bank')]" attrs="{'invisible':[('file_type','=',False)]}" context="{'default_type':'bank'}"/> | ||
167 | 16 | <field name="account_id" attrs="{'invisible':[('file_type','=',False)]}"/> | ||
168 | 17 | </group> | ||
169 | 18 | <group> | ||
170 | 19 | <b colspan="2"> How to import your bank statement in OpenERP.</b> | ||
171 | 20 | <label string= "1. Go to your bank account website." colspan="2"/> | ||
172 | 21 | <label string= "2. Download your bank statements in the right format. (.OFX, .QIF or CODA are accepted)" colspan="2"/> | ||
173 | 22 | <label string= "3. Upload right here the bank statements file into OpenERP. Click Import." colspan="2"/> | ||
174 | 23 | </group> | ||
175 | 24 | </group> | ||
176 | 25 | <footer> | ||
177 | 26 | <button name="parse_file" string="_Import" type="object" class="oe_highlight"/> | ||
178 | 27 | or | ||
179 | 28 | <button string="Cancel" class="oe_link" special="cancel"/> | ||
180 | 29 | </footer> | ||
181 | 30 | </form> | ||
182 | 31 | </field> | ||
183 | 32 | </record> | ||
184 | 33 | |||
185 | 34 | <record id="action_account_bank_statement_import" model="ir.actions.act_window"> | ||
186 | 35 | <field name="name">Import Bank Statements</field> | ||
187 | 36 | <field name="type">ir.actions.act_window</field> | ||
188 | 37 | <field name="res_model">account.bank.statement.import</field> | ||
189 | 38 | <field name="view_type">form</field> | ||
190 | 39 | <field name="view_mode">form</field> | ||
191 | 40 | <field name="target">new</field> | ||
192 | 41 | <field name="view_id" ref="account_bank_statement_import_view"/> | ||
193 | 42 | </record> | ||
194 | 43 | |||
195 | 44 | <menuitem parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_import" action="action_account_bank_statement_import" sequence="11"/> | ||
196 | 45 | |||
197 | 46 | </data> | ||
198 | 47 | </openerp> | ||
199 | 0 | 48 | ||
200 | === modified file 'account/tests/__init__.py' | |||
201 | --- account/tests/__init__.py 2013-12-06 17:00:12 +0000 | |||
202 | +++ account/tests/__init__.py 2014-04-02 04:28:41 +0000 | |||
203 | @@ -1,7 +1,11 @@ | |||
204 | 1 | from . import test_tax | 1 | from . import test_tax |
205 | 2 | from . import test_import_bank_statement | ||
206 | 2 | from . import test_search | 3 | from . import test_search |
207 | 3 | 4 | ||
208 | 4 | fast_suite = [ | 5 | fast_suite = [ |
209 | 5 | test_tax, | 6 | test_tax, |
210 | 6 | test_search, | 7 | test_search, |
211 | 7 | ] | 8 | ] |
212 | 9 | checks = [ | ||
213 | 10 | test_import_bank_statement | ||
214 | 11 | ] | ||
215 | 8 | 12 | ||
216 | === added file 'account/tests/test_import_bank_statement.py' | |||
217 | --- account/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000 | |||
218 | +++ account/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000 | |||
219 | @@ -0,0 +1,73 @@ | |||
220 | 1 | from openerp.tests.common import TransactionCase | ||
221 | 2 | |||
222 | 3 | ofx_file = """PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iQVNDSUkiPz4NCjw/ | ||
223 | 4 | T0ZYIE9GWEhFQURFUj0iMjAwIiBWRVJTSU9OPSIyMTEiIFNFQ1VSSVRZPSJOT05FIiBPTE | ||
224 | 5 | RGSUxFVUlEPSJOT05FIiBORVdGSUxFVUlEPSJOT05FIj8+DQo8T0ZYPg0KICA8U0lHTk9O | ||
225 | 6 | TVNHU1JTVjE+DQogICAgPFNPTlJTPg0KICAgICAgPFNUQVRVUz4NCiAgICAgICAgPENPRE | ||
226 | 7 | U+MDwvQ09ERT4NCiAgICAgICAgPFNFVkVSSVRZPklORk88L1NFVkVSSVRZPg0KICAgICAg | ||
227 | 8 | PC9TVEFUVVM+DQogICAgICA8RFRTRVJWRVI+MjAwNTA4MzExNjUxNTMuMDAwWy04OlBTVF | ||
228 | 9 | 08L0RUU0VSVkVSPg0KICAgICAgPExBTkdVQUdFPkVORzwvTEFOR1VBR0U+DQogICAgPC9T | ||
229 | 10 | T05SUz4NCiAgPC9TSUdOT05NU0dTUlNWMT4NCiAgPEJBTktNU0dTUlNWMT4NCiAgICA8U1 | ||
230 | 11 | RNVFRSTlJTPg0KICAgICAgPFRSTlVJRD4wPC9UUk5VSUQ+DQogICAgICA8U1RBVFVTPg0K | ||
231 | 12 | ICAgICAgICA8Q09ERT4wPC9DT0RFPg0KICAgICAgICA8U0VWRVJJVFk+SU5GTzwvU0VWRV | ||
232 | 13 | JJVFk+DQogICAgICA8L1NUQVRVUz4NCiAgICAgIDxTVE1UUlM+DQogICAgICAgIDxDVVJE | ||
233 | 14 | RUY+VVNEPC9DVVJERUY+DQogICAgICAgIDxCQU5LQUNDVEZST00+DQogICAgICAgICAgPE | ||
234 | 15 | JBTktJRD4wMDAwMDAxMjM8L0JBTktJRD4NCiAgICAgICAgICA8QUNDVElEPjEyMzQ1Njwv | ||
235 | 16 | QUNDVElEPg0KICAgICAgICAgIDxBQ0NUVFlQRT5DSEVDS0lORzwvQUNDVFRZUEU+DQogIC | ||
236 | 17 | AgICAgIDwvQkFOS0FDQ1RGUk9NPg0KICAgICAgICA8QkFOS1RSQU5MSVNUPg0KICAgICAg | ||
237 | 18 | ICAgIDxEVFNUQVJUPjIwMTQwODAxPC9EVFNUQVJUPg0KICAgICAgICAgIDxEVEVORD4yMD | ||
238 | 19 | E0MDgzMTE2NTE1My4wMDBbLTg6UFNUXTwvRFRFTkQ+DQogICAgICAgICAgPFNUTVRUUk4+ | ||
239 | 20 | DQogICAgICAgICAgICA8VFJOVFlQRT5QT1M8L1RSTlRZUEU+DQogICAgICAgICAgICA8RF | ||
240 | 21 | RQT1NURUQ+MjAwNTA4MjQwODAwMDA8L0RUUE9TVEVEPg0KICAgICAgICAgICAgPFRSTkFN | ||
241 | 22 | VD4tODA8L1RSTkFNVD4NCiAgICAgICAgICAgIDxGSVRJRD4yMTkzNzg8L0ZJVElEPg0KIC | ||
242 | 23 | AgICAgICAgICAgPE5BTUU+RnJvZ0tpY2sgU2N1YmEgR2VhcjwvTkFNRT4NCiAgICAgICAg | ||
243 | 24 | ICA8L1NUTVRUUk4+DQogICAgICAgIDwvQkFOS1RSQU5MSVNUPg0KICAgICAgICA8TEVER0 | ||
244 | 25 | VSQkFMPg0KICAgICAgICAgIDxCQUxBTVQ+MjE1Ni41NjwvQkFMQU1UPg0KICAgICAgICAg | ||
245 | 26 | IDxEVEFTT0Y+MjAwNTA4MzExNjUxNTM8L0RUQVNPRj4NCiAgICAgICAgPC9MRURHRVJCQU | ||
246 | 27 | w+DQogICAgICA8L1NUTVRSUz4NCiAgICA8L1NUTVRUUk5SUz4NCiAgPC9CQU5LTVNHU1JT | ||
247 | 28 | VjE+DQogIDxDUkVESVRDQVJETVNHU1JTVjE+DQogICAgPENDU1RNVFRSTlJTPg0KICAgIC | ||
248 | 29 | AgPFRSTlVJRD4wPC9UUk5VSUQ+DQogICAgICA8U1RBVFVTPg0KICAgICAgICA8Q09ERT4w | ||
249 | 30 | PC9DT0RFPg0KICAgICAgICA8U0VWRVJJVFk+SU5GTzwvU0VWRVJJVFk+DQogICAgICA8L1 | ||
250 | 31 | NUQVRVUz4NCiAgICAgIDxDQ1NUTVRSUz4NCiAgICAgICAgPENVUkRFRj5VU0Q8L0NVUkRF | ||
251 | 32 | Rj4NCiAgICAgICAgPENDQUNDVEZST00+DQogICAgICAgICAgPEFDQ1RJRD4xMjM0MTIzND | ||
252 | 33 | EyMzQ8L0FDQ1RJRD4NCiAgICAgICAgPC9DQ0FDQ1RGUk9NPg0KICAgICAgICA8QkFOS1RS | ||
253 | 34 | QU5MSVNUPg0KICAgICAgICAgIDxEVFNUQVJUPjIwMTQwODAxPC9EVFNUQVJUPg0KICAgIC | ||
254 | 35 | AgICAgIDxEVEVORD4yMDE0MDgzMTE2NTE1My4wMDBbLTg6UFNUXTwvRFRFTkQ+DQogICAg | ||
255 | 36 | ICAgICAgPFNUTVRUUk4+DQogICAgICAgICAgICA8VFJOVFlQRT5JTlQ8L1RSTlRZUEU+DQ | ||
256 | 37 | ogICAgICAgICAgICA8RFRQT1NURUQ+MjAwNTA4MTEwODAwMDA8L0RUUE9TVEVEPg0KICAg | ||
257 | 38 | ICAgICAgICAgPFRSTkFNVD4tMjMuMDA8L1RSTkFNVD4NCiAgICAgICAgICAgIDxGSVRJRD | ||
258 | 39 | 4yMTk4Njc8L0ZJVElEPg0KICAgICAgICAgICAgPE5BTUU+SW50ZXJlc3QgQ2hhcmdlPC9O | ||
259 | 40 | QU1FPg0KICAgICAgICAgIDwvU1RNVFRSTj4NCiAgICAgICAgICA8U1RNVFRSTj4NCiAgIC | ||
260 | 41 | AgICAgICAgIDxUUk5UWVBFPkNSRURJVDwvVFJOVFlQRT4NCiAgICAgICAgICAgIDxEVFBP | ||
261 | 42 | U1RFRD4yMDA1MDgxMTA4MDAwMDwvRFRQT1NURUQ+DQogICAgICAgICAgICA8VFJOQU1UPj | ||
262 | 43 | M1MC4wMDwvVFJOQU1UPg0KICAgICAgICAgICAgPEZJVElEPjIxOTg2ODwvRklUSUQ+DQog | ||
263 | 44 | ICAgICAgICAgICA8TkFNRT5QYXltZW50IC0gVGhhbmsgWW91PC9OQU1FPg0KICAgICAgIC | ||
264 | 45 | AgIDwvU1RNVFRSTj4NCiAgICAgICAgPC9CQU5LVFJBTkxJU1Q+DQogICAgICAgIDxMRURH | ||
265 | 46 | RVJCQUw+DQogICAgICAgICAgPEJBTEFNVD4tNTYyLjAwPC9CQUxBTVQ+DQogICAgICAgIC | ||
266 | 47 | AgPERUQVNPRj4yMDA1MDgzMTE2NTE1MzwvRFRBU09GPg0KICAgICAgICA8L0xFREdFUkJB | ||
267 | 48 | TD4NCiAgICAgIDwvQ0NTVE1UUlM+DQogICAgPC9DQ1NUTVRUUk5SUz4NCiAgPC9DUkVESV | ||
268 | 49 | RDQVJETVNHU1JTVjE+DQo8L09GWD4NCg==""" | ||
269 | 50 | |||
270 | 51 | class TestOfxFile(TransactionCase): | ||
271 | 52 | """Tests for import bank statement ofx file format (account.bank.statement.import) | ||
272 | 53 | """ | ||
273 | 54 | |||
274 | 55 | def setUp(self): | ||
275 | 56 | super(TestOfxFile, self).setUp() | ||
276 | 57 | self.statement_import_model = self.registry('account.bank.statement.import') | ||
277 | 58 | self.bank_statement_model = self.registry('account.bank.statement') | ||
278 | 59 | |||
279 | 60 | def test_ofx_file_import(self): | ||
280 | 61 | cr, uid = self.cr, self.uid | ||
281 | 62 | bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk') | ||
282 | 63 | self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False | ||
283 | 64 | bank_statement_id = self.statement_import_model.create(cr, uid, dict( | ||
284 | 65 | file_type = 'ofx', | ||
285 | 66 | data_file = ofx_file, | ||
286 | 67 | account_id = self.bank_temp_id | ||
287 | 68 | )) | ||
288 | 69 | self.statement_import_model.parse_file(cr, uid, [bank_statement_id]) | ||
289 | 70 | statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '000000123')])[0] | ||
290 | 71 | bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) | ||
291 | 72 | self.assertEquals(bank_st_record.balance_start, 2156.56) | ||
292 | 73 | self.assertEquals(bank_st_record.balance_end_real, 2076.56) | ||
293 | 0 | 74 | ||
294 | === modified file 'account/wizard/account_financial_report.py' | |||
295 | --- account/wizard/account_financial_report.py 2013-10-27 12:31:04 +0000 | |||
296 | +++ account/wizard/account_financial_report.py 2014-04-02 04:28:41 +0000 | |||
297 | @@ -2,7 +2,7 @@ | |||
298 | 2 | ############################################################################## | 2 | ############################################################################## |
299 | 3 | # | 3 | # |
300 | 4 | # OpenERP, Open Source Management Solution | 4 | # OpenERP, Open Source Management Solution |
302 | 5 | # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). | 5 | # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>). |
303 | 6 | # | 6 | # |
304 | 7 | # This program is free software: you can redistribute it and/or modify | 7 | # This program is free software: you can redistribute it and/or modify |
305 | 8 | # it under the terms of the GNU Affero General Public License as | 8 | # it under the terms of the GNU Affero General Public License as |
306 | 9 | 9 | ||
307 | === added directory 'account_qif' | |||
308 | === added file 'account_qif/__init__.py' | |||
309 | --- account_qif/__init__.py 1970-01-01 00:00:00 +0000 | |||
310 | +++ account_qif/__init__.py 2014-04-02 04:28:41 +0000 | |||
311 | @@ -0,0 +1,24 @@ | |||
312 | 1 | # -*- coding: utf-8 -*- | ||
313 | 2 | ############################################################################## | ||
314 | 3 | # | ||
315 | 4 | # OpenERP, Open Source Management Solution | ||
316 | 5 | # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>). | ||
317 | 6 | # | ||
318 | 7 | # This program is free software: you can redistribute it and/or modify | ||
319 | 8 | # it under the terms of the GNU Affero General Public License as | ||
320 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
321 | 10 | # License, or (at your option) any later version. | ||
322 | 11 | # | ||
323 | 12 | # This program is distributed in the hope that it will be useful, | ||
324 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
325 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
326 | 15 | # GNU Affero General Public License for more details. | ||
327 | 16 | # | ||
328 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
329 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
330 | 19 | # | ||
331 | 20 | ############################################################################## | ||
332 | 21 | |||
333 | 22 | import account_qif | ||
334 | 23 | |||
335 | 24 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
336 | 0 | 25 | ||
337 | === added file 'account_qif/__openerp__.py' | |||
338 | --- account_qif/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
339 | +++ account_qif/__openerp__.py 2014-04-02 04:28:41 +0000 | |||
340 | @@ -0,0 +1,49 @@ | |||
341 | 1 | # -*- coding: utf-8 -*- | ||
342 | 2 | ############################################################################## | ||
343 | 3 | # | ||
344 | 4 | # OpenERP, Open Source Management Solution | ||
345 | 5 | # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>). | ||
346 | 6 | # | ||
347 | 7 | # This program is free software: you can redistribute it and/or modify | ||
348 | 8 | # it under the terms of the GNU Affero General Public License as | ||
349 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
350 | 10 | # License, or (at your option) any later version. | ||
351 | 11 | # | ||
352 | 12 | # This program is distributed in the hope that it will be useful, | ||
353 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
354 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
355 | 15 | # GNU Affero General Public License for more details. | ||
356 | 16 | # | ||
357 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
358 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
359 | 19 | # | ||
360 | 20 | ############################################################################## | ||
361 | 21 | |||
362 | 22 | { | ||
363 | 23 | 'name': 'Import QIF Bank Statement', | ||
364 | 24 | 'version': '1.1', | ||
365 | 25 | 'author': 'OpenERP SA', | ||
366 | 26 | 'category': 'Accounting & Finance', | ||
367 | 27 | 'description': ''' | ||
368 | 28 | Module to import QIF bank statements. | ||
369 | 29 | ====================================== | ||
370 | 30 | |||
371 | 31 | The machine readable QIF Files are parsed and stored in human readable format in | ||
372 | 32 | Bank Statements. Also Bank Statements are generated containing a subset of | ||
373 | 33 | the QIF information (only those transaction lines that are required for the | ||
374 | 34 | creation of the Financial Accounting records). The Bank Statement is a | ||
375 | 35 | 'read-only' object, hence remaining a reliable representation of the original | ||
376 | 36 | QIF file whereas the Bank Statement will get modified as required by accounting | ||
377 | 37 | business processes. | ||
378 | 38 | |||
379 | 39 | QIF Bank Accounts configured as type 'QIF' will only generate QIF Bank Statements. | ||
380 | 40 | ''', | ||
381 | 41 | 'images' : [], | ||
382 | 42 | 'depends': ['account'], | ||
383 | 43 | 'demo': [], | ||
384 | 44 | 'data': [], | ||
385 | 45 | 'auto_install': False, | ||
386 | 46 | 'installable': True, | ||
387 | 47 | } | ||
388 | 48 | |||
389 | 49 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
390 | 0 | 50 | ||
391 | === added file 'account_qif/account_qif.py' | |||
392 | --- account_qif/account_qif.py 1970-01-01 00:00:00 +0000 | |||
393 | +++ account_qif/account_qif.py 2014-04-02 04:28:41 +0000 | |||
394 | @@ -0,0 +1,96 @@ | |||
395 | 1 | # -*- coding: utf-8 -*- | ||
396 | 2 | ############################################################################## | ||
397 | 3 | # | ||
398 | 4 | # OpenERP, Open Source Management Solution | ||
399 | 5 | # Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>). | ||
400 | 6 | # | ||
401 | 7 | # This program is free software: you can redistribute it and/or modify | ||
402 | 8 | # it under the terms of the GNU Affero General Public License as | ||
403 | 9 | # published by the Free Software Foundation, either version 3 of the | ||
404 | 10 | # License, or (at your option) any later version. | ||
405 | 11 | # | ||
406 | 12 | # This program is distributed in the hope that it will be useful, | ||
407 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
408 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
409 | 15 | # GNU Affero General Public License for more details. | ||
410 | 16 | # | ||
411 | 17 | # You should have received a copy of the GNU Affero General Public License | ||
412 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
413 | 19 | # | ||
414 | 20 | ############################################################################## | ||
415 | 21 | |||
416 | 22 | import dateutil.parser | ||
417 | 23 | import base64 | ||
418 | 24 | import logging | ||
419 | 25 | from tempfile import TemporaryFile | ||
420 | 26 | |||
421 | 27 | from openerp.tools.translate import _ | ||
422 | 28 | from openerp.osv import fields, osv | ||
423 | 29 | from openerp import tools | ||
424 | 30 | |||
425 | 31 | _logger = logging.getLogger(__name__) | ||
426 | 32 | |||
427 | 33 | from openerp.addons.account import account_bank_statement_import as ibs | ||
428 | 34 | |||
429 | 35 | ibs._IMPORT_FILE_TYPE.append(('qif', 'QIF')) | ||
430 | 36 | |||
431 | 37 | class account_bank_statement_import(osv.TransientModel): | ||
432 | 38 | _inherit = "account.bank.statement.import" | ||
433 | 39 | |||
434 | 40 | _columns = { | ||
435 | 41 | 'file_type': fields.selection(ibs._IMPORT_FILE_TYPE, 'File Type'), | ||
436 | 42 | } | ||
437 | 43 | |||
438 | 44 | def process_qif(self, cr, uid, data_file, journal_id=False, account_id=False, context=None): | ||
439 | 45 | try: | ||
440 | 46 | fileobj = TemporaryFile('wb+') | ||
441 | 47 | fileobj.write(base64.b64decode(data_file)) | ||
442 | 48 | fileobj.seek(0) | ||
443 | 49 | file_data = "" | ||
444 | 50 | for line in fileobj.readlines(): | ||
445 | 51 | file_data += line | ||
446 | 52 | fileobj.close() | ||
447 | 53 | if '\r' in file_data: | ||
448 | 54 | data_list = file_data.split('\r') | ||
449 | 55 | else: | ||
450 | 56 | data_list = file_data.split('\n') | ||
451 | 57 | header = data_list[0].strip() | ||
452 | 58 | header = header.split(":")[1] | ||
453 | 59 | except: | ||
454 | 60 | raise osv.except_osv(_('Import Error!'), _('Please check QIF file format is proper or not.')) | ||
455 | 61 | line_ids = [] | ||
456 | 62 | vals_line = {} | ||
457 | 63 | total = 0 | ||
458 | 64 | if header == "Bank": | ||
459 | 65 | vals_bank_statement = {} | ||
460 | 66 | for line in data_list: | ||
461 | 67 | line = line.strip() | ||
462 | 68 | if not line: continue | ||
463 | 69 | if line[0] == 'D': # date of transaction | ||
464 | 70 | vals_line['date'] = dateutil.parser.parse(line[1:], fuzzy=True).date() | ||
465 | 71 | if vals_line.get('date'): | ||
466 | 72 | period_ids = self.pool.get('account.period').find(cr, uid, vals_line['date'], context=context) | ||
467 | 73 | vals_bank_statement.update({'period_id': period_ids and period_ids[0] or False}) | ||
468 | 74 | elif line[0] == 'T': # Total amount | ||
469 | 75 | total += float(line[1:].replace(',', '')) | ||
470 | 76 | vals_line['amount'] = float(line[1:].replace(',', '')) | ||
471 | 77 | elif line[0] == 'N': # Check number | ||
472 | 78 | vals_line['ref'] = line[1:] | ||
473 | 79 | elif line[0] == 'P': # Payee | ||
474 | 80 | vals_line['name'] = line[1:] | ||
475 | 81 | elif line[0] == '^': # end of item | ||
476 | 82 | vals_line['account_id'] = account_id | ||
477 | 83 | line_ids.append((0, 0, vals_line)) | ||
478 | 84 | vals_line = {} | ||
479 | 85 | elif line[0] == '\n': | ||
480 | 86 | line_ids = [] | ||
481 | 87 | else: | ||
482 | 88 | pass | ||
483 | 89 | else: | ||
484 | 90 | raise osv.except_osv(_('Error!'), _('Cannot support this Format !Type:%s.') % (header,)) | ||
485 | 91 | vals_bank_statement.update({'balance_end_real': total, | ||
486 | 92 | 'line_ids': line_ids, | ||
487 | 93 | 'journal_id': journal_id}) | ||
488 | 94 | return vals_bank_statement | ||
489 | 95 | |||
490 | 96 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||
491 | 0 | 97 | ||
492 | === added directory 'account_qif/tests' | |||
493 | === added file 'account_qif/tests/__init__.py' | |||
494 | --- account_qif/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
495 | +++ account_qif/tests/__init__.py 2014-04-02 04:28:41 +0000 | |||
496 | @@ -0,0 +1,4 @@ | |||
497 | 1 | from . import test_import_bank_statement | ||
498 | 2 | checks = [ | ||
499 | 3 | test_import_bank_statement | ||
500 | 4 | ] | ||
501 | 0 | 5 | ||
502 | === added file 'account_qif/tests/test_import_bank_statement.py' | |||
503 | --- account_qif/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000 | |||
504 | +++ account_qif/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000 | |||
505 | @@ -0,0 +1,30 @@ | |||
506 | 1 | from openerp.tests.common import TransactionCase | ||
507 | 2 | |||
508 | 3 | qif_file = """IVR5cGU6QmFuawpEOC8xMi8xNApULTEsMDAwLjAwClBGcmFua3MgUGx1bWJpbmcKXgpEOC8xNS8xNApULTc1L | ||
509 | 4 | jQ2ClBXYWx0cyBEcnVncwpeCkQzLzMvMTQKVC0zNzkuMDAKUENJVFkgT0YgU1BSSU5HRklFTEQKXgpEMy80LzE0ClQtMjAuM | ||
510 | 5 | jgKUFlPVVIgTE9DQUwgU1VQRVJNQVJLRVQKXgpEMy8zLzE0ClQtNDIxLjM1ClBTUFJJTkdGSUVMRCBXQVRFUiBVVElMSVRZCl4K""" | ||
511 | 6 | |||
512 | 7 | class TestQifFile(TransactionCase): | ||
513 | 8 | """Tests for import bank statement qif file format (account.bank.statement.import) | ||
514 | 9 | """ | ||
515 | 10 | |||
516 | 11 | def setUp(self): | ||
517 | 12 | super(TestQifFile, self).setUp() | ||
518 | 13 | self.statement_import_model = self.registry('account.bank.statement.import') | ||
519 | 14 | self.bank_statement_model = self.registry('account.bank.statement') | ||
520 | 15 | self.bank_statement_line_model = self.registry('account.bank.statement.line') | ||
521 | 16 | |||
522 | 17 | def test_qif_file_import(self): | ||
523 | 18 | cr, uid = self.cr, self.uid | ||
524 | 19 | bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk') | ||
525 | 20 | self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False | ||
526 | 21 | bank_statement_id = self.statement_import_model.create(cr, uid, dict( | ||
527 | 22 | file_type = 'qif', | ||
528 | 23 | data_file = qif_file, | ||
529 | 24 | account_id = self.bank_temp_id | ||
530 | 25 | )) | ||
531 | 26 | self.statement_import_model.parse_file(cr, uid, [bank_statement_id]) | ||
532 | 27 | line_id = self.bank_statement_line_model.search(cr, uid, [('name', '=', 'YOUR LOCAL SUPERMARKET')])[0] | ||
533 | 28 | statement_id = self.bank_statement_line_model.browse(cr, uid, line_id).statement_id.id | ||
534 | 29 | bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) | ||
535 | 30 | self.assertEquals(bank_st_record.balance_end_real, -1896.09) | ||
536 | 0 | 31 | ||
537 | === modified file 'l10n_be_coda/__openerp__.py' | |||
538 | --- l10n_be_coda/__openerp__.py 2012-12-06 11:18:16 +0000 | |||
539 | +++ l10n_be_coda/__openerp__.py 2014-04-02 04:28:41 +0000 | |||
540 | @@ -93,7 +93,6 @@ | |||
541 | 93 | 'depends': ['account_voucher','base_iban', 'l10n_be_invoice_bba',], | 93 | 'depends': ['account_voucher','base_iban', 'l10n_be_invoice_bba',], |
542 | 94 | 'demo': [], | 94 | 'demo': [], |
543 | 95 | 'data': [ | 95 | 'data': [ |
544 | 96 | 'l10n_be_coda_wizard.xml', | ||
545 | 97 | 'l10n_be_coda_view.xml', | 96 | 'l10n_be_coda_view.xml', |
546 | 98 | ], | 97 | ], |
547 | 99 | 'auto_install': False, | 98 | 'auto_install': False, |
548 | 100 | 99 | ||
549 | === modified file 'l10n_be_coda/l10n_be_coda_view.xml' | |||
550 | --- l10n_be_coda/l10n_be_coda_view.xml 2013-10-27 12:31:04 +0000 | |||
551 | +++ l10n_be_coda/l10n_be_coda_view.xml 2014-04-02 04:28:41 +0000 | |||
552 | @@ -93,6 +93,5 @@ | |||
553 | 93 | </record> | 93 | </record> |
554 | 94 | 94 | ||
555 | 95 | <menuitem name="Bank Statement Lines" parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_line_coda" action="action_account_bank_statement_line_coda" sequence="8" groups="base.group_no_one"/> | 95 | <menuitem name="Bank Statement Lines" parent="account.menu_finance_bank_and_cash" id="menu_account_bank_statement_line_coda" action="action_account_bank_statement_line_coda" sequence="8" groups="base.group_no_one"/> |
556 | 96 | <menuitem name="Import CODA File" parent="account.menu_finance_bank_and_cash" id="menu_account_coda_import" action="action_account_coda_import" sequence="10"/> | ||
557 | 97 | </data> | 96 | </data> |
558 | 98 | </openerp> | ||
559 | 99 | \ No newline at end of file | 97 | \ No newline at end of file |
560 | 98 | </openerp> | ||
561 | 100 | 99 | ||
562 | === removed file 'l10n_be_coda/l10n_be_coda_wizard.xml' | |||
563 | --- l10n_be_coda/l10n_be_coda_wizard.xml 2012-12-20 14:52:27 +0000 | |||
564 | +++ l10n_be_coda/l10n_be_coda_wizard.xml 1970-01-01 00:00:00 +0000 | |||
565 | @@ -1,35 +0,0 @@ | |||
566 | 1 | <?xml version="1.0" ?> | ||
567 | 2 | <openerp> | ||
568 | 3 | <data> | ||
569 | 4 | |||
570 | 5 | <record id="account_coda_import_view" model="ir.ui.view"> | ||
571 | 6 | <field name="name">Import CODA File</field> | ||
572 | 7 | <field name="model">account.coda.import</field> | ||
573 | 8 | <field name="priority">1</field> | ||
574 | 9 | <field name="arch" type="xml"> | ||
575 | 10 | <form string="Import CODA File" version="7.0"> | ||
576 | 11 | <group col="2"> | ||
577 | 12 | <field name="coda_data" filename="coda_fname"/> | ||
578 | 13 | <field name="temporary_account_id" /> | ||
579 | 14 | </group> | ||
580 | 15 | <footer> | ||
581 | 16 | <button name="coda_parsing" string="_Import" type="object" class="oe_highlight"/> | ||
582 | 17 | or | ||
583 | 18 | <button string="Cancel" class="oe_link" special="cancel"/> | ||
584 | 19 | </footer> | ||
585 | 20 | </form> | ||
586 | 21 | </field> | ||
587 | 22 | </record> | ||
588 | 23 | |||
589 | 24 | <record id="action_account_coda_import" model="ir.actions.act_window"> | ||
590 | 25 | <field name="name">Import CODA File</field> | ||
591 | 26 | <field name="type">ir.actions.act_window</field> | ||
592 | 27 | <field name="res_model">account.coda.import</field> | ||
593 | 28 | <field name="view_type">form</field> | ||
594 | 29 | <field name="view_mode">form</field> | ||
595 | 30 | <field name="target">new</field> | ||
596 | 31 | <field name="view_id" ref="account_coda_import_view"/> | ||
597 | 32 | </record> | ||
598 | 33 | |||
599 | 34 | </data> | ||
600 | 35 | </openerp> | ||
601 | 36 | 0 | ||
602 | === renamed file 'l10n_be_coda/test_coda_file/Ontvangen_CODA.2011-01-11-18.59.15.txt' => 'l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt' | |||
603 | --- l10n_be_coda/test_coda_file/Ontvangen_CODA.2011-01-11-18.59.15.txt 2012-01-31 13:36:57 +0000 | |||
604 | +++ l10n_be_coda/test_coda_file/Ontvangen_CODA.2013-01-11-18.59.15.txt 2014-04-02 04:28:41 +0000 | |||
605 | @@ -1,24 +1,24 @@ | |||
607 | 1 | 0000011011172505 00178299 DE MEYER LUC KREDBEBB 00820512013 00000 2 | 1 | 0000011011472505 00178299 DE MEYER LUC KREDBEBB 00820512014 00000 2 |
608 | 2 | 12135BE33737018595246 EUR0000000011812700270710NOVIAT NV KBC-Business Comfortrekening 003 | 2 | 12135BE33737018595246 EUR0000000011812700270710NOVIAT NV KBC-Business Comfortrekening 003 |
610 | 3 | 2100010000OL44483FW SCTOFBIONLO1000000000435000110111001010000MEDEDELING 11011113501 0 | 3 | 2100010000OL44483FW SCTOFBIONLO1000000000435000110114001010000MEDEDELING 11011413501 0 |
611 | 4 | 2200010000 GKCCBEBB 1 0 | 4 | 2200010000 GKCCBEBB 1 0 |
612 | 5 | 2300010000BE41063012345610 PARTNER 1 0 1 | 5 | 2300010000BE41063012345610 PARTNER 1 0 1 |
613 | 6 | 3100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 0 | 6 | 3100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 0 |
615 | 7 | 2100020000OL4414AC8BOVSOVSOVERS00000000030444501101110015000002010237 11011113501 0 | 7 | 2100020000OL4414AC8BOVSOVSOVERS00000000030444501101140015000002010237 11011413501 0 |
616 | 8 | 2200020000 BBRUBEBB 1 0 | 8 | 2200020000 BBRUBEBB 1 0 |
617 | 9 | 2300020000BE61310126985517 PARTNER 2 0 1 | 9 | 2300020000BE61310126985517 PARTNER 2 0 1 |
618 | 10 | 3100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0 | 10 | 3100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0 |
619 | 11 | 3200020001MOLENSTRAAT 60 9340 LEDE 0 0 | 11 | 3200020001MOLENSTRAAT 60 9340 LEDE 0 0 |
627 | 12 | 2100030000AFECA0CVA IKLINNINNIG1000000000479040110111313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011113510 0 | 12 | 2100030000AFECA0CVA IKLINNINNIG1000000000479040110114313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011413510 0 |
628 | 13 | 2100030001AFECA0CVA IKLINNINNIG1000000000419920110111813410660 11011113500 0 | 13 | 2100030001AFECA0CVA IKLINNINNIG1000000000419920110114813410660 11011413500 0 |
629 | 14 | 2100030002AFECA0CVA IKLINNINNIG1000000000059120110111813410020 11011113510 0 | 14 | 2100030002AFECA0CVA IKLINNINNIG1000000000059120110114813410020 11011413510 0 |
630 | 15 | 2100040000AFECA0CVA IKLINNINNIG1000000000479040110111313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011113510 0 | 15 | 2100040000AFECA0CVA IKLINNINNIG1000000000479040110114313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011413510 0 |
631 | 16 | 2100040001AFECA0CVA IKLINNINNIG1000000000419920110111813410660 11011113500 0 | 16 | 2100040001AFECA0CVA IKLINNINNIG1000000000419920110114813410660 11011413500 0 |
632 | 17 | 2100040002AFECA0CVA IKLINNINNIG1000000000059120110111813410020 11011113510 0 | 17 | 2100040002AFECA0CVA IKLINNINNIG1000000000059120110114813410020 11011413510 0 |
633 | 18 | 2100050000AOGM00160BSCTOBOGOVER0000000000063740110111001500000TERUGGAVE 37232481 8400083296 . 11011113501 0 | 18 | 2100050000AOGM00160BSCTOBOGOVER0000000000063740110114001500000TERUGGAVE 37232481 8400083296 . 11011413501 0 |
634 | 19 | 2200050000 362/363 KREDBEBB 1 0 | 19 | 2200050000 362/363 KREDBEBB 1 0 |
635 | 20 | 2300050000BE43730004200601 KBC VERZEKERINGEN NV 0 1 | 20 | 2300050000BE43730004200601 KBC VERZEKERINGEN NV 0 1 |
636 | 21 | 3100050001AOGM00160BSCTOBOGOVER001500001001KBC VERZEKERINGEN NV 1 0 | 21 | 3100050001AOGM00160BSCTOBOGOVER001500001001KBC VERZEKERINGEN NV 1 0 |
637 | 22 | 3200050001VAN OVERSTRAETENPLEIN 2 3000 LEUVEN 0 0 | 22 | 3200050001VAN OVERSTRAETENPLEIN 2 3000 LEUVEN 0 0 |
639 | 23 | 8135BE44734024486445 EUR0000000013527810110111 0 | 23 | 8135BE44734024486445 EUR0000000013527810110114 0 |
640 | 24 | 9 000022000000001393080000000003108190 2 | 24 | 9 000022000000001393080000000003108190 2 |
641 | 25 | 25 | ||
642 | === added directory 'l10n_be_coda/tests' | |||
643 | === added file 'l10n_be_coda/tests/__init__.py' | |||
644 | --- l10n_be_coda/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
645 | +++ l10n_be_coda/tests/__init__.py 2014-04-02 04:28:41 +0000 | |||
646 | @@ -0,0 +1,4 @@ | |||
647 | 1 | from . import test_import_bank_statement | ||
648 | 2 | checks = [ | ||
649 | 3 | test_import_bank_statement | ||
650 | 4 | ] | ||
651 | 0 | 5 | ||
652 | === added file 'l10n_be_coda/tests/test_import_bank_statement.py' | |||
653 | --- l10n_be_coda/tests/test_import_bank_statement.py 1970-01-01 00:00:00 +0000 | |||
654 | +++ l10n_be_coda/tests/test_import_bank_statement.py 2014-04-02 04:28:41 +0000 | |||
655 | @@ -0,0 +1,39 @@ | |||
656 | 1 | from openerp.tests.common import TransactionCase | ||
657 | 2 | from openerp.modules.module import get_module_resource | ||
658 | 3 | |||
659 | 4 | class TestCodaFile(TransactionCase): | ||
660 | 5 | """Tests for import bank statement coda file format (account.bank.statement.import) | ||
661 | 6 | """ | ||
662 | 7 | |||
663 | 8 | def setUp(self): | ||
664 | 9 | super(TestCodaFile, self).setUp() | ||
665 | 10 | self.statement_import_model = self.registry('account.bank.statement.import') | ||
666 | 11 | self.bank_statement_model = self.registry('account.bank.statement') | ||
667 | 12 | |||
668 | 13 | def test_coda_file_import(self): | ||
669 | 14 | cr, uid = self.cr, self.uid | ||
670 | 15 | bank_temp_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'account', 'conf_bnk') | ||
671 | 16 | partner_id_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'main_partner') | ||
672 | 17 | company_id_ref = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'main_company') | ||
673 | 18 | self.bank_temp_id = bank_temp_ref and bank_temp_ref[1] or False | ||
674 | 19 | self.partner_id = partner_id_ref and partner_id_ref[1] or False | ||
675 | 20 | self.company_id = company_id_ref and company_id_ref[1] or False | ||
676 | 21 | coda_file_path = get_module_resource('l10n_be_coda', 'test_coda_file', 'Ontvangen_CODA.2013-01-11-18.59.15.txt') | ||
677 | 22 | coda_file = open(coda_file_path, 'rb').read().encode('base64') | ||
678 | 23 | bank_account_id = self.registry('res.partner.bank').create(cr, uid, dict( | ||
679 | 24 | state = 'bank', | ||
680 | 25 | acc_number = 'BE33737018595246', | ||
681 | 26 | bank_name = 'Reserve', | ||
682 | 27 | partner_id = self.partner_id, | ||
683 | 28 | company_id = self.company_id | ||
684 | 29 | )) | ||
685 | 30 | bank_statement_id = self.statement_import_model.create(cr, uid, dict( | ||
686 | 31 | file_type = 'coda', | ||
687 | 32 | data_file = coda_file, | ||
688 | 33 | account_id = self.bank_temp_id | ||
689 | 34 | )) | ||
690 | 35 | self.statement_import_model.parse_file(cr, uid, [bank_statement_id]) | ||
691 | 36 | statement_id = self.bank_statement_model.search(cr, uid, [('name', '=', '135')])[0] | ||
692 | 37 | bank_st_record = self.bank_statement_model.browse(cr, uid, statement_id) | ||
693 | 38 | self.assertEquals(bank_st_record.balance_start, 11812.70) | ||
694 | 39 | self.assertEquals(bank_st_record.balance_end_real, 13527.81) | ||
695 | 0 | 40 | ||
696 | === modified file 'l10n_be_coda/wizard/account_coda_import.py' | |||
697 | --- l10n_be_coda/wizard/account_coda_import.py 2013-10-27 12:31:04 +0000 | |||
698 | +++ l10n_be_coda/wizard/account_coda_import.py 2014-04-02 04:28:41 +0000 | |||
699 | @@ -30,44 +30,21 @@ | |||
700 | 30 | 30 | ||
701 | 31 | _logger = logging.getLogger(__name__) | 31 | _logger = logging.getLogger(__name__) |
702 | 32 | 32 | ||
705 | 33 | class account_coda_import(osv.osv_memory): | 33 | from openerp.addons.account import account_bank_statement_import as coda_ibs |
706 | 34 | _name = 'account.coda.import' | 34 | |
707 | 35 | coda_ibs._IMPORT_FILE_TYPE.append(('coda', 'CODA')) | ||
708 | 36 | |||
709 | 37 | class account_bank_statement_import(osv.TransientModel): | ||
710 | 38 | _inherit = "account.bank.statement.import" | ||
711 | 35 | _description = 'Import CODA File' | 39 | _description = 'Import CODA File' |
712 | 36 | _columns = { | 40 | _columns = { |
715 | 37 | 'coda_data': fields.binary('CODA File', required=True), | 41 | 'file_type': fields.selection(coda_ibs._IMPORT_FILE_TYPE, 'File Type'), |
714 | 38 | 'coda_fname': fields.char('CODA Filename', size=128, required=True), | ||
716 | 39 | 'note': fields.text('Log'), | 42 | 'note': fields.text('Log'), |
734 | 40 | 'temporary_account_id': fields.many2one('account.account', 'Temporary Account', domain="[('type','!=','view')]", help="It acts as a temporary account for general amount", required=True), | 43 | } |
735 | 41 | } | 44 | |
736 | 42 | 45 | def process_coda(self, cr, uid, codafile, journal_id=False, account_id=False, context=None): | |
720 | 43 | def _get_default_tmp_account(self, cr, uid, context): | ||
721 | 44 | tmp_accounts = self.pool.get('account.account').search(cr, uid, [('code', '=', '490000')]) | ||
722 | 45 | if tmp_accounts and len(tmp_accounts) > 0: | ||
723 | 46 | tmp_account_id = tmp_accounts[0] | ||
724 | 47 | else: | ||
725 | 48 | tmp_account_id = False | ||
726 | 49 | return tmp_account_id | ||
727 | 50 | |||
728 | 51 | _defaults = { | ||
729 | 52 | 'coda_fname': lambda *a: '', | ||
730 | 53 | 'temporary_account_id': _get_default_tmp_account, | ||
731 | 54 | } | ||
732 | 55 | |||
733 | 56 | def coda_parsing(self, cr, uid, ids, context=None, batch=False, codafile=None, codafilename=None): | ||
737 | 57 | if context is None: | 46 | if context is None: |
738 | 58 | context = {} | 47 | context = {} |
739 | 59 | if batch: | ||
740 | 60 | codafile = str(codafile) | ||
741 | 61 | codafilename = codafilename | ||
742 | 62 | else: | ||
743 | 63 | data = self.browse(cr, uid, ids)[0] | ||
744 | 64 | try: | ||
745 | 65 | codafile = data.coda_data | ||
746 | 66 | codafilename = data.coda_fname | ||
747 | 67 | temporaryaccount = data.temporary_account_id.id | ||
748 | 68 | except: | ||
749 | 69 | raise osv.except_osv(_('Error'), _('Wizard in incorrect state. Please hit the Cancel button')) | ||
750 | 70 | return {} | ||
751 | 71 | recordlist = unicode(base64.decodestring(codafile), 'windows-1252', 'strict').split('\n') | 48 | recordlist = unicode(base64.decodestring(codafile), 'windows-1252', 'strict').split('\n') |
752 | 72 | statements = [] | 49 | statements = [] |
753 | 73 | for line in recordlist: | 50 | for line in recordlist: |
754 | @@ -254,6 +231,7 @@ | |||
755 | 254 | statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin'] | 231 | statement['balance_end_real'] = statement['balance_start'] + statement['balancePlus'] - statement['balanceMin'] |
756 | 255 | for i, statement in enumerate(statements): | 232 | for i, statement in enumerate(statements): |
757 | 256 | statement['coda_note'] = '' | 233 | statement['coda_note'] = '' |
758 | 234 | statement_line = [] | ||
759 | 257 | balance_start_check_date = (len(statement['lines']) > 0 and statement['lines'][0]['entryDate']) or statement['date'] | 235 | balance_start_check_date = (len(statement['lines']) > 0 and statement['lines'][0]['entryDate']) or statement['date'] |
760 | 258 | cr.execute('SELECT balance_end_real \ | 236 | cr.execute('SELECT balance_end_real \ |
761 | 259 | FROM account_bank_statement \ | 237 | FROM account_bank_statement \ |
762 | @@ -278,7 +256,6 @@ | |||
763 | 278 | 'balance_start': statement['balance_start'], | 256 | 'balance_start': statement['balance_start'], |
764 | 279 | 'balance_end_real': statement['balance_end_real'], | 257 | 'balance_end_real': statement['balance_end_real'], |
765 | 280 | } | 258 | } |
766 | 281 | statement['id'] = self.pool.get('account.bank.statement').create(cr, uid, data, context=context) | ||
767 | 282 | for line in statement['lines']: | 259 | for line in statement['lines']: |
768 | 283 | if line['type'] == 'information': | 260 | if line['type'] == 'information': |
769 | 284 | statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' with Ref. ' + str(line['ref']), 'Date: ' + str(line['entryDate']), 'Communication: ' + line['communication'], '']) | 261 | statement['coda_note'] = "\n".join([statement['coda_note'], line['type'].title() + ' with Ref. ' + str(line['ref']), 'Date: ' + str(line['entryDate']), 'Communication: ' + line['communication'], '']) |
770 | @@ -372,12 +349,12 @@ | |||
771 | 372 | if partner.supplier: | 349 | if partner.supplier: |
772 | 373 | line['transaction_type'] = 'supplier' | 350 | line['transaction_type'] = 'supplier' |
773 | 374 | if not partner and not invoice: | 351 | if not partner and not invoice: |
775 | 375 | line['account'] = temporaryaccount | 352 | line['account'] = account_id |
776 | 376 | if 'communication' in line and line['communication'] != '': | 353 | if 'communication' in line and line['communication'] != '': |
777 | 377 | note.append(_('Communication') + ': ' + line['communication']) | 354 | note.append(_('Communication') + ': ' + line['communication']) |
778 | 378 | if 'voucher_id' not in line: | 355 | if 'voucher_id' not in line: |
779 | 379 | line['voucher_id'] = None | 356 | line['voucher_id'] = None |
781 | 380 | data = { | 357 | line_data = { |
782 | 381 | 'name': line['name'], | 358 | 'name': line['name'], |
783 | 382 | 'note': "\n".join(note), | 359 | 'note': "\n".join(note), |
784 | 383 | 'date': line['entryDate'], | 360 | 'date': line['entryDate'], |
785 | @@ -385,28 +362,16 @@ | |||
786 | 385 | 'type': line['transaction_type'], | 362 | 'type': line['transaction_type'], |
787 | 386 | 'partner_id': partner_id, | 363 | 'partner_id': partner_id, |
788 | 387 | 'account_id': line['account'], | 364 | 'account_id': line['account'], |
789 | 388 | 'statement_id': statement['id'], | ||
790 | 389 | 'ref': line['ref'], | 365 | 'ref': line['ref'], |
791 | 390 | 'sequence': line['sequence'], | 366 | 'sequence': line['sequence'], |
792 | 391 | 'voucher_id': line['voucher_id'], | 367 | 'voucher_id': line['voucher_id'], |
793 | 392 | 'coda_account_number': line['counterpartyNumber'], | 368 | 'coda_account_number': line['counterpartyNumber'], |
794 | 393 | } | 369 | } |
796 | 394 | self.pool.get('account.bank.statement.line').create(cr, uid, data, context=context) | 370 | statement_line.append((0, 0, line_data)) |
797 | 395 | if statement['coda_note'] != '': | 371 | if statement['coda_note'] != '': |
812 | 396 | self.pool.get('account.bank.statement').write(cr, uid, [statement['id']], {'coda_note': statement['coda_note']}, context=context) | 372 | data.update({'coda_note': statement['coda_note']}) |
813 | 397 | model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account', 'action_bank_statement_tree') | 373 | data.update({'journal_id': journal_id, 'line_ids' : statement_line}) |
814 | 398 | action = self.pool[model].browse(cr, uid, action_id, context=context) | 374 | return data |
801 | 399 | return { | ||
802 | 400 | 'name': action.name, | ||
803 | 401 | 'view_type': action.view_type, | ||
804 | 402 | 'view_mode': action.view_mode, | ||
805 | 403 | 'res_model': action.res_model, | ||
806 | 404 | 'domain': action.domain, | ||
807 | 405 | 'context': action.context, | ||
808 | 406 | 'type': 'ir.actions.act_window', | ||
809 | 407 | 'search_view_id': action.search_view_id.id, | ||
810 | 408 | 'views': [(v.view_id.id, v.view_mode) for v in action.view_ids] | ||
811 | 409 | } | ||
815 | 410 | 375 | ||
816 | 411 | 376 | ||
817 | 412 | def rmspaces(s): | 377 | def rmspaces(s): |