FIX: BIC requirement is now checked separately from IBAN (#30994)

This commit is contained in:
atm-thomasb 2024-09-18 01:30:56 +02:00 committed by GitHub
parent 3ecae791e1
commit fdca7b691a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 3 deletions

View File

@ -1747,7 +1747,7 @@ class Account extends CommonObject
}
/**
* Return 1 if IBAN / BIC is mandatory (otherwise option)
* Return 1 if IBAN is mandatory (otherwise option)
*
* @return int 1 = mandatory / 0 = Not mandatory
*/
@ -1803,6 +1803,37 @@ class Account extends CommonObject
return 0;
}
/**
* Return 1 if BIC is mandatory (otherwise option)
*
* @return int 1 = mandatory / 0 = Not mandatory
*/
public function needBIC()
{
if (getDolGlobalString('MAIN_IBAN_IS_NEVER_MANDATORY')) {
return 0;
}
$country_code = $this->getCountryCode();
$country_code_in_EEC = array(
'AD', // Andorra
'BH', // Bahrein
'DK', // Denmark
'FR', // France
'GH', // Ghana
'HU', // Hungary
'JP', // Japan
'LV', // Latvia
'SE', // Sweden
);
if (in_array($country_code, $country_code_in_EEC)) {
return 1; // Andorra, Bahrein, ...
}
return 0;
}
/**
* Load miscellaneous information for tab "Info"
*

View File

@ -158,6 +158,8 @@ if (empty($reshook)) {
$action = 'edit';
$error++;
}
}
if ($companybankaccount->needBIC() == 1) {
if (!GETPOST('bic') && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
$action = 'edit';
@ -341,6 +343,8 @@ if (empty($reshook)) {
$action = 'create';
$error++;
}
}
if ($companybankaccount->needBIC() == 1) {
if (!GETPOST('bic') && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
$action = 'create';
@ -2015,7 +2019,7 @@ if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) {
$name = 'bic';
$size = 12;
$content = $bankaccount->bic;
if ($bankaccount->needIBAN() && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
if ($bankaccount->needBIC() && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
$require = true;
}
$tooltip = $langs->trans("Example").': LIABLT2XXXX';
@ -2187,7 +2191,7 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) {
$name = 'bic';
$size = 12;
$content = $companybankaccount->bic;
if ($companybankaccount->needIBAN() && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
if ($companybankaccount->needBIC() && (getDolGlobalInt('WITHDRAWAL_WITHOUT_BIC') == 0)) {
$require = true;
}
$tooltip = $langs->trans("Example").': LIABLT2XXXX';