boobank OFX export: Identify credit card for each transaction
This commit is contained in:
parent
560ac5282d
commit
f9f933c32b
2 changed files with 8 additions and 1 deletions
|
|
@ -63,6 +63,9 @@ class AccountHistory(Page):
|
||||||
operations = []
|
operations = []
|
||||||
|
|
||||||
if deferred:
|
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
|
# 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()])
|
txt = u''.join([txt.strip() for txt in self.document.xpath('//div[@class="infosynthese"]')[0].itertext()])
|
||||||
m = re.search('(\d+)/(\d+)/(\d+)', txt)
|
m = re.search('(\d+)/(\d+)/(\d+)', txt)
|
||||||
|
|
@ -93,6 +96,7 @@ class AccountHistory(Page):
|
||||||
op.set_amount(amount)
|
op.set_amount(amount)
|
||||||
|
|
||||||
if deferred:
|
if deferred:
|
||||||
|
op._cardid = 'CARTE %s' % card_no
|
||||||
op.rdate = op.date
|
op.rdate = op.date
|
||||||
op.date = debit_date
|
op.date = debit_date
|
||||||
# on card page, amounts are without sign
|
# on card page, amounts are without sign
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,10 @@ class OfxFormatter(IFormatter):
|
||||||
self.output(u'<DTEND>%s' % datetime.date.today().strftime('%Y%m%d'))
|
self.output(u'<DTEND>%s' % datetime.date.today().strftime('%Y%m%d'))
|
||||||
|
|
||||||
def format_obj(self, obj, alias):
|
def format_obj(self, obj, alias):
|
||||||
if obj.type != 0:
|
# special case of coming operations with card ID
|
||||||
|
if hasattr(obj, '_coming') and obj._coming and hasattr(obj, 'obj._cardid') and not empty(obj._cardid):
|
||||||
|
result = u'<STMTTRN><TRNTYPE>%s\n' % obj._cardid
|
||||||
|
elif obj.type != 0:
|
||||||
result = u'<STMTTRN><TRNTYPE>%s\n' % self.TYPES_TRANS[obj.type]
|
result = u'<STMTTRN><TRNTYPE>%s\n' % self.TYPES_TRANS[obj.type]
|
||||||
else:
|
else:
|
||||||
result = u'<STMTTRN><TRNTYPE>%s\n' % ('DEBIT' if obj.amount < 0 else 'CREDIT')
|
result = u'<STMTTRN><TRNTYPE>%s\n' % ('DEBIT' if obj.amount < 0 else 'CREDIT')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue