Commit 190adbfb authored by Maxime Gasselin's avatar Maxime Gasselin Committed by Romain Bignon

[creditmutuel] Handle differed transfer

To do that, we have to add transfer object into the browser.py and
handle the exec_date.
parent 9cb1daf4
...@@ -501,7 +501,7 @@ class CreditMutuelBrowser(LoginBrowser, StatesMixin): ...@@ -501,7 +501,7 @@ class CreditMutuelBrowser(LoginBrowser, StatesMixin):
yield recipient yield recipient
@need_login @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': if to.category != 'Interne':
self.external_transfer.go(subbank=self.currentSubBank) self.external_transfer.go(subbank=self.currentSubBank)
else: else:
...@@ -514,8 +514,8 @@ class CreditMutuelBrowser(LoginBrowser, StatesMixin): ...@@ -514,8 +514,8 @@ class CreditMutuelBrowser(LoginBrowser, StatesMixin):
break break
self.page.IS_PRO_PAGE = True self.page.IS_PRO_PAGE = True
self.page.RECIPIENT_STRING = 'data_input_indiceBen' self.page.RECIPIENT_STRING = 'data_input_indiceBen'
self.page.prepare_transfer(account, to, amount, reason) self.page.prepare_transfer(account, to, amount, reason, exec_date)
return self.page.handle_response(account, to, amount, reason) return self.page.handle_response(account, to, amount, reason, exec_date)
@need_login @need_login
def execute_transfer(self, transfer, **params): def execute_transfer(self, transfer, **params):
......
...@@ -122,7 +122,7 @@ class CreditMutuelModule( ...@@ -122,7 +122,7 @@ class CreditMutuelModule(
# drop characters that can crash website # drop characters that can crash website
transfer.label = transfer.label.encode('cp1252', errors="ignore").decode('cp1252') 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): def execute_transfer(self, transfer, **params):
return self.browser.execute_transfer(transfer) return self.browser.execute_transfer(transfer)
......
...@@ -1330,11 +1330,12 @@ class InternalTransferPage(LoggedPage, HTMLPage): ...@@ -1330,11 +1330,12 @@ class InternalTransferPage(LoggedPage, HTMLPage):
# internal and external transfer form are differents # internal and external transfer form are differents
return self.get_form(id='P:F', submit='//input[@type="submit" and contains(@value, "Valider")]') 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 = self.get_transfer_form()
form['data_input_indiceCompteADebiter'] = self.get_from_account_index(account.id) form['data_input_indiceCompteADebiter'] = self.get_from_account_index(account.id)
form[self.RECIPIENT_STRING] = self.get_to_account_index(to.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%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(27)]data_input_libelleCompteDebite'] = reason
form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite'] = reason
form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite1'] = reason form['[t:dbt%3astring;x(31)]data_input_motifCompteCredite1'] = reason
...@@ -1374,7 +1375,6 @@ class InternalTransferPage(LoggedPage, HTMLPage): ...@@ -1374,7 +1375,6 @@ class InternalTransferPage(LoggedPage, HTMLPage):
exec_date = Date(Regexp(CleanText('//table[@summary]/tbody/tr[th[contains(text(), "Date")]]/td'), 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) 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', r_amount = CleanDecimal('//table[@summary]/tbody/tr[th[contains(text(), "Montant")]]/td',
replace_dots=True)(self.doc) replace_dots=True)(self.doc)
assert r_amount == Decimal(amount) assert r_amount == Decimal(amount)
...@@ -1383,7 +1383,7 @@ class InternalTransferPage(LoggedPage, HTMLPage): ...@@ -1383,7 +1383,7 @@ class InternalTransferPage(LoggedPage, HTMLPage):
assert reason.upper()[:22].strip() in CleanText('//table[@summary]/tbody/tr[th[contains(text(), "Intitulé pour le compte à débiter")]]/td')(self.doc) 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 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_errors()
self.check_success() self.check_success()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment