LCL: add support for various types of accounts
In addition to the exisiting Compte Courant, the following account types are now supported: Compte de dépôts Compte d'Epargne Reported-by: Luc Didry <luc@didry.org> Signed-off-by: Pierre Mazière <pierre.maziere@gmail.com> Tested-by: Luc Didry <luc@didry.org> Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
parent
4a1b559c5f
commit
22509971ca
2 changed files with 43 additions and 25 deletions
|
|
@ -37,7 +37,7 @@ class LCLBrowser(BaseBrowser):
|
||||||
'https://particuliers.secure.lcl.fr/everest/UWBI/UWBIAccueil\?DEST=IDENTIFICATION': LoginResultPage,
|
'https://particuliers.secure.lcl.fr/everest/UWBI/UWBIAccueil\?DEST=IDENTIFICATION': LoginResultPage,
|
||||||
'https://particuliers.secure.lcl.fr/outil/UWSP/Synthese/accesSynthese': AccountsPage,
|
'https://particuliers.secure.lcl.fr/outil/UWSP/Synthese/accesSynthese': AccountsPage,
|
||||||
'https://particuliers.secure.lcl.fr/outil/UWB2/Accueil\?DEST=INIT': FramePage,
|
'https://particuliers.secure.lcl.fr/outil/UWB2/Accueil\?DEST=INIT': FramePage,
|
||||||
'https://particuliers.secure.lcl.fr/outil/UWLM/ListeMouvementsPro/accesListeMouvementsPro.*': AccountHistoryPage,
|
'https://particuliers.secure.lcl.fr/outil/UWLM/ListeMouvements.*/accesListeMouvements.*': AccountHistoryPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, agency, *args, **kwargs):
|
def __init__(self, agency, *args, **kwargs):
|
||||||
|
|
@ -84,7 +84,7 @@ class LCLBrowser(BaseBrowser):
|
||||||
def get_history(self,account):
|
def get_history(self,account):
|
||||||
if not self.is_on_page(AccountHistoryPage) :
|
if not self.is_on_page(AccountHistoryPage) :
|
||||||
self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account.link_id))
|
self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account.link_id))
|
||||||
return self.page.get_operations()
|
return self.page.get_operations(account)
|
||||||
|
|
||||||
#def get_coming_operations(self, account):
|
#def get_coming_operations(self, account):
|
||||||
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,16 @@ class AccountsPage(BasePage):
|
||||||
def get_list(self):
|
def get_list(self):
|
||||||
l = []
|
l = []
|
||||||
for div in self.document.getiterator('div'):
|
for div in self.document.getiterator('div'):
|
||||||
if div.attrib.get('class')=="unCompte-CC" :
|
if div.attrib.get('class')=="unCompte-CA" or\
|
||||||
|
div.attrib.get('class')=="unCompte-CC" or\
|
||||||
|
div.attrib.get('class')=="unCompte-CD" or\
|
||||||
|
div.attrib.get('class')=="unCompte-CE":
|
||||||
|
#CA=> ? maybe Assurance-vie
|
||||||
|
#CC=> Compte Courant
|
||||||
|
#CD=> Compte Dépôt
|
||||||
|
#CE=> Compte d'Epargne
|
||||||
account = Account()
|
account = Account()
|
||||||
|
account.type=div.attrib.get('class')[-2:]
|
||||||
account.id = div.attrib.get('id').replace('-','')
|
account.id = div.attrib.get('id').replace('-','')
|
||||||
for td in div.getiterator('td'):
|
for td in div.getiterator('td'):
|
||||||
if td.find("div") is not None and td.find("div").attrib.get('class') == 'libelleCompte':
|
if td.find("div") is not None and td.find("div").attrib.get('class') == 'libelleCompte':
|
||||||
|
|
@ -71,30 +79,40 @@ class AccountsPage(BasePage):
|
||||||
return l
|
return l
|
||||||
|
|
||||||
class AccountHistoryPage(BasePage):
|
class AccountHistoryPage(BasePage):
|
||||||
def on_loaded(self):
|
def get_specific_operations(self,tableHeaderPrefixes,debitColumns,creditColumns):
|
||||||
self.operations = []
|
operations = []
|
||||||
for td in self.document.iter('td'):
|
for td in self.document.iter('td'):
|
||||||
text=td.findtext("b")
|
text=td.findtext("b")
|
||||||
if text is None:
|
if text is None:
|
||||||
continue
|
continue
|
||||||
prefix='Opérations effectuées'
|
for i in range(len(tableHeaderPrefixes)):
|
||||||
if text.startswith(prefix.decode('utf-8')):
|
if text.startswith(tableHeaderPrefixes[i].decode('utf-8')):
|
||||||
table=td.getparent().getparent()
|
tbody=td.getparent().getparent()
|
||||||
for tr in table.iter('tr'):
|
for tr in tbody.iter('tr'):
|
||||||
tr_class=tr.attrib.get('class')
|
tr_class=tr.attrib.get('class')
|
||||||
if tr_class == 'tbl1' or tr_class=='tbl2':
|
if tr_class == 'tbl1' or tr_class=='tbl2':
|
||||||
tds=tr.findall('td')
|
tds=tr.findall('td')
|
||||||
d=date(*reversed([int(x) for x in tds[0].text.split('/')]))
|
d=date(*reversed([int(x) for x in tds[0].text.split('/')]))
|
||||||
label=u''+tds[1].find('a').text.strip()
|
label=u''+tds[1].find('a').text.strip()
|
||||||
if tds[3].text.strip() != u"":
|
if tds[debitColumns[i]].text.strip() != u"":
|
||||||
amount = - float(tds[3].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
amount = - float(tds[debitColumns[i]].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||||
else:
|
else:
|
||||||
amount= float(tds[4].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
amount= float(tds[creditColumns[i]].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||||
operation=Operation(len(self.operations))
|
operation=Operation(len(operations))
|
||||||
operation.date=d
|
operation.date=d
|
||||||
operation.label=label
|
operation.label=label
|
||||||
operation.amount=amount
|
operation.amount=amount
|
||||||
self.operations.append(operation)
|
operations.append(operation)
|
||||||
|
return operations
|
||||||
|
|
||||||
|
def get_operations(self,account):
|
||||||
|
if account.type=="CA":
|
||||||
|
return [] # Not supported: page example required
|
||||||
|
elif account.type=="CC":
|
||||||
|
return self.get_specific_operations(['Opérations effectuées'],[3],[4])
|
||||||
|
elif account.type=="CD":
|
||||||
|
return self.get_specific_operations(['Solde au'],[2],[3])
|
||||||
|
elif account.type=="CE":
|
||||||
|
return self.get_specific_operations(['Solde au'],[2],[3])
|
||||||
|
|
||||||
|
|
||||||
def get_operations(self):
|
|
||||||
return self.operations
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue