Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Various code cleanup things and preparation for a new demo user.
James Coleafe98cda9f14
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.phpindex 89767b2240..41fd83d762 100644--- a/app/Console/Commands/CreateImport.php+++ b/app/Console/Commands/CreateImport.php@@ -50,11 +50,10 @@ class CreateImport extends Command}/**- *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped*/public function handle(){- // find the file/** @var UserRepositoryInterface $userRepository */$userRepository = app(UserRepositoryInterface::class);$file = $this->argument('file');@@ -67,7 +66,6 @@ class CreateImport extends Commandreturn;}- // try to parse configuration data:$configurationData = json_decode(file_get_contents($configuration));if (is_null($configurationData)) {$this->error(sprintf('Firefly III cannot read the contents of configuration file "%s" (working directory: "%s").', $configuration, $cwd));@@ -82,21 +80,17 @@ class CreateImport extends Command/** @var ImportJobRepositoryInterface $jobRepository */$jobRepository = app(ImportJobRepositoryInterface::class, [$user]);-- $job = $jobRepository->create($type);+ $job = $jobRepository->create($type);$this->line(sprintf('Created job "%s"...', $job->key));- // put the file in the proper place:Artisan::call('firefly:encrypt', ['file' => $file, 'key' => $job->key]);$this->line('Stored import data...');- // store the configuration in the job:$job->configuration = $configurationData;$job->status = 'settings_complete';$job->save();$this->line('Stored configuration...');- // if user wants to run it, do!if ($this->option('start') === true) {$this->line('The import will start in a moment. This process is not visible...');Log::debug('Go for import!');@@ -109,10 +103,10 @@ class CreateImport extends Command/*** @return bool+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's five exactly.*/private function validArguments(): bool{- // find the file/** @var UserRepositoryInterface $userRepository */$userRepository = app(UserRepositoryInterface::class);$file = $this->argument('file');diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.phpindex c339958641..c67f39000f 100644--- a/app/Console/Commands/Import.php+++ b/app/Console/Commands/Import.php@@ -18,6 +18,7 @@ use FireflyIII\Import\Logging\CommandHandler;use FireflyIII\Models\ImportJob;use FireflyIII\Models\TransactionJournal;use Illuminate\Console\Command;+use Illuminate\Support\Collection;use Log;/**@@ -69,34 +70,15 @@ class Import extends Command$monolog = Log::getMonolog();$handler = new CommandHandler($this);$monolog->pushHandler($handler);-$importProcedure = new ImportProcedure;+ $result = $importProcedure->runImport($job);- $result = $importProcedure->runImport($job);--- /**- * @var int $index- * @var TransactionJournal $journal- */- foreach ($result as $index => $journal) {- if (!is_null($journal->id)) {- $this->line(sprintf('Line #%d has been imported as transaction #%d.', $index, $journal->id));- continue;- }- $this->error(sprintf('Could not store line #%d', $index));- }-+ // display result to user:+ $this->presentResults($result);$this->line('The import has completed.');// get any errors from the importer:- $extendedStatus = $job->extended_status;- if (isset($extendedStatus['errors']) && count($extendedStatus['errors']) > 0) {- $this->line(sprintf('The following %d error(s) occured during the import:', count($extendedStatus['errors'])));- foreach ($extendedStatus['errors'] as $error) {- $this->error($error);- }- }+ $this->presentErrors($job);return;}@@ -122,4 +104,36 @@ class Import extends Commandreturn true;}++ /**+ * @param ImportJob $job+ */+ private function presentErrors(ImportJob $job)+ {+ $extendedStatus = $job->extended_status;+ if (isset($extendedStatus['errors']) && count($extendedStatus['errors']) > 0) {+ $this->line(sprintf('The following %d error(s) occured during the import:', count($extendedStatus['errors'])));+ foreach ($extendedStatus['errors'] as $error) {+ $this->error($error);+ }+ }+ }++ /**+ * @param Collection $result+ */+ private function presentResults(Collection $result)+ {+ /**+ * @var int $index+ * @var TransactionJournal $journal+ */+ foreach ($result as $index => $journal) {+ if (!is_null($journal->id)) {+ $this->line(sprintf('Line #%d has been imported as transaction #%d.', $index, $journal->id));+ continue;+ }+ $this->error(sprintf('Could not store line #%d', $index));+ }+ }}diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/ScanAttachments.phpindex 04254afb6f..0dc03631f1 100644--- a/app/Console/Commands/ScanAttachments.php+++ b/app/Console/Commands/ScanAttachments.php@@ -60,42 +60,26 @@ class ScanAttachments extends Command/** @var Attachment $attachment */foreach ($attachments as $attachment) {$fileName = $attachment->fileName();-- // try to grab file content:try {$content = $disk->get($fileName);} catch (FileNotFoundException $e) {$this->error(sprintf('Could not find data for attachment #%d', $attachment->id));continue;}- // try to decrypt content.try {$decrypted = Crypt::decrypt($content);} catch (DecryptException $e) {$this->error(sprintf('Could not decrypt data of attachment #%d', $attachment->id));continue;}-- // make temp file:$tmpfname = tempnam(sys_get_temp_dir(), 'FireflyIII');-- // store content in temp file:file_put_contents($tmpfname, $decrypted);-- // get md5 and mime- $md5 = md5_file($tmpfname);- $mime = mime_content_type($tmpfname);-- // update attachment:+ $md5 = md5_file($tmpfname);+ $mime = mime_content_type($tmpfname);$attachment->md5 = $md5;$attachment->mime = $mime;$attachment->save();--$this->line(sprintf('Fixed attachment #%d', $attachment->id));-- // find file:-}}}diff --git a/database/migrations/2016_06_16_000000_create_support_tables.php b/database/migrations/2016_06_16_000000_create_support_tables.phpindex 2ff3c650f8..6d0234802c 100644--- a/database/migrations/2016_06_16_000000_create_support_tables.php+++ b/database/migrations/2016_06_16_000000_create_support_tables.php@@ -21,7 +21,6 @@ class CreateSupportTables extends Migration/*** Reverse the migrations.*- * @return void*/public function down(){@@ -42,56 +41,20 @@ class CreateSupportTables extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){- /*- * account_types- */$this->createAccountTypeTable();- /*- * transaction_currencies- */$this->createCurrencyTable();-- /*- * transaction_types- */$this->createTransactionTypeTable();-- /*- * jobs- */$this->createJobsTable();-- /*- * password_resets- */$this->createPasswordTable();-- /*- * permissions- */$this->createPermissionsTable();-- /*- * roles- */$this->createRolesTable();-- /*- * permission_role- */$this->createPermissionRoleTable();-- /*- * sessions- */$this->createSessionsTable();-$this->createConfigurationTable();-}/**diff --git a/database/migrations/2016_06_16_000001_create_users_table.php b/database/migrations/2016_06_16_000001_create_users_table.phpindex 4b3991bd67..0120a485ed 100644--- a/database/migrations/2016_06_16_000001_create_users_table.php+++ b/database/migrations/2016_06_16_000001_create_users_table.php@@ -21,7 +21,7 @@ class CreateUsersTable extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){@@ -43,8 +43,6 @@ class CreateUsersTable extends Migration/*** Reverse the migrations.- *- * @return void*/public function down(){diff --git a/database/migrations/2016_06_16_000002_create_main_tables.php b/database/migrations/2016_06_16_000002_create_main_tables.phpindex 989fa06e10..ddbcd339bc 100644--- a/database/migrations/2016_06_16_000002_create_main_tables.php+++ b/database/migrations/2016_06_16_000002_create_main_tables.php@@ -55,6 +55,8 @@ class CreateMainTables extends Migration/*** Run the migrations.+ *+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){@@ -89,14 +91,9 @@ class CreateMainTables extends Migration$table->string('name', 1024);$table->decimal('virtual_balance', 14, 4)->nullable();$table->string('iban', 255)->nullable();-$table->boolean('active')->default(1);$table->boolean('encrypted')->default(0);-- // link user id to users table$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');-- // link account type id to account types table$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');});@@ -110,8 +107,6 @@ class CreateMainTables extends Migration$table->integer('account_id', false, true);$table->string('name');$table->text('data');-- // link account id to accounts:$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');});@@ -183,12 +178,10 @@ class CreateMainTables extends Migration}/**- *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.*/private function createBudgetTables(){--if (!Schema::hasTable('budgets')) {Schema::create('budgets', function (Blueprint $table) {@@ -199,8 +192,6 @@ class CreateMainTables extends Migration$table->string('name', 1024);$table->boolean('active')->default(1);$table->boolean('encrypted')->default(0);-- // link user id to users table$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');@@ -210,7 +201,6 @@ class CreateMainTables extends Migrationif (!Schema::hasTable('budget_limits')) {Schema::create('budget_limits', function (Blueprint $table) {-$table->increments('id');$table->timestamps();$table->integer('budget_id', false, true);@@ -218,8 +208,6 @@ class CreateMainTables extends Migration$table->decimal('amount', 14, 4);$table->string('repeat_freq', 30);$table->boolean('repeats')->default(0);-- // link budget id to budgets table$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');}@@ -234,8 +222,6 @@ class CreateMainTables extends Migration$table->date('startdate');$table->date('enddate');$table->decimal('amount', 14, 4);-- // link budget limit id to budget_limitss table$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');});@@ -319,8 +305,6 @@ class CreateMainTables extends Migration$table->integer('order', false, true)->default(0);$table->boolean('active')->default(0);$table->boolean('encrypted')->default(1);-- // link to account_id to accounts$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');});@@ -335,13 +319,10 @@ class CreateMainTables extends Migration$table->date('startdate')->nullable();$table->date('targetdate')->nullable();$table->decimal('currentamount', 14, 4);-$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');-});}-}/**@@ -388,7 +369,8 @@ class CreateMainTables extends Migration}/**- *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five*/private function createRuleTables(){@@ -503,7 +485,9 @@ class CreateMainTables extends Migration}/**- *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped.+ * @SuppressWarnings(PHPMD.NPathComplexity) // cannot be helped+ * @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five*/private function createTransactionTables(){@@ -513,26 +497,19 @@ class CreateMainTables extends Migration$table->increments('id');$table->timestamps();$table->softDeletes();-$table->integer('user_id', false, true);$table->integer('transaction_type_id', false, true);$table->integer('bill_id', false, true)->nullable();$table->integer('transaction_currency_id', false, true);-$table->string('description', 1024);-$table->date('date');$table->date('interest_date')->nullable();$table->date('book_date')->nullable();$table->date('process_date')->nullable();-$table->integer('order', false, true)->default(0);$table->integer('tag_count', false, true);-$table->boolean('encrypted')->default(1);$table->boolean('completed')->default(1);-- // links to other tables:$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');$table->foreign('bill_id')->references('id')->on('bills')->onDelete('set null');@@ -550,7 +527,6 @@ class CreateMainTables extends Migration$table->string('name', 255);$table->text('data');$table->string('hash', 64);-$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');});@@ -562,7 +538,6 @@ class CreateMainTables extends Migration$table->increments('id');$table->integer('tag_id', false, true);$table->integer('transaction_journal_id', false, true);-$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');@@ -577,7 +552,6 @@ class CreateMainTables extends Migration$table->increments('id');$table->integer('budget_id', false, true);$table->integer('transaction_journal_id', false, true);-$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');}@@ -590,7 +564,6 @@ class CreateMainTables extends Migration$table->increments('id');$table->integer('category_id', false, true);$table->integer('transaction_journal_id', false, true);-$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');}diff --git a/database/migrations/2016_08_25_091522_changes_for_3101.php b/database/migrations/2016_08_25_091522_changes_for_3101.phpindex 15a0c54afd..9d0e38a548 100644--- a/database/migrations/2016_08_25_091522_changes_for_3101.php+++ b/database/migrations/2016_08_25_091522_changes_for_3101.php@@ -20,8 +20,6 @@ class ChangesFor3101 extends Migration{/*** Reverse the migrations.- *- * @return void*/public function down(){@@ -31,7 +29,7 @@ class ChangesFor3101 extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){diff --git a/database/migrations/2016_09_12_121359_fix_nullables.php b/database/migrations/2016_09_12_121359_fix_nullables.phpindex ff89047969..54033eac70 100644--- a/database/migrations/2016_09_12_121359_fix_nullables.php+++ b/database/migrations/2016_09_12_121359_fix_nullables.php@@ -21,8 +21,6 @@ class FixNullables extends Migration/*** Reverse the migrations.- *- * @return void*/public function down(){@@ -32,7 +30,7 @@ class FixNullables extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){diff --git a/database/migrations/2016_10_09_150037_expand_transactions_table.php b/database/migrations/2016_10_09_150037_expand_transactions_table.phpindex e8dddca676..fdb957ba94 100644--- a/database/migrations/2016_10_09_150037_expand_transactions_table.php+++ b/database/migrations/2016_10_09_150037_expand_transactions_table.php@@ -19,8 +19,6 @@ class ExpandTransactionsTable extends Migration{/*** Reverse the migrations.- *- * @return void*/public function down(){@@ -30,7 +28,7 @@ class ExpandTransactionsTable extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){diff --git a/database/migrations/2016_10_22_075804_changes_for_v410.php b/database/migrations/2016_10_22_075804_changes_for_v410.phpindex ce56932066..e89daf743d 100644--- a/database/migrations/2016_10_22_075804_changes_for_v410.php+++ b/database/migrations/2016_10_22_075804_changes_for_v410.php@@ -20,8 +20,6 @@ class ChangesForV410 extends Migration{/*** Reverse the migrations.- *- * @return void*/public function down(){@@ -31,7 +29,7 @@ class ChangesForV410 extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){diff --git a/database/migrations/2016_11_24_210552_changes_for_v420.php b/database/migrations/2016_11_24_210552_changes_for_v420.phpindex a2ebc4c2ee..308bd6912a 100644--- a/database/migrations/2016_11_24_210552_changes_for_v420.php+++ b/database/migrations/2016_11_24_210552_changes_for_v420.php@@ -19,8 +19,6 @@ class ChangesForV420 extends Migration{/*** Reverse the migrations.- *- * @return void*/public function down(){@@ -30,7 +28,7 @@ class ChangesForV420 extends Migration/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){diff --git a/database/migrations/2016_12_22_150431_changes_for_v430.php b/database/migrations/2016_12_22_150431_changes_for_v430.phpindex d019dd0d8e..a01c462713 100644--- a/database/migrations/2016_12_22_150431_changes_for_v430.php+++ b/database/migrations/2016_12_22_150431_changes_for_v430.php@@ -1,21 +1,30 @@<?php-use Illuminate\Database\Schema\Blueprint;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;/*** Class ChangesForV430*/class ChangesForV430 extends Migration{+ /**+ * Reverse the migrations.+ */+ public function down()+ {+ Schema::dropIfExists('available_budgets');+ }+/*** Run the migrations.*- * @return void+ * @SuppressWarnings(PHPMD.ShortMethodName)*/public function up(){- Schema::create('available_budgets', function (Blueprint $table) {+ Schema::create(+ 'available_budgets', function (Blueprint $table) {$table->increments('id');$table->timestamps();$table->softDeletes();@@ -28,16 +37,7 @@ class ChangesForV430 extends Migration$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');- });- }-- /**- * Reverse the migrations.- *- * @return void- */- public function down()- {- Schema::dropIfExists('available_budgets');+ }+ );}}diff --git a/database/seeds/PermissionSeeder.php b/database/seeds/PermissionSeeder.phpindex 1bf36c21e7..2916470354 100644--- a/database/seeds/PermissionSeeder.php+++ b/database/seeds/PermissionSeeder.php@@ -29,6 +29,12 @@ class PermissionSeeder extends Seeder$owner->description = 'User runs this instance of FF3'; // optional$owner->save();+ $demo = new Role;+ $demo->name ='demo';+ $demo->display_name = 'Demo User';+ $demo->description = 'User is a demo user';+ $demo->save();+}}diff --git a/public/js/ff/split/journal/from-store.js b/public/js/ff/split/journal/from-store.jsindex f0c9d83f62..ef3480f827 100644--- a/public/js/ff/split/journal/from-store.js+++ b/public/js/ff/split/journal/from-store.js@@ -54,7 +54,6 @@ function removeRow(e) {$('table.split-table tbody tr[data-split="' + index + '"]').remove();-resetSplits();return false;@@ -171,8 +170,9 @@ function calculateSum() {for (var i = 0; i < set.length; i++) {var current = $(set[i]);sum += (current.val() == "" ? 0 : parseFloat(current.val()));-}+ sum = Math.round(sum * 100) / 100;+console.log("Sum is now " + sum);$('.amount-warning').remove();if (sum != originalSum) {diff --git a/public/manifest.json b/public/manifest.jsonindex 0cbb9a6a89..0b22ea1677 100644--- a/public/manifest.json+++ b/public/manifest.json@@ -14,7 +14,6 @@"type": "image\/png"}],- "theme_color": "#ffffff","display": "standalone","start_url": "/","orientation": "portrait"