Merge lp:~gs.clearcorp/openerp-costa-rica/7.0_l10n_cr_account_banking_cr_promerica into lp:openerp-costa-rica

Proposed by Glen Sojo
Status: Merged
Merged at revision: 279
Proposed branch: lp:~gs.clearcorp/openerp-costa-rica/7.0_l10n_cr_account_banking_cr_promerica
Merge into: lp:openerp-costa-rica
Diff against target: 633 lines (+591/-2)
7 files modified
l10n_cr_account_banking_cr_davivienda/davivienda_parser.py (+0/-2)
l10n_cr_account_banking_promerica/__init__.py (+27/-0)
l10n_cr_account_banking_promerica/__openerp__.py (+52/-0)
l10n_cr_account_banking_promerica/i18n/es.po (+64/-0)
l10n_cr_account_banking_promerica/i18n/l10n_cr_account_banking_promerica.pot (+61/-0)
l10n_cr_account_banking_promerica/promerica.py (+208/-0)
l10n_cr_account_banking_promerica/promerica_parser.py (+179/-0)
To merge this branch: bzr merge lp:~gs.clearcorp/openerp-costa-rica/7.0_l10n_cr_account_banking_cr_promerica
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+214628@code.launchpad.net

Description of the change

[ADD] - new module l10n_cr_account_banking_promerica: module to allow the import of statement from Promerica Bank.

To post a comment you must log in.
280. By Glen Sojo

[FIX] - l10n_cr_account_banking_promerica: added main feature to module description

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_cr_account_banking_cr_davivienda/davivienda_parser.py'
2--- l10n_cr_account_banking_cr_davivienda/davivienda_parser.py 2014-03-06 15:45:09 +0000
3+++ l10n_cr_account_banking_cr_davivienda/davivienda_parser.py 2014-04-08 22:30:06 +0000
4@@ -313,5 +313,3 @@
5 output.append( self.parse_stamenent_record( rec ) )
6
7 return output
8-
9-
10
11=== added directory 'l10n_cr_account_banking_promerica'
12=== added file 'l10n_cr_account_banking_promerica/__init__.py'
13--- l10n_cr_account_banking_promerica/__init__.py 1970-01-01 00:00:00 +0000
14+++ l10n_cr_account_banking_promerica/__init__.py 2014-04-08 22:30:06 +0000
15@@ -0,0 +1,27 @@
16+# -*- encoding: utf-8 -*-
17+##############################################################################
18+#
19+# Copyright (C) 2011 credativ Ltd (<http://www.credativ.co.uk>).
20+# All Rights Reserved
21+#
22+# This program is free software: you can redistribute it and/or modify
23+# it under the terms of the GNU Affero General Public License as
24+# published by the Free Software Foundation, either version 3 of the
25+# License, or (at your option) any later version.
26+#
27+# This program is distributed in the hope that it will be useful,
28+# but WITHOUT ANY WARRANTY; without even the implied warranty of
29+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+# GNU Affero General Public License for more details.
31+#
32+# You should have received a copy of the GNU Affero General Public License
33+# along with this program. If not, see <http://www.gnu.org/licenses/>.
34+#
35+# Refractoring and customization by
36+# (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
37+#
38+##############################################################################
39+
40+import promerica
41+
42+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
43\ No newline at end of file
44
45=== added file 'l10n_cr_account_banking_promerica/__openerp__.py'
46--- l10n_cr_account_banking_promerica/__openerp__.py 1970-01-01 00:00:00 +0000
47+++ l10n_cr_account_banking_promerica/__openerp__.py 2014-04-08 22:30:06 +0000
48@@ -0,0 +1,52 @@
49+# -*- coding: utf-8 -*-
50+##############################################################################
51+#
52+# OpenERP, Open Source Management Solution
53+# Addons modules by CLEARCORP S.A.
54+# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
55+#
56+# This program is free software: you can redistribute it and/or modify
57+# it under the terms of the GNU Affero General Public License as
58+# published by the Free Software Foundation, either version 3 of the
59+# License, or (at your option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful,
62+# but WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+# GNU Affero General Public License for more details.
65+#
66+# You should have received a copy of the GNU Affero General Public License
67+# along with this program. If not, see <http://www.gnu.org/licenses/>.
68+#
69+##############################################################################
70+
71+{
72+ 'name': 'Promerica Bank Statement Importer',
73+ 'version' : '1.0',
74+ 'author' : 'CLEARCORP S.A.',
75+ 'complexity': 'normal',
76+ 'description': '''
77+Promerica Bank Statement Importer
78+=================================
79+Parser for Promerica's Bank Statements for the use with account_banking_ccorp module.
80+
81+Main Features
82+-------------
83+* Parse xlsx format bank statements.
84+* Serve bank statements to account_banking_ccorp module.
85+''',
86+ 'category': 'Accounting & Finance',
87+ 'sequence': 3,
88+ 'website' : 'http://clearcorp.co.cr',
89+ 'images' : [],
90+ 'depends' : ['account'],
91+ 'data' : [],
92+ 'init_xml' : [],
93+ 'demo_xml' : [],
94+ 'update_xml' : [],
95+ 'test' : [],
96+ 'auto_install': False,
97+ 'application': False,
98+ 'installable': True,
99+ 'license': 'AGPL-3',
100+}
101
102=== added directory 'l10n_cr_account_banking_promerica/i18n'
103=== added file 'l10n_cr_account_banking_promerica/i18n/es.po'
104--- l10n_cr_account_banking_promerica/i18n/es.po 1970-01-01 00:00:00 +0000
105+++ l10n_cr_account_banking_promerica/i18n/es.po 2014-04-08 22:30:06 +0000
106@@ -0,0 +1,64 @@
107+# Translation of OpenERP Server.
108+# This file contains the translation of the following modules:
109+# * l10n_cr_account_banking_promerica
110+#
111+msgid ""
112+msgstr ""
113+"Project-Id-Version: OpenERP Server 7.0\n"
114+"Report-Msgid-Bugs-To: \n"
115+"POT-Creation-Date: 2014-04-07 22:01+0000\n"
116+"PO-Revision-Date: 2014-04-07 22:01+0000\n"
117+"Last-Translator: <>\n"
118+"Language-Team: \n"
119+"MIME-Version: 1.0\n"
120+"Content-Type: text/plain; charset=UTF-8\n"
121+"Content-Transfer-Encoding: \n"
122+"Plural-Forms: \n"
123+
124+#. module: l10n_cr_account_banking_promerica
125+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:65
126+#, python-format
127+msgid "Import Error"
128+msgstr "Error de importación"
129+
130+#. module: l10n_cr_account_banking_promerica
131+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:113
132+#, python-format
133+msgid "Import error"
134+msgstr "Error de importación"
135+
136+#. module: l10n_cr_account_banking_promerica
137+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:73
138+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:82
139+#, python-format
140+msgid "Promerica %s from %s to %s"
141+msgstr "Promerica %s desde %s hasta %s"
142+
143+#. module: l10n_cr_account_banking_promerica
144+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:125
145+#, python-format
146+msgid "Importer for Promerica's xslx bank statements"
147+msgstr "Importador para extractos bancarios xslx de Promerica"
148+
149+#. module: l10n_cr_account_banking_promerica
150+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:114
151+#, python-format
152+msgid "Error in import:%s\n"
153+"\n"
154+"%s"
155+msgstr "Error en importación:%s\n"
156+"\n"
157+"%s"
158+
159+#. module: l10n_cr_account_banking_promerica
160+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:123
161+#, python-format
162+msgid "Promerica Bank Statement Importer"
163+msgstr "Promerica Importador de extractos bancarios"
164+
165+#. module: l10n_cr_account_banking_promerica
166+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:66
167+#, python-format
168+msgid "The account specified in file does not match with the one selected in wizard."
169+msgstr "La cuenta especificada en el archivo no coincide con la seleccionada en el asistente."
170+
171
172=== added file 'l10n_cr_account_banking_promerica/i18n/l10n_cr_account_banking_promerica.pot'
173--- l10n_cr_account_banking_promerica/i18n/l10n_cr_account_banking_promerica.pot 1970-01-01 00:00:00 +0000
174+++ l10n_cr_account_banking_promerica/i18n/l10n_cr_account_banking_promerica.pot 2014-04-08 22:30:06 +0000
175@@ -0,0 +1,61 @@
176+# Translation of OpenERP Server.
177+# This file contains the translation of the following modules:
178+# * l10n_cr_account_banking_promerica
179+#
180+msgid ""
181+msgstr ""
182+"Project-Id-Version: OpenERP Server 7.0\n"
183+"Report-Msgid-Bugs-To: \n"
184+"POT-Creation-Date: 2014-04-07 22:01+0000\n"
185+"PO-Revision-Date: 2014-04-07 22:01+0000\n"
186+"Last-Translator: <>\n"
187+"Language-Team: \n"
188+"MIME-Version: 1.0\n"
189+"Content-Type: text/plain; charset=UTF-8\n"
190+"Content-Transfer-Encoding: \n"
191+"Plural-Forms: \n"
192+
193+#. module: l10n_cr_account_banking_promerica
194+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:65
195+#, python-format
196+msgid "Import Error"
197+msgstr ""
198+
199+#. module: l10n_cr_account_banking_promerica
200+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:113
201+#, python-format
202+msgid "Import error"
203+msgstr ""
204+
205+#. module: l10n_cr_account_banking_promerica
206+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:73
207+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:82
208+#, python-format
209+msgid "Promerica %s from %s to %s"
210+msgstr ""
211+
212+#. module: l10n_cr_account_banking_promerica
213+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:125
214+#, python-format
215+msgid "Importer for Promerica's xslx bank statements"
216+msgstr ""
217+
218+#. module: l10n_cr_account_banking_promerica
219+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:114
220+#, python-format
221+msgid "Error in import:%s\n"
222+"\n"
223+"%s"
224+msgstr ""
225+
226+#. module: l10n_cr_account_banking_promerica
227+#: code:addons/l10n_cr_account_banking_promerica/promerica.py:123
228+#, python-format
229+msgid "Promerica Bank Statement Importer"
230+msgstr ""
231+
232+#. module: l10n_cr_account_banking_promerica
233+#: code:addons/l10n_cr_account_banking_promerica/promerica_parser.py:66
234+#, python-format
235+msgid "The account specified in file does not match with the one selected in wizard."
236+msgstr ""
237
238=== added file 'l10n_cr_account_banking_promerica/promerica.py'
239--- l10n_cr_account_banking_promerica/promerica.py 1970-01-01 00:00:00 +0000
240+++ l10n_cr_account_banking_promerica/promerica.py 2014-04-08 22:30:06 +0000
241@@ -0,0 +1,208 @@
242+# -*- encoding: utf-8 -*-
243+##############################################################################
244+#
245+# Copyright (C) 2011 credativ Ltd (<http://www.credativ.co.uk>).
246+# All Rights Reserved
247+#
248+# This program is free software: you can redistribute it and/or modify
249+# it under the terms of the GNU Affero General Public License as
250+# published by the Free Software Foundation, either version 3 of the
251+# License, or (at your option) any later version.
252+#
253+# This program is distributed in the hope that it will be useful,
254+# but WITHOUT ANY WARRANTY; without even the implied warranty of
255+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
256+# GNU Affero General Public License for more details.
257+#
258+# You should have received a copy of the GNU Affero General Public License
259+# along with this program. If not, see <http://www.gnu.org/licenses/>.
260+#
261+##############################################################################<
262+
263+import re
264+import base64
265+import logging
266+import StringIO
267+from datetime import datetime
268+from openpyxl import load_workbook
269+from account_banking_ccorp.parsers import models
270+from promerica_parser import PromericaParser
271+from openerp.osv import osv, fields
272+from openerp.tools.translate import _
273+
274+bt = models.mem_bank_transaction
275+logger = logging.getLogger( 'l10n_cr_account_banking_promerica' )
276+
277+class transaction(models.mem_bank_transaction):
278+
279+ mapping = {
280+ 'execution_date' : '',
281+ 'effective_date' : '',
282+ 'local_currency' : '',
283+ 'transfer_type' : '',
284+ 'reference' : '',
285+ 'message' : '',
286+ 'name' : '',
287+ 'amount': '',
288+ 'creditmarker': '',
289+ }
290+
291+ def __init__(self, record, *args, **kwargs):
292+ '''Transaction creation'''
293+ #record is a dictionary, that is the reason to use iteritems().
294+ super(transaction, self).__init__(*args, **kwargs)
295+ for key, value in record.iteritems():
296+ if record.has_key(key):
297+ setattr(self, key, record[key])
298+
299+ if not self.is_valid():
300+ logger.info("Invalid: %s", record)
301+
302+ def is_valid(self):
303+ '''We don't have remote_account so override base'''
304+ return (self.execution_date and True) or False
305+
306+class statement(models.mem_bank_statement):
307+ '''Bank statement imported data '''
308+
309+ def _transmission_number(self, record):
310+ self.id = record['transref']
311+
312+ def _account_number(self, record):
313+ self.local_account = record['account_number']
314+ self.local_currency = record['currencycode']
315+
316+ def _statement_number(self, record):
317+ self.id = record['id']
318+
319+ def _opening_balance(self, record):
320+ self.start_balance = float(record['startingbalance'])
321+
322+ def _closing_balance(self, record):
323+ self.end_balance = float(record['endingbalance'])
324+ self.date = record['bookingdate']
325+
326+ def _transaction_new(self, record):
327+ parser = PromericaParser()
328+ sub_record = parser.statement_lines(record)
329+ for sub in sub_record:
330+ self.transactions.append(transaction(sub))
331+
332+ def _not_used():
333+ logger.info("Didn't use record: %s", record)
334+
335+ def _forward_available(self, record):
336+ self.end_balance = float(record['endingbalance'])
337+ self.date = record['bookingdate']
338+
339+ def _execution_date_transferred_amount (self, record):
340+ self.execution_date = record['bookingdate']
341+ self.transferred_amount = float(record['amount'])
342+
343+ def transaction_info(self, record):
344+ '''Add extra information to transaction'''
345+ # Additional information for previous transaction
346+ if len(self.transactions) < 1:
347+ logger.info("Received additional information for non existent transaction:")
348+ logger.info(record)
349+ else:
350+ transaction = self.transactions[-1]
351+ transaction.id = ','.join([record[k] for k in ['infoline{0}'.format(i) for i in range(2,5)] if record.has_key(k)])
352+
353+def raise_error(message, line):
354+ raise osv.osv.except_osv(_('Import error'),
355+ _('Error in import:%s\n\n%s') % (message, line))
356+
357+class parser_promerica(models.parser):
358+
359+ '''
360+ This adds a new parser in the selection options.
361+ When the account is associated to a parser, the following code makes it appear as an option
362+ '''
363+ code = 'Promerica-Parser'
364+ name = _('Promerica Bank Statement Importer')
365+ country_code = 'CR'
366+ doc = _('''Importer for Promerica's xslx bank statements''')
367+
368+ def parse(self, cr, statements_file, **kwargs):
369+ result = []
370+ parser = PromericaParser()
371+ stmnt = statement()
372+
373+ # Decode the base64 encoded file
374+ data = base64.decodestring(statements_file)
375+
376+ # Gather IO from the decoded string
377+ file = StringIO.StringIO()
378+ file.write(data)
379+
380+ # Load workbook from IO
381+ workbook = load_workbook(file)
382+ worksheet = workbook.get_active_sheet() # Get the first sheet
383+
384+ # General Information
385+ account_number = worksheet.cell('B7').value # TODO: setup configuration for account number cell
386+ starting_balance = worksheet.cell('G13').value
387+ date_fields = worksheet.cell('A5').value
388+
389+ try:
390+ # TODO: gather format from configuration
391+ # Get dates using Regular Expression
392+ expr = re.compile('[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]')
393+ dates = expr.findall(date_fields)
394+
395+ # Format date '%Y-%m-%d'
396+ date_from_str = datetime.strftime(datetime.strptime(dates[0],'%d/%m/%Y'),'%Y-%m-%d')
397+ date_to_str = datetime.strftime(datetime.strptime(dates[1],'%d/%m/%Y'),'%Y-%m-%d')
398+ except:
399+ logger.error('Not able to read dates from file, this will possibly fail.')
400+ date_from_str = False
401+ date_to_str = False
402+
403+ data_rows = worksheet.rows[13:]
404+ data = []
405+ for row in data_rows:
406+ if reduce(lambda result, value: result and (value is None),
407+ [cell.value for cell in row], True):
408+ break
409+ data.append([cell.value for cell in row])
410+
411+ ending_balance = starting_balance
412+ if data:
413+ ending_balance = data[len(data)-1][6]
414+
415+ # Update kwargs with read values
416+ kwargs.update({
417+ 'account_number': account_number,
418+ 'starting_balance': starting_balance,
419+ 'ending_balance': ending_balance,
420+ 'date_from_str': date_from_str,
421+ 'date_to_str': date_to_str,
422+ })
423+ # Parse the data for the header of the stament.amount
424+ records = parser.parse_stamenent_record(data, **kwargs)
425+
426+ stmnt._transmission_number(records)
427+ stmnt._account_number(records)
428+ stmnt._statement_number(records)
429+ stmnt._opening_balance(records)
430+ stmnt._closing_balance(records)
431+ stmnt._forward_available(records)
432+ stmnt._execution_date_transferred_amount (records)
433+ stmnt._transaction_new(data)
434+
435+ #call the method statement_lines in
436+ #parser to parse all the lines in file and add to stament.
437+
438+ '''
439+ A stament must have a header and transacctions. The method
440+ parse_stamenent_record parse the header and the
441+ method _transaction_new parse all the line
442+ (transactions) in the file.
443+ '''
444+ if stmnt.is_valid():
445+ result.append(stmnt)
446+
447+ return result
448+
449+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
450
451=== added file 'l10n_cr_account_banking_promerica/promerica_parser.py'
452--- l10n_cr_account_banking_promerica/promerica_parser.py 1970-01-01 00:00:00 +0000
453+++ l10n_cr_account_banking_promerica/promerica_parser.py 2014-04-08 22:30:06 +0000
454@@ -0,0 +1,179 @@
455+#!/usr/bin/env python
456+
457+# -*- encoding: utf-8 -*-
458+##############################################################################
459+#
460+# Copyright (C) 2011 credativ Ltd (<http://www.credativ.co.uk>).
461+# All Rights Reserved
462+#
463+# This program is free software: you can redistribute it and/or modify
464+# it under the terms of the GNU Affero General Public License as
465+# published by the Free Software Foundation, either version 3 of the
466+# License, or (at your option) any later version.
467+#
468+# This program is distributed in the hope that it will be useful,
469+# but WITHOUT ANY WARRANTY; without even the implied warranty of
470+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
471+# GNU Affero General Public License for more details.
472+#
473+# You should have received a copy of the GNU Affero General Public License
474+# along with this program. If not, see <http://www.gnu.org/licenses/>.
475+#
476+##############################################################################
477+
478+import re
479+from datetime import datetime
480+from dateutil import parser
481+from pprint import PrettyPrinter
482+from copy import copy
483+from openerp.osv import osv, fields
484+from openerp.tools.translate import _
485+
486+class PromericaParser(object):
487+ """Parser for Promerica's xlsx Bank Statements"""
488+ #from_card = False TODO: remove
489+
490+
491+ def statement_record (self, rec, **kwargs):
492+ '''** Kwargs parameter is used for a dynamic list of parameters. Due to
493+ the fact that not all bank statements include all the necessary information,
494+ so to get it is strictly necessary to gather information from user.
495+ If you need a new parameter, you specify its name and value, using the **kwargs
496+ as a dictionary, to extract a value use the respective key'''
497+
498+ line_dict = {
499+ 'transref': '', # _transmission_number
500+ 'account_number': '', #_account_number
501+ 'statementnr':'', # statement_number
502+ 'startingbalance': 0.0, #_opening_balance
503+ 'currencycode': '', #currencycode
504+ 'endingbalance': 0.0, #_closing_balance
505+ 'bookingdate': '', #moving_date
506+ 'amount': 0.0,
507+ 'id': '',
508+ }
509+
510+ real_account = kwargs['real_account']
511+ account_number = kwargs['account_number']
512+ date_from = kwargs['date_from_str']
513+ date_to = kwargs['date_to_str']
514+ starting_balance = kwargs['starting_balance']
515+ ending_balance = kwargs['ending_balance']
516+
517+ # Check if account numbers match
518+ if real_account != account_number:
519+ raise osv.except_osv(_('Import Error'),
520+ _('The account specified in file does not '
521+ 'match with the one selected in wizard.'))
522+
523+ line_dict['account_number'] = account_number
524+ # Get currency from wizard
525+ line_dict['currencycode'] = kwargs['local_currency']
526+ # Set name for the new bank statements to be created
527+ line_dict['statementnr'] = _('Promerica %s from %s to %s') % \
528+ (account_number, date_from, date_to)
529+ # transmission_number (Date when done the import)
530+ date_obj = datetime.strptime(date_from, '%Y-%m-%d')
531+ line_dict['transref'] = date_obj.strftime('%d-%m-%Y %H:%M:%S')
532+ line_dict['bookingdate'] = date_obj
533+ line_dict['startingbalance'] = starting_balance
534+ line_dict['endingbalance'] = ending_balance
535+ line_dict['amount'] = starting_balance + ending_balance
536+ line_dict['id'] = _('Promerica %s from %s to %s') % \
537+ (account_number, date_from, date_to)
538+
539+ return line_dict
540+
541+ '''
542+ Parse all the lines in the file. Once the header
543+ is parser, the next step are the lines.
544+ '''
545+ def statement_lines (self, rec):
546+ parser = PromericaParser()
547+ mapping = {
548+ 'execution_date' : '',
549+ 'effective_date' : '',
550+ 'transfer_type' : '',
551+ 'reference' : '',
552+ 'message' : '',
553+ 'name' : '',
554+ 'transferred_amount': '',
555+ 'creditmarker': '',
556+ }
557+
558+ lines = []
559+ currencycode = '' # TODO: remove not used
560+
561+ for record in rec:
562+ mapping['effective_date'] = record[0]
563+ mapping['execution_date'] = record[0]
564+ mapping['transfer_type'] = 'NTRF'
565+ mapping['reference'] = record[1]
566+ mapping['name'] = record[2]
567+ mapping['id'] = record[2]
568+ mapping['message'] = record[4]
569+
570+ #Check if it is debit or credit
571+ amount = record[5]
572+ mapping['transferred_amount'] = amount
573+ if amount < 0:
574+ mapping['creditmarker'] = 'D'
575+ else:
576+ mapping['creditmarker'] = 'C'
577+
578+ lines.append(copy(mapping))
579+
580+ return lines
581+
582+ #clear special characters in a row.
583+ def clean_special_characters(self, text_celd):
584+ special_characters = {'\r':''}
585+
586+ for i, j in special_characters.iteritems():
587+ text = text_celd.replace(i, j)
588+
589+ #remove all the blank space.
590+ return re.sub(r'\s', '', text)
591+
592+ """
593+ ** Kwargs parameter is used for a dynamic list of parameters.
594+ The wizard imported extracts used in all parsers
595+ and not all parsers have all the necessary information in your file,
596+ so get information from the wizard and passed by the ** kwargs.
597+ Then in the parses that are needed, are extracted from the ** kwargs and if needed,
598+ the parser still works the same way without this parameter.
599+
600+ The rest of the methods must receive this parameter. (As the
601+ method that parse the header and the lines).
602+
603+ If you need a new parameter, you specify its name and value,
604+ using the ** kwargs is a dictionary,
605+ extract its value, with the respective key
606+ """
607+
608+ def parse_stamenent_record( self, rec, **kwargs): #parse the header.
609+ matchdict = dict()
610+ # Set the header for the statement
611+ matchdict = self.statement_record(rec, **kwargs);
612+ # TODO: check if we need effective_date or execution_date as date
613+ return matchdict
614+
615+ #call the method that parse the header and the statements.
616+ def parse( self, cr, data ):
617+ records = []
618+ # Some records are multiline
619+ for line in data:
620+ if len(line) <= 1:
621+ continue
622+ if line[0] == ':' and len(line) > 1:
623+ records.append(line)
624+ else:
625+ records[-1] = '\n'.join([records[-1], line])
626+
627+ output = []
628+
629+ for rec in records:
630+ #parse_stamenent_record parse the header and the statements
631+ output.append( self.parse_stamenent_record( rec ) )
632+
633+ return output

Subscribers

People subscribed via source and target branches

to all changes: