From 190adbfb81dce29cba6717fb59201a8cbad82732 Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Mon, 12 Nov 2018 16:41:04 +0100 Subject: [PATCH] [creditmutuel] Handle differed transfer To do that, we have to add transfer object into the browser.py and handle the exec_date. --- modules/creditmutuel/browser.py | 6 +++--- modules/creditmutuel/module.py | 2 +- modules/creditmutuel/pages.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/creditmutuel/browser.py b/modules/creditmutuel/browser.py index 723d94083e..3ed93fefea 100644 --- a/modules/creditmutuel/browser.py +++ b/modules/creditmutuel/browser.py @@ -501,7 +501,7 @@ def iter_recipients(self, origin_account): yield recipient @need_login - def init_transfer(self, account, to, amount, reason=None): + def init_transfer(self, account, to, amount, exec_date, reason=None): if to.category != 'Interne': self.external_transfer.go(subbank=self.currentSubBank) else: @@ -514,8 +514,8 @@ def init_transfer(self, account, to, amount, reason=None): break self.page.IS_PRO_PAGE = True self.page.RECIPIENT_STRING = 'data_input_indiceBen' - self.page.prepare_transfer(account, to, amount, reason) - return self.page.handle_response(account, to, amount, reason) + self.page.prepare_transfer(account, to, amount, reason, exec_date) + return self.page.handle_response(account, to, amount, reason, exec_date) @need_login def execute_transfer(self, transfer, **params): diff --git a/modules/creditmutuel/module.py b/modules/creditmutuel/module.py index bec4903d23..b0a54e3206 100644 --- a/modules/creditmutuel/module.py +++ b/modules/creditmutuel/module.py @@ -122,7 +122,7 @@ def init_transfer(self, transfer, **params): # drop characters that can crash website transfer.label = transfer.label.encode('cp1252', errors="ignore").decode('cp1252') - return self.browser.init_transfer(account, recipient, amount, transfer.label) + return self.browser.init_transfer(account, recipient, amount, transfer.exec_date, transfer.label) def execute_transfer(self, transfer, **params): return self.browser.execute_transfer(transfer) diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index 4a0593e463..d81aac819a 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -1330,11 +1330,12 @@ def get_transfer_form(self): # internal and external transfer form are differents return self.get_form(id='P:F', submit='//input[@type="submit" and contains(@value, "Valider")]') - def prepare_transfer(self, account, to, amount, reason): + def prepare_transfer(self, account, to, amount, reason, exec_date): form = self.get_transfer_form() form['data_input_indiceCompteADebiter'] = self.get_from_account_index(account.id) form[self.RECIPIENT_STRING] = self.get_to_account_index(to.id) form['[t:dbt%3adouble;]data_input_montant_value_0_'] = str(amount).replace('.', ',') + form['[t:dbt%3adate;]data_input_date'] = exec_date.strftime("%d/%m/%Y") form['[t:dbt%3astring;x(27)]data_input_libelleCompteDebite'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite1'] = reason @@ -1374,7 +1375,6 @@ def check_data_consistency(self, account_id, recipient_id, amount, reason): exec_date = Date(Regexp(CleanText('//table[@summary]/tbody/tr[th[contains(text(), "Date")]]/td'), r'(\d{2}/\d{2}/\d{4})'), dayfirst=True)(self.doc) - assert exec_date == datetime.today().date() r_amount = CleanDecimal('//table[@summary]/tbody/tr[th[contains(text(), "Montant")]]/td', replace_dots=True)(self.doc) assert r_amount == Decimal(amount) @@ -1383,7 +1383,7 @@ def check_data_consistency(self, account_id, recipient_id, amount, reason): assert reason.upper()[:22].strip() in CleanText('//table[@summary]/tbody/tr[th[contains(text(), "Intitulé pour le compte à débiter")]]/td')(self.doc) return exec_date, r_amount, currency - def handle_response(self, account, recipient, amount, reason): + def handle_response(self, account, recipient, amount, reason, exec_date): self.check_errors() self.check_success() -- GitLab