Accounts can now have IBAN.

This commit is contained in:
James Cole
2015-07-03 12:51:14 +02:00
parent 854368a8f3
commit d8b65f62e7
12 changed files with 92 additions and 52 deletions

View File

@@ -54,6 +54,33 @@ class FireflyValidator extends Validator
}
/**
* @param $attribute
* @param $value
* @param $parameters
*/
public function validateIban($attribute, $value, $parameters)
{
$value = strtoupper($value);
if (strlen($value) < 6) {
return false;
}
$search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31',
'32', '33', '34', '35'];
// take
$first = substr($value, 0, 4);
$last = substr($value, 4);
$iban = $last . $first;
$iban = str_replace($search, $replace, $iban);
$checksum = bcmod($iban, '97');
return (intval($checksum) === 1);
}
/**
* @param $attribute
* @param $value