handling duplicate account id (closes #2114)

This commit is contained in:
Vincent Paredes 2015-06-25 14:33:46 +02:00 committed by Romain Bignon
commit a9957967b5

View file

@ -69,9 +69,10 @@ class AccountsPage(LoggedPage, HTMLPage):
class Type(Filter):
def filter(self, label):
if 'invest' in label.lower():
return Account.TYPE_MARKET
return Account.TYPE_UNKNOWN
obj_id = CleanText('./td[2]', replace=[('.', ''), (' ', '')])
obj_label = Label(CleanText('./td[1]/a'))
obj_coming = Env('coming')
obj_balance = CleanDecimal('./td[3]', replace_dots=True)
@ -80,6 +81,14 @@ class AccountsPage(LoggedPage, HTMLPage):
obj_type = Type(Field('label'))
obj_coming = NotAvailable
@property
def obj_id(self):
# Investment account and main account can have the same id
# so we had account type in case of Investment to prevent conflict
if Field('type')(self) == Account.TYPE_MARKET:
return CleanText(replace=[('.', ''), (' ', '')]).filter(self.el.xpath('./td[2]')) + ".INVEST"
return CleanText(replace=[('.', ''), (' ', '')]).filter(self.el.xpath('./td[2]'))
class Pagination(object):
def next_page(self):