diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php index 0aa01f5ff3c..92957004b61 100644 --- a/htdocs/compta/bank/bankid_fr.php +++ b/htdocs/compta/bank/bankid_fr.php @@ -31,6 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); $langs->load("banks"); +$langs->load("bills"); // Security check if (isset($_GET["id"]) || isset($_GET["ref"])) @@ -174,7 +175,7 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') print ''.$langs->trans("BankName").''; print ''.$account->bank.''; - if ($account->useDetailedBBAN()) + if ($account->useDetailedBBAN() == 1) { print ''.$langs->trans("BankCode").''; print ''.$account->code_banque.''; @@ -184,12 +185,18 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') print ''.$account->code_guichet.''; print ''; } + if ($account->useDetailedBBAN() == 2) + { + print ''.$langs->trans("BankCode").''; + print ''.$account->code_banque.''; + print ''; + } print ''.$langs->trans("BankAccountNumber").''; print ''.$account->number.''; print ''; - if ($account->useDetailedBBAN()) + if ($account->useDetailedBBAN() == 1) { print ''.$langs->trans("BankAccountNumberKey").''; print ''.$account->cle_rib.''; @@ -307,7 +314,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure print ''; // BBAN - if ($account->useDetailedBBAN()) + if ($account->useDetailedBBAN() == 1) { print ''.$langs->trans("BankCode").''; print ''; @@ -317,12 +324,18 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure print ''; print ''; } + if ($account->useDetailedBBAN() == 2) + { + print ''.$langs->trans("BankCode").''; + print ''; + print ''; + } print ''.$langs->trans("BankAccountNumber").''; print ''; print ''; - if ($account->useDetailedBBAN()) + if ($account->useDetailedBBAN() == 1) { print ''.$langs->trans("BankAccountNumberKey").''; print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 059f0b53ef9..33d83a1a681 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -23,7 +23,7 @@ /** * \file htdocs/compta/bank/class/account.class.php * \ingroup banque - * \brief Fichier de la classe des comptes bancaires + * \brief File of class to manage bank accounts * \version $Id$ */ @@ -869,6 +869,35 @@ class Account extends CommonObject return $result; } + + // Method after here are common to Account and CompanyBankAccount + + + /** + * Return if an account has valid information + * @return int 1 if correct, <=0 if wrong + */ + function verif() + { + require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php'; + + // Call function to check BAN + if (! checkBanForAccount($this)) + { + $this->error_number = 12; + $this->error_message = 'RIBControlError'; + } + + if ($this->error_number == 0) + { + return 1; + } + else + { + return 0; + } + } + /** * Return account country code * @return String country code @@ -889,7 +918,16 @@ class Account extends CommonObject if (preg_match("/^([a-zA-Z][a-zA-Z])/i",$this->iban,$reg)) return $reg[1]; } - // We return country code of company + // If this class is linked to a third party + if (! empty($this->socid)) + { + require_once(DOL_DOCUMENT_ROOT ."/societe/class/societe.class.php"); + $company=new Societe($this->db); + $result=$company->fetch($this->socid); + if (! empty($company->pays_code)) return $company->pays_code; + } + + // We return country code of managed company if (! empty($mysoc->pays_code)) return $mysoc->pays_code; return ''; @@ -897,17 +935,37 @@ class Account extends CommonObject /** * Return if a bank account is defined with detailed information (bank code, desk code, number and key) - * @return boolean true or false + * @return int 0=Use only an account number + * 1=Need Bank, Desk, Number and Key (France, Spain, ...) + * 2=Neek Bank onyl (BSB for Australia) */ function useDetailedBBAN() { $country_code=$this->getCountryCode(); - if ($country_code == 'FR') return true; // France - if ($country_code == 'ES') return true; // Spain - if ($country_code == 'GA') return true; // Gabon + if (in_array($country_code,array('FR','ES','GA'))) return 1; // France, Spain, Gabon + if (in_array($country_code,array('AU'))) return 2; // Australia + return 0; + } - return false; + /** + * Initialize properties with test values + */ + function initAsSpecimen() + { + $this->bank = 'MyBank'; + $this->courant = 1; + $this->clos = 0; + $this->code_banque = '123'; + $this->code_guichet = '456'; + $this->number = 'ABC12345'; + $this->cle_rib = 50; + $this->bic = 'AA12'; + $this->iban = 'FR999999999'; + $this->iban_prefix = 'FR'; // deprecated + $this->domiciliation = 'The bank addresse'; + $this->proprio = 'Owner'; + $this->adresse_proprio = 'Owner address'; } }