From 09444f5f43e3f50547374000446048cfe8014b98 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Fri, 6 Sep 2013 14:19:26 +0200 Subject: [PATCH] add transaction patterns --- modules/bnporc/enterprise/pages.py | 20 +++++++++++++++++--- modules/societegenerale/sgpe/pages.py | 26 +++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/modules/bnporc/enterprise/pages.py b/modules/bnporc/enterprise/pages.py index 8b81d816..2da19693 100644 --- a/modules/bnporc/enterprise/pages.py +++ b/modules/bnporc/enterprise/pages.py @@ -34,7 +34,23 @@ __all__ = ['LoginPage', 'AccountsPage', 'UnknownPage'] class Transaction(FrenchTransaction): - pass + PATTERNS = [(re.compile(u'^(?PCHEQUE)(?P.*)'), FrenchTransaction.TYPE_CHECK), + (re.compile('^(?PFACTURE CARTE) DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*?)( CA?R?T?E? ?\d*X*\d*)?$'), + FrenchTransaction.TYPE_CARD), + (re.compile('^(?P(PRELEVEMENT|TELEREGLEMENT|TIP)) (?P.*)'), + FrenchTransaction.TYPE_ORDER), + (re.compile('^(?PECHEANCEPRET)(?P.*)'), FrenchTransaction.TYPE_LOAN_PAYMENT), + (re.compile('^(?PRETRAIT DAB) (?P
\d{2})/(?P\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))? (?P.*)'), + FrenchTransaction.TYPE_WITHDRAWAL), + (re.compile('^(?PVIR(EMEN)?T? ((RECU|FAVEUR) TIERS|SEPA RECU)?)( /FRM)?(?P.*)'), + FrenchTransaction.TYPE_TRANSFER), + (re.compile('^(?PREMBOURST) CB DU (?P
\d{2})(?P\d{2})(?P\d{2}) (?P.*)'), + FrenchTransaction.TYPE_PAYBACK), + (re.compile('^(?PREMBOURST)(?P.*)'), FrenchTransaction.TYPE_PAYBACK), + (re.compile('^(?PCOMMISSIONS)(?P.*)'), FrenchTransaction.TYPE_BANK), + (re.compile('^(?P(?PREMUNERATION).*)'), FrenchTransaction.TYPE_BANK), + (re.compile('^(?PREMISE CHEQUES)(?P.*)'), FrenchTransaction.TYPE_DEPOSIT), + ] class BEPage(BasePage): @@ -94,7 +110,6 @@ class BNPVirtKeyboard(MappedVirtKeyboard): s += "O" s += "\n" s = '\n'.join([l for l in s.splitlines() if l.strip()]) - #print s return hashlib.md5(s).hexdigest() @@ -171,7 +186,6 @@ class HistoryPage(BEPage): radio = self.parser.select(self.document, '//input[@name="br_tout_date"]', 1, 'xpath') except BrokenPageError: input = self.document.xpath('//input[@name="chB"]')[0] - print '%r' % input.tail d1, d2 = re.findall('(\d+/\d+/\d+)', input.tail) else: d1 = radio.attrib['value'][0:10] diff --git a/modules/societegenerale/sgpe/pages.py b/modules/societegenerale/sgpe/pages.py index 931e2606..7a614b9e 100644 --- a/modules/societegenerale/sgpe/pages.py +++ b/modules/societegenerale/sgpe/pages.py @@ -38,7 +38,31 @@ __all__ = ['LoginPage', 'AccountsPage', 'CardsPage', 'HistoryPage', 'CardHistory class Transaction(FrenchTransaction): - _coming = False + PATTERNS = [(re.compile(r'^CARTE \w+ RETRAIT DAB.* (?P
\d{2})/(?P\d{2})( (?P\d+)H(?P\d+))? (?P.*)'), + FrenchTransaction.TYPE_WITHDRAWAL), + (re.compile(r'^CARTE \w+ (?P
\d{2})/(?P\d{2})( A (?P\d+)H(?P\d+))? RETRAIT DAB (?P.*)'), + FrenchTransaction.TYPE_WITHDRAWAL), + (re.compile(r'^CARTE \w+ REMBT (?P
\d{2})/(?P\d{2})( A (?P\d+)H(?P\d+))? (?P.*)'), + FrenchTransaction.TYPE_PAYBACK), + (re.compile(r'^(?PCARTE) \w+ (?P
\d{2})/(?P\d{2}) (?P.*)'), + FrenchTransaction.TYPE_CARD), + (re.compile(r'^(?P
\d{2})(?P\d{2})/(?P.*?)/?(-[\d,]+)?$'), + FrenchTransaction.TYPE_CARD), + (re.compile(r'^(?P(COTISATION|PRELEVEMENT|TELEREGLEMENT|TIP)) (?P.*)'), + FrenchTransaction.TYPE_ORDER), + (re.compile(r'^(\d+ )?VIR (PERM )?POUR: (.*?) (REF: \d+ )?MOTIF: (?P.*)'), + FrenchTransaction.TYPE_TRANSFER), + (re.compile(r'^(?PVIR(EMEN)?T? \w+) (?P.*)'), + FrenchTransaction.TYPE_TRANSFER), + (re.compile(r'^(CHEQUE) (?P.*)'), FrenchTransaction.TYPE_CHECK), + (re.compile(r'^(FRAIS) (?P.*)'), FrenchTransaction.TYPE_BANK), + (re.compile(r'^(?PECHEANCEPRET)(?P.*)'), + FrenchTransaction.TYPE_LOAN_PAYMENT), + (re.compile(r'^(?PREMISE CHEQUES)(?P.*)'), + FrenchTransaction.TYPE_DEPOSIT), + (re.compile(r'^CARTE RETRAIT (?P.*)'), + FrenchTransaction.TYPE_WITHDRAWAL), + ] class SGPEPage(BasePage):