From d5fb50c4b3d104a1669a1c91404129ac0be0ca91 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Tue, 21 Jul 2020 11:26:10 +0200 Subject: [PATCH] [ing] implement fillobj for "coming" No need to fetch them in iter_accounts. --- modules/ing/api/accounts_page.py | 2 +- modules/ing/api_browser.py | 19 +++++++++++++------ modules/ing/module.py | 10 ++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/ing/api/accounts_page.py b/modules/ing/api/accounts_page.py index c2b0976014..baa9da21fb 100644 --- a/modules/ing/api/accounts_page.py +++ b/modules/ing/api/accounts_page.py @@ -207,7 +207,7 @@ def obj_raw(self): ) @method - class get_account_coming(ItemElement): + class fill_account_coming(ItemElement): klass = Account obj_coming = CleanDecimal(Dict('totalAmount', default=NotAvailable), default=NotAvailable) diff --git a/modules/ing/api_browser.py b/modules/ing/api_browser.py index 2c6b5c330d..520f6bc54d 100644 --- a/modules/ing/api_browser.py +++ b/modules/ing/api_browser.py @@ -303,9 +303,6 @@ def get_api_accounts(self): """iter accounts on new website""" self.accounts.stay_or_go() for account in self.page.iter_accounts(): - self.coming.go(account_uid=account.id) - account = self.page.get_account_coming(obj=account) - # We get life insurance details from the API, not the old website # If the balance is 0, the details page throws an error 500 if account.type == Account.TYPE_LIFE_INSURANCE: @@ -317,9 +314,6 @@ def get_api_accounts(self): } ) self.page.fill_account(obj=account) - elif account.type in self.types_with_iban: - self.account_info.go(account_uid=account.id) - account.iban = self.page.get_iban() yield account @@ -432,6 +426,19 @@ def iter_coming(self, account): else: return self.get_api_coming(account) + @need_to_be_on_website('api') + @need_login + def fill_account_coming(self, account): + self.coming.go(account_uid=account._uid) + self.page.fill_account_coming(obj=account) + + @need_to_be_on_website('api') + @need_login + def fill_account_iban(self, account): + if account.type in self.types_with_iban: + self.account_info.go(account_uid=account._uid) + account.iban = self.page.get_iban() + ############# CapWealth ############# @need_login def get_investments(self, account): diff --git a/modules/ing/module.py b/modules/ing/module.py index e3ff80b73d..6a789f95c2 100644 --- a/modules/ing/module.py +++ b/modules/ing/module.py @@ -89,6 +89,11 @@ def iter_coming(self, account): account = self.get_account(account) return self.browser.iter_coming(account) + def fill_account(self, account, fields): + # TODO iban + if 'coming' in fields: + self.browser.fill_account_coming(account) + ############# CapWealth ############# def iter_investment(self, account): if not isinstance(account, Account): @@ -179,3 +184,8 @@ def download_document(self, bill): ############# CapProfile ############# def get_profile(self): return self.browser.get_profile() + + # fillobj + OBJECTS = { + Account: fill_account, + } -- GitLab