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/outil/UWSP/Synthese/accesSynthese': AccountsPage,
|
||||
'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):
|
||||
|
|
@ -84,7 +84,7 @@ class LCLBrowser(BaseBrowser):
|
|||
def get_history(self,account):
|
||||
if not self.is_on_page(AccountHistoryPage) :
|
||||
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):
|
||||
# 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):
|
||||
l = []
|
||||
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.type=div.attrib.get('class')[-2:]
|
||||
account.id = div.attrib.get('id').replace('-','')
|
||||
for td in div.getiterator('td'):
|
||||
if td.find("div") is not None and td.find("div").attrib.get('class') == 'libelleCompte':
|
||||
|
|
@ -71,30 +79,40 @@ class AccountsPage(BasePage):
|
|||
return l
|
||||
|
||||
class AccountHistoryPage(BasePage):
|
||||
def on_loaded(self):
|
||||
self.operations = []
|
||||
def get_specific_operations(self,tableHeaderPrefixes,debitColumns,creditColumns):
|
||||
operations = []
|
||||
for td in self.document.iter('td'):
|
||||
text=td.findtext("b")
|
||||
if text is None:
|
||||
continue
|
||||
prefix='Opérations effectuées'
|
||||
if text.startswith(prefix.decode('utf-8')):
|
||||
table=td.getparent().getparent()
|
||||
for tr in table.iter('tr'):
|
||||
tr_class=tr.attrib.get('class')
|
||||
if tr_class == 'tbl1' or tr_class=='tbl2':
|
||||
tds=tr.findall('td')
|
||||
d=date(*reversed([int(x) for x in tds[0].text.split('/')]))
|
||||
label=u''+tds[1].find('a').text.strip()
|
||||
if tds[3].text.strip() != u"":
|
||||
amount = - float(tds[3].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||
else:
|
||||
amount= float(tds[4].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||
operation=Operation(len(self.operations))
|
||||
operation.date=d
|
||||
operation.label=label
|
||||
operation.amount=amount
|
||||
self.operations.append(operation)
|
||||
for i in range(len(tableHeaderPrefixes)):
|
||||
if text.startswith(tableHeaderPrefixes[i].decode('utf-8')):
|
||||
tbody=td.getparent().getparent()
|
||||
for tr in tbody.iter('tr'):
|
||||
tr_class=tr.attrib.get('class')
|
||||
if tr_class == 'tbl1' or tr_class=='tbl2':
|
||||
tds=tr.findall('td')
|
||||
d=date(*reversed([int(x) for x in tds[0].text.split('/')]))
|
||||
label=u''+tds[1].find('a').text.strip()
|
||||
if tds[debitColumns[i]].text.strip() != u"":
|
||||
amount = - float(tds[debitColumns[i]].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||
else:
|
||||
amount= float(tds[creditColumns[i]].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
|
||||
operation=Operation(len(operations))
|
||||
operation.date=d
|
||||
operation.label=label
|
||||
operation.amount=amount
|
||||
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