Merge lp:~therp-nl/banking-addons/ba70-ing_acceptgiros into lp:banking-addons

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 173
Proposed branch: lp:~therp-nl/banking-addons/ba70-ing_acceptgiros
Merge into: lp:banking-addons
Diff against target: 79 lines (+55/-0)
1 file modified
account_banking_nl_ing/ing.py (+55/-0)
To merge this branch: bzr merge lp:~therp-nl/banking-addons/ba70-ing_acceptgiros
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+167523@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_banking_nl_ing/ing.py'
--- account_banking_nl_ing/ing.py 2013-04-15 13:56:18 +0000
+++ account_banking_nl_ing/ing.py 2013-06-05 12:32:32 +0000
@@ -77,6 +77,7 @@
77 # Normalize basic account numbers77 # Normalize basic account numbers
78 self.remote_account = self.remote_account.replace('.', '').zfill(10)78 self.remote_account = self.remote_account.replace('.', '').zfill(10)
79 self.local_account = self.local_account.replace('.', '').zfill(10) 79 self.local_account = self.local_account.replace('.', '').zfill(10)
80
8081
81class transaction(models.mem_bank_transaction):82class transaction(models.mem_bank_transaction):
82 '''83 '''
@@ -114,6 +115,8 @@
114115
115 # global expression for matching storno references116 # global expression for matching storno references
116 ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')117 ref_expr = re.compile('REF[\*:]([0-9A-Z-z_-]+)')
118 # match references for Acceptgiro's through Internet banking
119 kn_expr = re.compile('KN: ([^ ]+)')
117120
118 def __init__(self, line, *args, **kwargs):121 def __init__(self, line, *args, **kwargs):
119 '''122 '''
@@ -149,6 +152,58 @@
149 self.reference = res.group(1)152 self.reference = res.group(1)
150 self.storno_retry = True153 self.storno_retry = True
151 self.remote_owner = False154 self.remote_owner = False
155 if self.transfer_type == 'GT':
156 res = self.kn_expr.search(self.message)
157 if res:
158 self.reference = res.group(1)
159 if self.transfer_type == 'AC':
160 self.parse_acceptgiro()
161 if self.message and not self.reference:
162 self.reference = self.message
163
164 def parse_acceptgiro(self):
165 """
166 Entries of type 'Acceptgiro' can contain the reference
167 in the 'name' column, as well as full address information
168 in the 'message' column'
169 """
170 reference = ''
171 street = False
172 zipcode = False
173 street = False
174 before = False
175 if self.remote_owner.startswith('KN: '):
176 self.reference = self.remote_owner[4:]
177 self.remote_owner = ''
178 if 'KN: ' in self.message:
179 index = self.message.index('KN: ')
180 before = self.message[:index]
181 self.message = self.message[index:]
182 expression = (
183 "^\s*(KN:\s*(?P<kn>[^\s]+))?(\s*)"
184 "(?P<navr>NAVR:\s*[^\s]+)?(\s*)(?P<after>.*?)$")
185 msg_match = re.match(expression, self.message)
186 after = msg_match.group('after')
187 kn = msg_match.group('kn')
188 navr = msg_match.group('navr')
189 if kn:
190 self.reference = kn[4:]
191 self.message = 'Acceptgiro %s' % (navr or '')
192 if after:
193 parts = [after[i:i+33] for i in range(0, len(after), 33)]
194 if parts and not self.remote_owner:
195 self.remote_owner = parts.pop(0).strip()
196 if parts:
197 self.remote_owner_address = [parts.pop(0).strip()]
198 if parts:
199 zip_city = parts.pop(0).strip()
200 zip_match = re.match(
201 "^(?P<zipcode>[^ ]{6})\s+(?P<city>.*?)$", zip_city)
202 if zip_match:
203 self.remote_owner_postalcode = zip_match.group('zipcode')
204 self.remote_owner_city = zip_match.group('city')
205 if before and not self.remote_owner_city:
206 self.remote_owner_city = before.strip()
152207
153 def is_valid(self):208 def is_valid(self):
154 if not self.error_message:209 if not self.error_message:

Subscribers

People subscribed via source and target branches

to status/vote changes: