From 387a3e3cdc31032e63b3c0e660d6629e91b6ccdd Mon Sep 17 00:00:00 2001 From: Damien Mat Date: Tue, 25 Jun 2019 10:01:37 +0200 Subject: [PATCH] [cices] Account typing (cmes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typing 'compte courant bloqué' account as TYPE_LIFE_DEPOSIT Build to associate a transaction to the proper account in case of several transactions on the OperationPage Closes: 11364@zendesk --- modules/cmes/browser.py | 7 ++++--- modules/cmes/pages.py | 33 +++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/modules/cmes/browser.py b/modules/cmes/browser.py index 996879a612..11ae936a27 100644 --- a/modules/cmes/browser.py +++ b/modules/cmes/browser.py @@ -78,9 +78,10 @@ def iter_investment(self, account): def iter_history(self, account): self.operations_list.stay_or_go(subsite=self.subsite, client_space=self.client_space) for idx in self.page.get_operations_idx(): - tr = self.operation.go(subsite=self.subsite, client_space=self.client_space, idx=idx).get_transaction() - if account.label == tr._account_label: - yield tr + self.operation.go(subsite=self.subsite, client_space=self.client_space, idx=idx) + for tr in self.page.get_transactions(): + if account.label == tr._account_label: + yield tr @need_login def iter_pocket(self, account): diff --git a/modules/cmes/pages.py b/modules/cmes/pages.py index fd661e4104..1b5096ec63 100644 --- a/modules/cmes/pages.py +++ b/modules/cmes/pages.py @@ -77,14 +77,15 @@ def on_load(self): ACCOUNTS_TYPES = { "pargne entreprise": Account.TYPE_PEE, "pargne groupe": Account.TYPE_PEE, - "pargne retraite": Account.TYPE_PERCO + "pargne retraite": Account.TYPE_PERCO, + "courant bloqué": Account.TYPE_DEPOSIT, } class NewAccountsPage(LoggedPage, HTMLPage): @method class iter_accounts(ListElement): - item_xpath = '//th[text()= "Nom du support" or text()="Nom du profil"]/ancestor::table/ancestor::table' + item_xpath = '//th[text()= "Nom du support" or text()="Nom du profil" or text()="Nom du compte"]/ancestor::table/ancestor::table' class item(ItemElement): klass = Account @@ -166,15 +167,27 @@ def iter_pocket(self, inv): class OperationPage(LoggedPage, HTMLPage): + + # Most '_account_label' correspond 'account.label', but there are exceptions + ACCOUNTS_SPE_LABELS = { + 'CCB': 'Compte courant bloqué', + } + @method - class get_transaction(ItemElement): - klass = Transaction - - obj_amount = MyDecimal('//td[contains(text(), "Montant total")]/following-sibling::td') - obj_label = CleanText('(//p[contains(@id, "smltitle")])[2]') - obj_raw = Transaction.Raw(Field('label')) - obj_date = Date(Regexp(CleanText('(//p[contains(@id, "smltitle")])[1]'), r'(\d{1,2}/\d{1,2}/\d+)'), dayfirst=True) - obj__account_label = CleanText('//td[contains(text(), "Montant total")]/../following-sibling::tr/th[1]') + class get_transactions(ListElement): + item_xpath = '//tr[@id]' + + class item(ItemElement): + klass = Transaction + + obj_amount = MyDecimal('./th[@scope="rowgroup"][2]') + obj_label = CleanText('(//p[contains(@id, "smltitle")])[2]') + obj_raw = Transaction.Raw(Field('label')) + obj_date = Date(Regexp(CleanText('(//p[contains(@id, "smltitle")])[1]'), r'(\d{1,2}/\d{1,2}/\d+)'), dayfirst=True) + + def obj__account_label(self): + account_label = CleanText('./th[@scope="rowgroup"][1]')(self) + return self.page.ACCOUNTS_SPE_LABELS.get(account_label, account_label) class OperationsListPage(LoggedPage, HTMLPage): -- GitLab