Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add BIC support. This fixes #430
James Cole8cdbc96aa534
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.phpindex e750801963..e129fc9128 100644--- a/app/Http/Controllers/AccountController.php+++ b/app/Http/Controllers/AccountController.php@@ -171,6 +171,7 @@ class AccountController extends Controller'accountRole' => $account->getMeta('accountRole'),'ccType' => $account->getMeta('ccType'),'ccMonthlyPaymentDate' => $account->getMeta('ccMonthlyPaymentDate'),+ 'BIC' => $account->getMeta('BIC'),'openingBalanceDate' => $openingBalanceDate,'openingBalance' => $openingBalanceAmount,'virtualBalance' => $account->virtual_balance,diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.phpindex 95cf746044..faac1971d8 100644--- a/app/Http/Requests/AccountFormRequest.php+++ b/app/Http/Requests/AccountFormRequest.php@@ -42,10 +42,11 @@ class AccountFormRequest extends Request'name' => trim($this->input('name')),'active' => intval($this->input('active')) === 1,'accountType' => $this->input('what'),- 'currency_id' => intval($this->input('currency_id')),+ 'currency_id' => intval($this->input('currency_id')),'virtualBalance' => round($this->input('virtualBalance'), 2),'virtualBalanceCurrency' => intval($this->input('amount_currency_id_virtualBalance')),'iban' => trim($this->input('iban')),+ 'BIC' => trim($this->input('BIC')),'accountNumber' => trim($this->input('accountNumber')),'accountRole' => $this->input('accountRole'),'openingBalance' => round($this->input('openingBalance'), 2),@@ -79,6 +80,7 @@ class AccountFormRequest extends Request'name' => $nameRule,'openingBalance' => 'numeric','iban' => 'iban',+ 'BIC' => 'bic','virtualBalance' => 'numeric','openingBalanceDate' => 'date','currency_id' => 'exists:transaction_currencies,id',diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex aeb1535a31..65f21055b2 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -41,7 +41,7 @@ class AccountRepository implements AccountRepositoryInterface/** @var User */private $user;/** @var array */- private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber','currency_id'];+ private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];/*** AttachmentRepository constructor.@@ -60,7 +60,7 @@ class AccountRepository implements AccountRepositoryInterface** @return int*/- public function count(array $types):int+ public function count(array $types): int{$count = $this->user->accounts()->accountTypeIn($types)->count();@@ -482,7 +482,7 @@ class AccountRepository implements AccountRepositoryInterface** @return Account*/- protected function storeOpposingAccount(float $amount, string $name):Account+ protected function storeOpposingAccount(float $amount, string $name): Account{$type = $amount < 0 ? 'expense' : 'revenue';$opposingData = [diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.phpindex d306e433de..6aca02047e 100644--- a/app/Repositories/Account/AccountRepositoryInterface.php+++ b/app/Repositories/Account/AccountRepositoryInterface.php@@ -119,6 +119,6 @@ interface AccountRepositoryInterface** @return Account*/- public function store(array $data) : Account;+ public function store(array $data): Account;}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 8a272dd397..d20fb5dc5f 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -57,8 +57,6 @@ class FireflyValidator extends Validator* @param $value** @return bool- * @internal param $parameters- ***/public function validate2faCode($attribute, $value): bool@@ -95,6 +93,27 @@ class FireflyValidator extends Validator}+ /**+ * @param $attribute+ * @param $value+ *+ * @return bool+ *+ */+ public function validateBic($attribute, $value): bool+ {+ $regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';+ $result = preg_match($regex, $value);+ if ($result === false) {+ return false;+ }+ if ($result === 0) {+ return false;+ }++ return true;+ }+/*** @param $attribute* @param $valuediff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.phpindex 5418b22d8b..a417f504a9 100644--- a/resources/lang/en_US/form.php+++ b/resources/lang/en_US/form.php@@ -31,6 +31,7 @@ return ['journal_asset_source_account' => 'Asset account (source)','journal_source_account_name' => 'Revenue account (source)','journal_source_account_id' => 'Asset account (source)',+ 'BIC' => 'BIC','account_from_id' => 'From account','account_to_id' => 'To account','source_account' => 'Source account',diff --git a/resources/lang/en_US/validation.php b/resources/lang/en_US/validation.phpindex 030e6a72c5..fd25fbd685 100644--- a/resources/lang/en_US/validation.php+++ b/resources/lang/en_US/validation.php@@ -21,6 +21,7 @@ return ['file_too_large' => 'File ":name" is too large.','belongs_to_user' => 'The value of :attribute is unknown','accepted' => 'The :attribute must be accepted.',+ 'bic' => 'This is not a valid BIC.','active_url' => 'The :attribute is not a valid URL.','after' => 'The :attribute must be a date after :date.','alpha' => 'The :attribute may only contain letters.',diff --git a/resources/views/accounts/create.twig b/resources/views/accounts/create.twigindex f4f560fd5b..e1ccc79fd7 100644--- a/resources/views/accounts/create.twig+++ b/resources/views/accounts/create.twig@@ -34,6 +34,7 @@<div class="box-body">{{ ExpandedForm.text('iban') }}+ {{ ExpandedForm.text('BIC', null, {maxlength: 11}) }}{{ ExpandedForm.text('accountNumber') }}{% if what == 'asset' %}diff --git a/resources/views/accounts/edit.twig b/resources/views/accounts/edit.twigindex 4ebee7dc6e..d849fa50d4 100644--- a/resources/views/accounts/edit.twig+++ b/resources/views/accounts/edit.twig@@ -32,6 +32,7 @@</div><div class="box-body">{{ ExpandedForm.text('iban') }}+ {{ ExpandedForm.text('BIC', null, {maxlength: 11}) }}{{ ExpandedForm.text('accountNumber') }}{% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %}