Support internationnal BBAN (Basic Bank Account Number)

This commit is contained in:
Laurent Destailleur 2008-11-24 19:17:09 +00:00
parent 8d867a75d4
commit 750e5a45c2
21 changed files with 1190 additions and 1122 deletions

View File

@ -14,16 +14,21 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/*
* \version $Id$
*/
/**
* \brief Class
*
*/
class CompanyBankAccount
{
var $rowid;
var $socid;
var $bank;
var $courant;
var $clos;
@ -32,209 +37,194 @@ class CompanyBankAccount
var $number;
var $cle_rib;
var $bic;
var $iban_prefix;
var $iban;
var $iban_prefix; // deprecated
var $proprio;
var $adresse_proprio;
/**
* Constructor
*/
function CompanyBankAccount($DB)
{
$this->db = $DB;
$this->socid = 0;
$this->clos = 0;
$this->solde = 0;
$this->error_number = 0;
return 1;
}
/*
* Creation du compte bancaire
*
*/
function create()
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, ".$this->db->idate(mktime()).")";
if ($this->db->query($sql))
{
if ($this->db->affected_rows())
{
return 1;
}
}
else
{
print $this->db->error();
return 0;
}
}
/*
*
*
*/
function update($user='')
{
$sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib";
$sql .= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows() == 0)
{
$this->create();
}
}
else
{
print $this->db->error();
return 0;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET ";
$sql .= " bank = '" .addslashes($this->bank)."'";
$sql .= ",code_banque='".$this->code_banque."'";
$sql .= ",code_guichet='".$this->code_guichet."'";
$sql .= ",number='".$this->number."'";
$sql .= ",cle_rib='".$this->cle_rib."'";
$sql .= ",bic='".$this->bic."'";
$sql .= ",iban_prefix = '".$this->iban_prefix."'";
$sql .= ",domiciliation='".addslashes($this->domiciliation)."'";
$sql .= ",proprio = '".addslashes($this->proprio)."'";
$sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'";
$sql .= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return 0;
}
}
/*
*
*
*/
function fetch()
{
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object($result);
$this->bank = $obj->bank;
$this->courant = $obj->courant;
$this->clos = $obj->clos;
$this->code_banque = $obj->code_banque;
$this->code_guichet = $obj->code_guichet;
$this->number = $obj->number;
$this->cle_rib = $obj->cle_rib;
$this->bic = $obj->bic;
$this->iban = $obj->iban;
$this->iban_prefix = $obj->iban; // deprecated
$this->domiciliation = $obj->domiciliation;
$this->proprio = $obj->proprio;
$this->adresse_proprio = $obj->adresse_proprio;
}
$this->db->free();
}
else
{
dolibarr_print_error($this->db);
}
}
/*
*
*
*/
function error()
{
return $this->error;
}
function CompanyBankAccount($DB, $socid)
/**
*
*
*/
function verif()
{
global $config;
$this->db = $DB;
$this->socid = $socid;
require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php';
$this->clos = 0;
$this->solde = 0;
$this->error_number = 0;
return 1;
}
// Call function to check BAN
if (! verif_rib($this))
{
$this->error_number = 12;
$this->error_message = 'RIBControlError';
}
/*
* Creation du compte bancaire
*
*/
function create()
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, ".$this->db->idate(mktime()).")";
if ($this->db->query($sql))
{
if ($this->db->affected_rows())
{
return 1;
}
if ($this->error_number == 0)
{
return 1;
}
else
{
return 0;
}
}
else
/**
* \brief Return account country code
* \return String country code
*/
function getCountryCode()
{
print $this->db->error();
return 0;
if (! empty($this->iban))
{
// If IBAN defined, we can know country of account from it
if (eregi("^([a-zA-Z][a-zA-Z])",$this->iban,$reg)) return $reg[1];
}
// We return country code
$company=new Societe($this->db);
$result=$company->fetch($this->socid);
if (! empty($company->pays_code)) return $company->pays_code;
}
}
/*
*
*
*/
function update($user='')
{
$sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib ";
$sql .= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows() == 0)
{
$this->create();
}
}
else
{
print $this->db->error();
return 0;
}
if (strlen(trim($this->iban_prefix)) == 0)
{
// Indispensable de la positionner pour vérifier le RIB
$this->iban_prefix = 'FR';
}
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET ";
$sql .= " bank = '" .addslashes($this->bank)."'";
$sql .= ",code_banque='".$this->code_banque."'";
$sql .= ",code_guichet='".$this->code_guichet."'";
$sql .= ",number='".$this->number."'";
$sql .= ",cle_rib='".$this->cle_rib."'";
$sql .= ",bic='".$this->bic."'";
$sql .= ",iban_prefix = '".$this->iban_prefix."'";
$sql .= ",domiciliation='".addslashes($this->domiciliation)."'";
$sql .= ",proprio = '".addslashes($this->proprio)."'";
$sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'";
$sql .= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
return 1;
}
else
{
dolibarr_print_error($this->db);
return 0;
}
}
/*
*
*
*/
function fetch()
{
$sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib";
$sql .= " WHERE fk_soc = ".$this->socid;
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object($result);
$this->bank = $obj->bank;
$this->courant = $obj->courant;
$this->clos = $obj->clos;
$this->code_banque = $obj->code_banque;
$this->code_guichet = $obj->code_guichet;
$this->number = $obj->number;
$this->cle_rib = $obj->cle_rib;
$this->bic = $obj->bic;
$this->iban_prefix = $obj->iban_prefix;
$this->domiciliation = $obj->domiciliation;
$this->proprio = $obj->proprio;
$this->adresse_proprio = $obj->adresse_proprio;
}
$this->db->free();
}
else
{
dolibarr_print_error($this->db);
}
}
/*
*
*
*/
function error()
{
return $this->error;
}
/*
*
*
*/
function verif()
{
require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php';
if (strlen(trim($this->code_banque)) == 0)
{
$this->error_number = 32;
$this->error_message = "Le code banque n'est pas renseigné";
}
if (strlen(trim($this->code_guichet)) == 0)
{
$this->error_number = 33;
$this->error_message = "Le code guichet n'est pas renseigné";
}
if (strlen(trim($this->number)) == 0)
{
$this->error_number = 34;
$this->error_message = "Le numéro de compte n'est pas renseigné";
}
if (strlen(trim($this->cle_rib)) == 0)
{
$this->error_number = 35;
$this->error_message = "La clé n'est pas renseignée";
}
if (strlen(trim($this->iban_prefix)) == 0)
{
$this->error_number = 36;
$this->error_message = "La cle IBAN n'est pas renseignée";
}
if (! verif_rib($this->code_banque, $this->code_guichet, $this->number, $this->cle_rib, $this->iban_prefix))
{
$this->error_number = 12;
$this->error_message = "Le RIB n'est pas valide";
}
if ($this->error_number == 0)
{
return 1;
}
else
{
return 0;
}
}
return '';
}
}
?>

View File

@ -48,17 +48,17 @@ class Account extends CommonObject
var $clos;
var $rappro;
var $url;
//! Code banque dans le RIB
//! BBAN field for French Code banque
var $code_banque;
//! Code guichet dans le RIB
//! BBAN field for French Code guichet
var $code_guichet;
//! Numero du compte dans le RIB
//! BBAN main account number
var $number;
//! Cle de controle du RIB
//! BBAN field for French Cle de controle
var $cle_rib;
//! Numero BIC/SWIFT du compte
//! BIC/SWIFT number
var $bic;
//! Prefix IBAN a utiliser pour creer la cle IBAN International Bank Account Number
//! IBAN number (International Bank Account Number)
var $iban_prefix;
var $proprio;
var $adresse_proprio;
@ -277,9 +277,10 @@ class Account extends CommonObject
// Chargement librairie pour acces fonction controle RIB
require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php';
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
$this->error="Le controle de la cle indique que les informations de votre compte bancaire sont incorrectes.";
return 0;
if (! verif_rib($this))
{
$this->error='RIBControlError';
return -1;
}
if (! $this->ref)
@ -345,6 +346,7 @@ class Account extends CommonObject
if (! $this->ref)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
dolibarr_syslog("Account::update ".$this->error);
return -1;
}
if (! $this->label) $this->label = "???";
@ -368,7 +370,7 @@ class Account extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
dolibarr_syslog("Account::update sql=$sql");
dolibarr_syslog("Account::update sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
@ -384,29 +386,24 @@ class Account extends CommonObject
/*
* \brief Mise a jour compte, partie RIB
* \brief Update BBAN (RIB) account fields
* \param user Object utilisateur qui modifie
* \return int <0 si ko, >0 si ok
*/
function update_rib($user='')
function update_bban($user='')
{
global $langs;
// Chargement librairie pour acces fonction controle RIB
require_once(DOL_DOCUMENT_ROOT.'/lib/bank.lib.php');
dolibarr_syslog("Account::update $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix");
// Verification parametres
if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) {
$this->error="Le contr<74>le de la cl<63> indique que les informations de votre compte bancaire sont incorrectes.";
return 0;
}
dolibarr_syslog("Account::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban");
// Check parameters
if (! $this->ref)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
return -1;
return -2;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET ";
@ -416,13 +413,13 @@ class Account extends CommonObject
$sql .= ",number='".$this->number."'";
$sql .= ",cle_rib='".$this->cle_rib."'";
$sql .= ",bic='".$this->bic."'";
$sql .= ",iban_prefix = '".$this->iban_prefix."'";
$sql .= ",iban_prefix = '".$this->iban."'";
$sql .= ",domiciliation='".addslashes($this->domiciliation)."'";
$sql .= ",proprio = '".addslashes($this->proprio)."'";
$sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'";
$sql .= " WHERE rowid = ".$this->id;
dolibarr_syslog("Account::update_rib sql=$sql");
dolibarr_syslog("Account::update_bban sql=$sql");
$result = $this->db->query($sql);
if ($result)
@ -446,7 +443,7 @@ class Account extends CommonObject
function fetch($id,$ref='')
{
$sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,";
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,";
$sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,";
$sql.= " domiciliation, proprio, adresse_proprio,";
$sql.= " account_number, currency_code,";
$sql.= " min_allowed, min_desired, comment";
@ -478,7 +475,8 @@ class Account extends CommonObject
$this->number = $obj->number;
$this->cle_rib = $obj->cle_rib;
$this->bic = $obj->bic;
$this->iban_prefix = $obj->iban_prefix;
$this->iban = $obj->iban;
$this->iban_prefix = $obj->iban; // deprecated
$this->domiciliation = $obj->domiciliation;
$this->proprio = $obj->proprio;
$this->adresse_proprio = $obj->adresse_proprio;
@ -747,12 +745,32 @@ class Account extends CommonObject
return $result;
}
/**
* \brief Return account country code
* \return String country code
*/
function getCountryCode()
{
global $mysoc;
if (! empty($this->iban))
{
// If IBAN defined, we can know country of account from it
if (eregi("^([a-zA-Z][a-zA-Z])",$this->iban,$reg)) return $reg[1];
}
// We return country code
if (! empty($mysoc->pays_code)) return $mysoc->pays_code;
return '';
}
}
/**
\class AccountLine
\brief Classe permettant la gestion des lignes de transactions bancaires
* \class AccountLine
* \brief Classe permettant la gestion des lignes de transactions bancaires
*/
class AccountLine
{
@ -997,6 +1015,7 @@ class AccountLine
return $result;
}
}
?>

View File

@ -48,14 +48,15 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$account->number = trim($_POST["number"]);
$account->cle_rib = trim($_POST["cle_rib"]);
$account->bic = trim($_POST["bic"]);
$account->iban_prefix = trim($_POST["iban_prefix"]);
$account->iban = trim($_POST["iban_prefix"]);
$account->iban_prefix = trim($_POST["iban_prefix"]); // deprecated
$account->domiciliation = trim($_POST["domiciliation"]);
$account->proprio = trim($_POST["proprio"]);
$account->adresse_proprio = trim($_POST["adresse_proprio"]);
if ($account->id)
{
$result = $account->update_rib($user);
$result = $account->update_bban($user);
if ($result >= 0)
{
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
@ -122,6 +123,13 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print '<br />';
}
// Check BBAN
if (! checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div><br>';
}
print '<table class="border" width="100%">';
// Ref
@ -144,22 +152,28 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print '<tr><td valign="top">'.$langs->trans("BankName").'</td>';
print '<td colspan="3">'.$account->bank.'</td></tr>';
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td colspan="3">'.$account->code_guichet.'</td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td colspan="3">'.$account->code_guichet.'</td>';
print '</tr>';
}
print '<tr><td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td colspan="3">'.$account->number.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
print '</tr>';
}
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="3">'.$account->iban_prefix.'</td></tr>';
@ -245,22 +259,30 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td>';
print '</tr>';
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
// BBAN
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
}
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="15" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
}
// IBAN
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="3"><input size="24" type="text" class="flat" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';

View File

@ -1152,22 +1152,6 @@ class BonPrelevement extends CommonObject
{
$result = -2;
}
/*
$nbfactures = sizeof($this->factures);
for ($i = 0 ; $i < $nbfactures ; $i++)
{
$fac = new Facture($this->db);
$fac->fetch($this->factures[$i]);
$fac->fetch_client();
$fac->client->rib();
if ($fac->client->bank_account->verif()) {
$this->total = $this->total + $fac->total_ttc;
$this->EnregDestinataire($fac);
}else{
print $fac->client->bank_account->error_message;
print $fac->client->nom; }
}
*/
/*
* Pied de page total

View File

@ -2422,7 +2422,8 @@ class Facture extends CommonObject
$soc = new Societe($this->db);
$soc->id = $this->socid;
$soc->rib();
$soc->load_ban();
if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3)
{
$sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';

View File

@ -27,7 +27,7 @@ CurrentBalance=Current balance
FutureBalance=Future balance
ShowAllTimeBalance=Show balance from start
Reconciliation=Reconciliation
RIB=RIB
RIB=Bank Account Number
IBAN=IBAN number
BIC=BIC/SWIFT number
StandingOrders=Standing orders
@ -43,7 +43,7 @@ IOMonthlyReporting=Monthly reporting
BankAccountDomiciliation=Account address
BankAccountOwner=Account owner name
BankAccountOwnerAddress=Account owner address
RIBControlError=Control of key says informations for this account number are not complete or wrong.
RIBControlError=Inetgrity checks of values fails. This means information for this account number are not complete or wrong (check country, numbers and IBAN).
CreateAccount=Create account
StandingOrderToProcess=To process
StandingOrderProcessed=Processed

View File

@ -106,7 +106,7 @@ ProfId4PT=Prof Id 4 (Conservatory)
ProfId1TN=Prof Id 1 (RC)
ProfId2TN=Prof Id 2 (Fiscal matricule)
ProfId3TN=Prof Id 3 (Douane code)
ProfId4TN=Prof Id 4 (RIB)
ProfId4TN=Prof Id 4 (BAN)
VATIntra=VAT number
VATIntraShort=VAT number
VATIntraVeryShort=VAT
@ -226,7 +226,7 @@ ProspectsByStatus=Prospects by status
BillingContact=Billing contact
NbOfAttachedFiles=Number of attached files
AttachANewFile=Attach a new file
NoRIB=No RIB defined
NoRIB=No BAN defined
NoParentCompany=None
ExportImport=Import-Export
ExportCardToFormat=Export card to format

View File

@ -29,5 +29,5 @@ LastWithdrawalReceipt=Last %s withdrawing receipts
MakeWithdrawRequest=Make a withdraw request
ThirdPartyBankCode=Third party bank code
ThirdPartyDeskCode=Third party desk code
NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid RIB.
NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid BAN.
ClassCredited=Classer crédité

View File

@ -663,7 +663,7 @@ ForceInvoiceDate=Forcer la date de facture
DisableRepeatable=Désactiver les factures récurrentes
SuggestedPaymentModesIfNotDefinedInInvoice=Modes de paiements suggérés par défaut si non défini au niveau de la facture
EnableEditDeleteValidInvoice=Activer la possibilité de rééditer/supprimer une facture validée sans paiement
SuggestPaymentByRIBOnAccount=Proposer paiement par RIB sur le compte
SuggestPaymentByRIBOnAccount=Proposer paiement par virement sur le compte
SuggestPaymentByChequeToAddress=Proposer paiement par chèque à l'ordre et adresse de
FreeLegalTextOnInvoices=Mention complémentaire sur les factures
WatermarkOnDraftInvoices=Filigrane sur les brouillons de factures (aucun si vide)

View File

@ -27,7 +27,7 @@ CurrentBalance=Solde actuel
FutureBalance=Solde futur
ShowAllTimeBalance=Afficher solde depuis début
Reconciliation=Rapprochement
RIB=RIB
RIB=Numéro compte
IBAN=Identifiant IBAN
BIC=Identifiant BIC/SWIFT
StandingOrders=Prélèvements
@ -43,7 +43,7 @@ IOMonthlyReporting=Rapport mensuel E/S
BankAccountDomiciliation=Domiciliation du compte
BankAccountOwner=Nom du propriétaire du compte
BankAccountOwnerAddress=Adresse du propriétaire du compte
RIBControlError=Le contrôle de la clé indique que les informations de ce compte bancaire sont incomplètes ou incorrectes.
RIBControlError=Les contrôles indiquent que les informations de ce compte bancaire sont incomplètes ou incorrectes (vérifier le pays, les numéros de compte ou IBAN).
CreateAccount=Créer compte
StandingOrderToProcess=À traiter
StandingOrderProcessed=Traités

View File

@ -106,7 +106,7 @@ ProfId4PT=Id prof. 4 (Conservatory)
ProfId1TN=Id prof. 1 (RC)
ProfId2TN=Id prof. 2 (Matricule fiscale)
ProfId3TN=Id prof. 3 (Code en douane)
ProfId4TN=Id prof. 4 (RIB)
ProfId4TN=Id prof. 4 (BAN)
VATIntra=Numéro de TVA
VATIntraShort=Num TVA
VATIntraVeryShort=N° TVA
@ -226,7 +226,7 @@ ProspectsByStatus=Prospects par
BillingContact=Contact facturation
NbOfAttachedFiles=Nombre de fichiers joints
AttachANewFile=Joindre un nouveau fichier
NoRIB=Aucun RIB défini
NoRIB=Aucun BAN (RIB) défini
NoParentCompany=Aucune
ExportImport=Import-Export
ExportCardToFormat=Exporter fiche au format

View File

@ -29,5 +29,5 @@ LastWithdrawalReceipt=Les %s derniers bons de pr
MakeWithdrawRequest=Faire une demande de prélèvement
ThirdPartyBankCode=Code banque du tiers
ThirdPartyDeskCode=Code guichet du tiers
NoInvoiceCouldBeWithdrawed=Aucune facture prélevable, prélevé avec succès. Vérifiez que les factures sont sur des sociétés dont le RIB est correctement renseigné.
NoInvoiceCouldBeWithdrawed=Aucune facture prélevable, prélevé avec succès. Vérifiez que les factures sont sur des sociétés dont le BAN(RIB) est correctement renseigné.
ClassCredited=Classer crédité

View File

@ -81,29 +81,32 @@ function bank_prepare_head($obj)
/**
\brief Verifie le RIB d'un compte bancaire grace à sa clé
\param code_banque code banque
\param code_guichet code guichet
\param num_compte numero de compte
\param cle cle
\param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays
\return int true si les infos sont bonnes, false si la clé ne correspond pas
*/
function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban)
* \brief Check account number informations for a bank account
* \param code_banque code banque
* \param code_guichet code guichet
* \param num_compte numero de compte
* \param cle cle
* \param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays
* \return int true si les infos sont bonnes, false si erreur
*/
function checkBanForAccount($account)
{
if (eregi("^FR",$iban))
$country_code=$account->getCountryCode();
dolibarr_syslog("Bank.lib::checkBanForAccount account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);
if ($country_code == 'FR')
{ // Cas de la France
$coef = array(62, 34, 3) ;
// Concatenation des differents codes.
$rib = strtolower(trim($code_banque).trim($code_guichet).trim($num_compte).trim($cle));
$rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->num_compte).trim($account->cle));
// On remplace les eventuelles lettres par des chiffres.
//Ne marche pas
//$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678");
//$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas
$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678923456789");
// Separation du rib en 3 groupes de 7 + 1 groupe de 2.
@ -124,7 +127,19 @@ function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban)
return false;
}
if ($country_code == 'BE') // Belgium rules
{
}
// No particular rule
// If account is CompanyBankAccount class, we use number
// If account is Account class, we use num_compte
if (empty($account->num_compte) && empty($account->number))
{
return false;
}
return true;
}

View File

@ -36,6 +36,7 @@ require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
$langs->load("companies");
$langs->load("commercial");
$langs->load("bills");
$langs->load("banks");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -1154,7 +1155,7 @@ else
$soc->typent= $arr[$soc->typent_code];
print '<tr><td>'.$langs->trans("Type").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>';
// RIB
// Ban
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('RIB');
@ -1169,7 +1170,7 @@ else
print $soc->display_rib();
print '</td></tr>';
// Maison mère
// Parent company
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('ParentCompany');
@ -1185,7 +1186,8 @@ else
{
$socm = new Societe($db);
$socm->fetch($soc->parent);
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socm->id.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.'</a>'.($socm->code_client?"(".$socm->code_client.")":"").' - '.$socm->ville;
print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":"");
print $socm->ville?' - '.$socm->ville:'';
}
else {
print $langs->trans("NoParentCompany");

View File

@ -1361,12 +1361,14 @@ class Societe extends CommonObject
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
$bac = new CompanyBankAccount($this->db, $this->id);
$bac->fetch();
$bac = new CompanyBankAccount($this->db);
$bac->socid = $this->id;
$bac->fetch($this->id);
if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib)
{
$rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." (".$bac->cle_rib.")";
$rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number;
$rib.=($bac->cle_rib?" (".$bac->cle_rib.")":"");
}
else
{
@ -1375,23 +1377,24 @@ class Societe extends CommonObject
return $rib;
}
function rib()
/**
* Load this->bank_account attribut
*/
function load_ban()
{
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
$bac = new CompanyBankAccount($this->db, $this->id);
$bac->fetch();
$bac->fetch($this->id);
$this->bank_account = $bac;
return 1;
}
function verif_rib()
{
$this->rib();
$this->load_ban();
return $this->bank_account->verif();
}

View File

@ -185,12 +185,10 @@ if($_GET["socid"])
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
$sql.= " ".MAIN_DB_PREFIX."c_typent as te";
$sql.= " WHERE s.fk_typent = te.id";
if (strlen(trim($_GET["search_nom"])))
{
$sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'";
}
$sql .= " ORDER BY s.nom ASC " . $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
@ -201,7 +199,7 @@ if($_GET["socid"])
$params = "&amp;socid=".$_GET["socid"];
print_barre_liste($title, $page, "lien.php",$params,$sortfield,$sortorder,'',$num);
print_barre_liste($title, $page, "lien.php",$params,$sortfield,$sortorder,'',$num,0,'');
// Lignes des titres
print '<table class="noborder" width="100%">';

View File

@ -19,18 +19,20 @@
*/
/**
\file htdocs/societe/rib.php
\ingroup societe
\brief Onglet rib de societe
\version $Id$
*/
* \file htdocs/societe/rib.php
* \ingroup societe
* \brief BAN tab for companies
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
require_once DOL_DOCUMENT_ROOT."/companybankaccount.class.php";
$langs->load("companies");
$langs->load("banks");
$langs->load("bills");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -43,52 +45,57 @@ $soc->fetch($_GET["socid"]);
/*
* Actions
*/
* Actions
*/
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
{
// Modification
$account = new CompanyBankAccount($db, $soc->id);
// Modification
$account = new CompanyBankAccount($db);
$account->bank = $_POST["bank"];
$account->label = $_POST["label"];
$account->courant = $_POST["courant"];
$account->clos = $_POST["clos"];
$account->code_banque = $_POST["code_banque"];
$account->code_guichet = $_POST["code_guichet"];
$account->number = $_POST["number"];
$account->cle_rib = $_POST["cle_rib"];
$account->bic = $_POST["bic"];
$account->iban_prefix = $_POST["iban_prefix"];
$account->domiciliation = $_POST["domiciliation"];
$account->proprio = $_POST["proprio"];
$account->adresse_proprio = $_POST["adresse_proprio"];
$account->socid = $soc->id;
$result = $account->update($user);
if (! $result)
{
$message=$account->error();
$_GET["action"]='edit'; // Force chargement page edition
}
else
{
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
}
$account->bank = $_POST["bank"];
$account->label = $_POST["label"];
$account->courant = $_POST["courant"];
$account->clos = $_POST["clos"];
$account->code_banque = $_POST["code_banque"];
$account->code_guichet = $_POST["code_guichet"];
$account->number = $_POST["number"];
$account->cle_rib = $_POST["cle_rib"];
$account->bic = $_POST["bic"];
$account->iban_prefix = $_POST["iban_prefix"];
$account->domiciliation = $_POST["domiciliation"];
$account->proprio = $_POST["proprio"];
$account->adresse_proprio = $_POST["adresse_proprio"];
$result = $account->update($user);
if (! $result)
{
$message=$account->error();
$_GET["action"]='edit'; // Force chargement page edition
}
else
{
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
}
}
/*
* View
*/
* View
*/
llxHeader();
$head=societe_prepare_head2($soc);
dolibarr_fiche_head($head, 'rib', $langs->trans("ThirdParty"));
$account = new CompanyBankAccount($db, $soc->id);
$account->fetch();
$account = new CompanyBankAccount($db);
$account->socid=$soc->id;
$account->fetch($soc->id);
/* ************************************************************************** */
@ -99,64 +106,75 @@ $account->fetch();
if ($_GET["socid"] && $_GET["action"] != 'edit')
{
if (!$account->verif())
{
print '<div class="error">'.$langs->trans("RIBControlError").'</div><br>';
}
// Check BBAN
if (! checkBanForAccount($account))
{
print '<div class="warning">'.$langs->trans("RIBControlError").'</div><br>';
}
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
print '<td colspan="4">'.$account->bank.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
print '<td colspan="4">'.$account->bank.'</td></tr>';
print '<tr><td>'.$langs->trans("RIB").'</td>';
print '<td align="center">'.$langs->trans("BankCode").'</td>';
print '<td align="center">'.$langs->trans("DeskCode").'</td>';
print '<td align="center">'.$langs->trans("BankAccountNumber").'</td>';
print '<td align="center">'.$langs->trans("BankAccountNumberKey").'</td>';
print '</tr>';
print '<tr><td>&nbsp;</td><td align="center">'.$account->code_banque.'</td>';
print '<td align="center">'.$account->code_guichet.'</td>';
print '<td align="center">'.$account->number.'</td>';
print '<td align="center">'.$account->cle_rib.'</td></tr>';
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
print '</tr>';
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4">'.$account->iban_prefix.'</td></tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td colspan="3">'.$account->code_guichet.'</td>';
print '</tr>';
}
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="4">'.$account->bic.'</td></tr>';
print '<tr><td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td colspan="3">'.$account->number.'</td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
print '</tr>';
}
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
print $account->domiciliation;
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4">'.$account->iban_prefix.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="4">';
print $account->proprio;
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="4">'.$account->bic.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
print $account->adresse_proprio;
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
print $account->domiciliation;
print "</td></tr>\n";
print '</table>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="4">';
print $account->proprio;
print "</td></tr>\n";
print '</div>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
print $account->adresse_proprio;
print "</td></tr>\n";
print '</table>';
print '</div>';
/*
* Barre d'actions
*
*/
print '<div class="tabsAction">';
/*
* Barre d'actions
*
*/
print '<div class="tabsAction">';
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="rib.php?socid='.$soc->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
}
if ($user->rights->societe->creer)
{
print '<a class="butAction" href="rib.php?socid='.$soc->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
}
print '</div>';
print '</div>';
}
@ -169,54 +187,69 @@ if ($_GET["socid"] && $_GET["action"] != 'edit')
if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer)
{
$form = new Form($db);
$form = new Form($db);
if ($message) { print "$message<br><br>\n"; }
if ($message) { print "$message<br><br>\n"; }
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
print '<td colspan="4"><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
print '<td colspan="4"><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
print '<tr><td>'.$langs->trans("RIB").'</td><td>'.$langs->trans("BankCode").'</td>';
print '<td>'.$langs->trans("DeskCode").'</td>';
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td>'.$langs->trans("BankAccountNumberKey").'</td></tr>';
print '<tr><td>&nbsp;</td><td><input size="8" type="text" name="code_banque" value="'.$account->code_banque.'"></td>';
print '<td><input size="8" type="text" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '<td><input size="15" type="text" name="number" value="'.$account->number.'"></td>';
print '<td><input size="3" type="text" name="cle_rib" value="'.$account->cle_rib.'"></td></tr>';
// BBAN
if ($account->getCountryCode() == 'FR')
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
print '</tr>';
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4"><input size="30" type="text" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';
print '<tr><td>'.$langs->trans("DeskCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
print '</tr>';
}
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="15" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
if ($account->getCountryCode() == 'FR')
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
print '</tr>';
}
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
print "<textarea name=\"domiciliation\" rows=\"4\" cols=\"40\">";
print $account->domiciliation;
print "</textarea></td></tr>";
// IBAN
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4"><input size="30" type="text" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="4"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
print "</td></tr>\n";
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
print "<textarea name=\"adresse_proprio\" rows=\"4\" cols=\"40\">";
print $account->adresse_proprio;
print "</textarea></td></tr>";
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
print "<textarea name=\"domiciliation\" rows=\"4\" cols=\"40\">";
print $account->domiciliation;
print "</textarea></td></tr>";
print '<tr><td align="center" colspan="5"><input class="button" value="'.$langs->trans("Modify").'" type="submit">';
print ' &nbsp; <input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="4"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
print "</td></tr>\n";
print '</form>';
print '</table>';
print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
print "<textarea name=\"adresse_proprio\" rows=\"4\" cols=\"40\">";
print $account->adresse_proprio;
print "</textarea></td></tr>";
print '<tr><td align="center" colspan="5"><input class="button" value="'.$langs->trans("Modify").'" type="submit">';
print ' &nbsp; <input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
print '</td></tr>';
print '</form>';
print '</table>';
}

File diff suppressed because it is too large Load Diff

View File

@ -802,7 +802,7 @@ class FacturationEmission {
$fac->fetch($facid);
$fac->fetch_client();
$fac->client->rib();
$fac->client->load_ban();
$message = "";

View File

@ -105,11 +105,11 @@ if ($_GET["id"] or $_GET["numero"])
}
print '<table>';
print "<tr><td>Num<EFBFBD>ro correct </td><td> ".$ok_commande .'</td></tr>';
print "<tr><td>Commandes ouvertes aupr<EFBFBD>s du fournisseur </td><td> ".$ftx->commande_enable .'</td></tr>';
print "<tr><td>Numero correct </td><td> ".$ok_commande .'</td></tr>';
print "<tr><td>Commandes ouvertes aupres du fournisseur </td><td> ".$ftx->commande_enable .'</td></tr>';
print "<tr><td>Permission pour l'utilisateur de commander des lignes </td><td> ".$user->rights->telephonie->ligne_commander.'</td></tr>';
print "<tr><td>Statut de la ligne compatible </td><td> ".($ligne->statut == 1 or $ligne->statut == -1) .'</td></tr>';
print "<tr><td>Rib ok ou mode de r<EFBFBD>glement par virement </td><td> ".($client_facture->verif_rib() or $ligne->mode_paiement == 'vir').'</td></tr>';
print "<tr><td>Rib ok ou mode de reglement par virement </td><td> ".($client_facture->verif_rib() or $ligne->mode_paiement == 'vir').'</td></tr>';
print '</table>';
}
@ -121,5 +121,5 @@ else
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
llxFooter('$Date$ - $Revision$');
?>

View File

@ -788,7 +788,7 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact
$fac->fetch($facid);
$fac->fetch_client();
$fac->client->rib();
$fac->client->load_ban();
$message = "";
@ -809,7 +809,8 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact
if (!$error && !$cancel_facture)
{
$db->query("COMMIT");
$db->commit();
/* $soc
* $ligne
*/
@ -832,8 +833,7 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact
}
else
{
$db->query("ROLLBACK");
dolibarr_syslog("ROLLBACK de la transaction $error");
$db->rollback();
}
}