Spanish bank account use full detailed informations

This commit is contained in:
Laurent Destailleur 2008-11-26 07:50:47 +00:00
parent ac626dd189
commit 43aedb0020
6 changed files with 44 additions and 22 deletions

View File

@ -224,7 +224,19 @@ class CompanyBankAccount
if (! empty($company->pays_code)) return $company->pays_code;
return '';
}
/**
* \brief Return if a bank account is defined with detailed information (bank code, desk code, number and key)
* \return boolean true or false
*/
function useDetailedBBAN()
{
if ($this->getCountryCode() == 'FR') return true;
if ($this->getCountryCode() == 'ES') return true;
return false;
}
}
?>

View File

@ -764,6 +764,20 @@ class Account extends CommonObject
return '';
}
/**
* \brief Return if a bank account is defined with detailed information (bank code, desk code, number and key)
* \return boolean true or false
*/
function useDetailedBBAN()
{
$country_code=$this->getCountryCode();
if ($country_code == 'FR') return true;
if ($country_code == 'ES') return true;
return false;
}
}

View File

@ -260,7 +260,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
print '</tr>';
// BBAN
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
@ -272,10 +272,10 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
}
print '<td>'.$langs->trans("BankAccountNumber").'</td>';
print '<td><input size="15" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
@ -284,10 +284,10 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
// 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>';
print '<td colspan="3"><input size="26" type="text" class="flat" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="3"><input size="24" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
print '<td colspan="3"><input size="26" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";

View File

@ -96,19 +96,14 @@ function checkBanForAccount($account)
dolibarr_syslog("Bank.lib::checkBanForAccount account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);
if ($country_code == 'FR')
{ // Cas de la France
if ($country_code == 'FR') // France rules
{
$coef = array(62, 34, 3) ;
// Concatenation des differents codes.
$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.
//$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.
// Multiplication de chaque groupe par les coef du tableau
for ($i=0, $s=0; $i<3; $i++)
@ -116,15 +111,12 @@ function checkBanForAccount($account)
$code = substr($rib, 7 * $i, 7) ;
$s += (0 + $code) * $coef[$i] ;
}
// Soustraction du modulo 97 de $s à 97 pour obtenir la clé RIB
// Soustraction du modulo 97 de $s a 97 pour obtenir la cle
$cle_rib = 97 - ($s % 97) ;
if ($cle_rib == $cle)
{
return true;
}
return false;
}
@ -132,6 +124,10 @@ function checkBanForAccount($account)
{
}
if ($country_code == 'ES') // Spanish rules
{
}
// No particular rule
// If account is CompanyBankAccount class, we use number
// If account is Account class, we use num_compte

View File

@ -689,9 +689,9 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
$pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
$cury+=4;
$country_code=$account->getCountryCode();
$usedetailedbban=$account->useDetailedBBAN();
if ($country_code == 'FR')
if ($usedetailedbban)
{
$pdf->SetFont('Arial','B',6);
$pdf->line($curx+1, $cury, $curx+1, $cury+10 );

View File

@ -117,7 +117,7 @@ if ($_GET["socid"] && $_GET["action"] != 'edit')
print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
print '<td colspan="4">'.$account->bank.'</td></tr>';
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td colspan="3">'.$account->code_banque.'</td>';
@ -132,7 +132,7 @@ if ($_GET["socid"] && $_GET["action"] != 'edit')
print '<td colspan="3">'.$account->number.'</td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td colspan="3">'.$account->cle_rib.'</td>';
@ -201,7 +201,7 @@ if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer
print '<td colspan="4"><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
// BBAN
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<tr><td>'.$langs->trans("BankCode").'</td>';
print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
@ -216,7 +216,7 @@ if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer
print '<td><input size="15" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
print '</tr>';
if ($account->getCountryCode() == 'FR')
if ($account->useDetailedBBAN())
{
print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';