display card as accounts (closes #1362)

This commit is contained in:
Romain Bignon 2014-05-17 16:44:32 +02:00
commit 0349e85360
2 changed files with 18 additions and 32 deletions

View file

@ -106,24 +106,15 @@ class SocieteGenerale(BaseBrowser):
def iter_history(self, account):
self.location(account._link_id)
if not self.is_on_page(AccountHistory):
# TODO: support other kind of accounts
self.logger.warning('This account is not supported')
raise NotImplementedError('This account is not supported')
transactions = list(self.page.iter_transactions(coming=False))
for card_link in account._card_links:
self.location(card_link)
if self.is_on_page(CardsList):
for card_link in self.page.iter_cards():
self.location(card_link)
transactions += list(self.page.iter_transactions(coming=True))
elif self.is_on_page(AccountHistory):
transactions = []
if self.is_on_page(CardsList):
for card_link in self.page.iter_cards():
self.location(card_link)
transactions += list(self.page.iter_transactions(coming=True))
else:
self.logger.warning('This card is not supported')
elif self.is_on_page(AccountHistory):
transactions += list(self.page.iter_transactions(coming=(account.type == account.TYPE_CARD)))
else:
self.logger.warning('This account is not supported')
def key(tr):
# Can't compare datetime and date, so cast them.

View file

@ -55,7 +55,6 @@ class AccountsList(BasePage):
def get_list(self):
accounts = []
for tr in self.document.getiterator('tr'):
if not 'LGNTableRow' in tr.attrib.get('class', '').split():
continue
@ -66,19 +65,19 @@ class AccountsList(BasePage):
a = td.find('a')
if a is None:
break
account.label = unicode(a.find("span").text)
account.label = self.parser.tocleanstring(a)
for pattern, actype in self.TYPES.iteritems():
if account.label.startswith(pattern):
account.type = actype
account._link_id = a.get('href', '')
elif td.attrib.get('headers', '') == 'NumeroCompte':
id = td.text
id = id.replace(u'\xa0','')
account.id = id
account.id = self.parser.tocleanstring(td)
elif td.attrib.get('headers', '') == 'Libelle':
pass
text = self.parser.tocleanstring(td)
if text != '':
account.label = text
elif td.attrib.get('headers', '') == 'Solde':
div = td.xpath('./div[@class="Solde"]')
@ -97,15 +96,11 @@ class AccountsList(BasePage):
continue
if 'CARTE_' in account._link_id:
ac = accounts[0]
ac._card_links.append(account._link_id)
if not ac.coming:
ac.coming = Decimal('0.0')
ac.coming += account.balance
else:
account._card_links = []
accounts.append(account)
return iter(accounts)
account.type = account.TYPE_CARD
account.coming = account.balance
account.balance = Decimal('0')
yield account
class CardsList(BasePage):