Add get_balance to nettokom
This commit is contained in:
parent
80e9c2638e
commit
3a0e3b4028
2 changed files with 14 additions and 3 deletions
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from weboob.capabilities.bill import ICapBill, SubscriptionNotFound
|
from weboob.capabilities.bill import ICapBill, Subscription, SubscriptionNotFound, Detail
|
||||||
|
from weboob.capabilities.base import Currency
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.tools.value import ValueBackendPassword
|
from weboob.tools.value import ValueBackendPassword
|
||||||
|
|
||||||
|
|
@ -54,8 +55,6 @@ class NettoKomBackend(BaseBackend, ICapBill):
|
||||||
yield subscription
|
yield subscription
|
||||||
|
|
||||||
def get_subscription(self, _id):
|
def get_subscription(self, _id):
|
||||||
if not _id.isdigit():
|
|
||||||
raise SubscriptionNotFound()
|
|
||||||
with self.browser:
|
with self.browser:
|
||||||
subscription = self.browser.get_subscription(_id)
|
subscription = self.browser.get_subscription(_id)
|
||||||
if subscription:
|
if subscription:
|
||||||
|
|
@ -73,3 +72,12 @@ class NettoKomBackend(BaseBackend, ICapBill):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
for detail in self.browser.get_details():
|
for detail in self.browser.get_details():
|
||||||
yield detail
|
yield detail
|
||||||
|
|
||||||
|
def get_balance(self, subscription):
|
||||||
|
if not isinstance(subscription, Subscription):
|
||||||
|
subscription = self.get_subscription(subscription)
|
||||||
|
balance = Detail()
|
||||||
|
balance.price = subscription._balance
|
||||||
|
balance.label = u"Balance"
|
||||||
|
balance.currency = Currency.CUR_EUR
|
||||||
|
return balance
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.capabilities.bill import Subscription
|
from weboob.capabilities.bill import Subscription
|
||||||
|
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
__all__ = ['HomePage']
|
__all__ = ['HomePage']
|
||||||
|
|
||||||
|
|
@ -48,6 +50,7 @@ class HomePage(BasePage):
|
||||||
subscription.subscriber = unicode(owner)
|
subscription.subscriber = unicode(owner)
|
||||||
expiredate = date(*reversed([int(x) for x in expiredate.split(".")]))
|
expiredate = date(*reversed([int(x) for x in expiredate.split(".")]))
|
||||||
subscription.validity = expiredate
|
subscription.validity = expiredate
|
||||||
|
subscription._balance = Decimal(FrenchTransaction.clean_amount(credit))
|
||||||
|
|
||||||
l.append(subscription)
|
l.append(subscription)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue