diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 6a806b24280..3a1f57ec9bb 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -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" * diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 723c23b77d4..3184a9356e8 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -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';