Merge pull request #5424 from atm-florian/dev_fix5353
NEW #5353 IBAN and BIC should be now always mandatory for all country regarding accounting managment
This commit is contained in:
commit
6d0ebbc4a3
@ -187,7 +187,9 @@
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.MissingTag" />
|
||||
<rule ref="PEAR.Commenting.ClassComment.MissingTag">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="PEAR.Commenting.ClassComment.MissingAuthorTag">
|
||||
<severity>0</severity>
|
||||
|
||||
@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
|
||||
* Class Skeleton_Class
|
||||
*
|
||||
* Put here description of your class
|
||||
*
|
||||
* @see CommonObject
|
||||
*/
|
||||
class Skeleton_Class extends CommonObject
|
||||
|
||||
@ -258,6 +258,10 @@ class Account extends CommonObject
|
||||
$string .= $this->code_guichet.' ';
|
||||
} elseif ($val == 'BankAccountNumberKey') {
|
||||
$string .= $this->cle_rib.' ';
|
||||
}elseif ($val == 'BIC') {
|
||||
$string .= $this->bic.' ';
|
||||
}elseif ($val == 'IBAN') {
|
||||
$string .= $this->iban.' ';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1293,6 +1297,55 @@ class Account extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return 1 is IBAN is need for UE country
|
||||
*
|
||||
* @return int 1 yes / 0 No
|
||||
*/
|
||||
function needIBAN()
|
||||
{
|
||||
$country_code=$this->getCountryCode();
|
||||
|
||||
$country_code_in_EEC=array(
|
||||
'AT', // Austria
|
||||
'BE', // Belgium
|
||||
'BG', // Bulgaria
|
||||
'CY', // Cyprus
|
||||
'CZ', // Czech republic
|
||||
'DE', // Germany
|
||||
'DK', // Danemark
|
||||
'EE', // Estonia
|
||||
'ES', // Spain
|
||||
'FI', // Finland
|
||||
'FR', // France
|
||||
'GB', // United Kingdom
|
||||
'GR', // Greece
|
||||
'HR', // Croatia
|
||||
'NL', // Holland
|
||||
'HU', // Hungary
|
||||
'IE', // Ireland
|
||||
'IM', // Isle of Man - Included in UK
|
||||
'IT', // Italy
|
||||
'LT', // Lithuania
|
||||
'LU', // Luxembourg
|
||||
'LV', // Latvia
|
||||
'MC', // Monaco - Included in France
|
||||
'MT', // Malta
|
||||
//'NO', // Norway
|
||||
'PL', // Poland
|
||||
'PT', // Portugal
|
||||
'RO', // Romania
|
||||
'SE', // Sweden
|
||||
'SK', // Slovakia
|
||||
'SI', // Slovenia
|
||||
'UK', // United Kingdom
|
||||
//'CH', // Switzerland - No. Swizerland in not in EEC
|
||||
);
|
||||
|
||||
if (in_array($country_code,$country_code_in_EEC)) return 1; // France, Spain, Gabon, ...
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load miscellaneous information for tab "Info"
|
||||
*
|
||||
@ -1323,18 +1376,26 @@ class Account extends CommonObject
|
||||
$detailedBBAN = $this->useDetailedBBAN();
|
||||
|
||||
if ($detailedBBAN == 0) {
|
||||
return array(
|
||||
$fieldarray= array(
|
||||
'BankAccountNumber'
|
||||
);
|
||||
} elseif ($detailedBBAN == 2) {
|
||||
return array(
|
||||
$fieldarray= array(
|
||||
'BankCode',
|
||||
'BankAccountNumber'
|
||||
);
|
||||
} else {
|
||||
$fieldarray=self::getAccountNumberOrder();
|
||||
}
|
||||
|
||||
if ($this->needIBAN()) {
|
||||
$fieldarray[]='IBAN';
|
||||
$fieldarray[]='BIC';
|
||||
}
|
||||
|
||||
//Get the order the properties are shown
|
||||
return self::getAccountNumberOrder();
|
||||
return $fieldarray;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -706,8 +706,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
|
||||
// Key
|
||||
$tmplength = 13;
|
||||
$content = $account->cle_rib;
|
||||
}elseif ($val == 'IBAN' || $val == 'BIC') {
|
||||
// Key
|
||||
$tmplength = 0;
|
||||
$content = '';
|
||||
} else {
|
||||
dol_print_error($this->db, 'Unexpected value for getFieldsToShow: '.$val);
|
||||
dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ class mailing_advthirdparties extends MailingTargets
|
||||
* For example if this selector is used to extract 500 different
|
||||
* emails from a text file, this function must return 500.
|
||||
*
|
||||
* @param string $sql Sql request to use
|
||||
* @param string $sql Not use here
|
||||
* @return int Nb of recipients
|
||||
*/
|
||||
function getNbOfRecipients($sql='')
|
||||
|
||||
@ -233,7 +233,7 @@ class CompanyBankAccount extends Account
|
||||
{
|
||||
$rib = '';
|
||||
|
||||
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) {
|
||||
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
|
||||
|
||||
if ($this->label && $displayriblabel) {
|
||||
$rib = $this->label." : ";
|
||||
|
||||
@ -2216,6 +2216,7 @@ class Societe extends CommonObject
|
||||
function display_rib($mode='label')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
||||
|
||||
$bac = new CompanyBankAccount($this->db);
|
||||
$bac->fetch(0,$this->id);
|
||||
|
||||
@ -2227,6 +2228,7 @@ class Societe extends CommonObject
|
||||
{
|
||||
if (empty($bac->rum))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php';
|
||||
$prelevement = new BonPrelevement($this->db);
|
||||
$bac->fetch_thirdparty();
|
||||
$bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
|
||||
@ -3499,13 +3501,11 @@ class Societe extends CommonObject
|
||||
* Thirdparty commercials cannot be the same in both thirdparties so we look for them and remove some
|
||||
* Because this function is meant to be executed within a transaction, we won't take care of it.
|
||||
*/
|
||||
$sql = 'SELECT rowid
|
||||
FROM '.MAIN_DB_PREFIX.'societe_commerciaux
|
||||
WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN (
|
||||
SELECT fk_user
|
||||
FROM '.MAIN_DB_PREFIX.'societe_commerciaux
|
||||
WHERE fk_soc = '.(int) $origin_id.'
|
||||
);';
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'societe_commerciaux ';
|
||||
$sql .= ' WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN ( ';
|
||||
$sql = ' SELECT fk_user ';
|
||||
$sql = ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux ';
|
||||
$sql = ' WHERE fk_soc = '.(int) $origin_id.') ';
|
||||
|
||||
$query = $db->query($sql);
|
||||
|
||||
|
||||
@ -59,30 +59,59 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
// Modification
|
||||
$account = new CompanyBankAccount($db);
|
||||
|
||||
$account->fetch($id);
|
||||
|
||||
if (! GETPOST('label'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$action='update';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bank'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
|
||||
$action='update';
|
||||
$error++;
|
||||
}
|
||||
if ($account->needIBAN() == 1)
|
||||
{
|
||||
if (! GETPOST('iban'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||
$action='update';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bic'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
|
||||
$action='update';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
$account->fetch($id);
|
||||
if (! $error)
|
||||
{
|
||||
$account->socid = $object->id;
|
||||
|
||||
$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 = $_POST["iban"];
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->owner_address = $_POST["owner_address"];
|
||||
$account->frstrecur = GETPOST('frstrecur');
|
||||
$account->bank = GETPOST('bank','alpha');
|
||||
$account->label = GETPOST('label','alpha');
|
||||
$account->courant = GETPOST('courant','alpha');
|
||||
$account->clos = GETPOST('clos','alpha');
|
||||
$account->code_banque = GETPOST('code_banque','alpha');
|
||||
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||
$account->number = GETPOST('number','alpha');
|
||||
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||
$account->bic = GETPOST('bic','alpha');
|
||||
$account->iban = GETPOST('iban','alpha');
|
||||
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||
$account->proprio = GETPOST('proprio','alpha');
|
||||
$account->owner_address = GETPOST('owner_address','alpha');
|
||||
$account->frstrecur = GETPOST('frstrecur','alpha');
|
||||
|
||||
$result = $account->update($user);
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$_GET["action"]='edit'; // Force chargement page edition
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,6 +126,7 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add' && ! $_POST["cancel"])
|
||||
{
|
||||
@ -114,6 +144,21 @@ if ($action == 'add' && ! $_POST["cancel"])
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if ($account->needIBAN() == 1)
|
||||
{
|
||||
if (! GETPOST('iban'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bic'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -122,19 +167,19 @@ if ($action == 'add' && ! $_POST["cancel"])
|
||||
|
||||
$account->socid = $object->id;
|
||||
|
||||
$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 = $_POST["iban"];
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->owner_address = $_POST["owner_address"];
|
||||
$account->bank = GETPOST('bank','alpha');
|
||||
$account->label = GETPOST('label','alpha');
|
||||
$account->courant = GETPOST('courant','alpha');
|
||||
$account->clos = GETPOST('clos','alpha');
|
||||
$account->code_banque = GETPOST('code_banque','alpha');
|
||||
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||
$account->number = GETPOST('number','alpha');
|
||||
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||
$account->bic = GETPOST('bic','alpha');
|
||||
$account->iban = GETPOST('iban','alpha');
|
||||
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||
$account->proprio = GETPOST('proprio','alpha');
|
||||
$account->owner_address = GETPOST('owner_address','alpha');
|
||||
$account->frstrecur = GETPOST('frstrecur');
|
||||
|
||||
$result = $account->update($user); // TODO Use create and include update into create method
|
||||
@ -265,35 +310,31 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
$content = $account->number;
|
||||
} elseif ($val == 'BankAccountNumberKey') {
|
||||
$content = $account->cle_rib;
|
||||
}elseif ($val == 'IBAN') {
|
||||
$content = $account->iban;
|
||||
if (! empty($account->iban)) {
|
||||
if (! checkIbanForAccount($account)) {
|
||||
$content.= img_picto($langs->trans("IbanNotValid"),'warning');
|
||||
} else {
|
||||
$content.= img_picto($langs->trans("IbanValid"),'info');
|
||||
}
|
||||
}
|
||||
}elseif ($val == 'BIC') {
|
||||
$content = $account->bic;
|
||||
if (! empty($account->bic)) {
|
||||
if (! checkSwiftForAccount($account)) {
|
||||
$content.= img_picto($langs->trans("SwiftNotValid"),'warning');
|
||||
} else {
|
||||
$content.= img_picto($langs->trans("SwiftValid"),'info');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans($val).'</td>';
|
||||
print '<td colspan="3">'.$content.'</td>';
|
||||
print '<td colspan="4">'.$content.'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
|
||||
print '<td colspan="4">'.$account->iban . ' ';
|
||||
if (! empty($account->iban)) {
|
||||
if (! checkIbanForAccount($account)) {
|
||||
print img_picto($langs->trans("IbanNotValid"),'warning');
|
||||
} else {
|
||||
print img_picto($langs->trans("IbanValid"),'info');
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
|
||||
print '<td colspan="4">'.$account->bic.' ';
|
||||
if (! empty($account->bic)) {
|
||||
if (! checkSwiftForAccount($account)) {
|
||||
print img_picto($langs->trans("SwiftNotValid"),'warning');
|
||||
} else {
|
||||
print img_picto($langs->trans("SwiftValid"),'info');
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||
print $account->domiciliation;
|
||||
print "</td></tr>\n";
|
||||
@ -432,6 +473,8 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
|
||||
// Show fields of bank account
|
||||
foreach ($account->getFieldsToShow() as $val) {
|
||||
|
||||
$require=false;
|
||||
if ($val == 'BankCode') {
|
||||
$name = 'code_banque';
|
||||
$size = 8;
|
||||
@ -448,20 +491,23 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
$name = 'cle_rib';
|
||||
$size = 3;
|
||||
$content = $account->cle_rib;
|
||||
} elseif ($val == 'IBAN') {
|
||||
$name = 'iban';
|
||||
$size = 30;
|
||||
$content = $account->iban;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
} elseif ($val == 'BIC') {
|
||||
$name = 'bic';
|
||||
$size = 12;
|
||||
$content = $account->bic;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans($val).'</td>';
|
||||
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
||||
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// IBAN
|
||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top" class="fieldrequired">'.$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("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||
print '<textarea name="domiciliation" rows="4" cols="40">';
|
||||
print $account->domiciliation;
|
||||
@ -527,6 +573,13 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
|
||||
print '<td><input size="30" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
|
||||
|
||||
// IBAN
|
||||
print '<tr><td valign="top" '.($account->needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top" '.($account->needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").'</td>';
|
||||
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
||||
|
||||
// BBAN
|
||||
if ($account->useDetailedBBAN() == 1)
|
||||
{
|
||||
@ -556,13 +609,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// IBAN
|
||||
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
|
||||
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||
print '<textarea name="domiciliation" rows="4" cols="40">';
|
||||
print GETPOST('domiciliation');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user