From 66038093e451cc67a0a682fdef9fd5bccf1864ce Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Wed, 13 Mar 2019 14:15:37 +0100 Subject: [PATCH] [yomoni] Allows Investments empty date and empty quantity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moreover, add xx-liquidity Code type for "Soldes Espèces" Invests. Closes: 36887@sibi --- modules/yomoni/browser.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/yomoni/browser.py b/modules/yomoni/browser.py index c6a7bbebca..4ce9805119 100644 --- a/modules/yomoni/browser.py +++ b/modules/yomoni/browser.py @@ -17,6 +17,10 @@ # You should have received a copy of the GNU Lesser General Public License # along with this weboob module. If not, see . + +from __future__ import unicode_literals + + from base64 import b64encode from functools import wraps import json @@ -28,6 +32,7 @@ from weboob.exceptions import BrowserIncorrectPassword, ActionNeeded from weboob.capabilities.bank import Account, Investment, Transaction from weboob.capabilities.base import NotAvailable +from weboob.tools.capabilities.bank.investments import is_isin_valid def need_login(func): @@ -137,12 +142,21 @@ def iter_investment(self, account, invs=None): i = Investment() i.label = "%s - %s" % (inv['classification'], inv['description']) i.code = inv['isin'] - i.code_type = Investment.CODE_TYPE_ISIN - i.quantity = CleanDecimal().filter(inv['nombreParts']) + if not is_isin_valid(i.code): + i.code = NotAvailable + i.code_type = NotAvailable + if u'Solde Espèces' in i.label: + i.code = 'XX-liquidity' + else: + i.code_type = Investment.CODE_TYPE_ISIN + + i.quantity = CleanDecimal(default=NotAvailable).filter(inv['nombreParts']) i.unitprice = CleanDecimal().filter(inv['prixMoyenAchat']) i.unitvalue = CleanDecimal().filter(inv['valeurCotation']) i.valuation = CleanDecimal().filter(inv['montantEuro']) - i.vdate = Date().filter(inv['datePosition']) + # For some invests the vdate returned is None + # Consequently we set the default value at NotAvailable + i.vdate = Date(default=NotAvailable).filter(inv['datePosition']) # performanceEuro is null sometimes in the JSON we retrieve. if inv['performanceEuro']: i.diff = CleanDecimal().filter(inv['performanceEuro']) -- GitLab