~therp-nl/banking-addons/6.1-empty_message_direct_debit

« back to all changes in this revision

Viewing changes to account_banking_nl_girotel/girotel.py

  • Committer: Stefan Rijnhart
  • Author(s): hbrunn at therp
  • Date: 2013-06-29 09:16:25 UTC
  • mfrom: (173.1.1 banking-addons-6.1)
  • Revision ID: stefan@therp.nl-20130629091625-3yjai9pmqgmsvuc6
[ADD] try to parse the structured description which seems to be used
sometimes for girotel exports

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
from account_banking.parsers.convert import str2date, to_swift
47
47
from tools.translate import _
48
48
import csv
 
49
import re
49
50
 
50
51
bt = models.mem_bank_transaction
51
52
 
143
144
        'VZ': bt.PAYMENT_BATCH,
144
145
    }
145
146
 
 
147
    structured_description_regex = re.compile(
 
148
            '^IBAN: (?P<iban>\w+) BIC: (?P<bic>\w+) Naam: (?P<name>.+) '
 
149
            'Omschrijving: (?P<desc>.+)$')
 
150
 
146
151
    def __init__(self, line, *args, **kwargs):
147
152
        '''
148
153
        Initialize own dict with read values.
274
279
            # Normal transaction, but remote_owner can contain city, depending
275
280
            # on length of total. As there is no clear pattern, leave it as
276
281
            # is.
 
282
            structured_description = self.structured_description_regex.match(
 
283
                    ''.join(self.message.split('\n')))
 
284
            if structured_description:
 
285
                values = structured_description.groupdict()
 
286
                self.reference = values['desc']
277
287
            self.message = self.refold_message(self.message)
278
288
 
279
289
        else: