Add balance command to leclercmobile
This commit is contained in:
parent
757167a6eb
commit
681b83e4b3
4 changed files with 20 additions and 1 deletions
|
|
@ -96,3 +96,7 @@ class LeclercMobileBackend(BaseBackend, ICapBill):
|
||||||
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
return self.browser.readurl(bill._url)
|
return self.browser.readurl(bill._url)
|
||||||
|
|
||||||
|
def get_balance(self, subscription):
|
||||||
|
with self.browser:
|
||||||
|
return self.browser.get_balance()
|
||||||
|
|
|
||||||
|
|
@ -129,3 +129,10 @@ class Leclercmobile(BaseBrowser):
|
||||||
for a in l:
|
for a in l:
|
||||||
if a.id == id:
|
if a.id == id:
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
def get_balance(self):
|
||||||
|
if not self.is_on_page(HistoryPage):
|
||||||
|
self.location(self.conso)
|
||||||
|
response = self.openurl('/EspaceClient/pgeWERL015_RecupReleveConso.aspx?m=-0')
|
||||||
|
pdf = PdfPage(StringIO.StringIO(response.read()))
|
||||||
|
return pdf.get_balance()
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,14 @@ class PdfPage():
|
||||||
details.append(detail)
|
details.append(detail)
|
||||||
return details
|
return details
|
||||||
|
|
||||||
|
def get_balance(self):
|
||||||
|
for calls in self.get_calls():
|
||||||
|
if "Votre solde" in calls.label:
|
||||||
|
detail = Detail()
|
||||||
|
detail.price = calls.price
|
||||||
|
detail.label = u"Balance"
|
||||||
|
return detail
|
||||||
|
|
||||||
# Standard pdf text extractor take text line by line
|
# Standard pdf text extractor take text line by line
|
||||||
# But the position in the file is not always the "real" position to display...
|
# But the position in the file is not always the "real" position to display...
|
||||||
# It produce some unsorted and unparsable data
|
# It produce some unsorted and unparsable data
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,6 @@ class ICapBill(ICapCollection):
|
||||||
|
|
||||||
:param subscription: subscription to get balance
|
:param subscription: subscription to get balance
|
||||||
:type subscription: :class:`Subscription`
|
:type subscription: :class:`Subscription`
|
||||||
:rtype :class:`Decimal`
|
:rtype :class:`Detail`
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue