[weboob] boobank OFX export: Identify credit card for each transaction (full patch)

caramdache at gmail.com caramdache at gmail.com
Sun May 3 17:15:23 CEST 2015


         if deferred:
+            card_no_re = re.compile('indexCarte=(\d)')
+            card_no = card_no_re.search(self.url).group(0).replace('indexCarte=', '')
+
             # look for the debit date, and if it is already debited
             txt = u''.join([txt.strip() for txt in self.document.xpath('//div[@class="infosynthese"]')[0].itertext()])
             m = re.search('(\d+)/(\d+)/(\d+)', txt)
@@ -93,6 +96,7 @@ class AccountHistory(Page):
             op.set_amount(amount)
 
             if deferred:
+                op.category = 'CARTE %s' % card_no
                 op.rdate = op.date
                 op.date = debit_date
                 # on card page, amounts are without sign
diff --git a/weboob/applications/boobank/boobank.py b/weboob/applications/boobank/boobank.py
index 6ffbf34..3bbbc71 100644
--- a/weboob/applications/boobank/boobank.py
+++ b/weboob/applications/boobank/boobank.py
@@ -79,7 +79,10 @@ class OfxFormatter(IFormatter):
         self.output(u'<DTEND>%s' % datetime.date.today().strftime('%Y%m%d'))
 
     def format_obj(self, obj, alias):
-        if obj.type != 0:
+        if hasattr(obj, '_coming') and obj._coming == True and hasattr(obj, 'category') and not empty(obj.category):
+            # category contains credit card number for deferred transactions
+            result = u'<STMTTRN><TRNTYPE>%s\n' % obj.category
+        elif obj.type != 0:
             result = u'<STMTTRN><TRNTYPE>%s\n' % self.TYPES_TRANS[obj.type]
         else:
             result = u'<STMTTRN><TRNTYPE>%s\n' % ('DEBIT' if obj.amount < 0 else 'CREDIT')



More information about the weboob mailing list