display card as accounts (closes #1362)
This commit is contained in:
parent
ee8b57b437
commit
0349e85360
2 changed files with 18 additions and 32 deletions
|
|
@ -106,24 +106,15 @@ class SocieteGenerale(BaseBrowser):
|
||||||
def iter_history(self, account):
|
def iter_history(self, account):
|
||||||
self.location(account._link_id)
|
self.location(account._link_id)
|
||||||
|
|
||||||
if not self.is_on_page(AccountHistory):
|
transactions = []
|
||||||
# TODO: support other kind of accounts
|
if self.is_on_page(CardsList):
|
||||||
self.logger.warning('This account is not supported')
|
for card_link in self.page.iter_cards():
|
||||||
raise NotImplementedError('This account is not supported')
|
self.location(card_link)
|
||||||
|
|
||||||
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 += list(self.page.iter_transactions(coming=True))
|
transactions += list(self.page.iter_transactions(coming=True))
|
||||||
else:
|
elif self.is_on_page(AccountHistory):
|
||||||
self.logger.warning('This card is not supported')
|
transactions += list(self.page.iter_transactions(coming=(account.type == account.TYPE_CARD)))
|
||||||
|
else:
|
||||||
|
self.logger.warning('This account is not supported')
|
||||||
|
|
||||||
def key(tr):
|
def key(tr):
|
||||||
# Can't compare datetime and date, so cast them.
|
# Can't compare datetime and date, so cast them.
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ class AccountsList(BasePage):
|
||||||
|
|
||||||
|
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
accounts = []
|
|
||||||
for tr in self.document.getiterator('tr'):
|
for tr in self.document.getiterator('tr'):
|
||||||
if not 'LGNTableRow' in tr.attrib.get('class', '').split():
|
if not 'LGNTableRow' in tr.attrib.get('class', '').split():
|
||||||
continue
|
continue
|
||||||
|
|
@ -66,19 +65,19 @@ class AccountsList(BasePage):
|
||||||
a = td.find('a')
|
a = td.find('a')
|
||||||
if a is None:
|
if a is None:
|
||||||
break
|
break
|
||||||
account.label = unicode(a.find("span").text)
|
account.label = self.parser.tocleanstring(a)
|
||||||
for pattern, actype in self.TYPES.iteritems():
|
for pattern, actype in self.TYPES.iteritems():
|
||||||
if account.label.startswith(pattern):
|
if account.label.startswith(pattern):
|
||||||
account.type = actype
|
account.type = actype
|
||||||
account._link_id = a.get('href', '')
|
account._link_id = a.get('href', '')
|
||||||
|
|
||||||
elif td.attrib.get('headers', '') == 'NumeroCompte':
|
elif td.attrib.get('headers', '') == 'NumeroCompte':
|
||||||
id = td.text
|
account.id = self.parser.tocleanstring(td)
|
||||||
id = id.replace(u'\xa0','')
|
|
||||||
account.id = id
|
|
||||||
|
|
||||||
elif td.attrib.get('headers', '') == 'Libelle':
|
elif td.attrib.get('headers', '') == 'Libelle':
|
||||||
pass
|
text = self.parser.tocleanstring(td)
|
||||||
|
if text != '':
|
||||||
|
account.label = text
|
||||||
|
|
||||||
elif td.attrib.get('headers', '') == 'Solde':
|
elif td.attrib.get('headers', '') == 'Solde':
|
||||||
div = td.xpath('./div[@class="Solde"]')
|
div = td.xpath('./div[@class="Solde"]')
|
||||||
|
|
@ -97,15 +96,11 @@ class AccountsList(BasePage):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if 'CARTE_' in account._link_id:
|
if 'CARTE_' in account._link_id:
|
||||||
ac = accounts[0]
|
account.type = account.TYPE_CARD
|
||||||
ac._card_links.append(account._link_id)
|
account.coming = account.balance
|
||||||
if not ac.coming:
|
account.balance = Decimal('0')
|
||||||
ac.coming = Decimal('0.0')
|
|
||||||
ac.coming += account.balance
|
yield account
|
||||||
else:
|
|
||||||
account._card_links = []
|
|
||||||
accounts.append(account)
|
|
||||||
return iter(accounts)
|
|
||||||
|
|
||||||
|
|
||||||
class CardsList(BasePage):
|
class CardsList(BasePage):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue