From c8421136104fcb1313f9c2507830505c3a0a2650 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 10:32:16 +0200 Subject: [PATCH 1/4] New read me. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6f6bf573ba..a601b48810 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Total Downloads](https://poser.pugx.org/grumpydictator/firefly-iii/downloads)](https://packagist.org/packages/grumpydictator/firefly-iii) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/JC5/firefly-iii/badges/build.png?b=master)](https://scrutinizer-ci.com/g/JC5/firefly-iii/build-status/master) ## About From 4a20eef35181d41308242821bb69cf07c4fa741c Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:27:49 +0200 Subject: [PATCH 2/4] Add IBAN field. --- .../2015_06_23_050233_changes_for_v3451.php | 16 +++++++---- .../2015_07_03_102450_changes_for_v3462.php | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2015_07_03_102450_changes_for_v3462.php diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php index 7c2ee2ccaa..72c6f799f2 100644 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ b/database/migrations/2015_06_23_050233_changes_for_v3451.php @@ -1,6 +1,7 @@ dropColumn('iban'); + } + ); } - //$table->smallInteger('reminder_skip')->unsigned(); - //$table->boolean('remind_me'); - /** * Run the migrations. * @@ -27,7 +29,11 @@ class ChangesForV3451 extends Migration */ public function up() { - + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban', 38)->nullable(); + } + ); } } diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php new file mode 100644 index 0000000000..7dd6e4b833 --- /dev/null +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -0,0 +1,28 @@ + Date: Fri, 3 Jul 2015 12:51:14 +0200 Subject: [PATCH 3/4] Accounts can now have IBAN. --- app/Http/Controllers/AccountController.php | 2 + app/Http/Requests/AccountFormRequest.php | 1 + app/Models/Account.php | 29 ++++++++++++++ .../Account/AccountRepository.php | 6 ++- app/Validation/FireflyValidator.php | 27 +++++++++++++ .../2015_06_23_050233_changes_for_v3451.php | 39 ------------------- .../2015_07_03_102450_changes_for_v3462.php | 35 +++++++++++------ database/seeds/TestDataSeeder.php | 1 + resources/lang/en/form.php | 1 + resources/lang/nl/form.php | 1 + resources/twig/accounts/create.twig | 1 + resources/twig/accounts/edit.twig | 1 + 12 files changed, 92 insertions(+), 52 deletions(-) delete mode 100644 database/migrations/2015_06_23_050233_changes_for_v3451.php diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index be1a8545c8..f9dc21694b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -199,6 +199,7 @@ class AccountController extends Controller 'virtualBalance' => floatval($request->input('virtualBalance')), 'active' => true, 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'openingBalance' => floatval($request->input('openingBalance')), 'openingBalanceDate' => new Carbon((string)$request->input('openingBalanceDate')), @@ -237,6 +238,7 @@ class AccountController extends Controller 'name' => $request->input('name'), 'active' => $request->input('active'), 'user' => Auth::user()->id, + 'iban' => $request->input('iban'), 'accountRole' => $request->input('accountRole'), 'virtualBalance' => floatval($request->input('virtualBalance')), 'openingBalance' => floatval($request->input('openingBalance')), diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 83275c966d..a0ff4e9617 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -44,6 +44,7 @@ class AccountFormRequest extends Request 'id' => $idRule, 'name' => $nameRule, 'openingBalance' => 'numeric', + 'iban' => 'iban', 'virtualBalance' => 'numeric', 'openingBalanceDate' => 'date', 'accountRole' => 'in:' . $accountRoles, diff --git a/app/Models/Account.php b/app/Models/Account.php index a09825c266..9c061021d3 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -47,6 +47,9 @@ use Watson\Validating\ValidatingTrait; * @property mixed piggyBalance * @property mixed difference * @property mixed percentage + * @property string $iban + * @property-read mixed $name_for_editform + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereIban($value) */ class Account extends Model { @@ -143,6 +146,22 @@ class Account extends Model return ['created_at', 'updated_at', 'deleted_at']; } + /** + * @codeCoverageIgnore + * + * @param $value + * + * @return string + */ + public function getIbanAttribute($value) + { + if (is_null($value)) { + return null; + } + + return Crypt::decrypt($value); + } + /** * * @param string $fieldName @@ -236,6 +255,16 @@ class Account extends Model $query->where($joinName . '.data', json_encode($value)); } + /** + * @codeCoverageIgnore + * + * @param $value + */ + public function setIbanAttribute($value) + { + $this->attributes['iban'] = Crypt::encrypt($value); + } + /** * @codeCoverageIgnore * diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 8785c588ef..9ee8e6dca2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -401,6 +401,7 @@ class AccountRepository implements AccountRepositoryInterface 'virtualBalance' => 0, 'name' => $data['name'] . ' initial balance', 'active' => false, + 'iban' => '', ]; $opposing = $this->storeAccount($opposingData); $this->storeInitialBalance($newAccount, $opposing, $data); @@ -431,6 +432,7 @@ class AccountRepository implements AccountRepositoryInterface $account->name = $data['name']; $account->active = $data['active'] == '1' ? true : false; $account->virtual_balance = $data['virtualBalance']; + $account->iban = $data['iban']; $account->save(); $this->updateMetadata($account, $data); @@ -481,6 +483,7 @@ class AccountRepository implements AccountRepositoryInterface 'name' => $data['name'], 'virtual_balance' => $data['virtualBalance'], 'active' => $data['active'] === true ? true : false, + 'iban' => $data['iban'], ] ); @@ -490,7 +493,8 @@ class AccountRepository implements AccountRepositoryInterface 'user_id' => $data['user'], 'account_type_id' => $accountType->id, 'virtual_balance' => $data['virtualBalance'], - 'name' => $data['name'] + 'name' => $data['name'], + 'iban' => $data['iban'], ]; $existingAccount = Account::firstOrNullEncrypted($searchData); if (!$existingAccount) { diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 4e6e1397cb..6c177af69d 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -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 diff --git a/database/migrations/2015_06_23_050233_changes_for_v3451.php b/database/migrations/2015_06_23_050233_changes_for_v3451.php deleted file mode 100644 index 72c6f799f2..0000000000 --- a/database/migrations/2015_06_23_050233_changes_for_v3451.php +++ /dev/null @@ -1,39 +0,0 @@ -dropColumn('iban'); - } - ); - } - - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table( - 'accounts', function (Blueprint $table) { - $table->string('iban', 38)->nullable(); - } - ); - - } -} diff --git a/database/migrations/2015_07_03_102450_changes_for_v3462.php b/database/migrations/2015_07_03_102450_changes_for_v3462.php index 7dd6e4b833..930c8b0bab 100644 --- a/database/migrations/2015_07_03_102450_changes_for_v3462.php +++ b/database/migrations/2015_07_03_102450_changes_for_v3462.php @@ -1,10 +1,27 @@ dropColumn('iban'); + } + ); + } + /** * Run the migrations. * @@ -13,16 +30,10 @@ class ChangesForV3462 extends Migration public function up() { // add IBAN to accounts: - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - // + Schema::table( + 'accounts', function (Blueprint $table) { + $table->string('iban')->nullable(); + } + ); } } diff --git a/database/seeds/TestDataSeeder.php b/database/seeds/TestDataSeeder.php index 2ef6f90674..fedf19c97a 100644 --- a/database/seeds/TestDataSeeder.php +++ b/database/seeds/TestDataSeeder.php @@ -126,6 +126,7 @@ class TestDataSeeder extends Seeder 'name' => $name, 'active' => 1, 'encrypted' => 1, + 'iban' => 'GB82WEST12345698765432' ] ); foreach ($assetMeta[$index] as $name => $value) { diff --git a/resources/lang/en/form.php b/resources/lang/en/form.php index 4fbb9a44f3..4edfa130f8 100644 --- a/resources/lang/en/form.php +++ b/resources/lang/en/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Under', 'symbol' => 'Symbol', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Store new withdrawal', 'store_new_deposit' => 'Store new deposit', diff --git a/resources/lang/nl/form.php b/resources/lang/nl/form.php index 5ab0cd308b..f2ce23701f 100644 --- a/resources/lang/nl/form.php +++ b/resources/lang/nl/form.php @@ -45,6 +45,7 @@ return [ 'under' => 'Onder', 'symbol' => 'Symbool', 'code' => 'Code', + 'iban' => 'IBAN', 'store_new_withdrawal' => 'Nieuwe uitgave opslaan', 'store_new_deposit' => 'Nieuwe inkomsten opslaan', diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig index da6437d0e7..c52b5321ea 100644 --- a/resources/twig/accounts/create.twig +++ b/resources/twig/accounts/create.twig @@ -29,6 +29,7 @@
+ {{ ExpandedForm.text('iban') }} {{ ExpandedForm.balance('openingBalance') }} {{ ExpandedForm.date('openingBalanceDate', phpdate('Y-m-d')) }} {{ ExpandedForm.select('accountRole', Config.get('firefly.accountRoles'),null,{'helpText' : 'Any extra options resulting from your choice can be set later.'}) }} diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig index 78d846f546..32e0c55972 100644 --- a/resources/twig/accounts/edit.twig +++ b/resources/twig/accounts/edit.twig @@ -27,6 +27,7 @@

{{ 'optionalFields'|_ }}

+ {{ ExpandedForm.text('iban') }} {% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %} {{ ExpandedForm.balance('openingBalance',null, {'currency' : openingBalance ? openingBalance.transactionCurrency : null}) }} {{ ExpandedForm.date('openingBalanceDate') }} From ee50b58e0014e53e857fb7393659b907de1f9602 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 3 Jul 2015 12:52:03 +0200 Subject: [PATCH 4/4] Update model info. --- app/Models/AccountMeta.php | 2 +- app/Models/AccountType.php | 2 +- app/Models/Bill.php | 2 +- app/Models/Budget.php | 2 +- app/Models/BudgetLimit.php | 2 +- app/Models/Component.php | 2 +- app/Models/LimitRepetition.php | 2 +- app/Models/PiggyBank.php | 8 +++++++- app/Models/PiggyBankEvent.php | 2 +- app/Models/PiggyBankRepetition.php | 2 +- app/Models/Preference.php | 2 +- app/Models/Transaction.php | 2 +- app/Models/TransactionCurrency.php | 2 +- app/Models/TransactionGroup.php | 2 +- app/Models/TransactionRelation.php | 2 +- app/Models/TransactionType.php | 2 +- app/User.php | 3 +-- 17 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php index 279fe60765..1e2d0ce3c3 100644 --- a/app/Models/AccountMeta.php +++ b/app/Models/AccountMeta.php @@ -6,7 +6,7 @@ use Watson\Validating\ValidatingTrait; /** * Class AccountMeta * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 2148b9e961..6de461749b 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class AccountType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Bill.php b/app/Models/Bill.php index 76ce0b66ad..4cc50a19da 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; * FireflyIII\Models\Bill * * @codeCoverageIgnore Class Bill - * @package FireflyIII\Models + * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at diff --git a/app/Models/Budget.php b/app/Models/Budget.php index 83ab460422..96886037f0 100644 --- a/app/Models/Budget.php +++ b/app/Models/Budget.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Budget * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php index 42e72dc502..97f2b16dab 100644 --- a/app/Models/BudgetLimit.php +++ b/app/Models/BudgetLimit.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class BudgetLimit * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Component.php b/app/Models/Component.php index 84686751be..c65a9c8812 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Component * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php index d5fd692dae..5f6ea2a6cf 100644 --- a/app/Models/LimitRepetition.php +++ b/app/Models/LimitRepetition.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class LimitRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index ebe5379da2..cdabb6d4e8 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class PiggyBank * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at @@ -37,6 +37,12 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereOrder($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereEncrypted($value) * @property PiggyBankRepetition currentRep + * @property string $reminder + * @property integer $reminder_skip + * @property boolean $remind_me + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminder($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereReminderSkip($value) + * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\PiggyBank whereRemindMe($value) */ class PiggyBank extends Model { diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php index 6b9bdceda1..98de0f04ef 100644 --- a/app/Models/PiggyBankEvent.php +++ b/app/Models/PiggyBankEvent.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankEvent * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php index a24066f2ee..68d2388acc 100644 --- a/app/Models/PiggyBankRepetition.php +++ b/app/Models/PiggyBankRepetition.php @@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class PiggyBankRepetition * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 56bc6f7cfd..263e7e33bc 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Preference * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 26ca48ef45..43f9928439 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -9,7 +9,7 @@ use Watson\Validating\ValidatingTrait; /** * Class Transaction * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php index 27b21f36c3..4adad9b216 100644 --- a/app/Models/TransactionCurrency.php +++ b/app/Models/TransactionCurrency.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionCurrency * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php index bb41749ca2..6c980bfac0 100644 --- a/app/Models/TransactionGroup.php +++ b/app/Models/TransactionGroup.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionGroup * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/Models/TransactionRelation.php b/app/Models/TransactionRelation.php index aa4d3810af..056d61fdd8 100644 --- a/app/Models/TransactionRelation.php +++ b/app/Models/TransactionRelation.php @@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class TransactionRelation * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models */ class TransactionRelation extends Model diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index 098d5bcfc7..886858bb2c 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; /** * Class TransactionType * - * @codeCoverageIgnore + * @codeCoverageIgnore * @package FireflyIII\Models * @property integer $id * @property \Carbon\Carbon $created_at diff --git a/app/User.php b/app/User.php index 408b621188..0763ff9e56 100644 --- a/app/User.php +++ b/app/User.php @@ -10,8 +10,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait; /** * Class User * - * @codeCoverageIgnore - * + * @codeCoverageIgnore * @package FireflyIII * @property integer $id * @property \Carbon\Carbon $created_at