From b340e6946f9c2a880650c28302223f11230af395 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Fri, 3 Feb 2017 10:37:33 +0100 Subject: [PATCH] [societegenerale] some loans have no balance in the loan json --- modules/societegenerale/pages/accounts_list.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/societegenerale/pages/accounts_list.py b/modules/societegenerale/pages/accounts_list.py index 1400f0b10f..15843b1347 100644 --- a/modules/societegenerale/pages/accounts_list.py +++ b/modules/societegenerale/pages/accounts_list.py @@ -470,11 +470,15 @@ class item(ItemElement): obj_id = Dict('idPrestation') obj_type = Account.TYPE_LOAN obj_label = Dict('libelle') - obj_currency = Dict('capitalRestantDu/devise') + obj_currency = Dict('capitalRestantDu/devise', default=NotAvailable) obj__link_id = None def obj_balance(self): - val = Decimal(Dict('capitalRestantDu/valeur')(self)) + val = Dict('capitalRestantDu/valeur', default=NotAvailable)(self) + if val is NotAvailable: + return val + + val = Decimal(val) point = Decimal(Dict('capitalRestantDu/posDecimale')(self)) assert point >= 0 return val.scaleb(-point) @@ -482,4 +486,8 @@ def obj_balance(self): def validate(self, obj): assert obj.id assert obj.label + if obj.balance is NotAvailable: + # ... but the account may be in the main AccountsList anyway + self.logger.debug('skipping account %r %r due to missing balance', obj.id, obj.label) + return False return True -- GitLab