fix determination of balance
This commit is contained in:
parent
627aa08bb2
commit
a64ae7ddfe
2 changed files with 8 additions and 4 deletions
|
|
@ -65,6 +65,8 @@ class BanqueAccordBrowser(LoginBrowser):
|
|||
self.accounts.go()
|
||||
a.balance = self.page.get_balance()
|
||||
a.type = a.TYPE_CARD
|
||||
if a.balance is None:
|
||||
continue
|
||||
yield a
|
||||
|
||||
@need_login
|
||||
|
|
|
|||
|
|
@ -154,7 +154,11 @@ class IndexPage(LoggedPage, HTMLPage):
|
|||
class AccountsPage(LoggedPage, HTMLPage):
|
||||
def get_balance(self):
|
||||
balance = Decimal('0.0')
|
||||
for line in self.doc.xpath('//div[@class="detail"]/table//tr'):
|
||||
lines = self.doc.xpath('//div[@class="detail"]/table//tr')
|
||||
if len(lines) == 0:
|
||||
return None
|
||||
|
||||
for line in lines:
|
||||
try:
|
||||
left = line.xpath('./td[@class="gauche"]')[0]
|
||||
right = line.xpath('./td[@class="droite"]')[0]
|
||||
|
|
@ -163,9 +167,7 @@ class AccountsPage(LoggedPage, HTMLPage):
|
|||
continue
|
||||
|
||||
if len(left.xpath('./span[@class="precision"]')) == 0 or \
|
||||
(left.text is None or
|
||||
not 'total' in left.text.lower() or
|
||||
u'prélevé' in left.xpath('./span[@class="precision"]')[0].text.lower()):
|
||||
(left.text is None or not 'total' in left.text.lower()):
|
||||
continue
|
||||
|
||||
balance -= CleanDecimal('.', replace_dots=False)(right)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue