diff --git a/htdocs/companybankaccount.class.php b/htdocs/companybankaccount.class.php index df8c395f12c..81df314c1a0 100644 --- a/htdocs/companybankaccount.class.php +++ b/htdocs/companybankaccount.class.php @@ -190,7 +190,7 @@ class CompanyBankAccount require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php'; // Call function to check BAN - if (! verif_rib($this)) + if (! checkBanForAccount($this)) { $this->error_number = 12; $this->error_message = 'RIBControlError'; diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index fbf13f0885e..a3f1c1ac493 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -262,7 +262,7 @@ class Account extends CommonObject } } - /* + /** * \brief Creation du compte bancaire en base * \return int < 0 si erreur, > 0 si ok */ @@ -270,19 +270,13 @@ class Account extends CommonObject { global $langs; - // Verification parametres + // Check parameters if (! $this->min_allowed) $this->min_allowed=0; if (! $this->min_desired) $this->min_desired=0; // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php'; - if (! verif_rib($this)) - { - $this->error='RIBControlError'; - return -1; - } - if (! $this->ref) { $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); @@ -332,7 +326,7 @@ class Account extends CommonObject } } - /* + /** * \brief Mise a jour compte, partie generale * \param user Object utilisateur qui modifie * \return int <0 si ko, >0 si ok @@ -341,8 +335,10 @@ class Account extends CommonObject { global $langs; - dolibarr_syslog("Account::update"); - + // Check parameters + if (! $this->min_allowed) $this->min_allowed=0; + if (! $this->min_desired) $this->min_desired=0; + if (! $this->ref) { $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); diff --git a/htdocs/lib/bank.lib.php b/htdocs/lib/bank.lib.php index 553c24844be..613f2106f16 100644 --- a/htdocs/lib/bank.lib.php +++ b/htdocs/lib/bank.lib.php @@ -94,11 +94,12 @@ function checkBanForAccount($account) $country_code=$account->getCountryCode(); // For compatibility between - // account of type CompanyBankAccount class (we use number) - // account of type Account class (we use num_compte) + // account of type CompanyBankAccount class (we use number, cle_rib) + // account of type Account class (we use num_compte, cle) if (empty($account->number)) $account->number=$account->num_compte; - - dolibarr_syslog("Bank.lib::checkBanForAccount account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); + if (empty($account->cle)) $account->cle=$account->cle_rib; + + dolibarr_syslog("Bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); if ($country_code == 'FR') // France rules { @@ -117,7 +118,7 @@ function checkBanForAccount($account) } // Soustraction du modulo 97 de $s a 97 pour obtenir la cle $cle_rib = 97 - ($s % 97) ; - if ($cle_rib == $cle) + if ($cle_rib == $account->cle) { return true; } @@ -136,7 +137,7 @@ function checkBanForAccount($account) $cle_rib=strtolower(CheckES($rib,$CCC)); - if ($cle_rib == strtolower($account->cle_rib)) + if ($cle_rib == strtolower($account->cle)) { return true; }