diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 1a021996163..0e82681c686 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -48,11 +48,11 @@ if ($action == "set")
$id=GETPOST('PRELEVEMENT_ID_BANKACCOUNT','int');
$account = new Account($db);
-
if($account->fetch($id)>0)
{
$res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
+ /*
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
@@ -67,6 +67,7 @@ if ($action == "set")
if (! $res > 0) $error++;
$res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
+ */
}
else $error++;
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 800cd8492c9..a49b5f5f7c6 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -27,6 +27,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@@ -1015,15 +1016,21 @@ class BonPrelevement extends CommonObject
$this->date_echeance = $datetimeprev;
$this->reference_remise = $ref;
- $this->raison_sociale = $conf->global->PRELEVEMENT_RAISON_SOCIALE;
+ $id=$conf->global->PRELEVEMENT_ID_BANKACCOUNT;
+ $account = new Account($this->db);
+ if ($account->fetch($id)>0)
+ {
+ $this->emetteur_code_banque = $account->code_banque;
+ $this->emetteur_code_guichet = $account->code_guichet;
+ $this->emetteur_numero_compte = $account->number;
+ $this->emetteur_number_key = $account->cle_rib;
+ $this->emetteur_iban = $account->iban;
+ $this->emetteur_bic = $account->bic;
- $this->emetteur_code_banque = $conf->global->PRELEVEMENT_CODE_BANQUE;
- $this->emetteur_code_guichet = $conf->global->PRELEVEMENT_CODE_GUICHET;
- $this->emetteur_numero_compte = $conf->global->PRELEVEMENT_NUMERO_COMPTE;
- $this->emetteur_number_key = $conf->global->PRELEVEMENT_NUMBER_KEY;
- $this->emetteur_iban = $conf->global->PRELEVEMENT_IBAN;
- $this->emetteur_bic = $conf->global->PRELEVEMENT_BIC;
- $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
+ $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
+
+ $this->raison_sociale = $account->proprio;
+ }
$this->factures = $factures_prev_id;
@@ -1680,6 +1687,23 @@ class BonPrelevement extends CommonObject
$dateTime_ETAD = dol_print_date($ladate, '%Y-%m-%d');
$dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S');
+ // Get data of bank account
+ $id=$configuration->global->PRELEVEMENT_ID_BANKACCOUNT;
+ $account = new Account($this->db);
+ if ($account->fetch($id)>0)
+ {
+ $this->emetteur_code_banque = $account->code_banque;
+ $this->emetteur_code_guichet = $account->code_guichet;
+ $this->emetteur_numero_compte = $account->number;
+ $this->emetteur_number_key = $account->cle_rib;
+ $this->emetteur_iban = $account->iban;
+ $this->emetteur_bic = $account->bic;
+
+ $this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
+
+ $this->raison_sociale = $account->proprio;
+ }
+
// Récupération info demandeur
$sql = "SELECT rowid, ref";
$sql.= " FROM";
@@ -1714,7 +1738,7 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->PRELEVEMENT_RAISON_SOCIALE)).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($this->raison_sociale)).''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
$XML_SEPA_INFO .= ' '.strtoupper(dol_string_unaccent($configuration->global->MAIN_INFO_SOCIETE_ADDRESS)).''.$CrLf;
@@ -1723,16 +1747,16 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $configuration->global->PRELEVEMENT_IBAN).''.$CrLf;
+ $XML_SEPA_INFO .= ' '.preg_replace('/\s/', '', $this->emetteur_iban).''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_BIC.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
/* $XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_RAISON_SOCIALE.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$country[1].''.$CrLf;
$XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf;
@@ -1744,7 +1768,7 @@ class BonPrelevement extends CommonObject
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
- $XML_SEPA_INFO .= ' '.$configuration->global->PRELEVEMENT_ICS.''.$CrLf;
+ $XML_SEPA_INFO .= ' '.$this->emetteur_ics.''.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
$XML_SEPA_INFO .= ' SEPA'.$CrLf;
$XML_SEPA_INFO .= ' '.$CrLf;
diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php
index 1a8c673c5f9..d381c32676a 100755
--- a/scripts/withdrawals/build_withdrawal_file.php
+++ b/scripts/withdrawals/build_withdrawal_file.php
@@ -70,6 +70,7 @@ if (! isset($argv[1])) { // Check parameters
$withdrawreceipt=new BonPrelevement($db);
+// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
$result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->global->PRELEVEMENT_CODE_GUICHET,$argv[1]);