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

Proposed by Glen Sojo
Status: Merged
Merged at revision: 268
Proposed branch: lp:~gs.clearcorp/openerp-costa-rica/7.0_l10n_cr_account_banking_cr_davivienda
Merge into: lp:openerp-costa-rica
Diff against target: 123 lines (+33/-15)
2 files modified
l10n_cr_account_banking_cr_davivienda/davivienda_format.py (+1/-2)
l10n_cr_account_banking_cr_davivienda/davivienda_parser.py (+32/-13)
To merge this branch: bzr merge lp:~gs.clearcorp/openerp-costa-rica/7.0_l10n_cr_account_banking_cr_davivienda
Reviewer Review Type Date Requested Status
ClearCorp drivers Pending
Review via email: mp+202908@code.launchpad.net

Description of the change

[FIX] Fixed davivienda_parser import error from credits and empty transactions

To post a comment you must log in.
268. By Ronald Rubi

[MRG] Fixed davivienda_parser import error from credits and empty transactions

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_format.py'
2--- l10n_cr_account_banking_cr_davivienda/davivienda_format.py 2013-12-09 18:32:13 +0000
3+++ l10n_cr_account_banking_cr_davivienda/davivienda_format.py 2014-01-23 17:57:54 +0000
4@@ -65,8 +65,7 @@
5 '''
6 We don't have remote_account so override base
7 '''
8- return (self.execution_date
9- and self.transferred_amount and True) or False
10+ return (self.execution_date and True) or False
11
12 class statement(models.mem_bank_statement):
13 '''
14
15=== modified file 'l10n_cr_account_banking_cr_davivienda/davivienda_parser.py'
16--- l10n_cr_account_banking_cr_davivienda/davivienda_parser.py 2014-01-14 16:52:15 +0000
17+++ l10n_cr_account_banking_cr_davivienda/davivienda_parser.py 2014-01-23 17:57:54 +0000
18@@ -48,6 +48,8 @@
19 using the ** kwargs is a dictionary,
20 extract its value, with the respective key
21 '''
22+ from_card = False
23+
24 def statement_record ( self, rec, **kwargs):
25 lines = []
26 line_dict = {}
27@@ -63,7 +65,7 @@
28 'amount': 0.0,
29 'id': '',
30 }
31-
32+ rec = rec.replace('ABONO A SU CUENTA .... GRACIA;','ABONO A SU CUENTA .... GRACIAS')
33 #Split the file in statements
34 list_split = rec.split('\n')
35 #Obtain the first line to know the account number
36@@ -71,11 +73,11 @@
37 first_line_split = fist_line.split(';')
38
39 account_number_wizard = kwargs['account_number']#from wizard
40- from_card = False
41+ self.from_card = False
42 try:
43 account_number_file = first_line_split[11]#from account file.
44 except:
45- from_card = True
46+ self.from_card = True
47 account_number_file = first_line_split[10]#from credit or debit card file
48
49 #if the account_number in the file match with the account
50@@ -110,7 +112,7 @@
51 first_line_split = fist_line.split(';')
52 #If it comes from credit/debit card account we don't have access to starting
53 #balance assuming 0.0
54- if not from_card:
55+ if not self.from_card:
56 startingbalance = float(first_line_split[5].replace(",","")) + \
57 float(first_line_split[3].replace(",","")) - \
58 float(first_line_split[4].replace(",",""))
59@@ -127,7 +129,7 @@
60 if len(last_line) > 0 and last_line != "" and last_line != '\r':
61 break
62 last_line_split = last_line.split(';')
63- if not from_card:
64+ if not self.from_card:
65 endingbalance += float(last_line_split[5].replace(",",""))
66 #Calculating ending_balance assuming starting balance as 0.0
67 else:
68@@ -172,6 +174,7 @@
69 line_dict = {}
70 currencycode = ''
71
72+ rec = rec.replace('ABONO A SU CUENTA .... GRACIA;','ABONO A SU CUENTA .... GRACIAS')
73 list_split = rec.split('\n')
74 entrada = False
75
76@@ -186,6 +189,11 @@
77 break
78 end -= 1
79 sub_list = list_split [start:end+1]
80+ self.from_card = False
81+ try:
82+ sub_list[0].split(';')[11]
83+ except:
84+ self.from_card = True
85 for sub in sub_list:
86 line = sub.split(';')
87 #effective_date
88@@ -201,16 +209,27 @@
89 mapping['name'] = line[1] #Description
90 mapping['id'] = line[1] #Description
91
92- if line[10] == 'C':
93+ if not self.from_card:
94+ if line[10] == 'C':
95+ credit = float(line[4].replace(",",""))
96+ mapping['transferred_amount'] = credit
97+ mapping['creditmarker'] = 'C'
98+
99+ else:
100+ #In this case, the debit is negative.
101+ debit = float(line[3].replace(",",""))
102+ mapping['transferred_amount'] = -1 * debit
103+ else:
104 credit = float(line[4].replace(",",""))
105- mapping['transferred_amount'] = credit
106- mapping['creditmarker'] = 'C'
107-
108- else:
109- #In this case, the debit is negative.
110 debit = float(line[3].replace(",",""))
111- mapping['transferred_amount'] = -1 * debit
112-
113+ if credit:
114+ mapping['transferred_amount'] = credit
115+ mapping['creditmarker'] = 'C'
116+
117+ else:
118+ #In this case, the debit is negative.
119+ mapping['transferred_amount'] = -1 * debit
120+
121 lines.append(copy(mapping))
122
123 return lines

Subscribers

People subscribed via source and target branches

to all changes: