Skip to content

Firefly III: a personal finances manager

Fix start and upgrade commands

James Colee6a84ab38708
diff --git a/app/Console/Commands/Correction/CorrectAmounts.php b/app/Console/Commands/Correction/CorrectAmounts.php
new file mode 100644
index 0000000000..195eebcf6f
--- /dev/null
+++ b/app/Console/Commands/Correction/CorrectAmounts.php
@@ -0,0 +1,263 @@
+<?php
+/*
+ * CorrectAmounts.php
+ * Copyright (c) 2023 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Console\Commands\Correction;
+
+use FireflyIII\Models\AutoBudget;
+use FireflyIII\Models\AvailableBudget;
+use FireflyIII\Models\Bill;
+use FireflyIII\Models\BudgetLimit;
+use FireflyIII\Models\CurrencyExchangeRate;
+use FireflyIII\Models\PiggyBank;
+use FireflyIII\Models\PiggyBankRepetition;
+use FireflyIII\Models\RecurrenceTransaction;
+use FireflyIII\Models\RuleTrigger;
+use Illuminate\Console\Command;
+
+/**
+ * Class ReportSkeleton
+ */
+class CorrectAmounts extends Command
+{
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'firefly-iii:fix-amount-pos-neg';
+
+ /**
+ * Execute the console command.
+ *
+ * @return int
+ */
+ public function handle(): int
+ {
+ // auto budgets must be positive
+ $this->fixAutoBudgets();
+ // available budgets must be positive
+ $this->fixAvailableBudgets();
+ // bills must be positive (both amounts)
+ $this->fixBills();
+ // budget limits must be positive
+ $this->fixBudgetLimits();
+ // currency_exchange_rates must be positive
+ $this->fixExchangeRates();
+ // piggy_bank_repetitions must be positive
+ $this->fixRepetitions();
+ // piggy_banks must be positive
+ $this->fixPiggyBanks();
+ // recurrences_transactions amount must be positive
+ $this->fixRecurrences();
+ // rule_triggers must be positive or zero (amount_less, amount_more, amount_is)
+ $this->fixRuleTriggers();
+
+
+ return 0;
+ }
+
+ /**
+ * @return void
+ */
+ private function fixAutoBudgets(): void
+ {
+ $set = AutoBudget::where('amount', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All auto budget amounts are positive.');
+ return;
+ }
+ /** @var AutoBudget $item */
+ foreach ($set as $item) {
+ $item->amount = app('steam')->positive((string)$item->amount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d auto budget amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixAvailableBudgets(): void
+ {
+ $set = AvailableBudget::where('amount', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All available budget amounts are positive.');
+ return;
+ }
+ /** @var AvailableBudget $item */
+ foreach ($set as $item) {
+ $item->amount = app('steam')->positive((string)$item->amount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d available budget amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixBills(): void
+ {
+ $set = Bill::where('amount_min', '<', 0)->orWhere('amount_max', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All bill amounts are positive.');
+ return;
+ }
+ /** @var Bill $item */
+ foreach ($set as $item) {
+ $item->amount_min = app('steam')->positive((string)$item->amount_min);
+ $item->amount_max = app('steam')->positive((string)$item->amount_max);
+ $item->save();
+ }
+ }
+
+ /**
+ * @return void
+ */
+ private function fixBudgetLimits(): void
+ {
+ $set = BudgetLimit::where('amount', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All budget limit amounts are positive.');
+ return;
+ }
+ /** @var BudgetLimit $item */
+ foreach ($set as $item) {
+ $item->amount = app('steam')->positive((string)$item->amount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d budget limit amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixExchangeRates(): void
+ {
+ $set = CurrencyExchangeRate::where('rate', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All currency exchange rates are positive.');
+ return;
+ }
+ /** @var BudgetLimit $item */
+ foreach ($set as $item) {
+ $item->rate = app('steam')->positive((string)$item->rate);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d currency exchange rate(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixRepetitions(): void
+ {
+ $set = PiggyBankRepetition::where('currentamount', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All piggy bank repetition amounts are positive.');
+ return;
+ }
+ /** @var PiggyBankRepetition $item */
+ foreach ($set as $item) {
+ $item->currentamount = app('steam')->positive((string)$item->currentamount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d piggy bank repetition amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixPiggyBanks(): void
+ {
+ $set = PiggyBank::where('targetamount', '<', 0)->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All piggy bank amounts are positive.');
+ return;
+ }
+ /** @var PiggyBankRepetition $item */
+ foreach ($set as $item) {
+ $item->targetamount = app('steam')->positive((string)$item->targetamount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d piggy bank amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixRecurrences(): void
+ {
+ $set = RecurrenceTransaction::where('amount', '<', 0)
+ ->orWhere('foreign_amount', '<', 0)
+ ->get();
+ $count = $set->count();
+ if (0 === $count) {
+ $this->info('All recurring transaction amounts are positive.');
+ return;
+ }
+ /** @var PiggyBankRepetition $item */
+ foreach ($set as $item) {
+ $item->amount = app('steam')->positive((string)$item->amount);
+ $item->foreign_amount = app('steam')->positive((string)$item->foreign_amount);
+ $item->save();
+ }
+ $this->line(sprintf('Corrected %d recurring transaction amount(s).', $count));
+ }
+
+ /**
+ * @return void
+ */
+ private function fixRuleTriggers(): void
+ {
+ $set = RuleTrigger::whereIn('trigger_type', ['amount_less', 'amount_more', 'amount_is'])->get();
+ $fixed = 0;
+ /** @var RuleTrigger $item */
+ foreach ($set as $item) {
+ // basic check:
+ if (-1 === bccomp((string)$item->trigger_value, '0')) {
+ $fixed++;
+ $item->trigger_value = app('steam')->positive((string)$item->trigger_value);
+ $item->save();
+ }
+ }
+ if (0 === $fixed) {
+ $this->info('All rule trigger amounts are positive.');
+ return;
+ }
+ $this->line(sprintf('Corrected %d rule trigger amount(s).', $fixed));
+ }
+
+}
diff --git a/app/Console/Commands/Correction/CorrectDatabase.php b/app/Console/Commands/Correction/CorrectDatabase.php
index 1d34acd1be..6c8c9bf1d8 100644
--- a/app/Console/Commands/Correction/CorrectDatabase.php
+++ b/app/Console/Commands/Correction/CorrectDatabase.php
@@ -52,8 +52,10 @@ class CorrectDatabase extends Command
*/
public function handle(): int
{
+ $this->line('Handle Firefly III database correction commands.');
// if table does not exist, return false
if (!Schema::hasTable('users')) {
+ $this->error('No "users"-table, will not continue.');
return 1;
}
$commands = [
@@ -61,7 +63,7 @@ class CorrectDatabase extends Command
'firefly-iii:create-link-types',
'firefly-iii:create-access-tokens',
'firefly-iii:remove-bills',
- 'firefly-iii:fix-negative-limits',
+ 'firefly-iii:fix-amount-pos-neg',
'firefly-iii:enable-currencies',
'firefly-iii:fix-transfer-budgets',
'firefly-iii:fix-uneven-amount',
@@ -76,16 +78,16 @@ class CorrectDatabase extends Command
'firefly-iii:fix-ob-currencies',
'firefly-iii:fix-long-descriptions',
'firefly-iii:fix-recurring-transactions',
- 'firefly-iii:restore-oauth-keys',
'firefly-iii:upgrade-group-information',
'firefly-iii:fix-transaction-types',
'firefly-iii:fix-frontpage-accounts',
+ // new!
+ 'firefly-iii:unify-group-accounts',
+ 'firefly-iii:trigger-credit-recalculation'
];
foreach ($commands as $command) {
- $this->line(sprintf('Now executing %s', $command));
- Artisan::call($command);
- $result = Artisan::output();
- echo $result;
+ $this->line(sprintf('Now executing command "%s"', $command));
+ $this->call($command);
}
return 0;
diff --git a/app/Console/Commands/Correction/FixBudgetLimits.php b/app/Console/Commands/Correction/FixBudgetLimits.php
deleted file mode 100644
index 39405ac70f..0000000000
--- a/app/Console/Commands/Correction/FixBudgetLimits.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-/*
- * FixBudgetLimits.php
- * Copyright (c) 2022 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace FireflyIII\Console\Commands\Correction;
-
-use DB;
-use FireflyIII\Models\BudgetLimit;
-use Illuminate\Console\Command;
-
-/**
- * Class CorrectionSkeleton
- */
-class FixBudgetLimits extends Command
-{
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Fixes negative budget limits';
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'firefly-iii:fix-negative-limits';
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle(): int
- {
- $set = BudgetLimit::where('amount', '<', '0')->get();
- if (0 === $set->count()) {
- $this->info('All budget limits are OK.');
- return 0;
- }
- $count = BudgetLimit::where('amount', '<', '0')->update(['amount' => DB::raw('amount * -1')]);
-
- $this->info(sprintf('Fixed %d budget limit(s)', $count));
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/Integrity/ReportIntegrity.php b/app/Console/Commands/Integrity/ReportIntegrity.php
index 42d1459b84..f6c21234f7 100644
--- a/app/Console/Commands/Integrity/ReportIntegrity.php
+++ b/app/Console/Commands/Integrity/ReportIntegrity.php
@@ -57,14 +57,15 @@ class ReportIntegrity extends Command
return 1;
}
$commands = [
+ 'firefly-iii:create-group-memberships',
'firefly-iii:report-empty-objects',
'firefly-iii:report-sum',
+ 'firefly-iii:restore-oauth-keys',
+ 'firefly-iii:upgrade-group-information'
];
foreach ($commands as $command) {
$this->line(sprintf('Now executing %s', $command));
- Artisan::call($command);
- $result = Artisan::output();
- echo $result;
+ $this->call($command);
}
return 0;
diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/System/CreateDatabase.php
similarity index 97%
rename from app/Console/Commands/CreateDatabase.php
rename to app/Console/Commands/System/CreateDatabase.php
index b96a070556..0022e02a4e 100644
--- a/app/Console/Commands/CreateDatabase.php
+++ b/app/Console/Commands/System/CreateDatabase.php
@@ -1,8 +1,8 @@
<?php
-/**
+/*
* CreateDatabase.php
- * Copyright (c) 2020 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,7 +22,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use Illuminate\Console\Command;
use PDO;
diff --git a/app/Console/Commands/CreateFirstUser.php b/app/Console/Commands/System/CreateFirstUser.php
similarity index 97%
rename from app/Console/Commands/CreateFirstUser.php
rename to app/Console/Commands/System/CreateFirstUser.php
index 5f8d5152a5..96a48da85f 100644
--- a/app/Console/Commands/CreateFirstUser.php
+++ b/app/Console/Commands/System/CreateFirstUser.php
@@ -2,7 +2,7 @@
/*
* CreateFirstUser.php
- * Copyright (c) 2021 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,7 +22,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Console\Command;
diff --git a/app/Console/Commands/ForceDecimalSize.php b/app/Console/Commands/System/ForceDecimalSize.php
similarity index 75%
rename from app/Console/Commands/ForceDecimalSize.php
rename to app/Console/Commands/System/ForceDecimalSize.php
index 519bcce273..66eefca3a5 100644
--- a/app/Console/Commands/ForceDecimalSize.php
+++ b/app/Console/Commands/System/ForceDecimalSize.php
@@ -1,9 +1,29 @@
<?php
+/*
+ * ForceDecimalSize.php
+ * Copyright (c) 2023 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
+use FireflyIII\Console\Commands\VerifiesAccessToken;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
diff --git a/app/Console/Commands/ForceMigration.php b/app/Console/Commands/System/ForceMigration.php
similarity index 70%
rename from app/Console/Commands/ForceMigration.php
rename to app/Console/Commands/System/ForceMigration.php
index 99dcc8cb95..43c96ebe7a 100644
--- a/app/Console/Commands/ForceMigration.php
+++ b/app/Console/Commands/System/ForceMigration.php
@@ -1,9 +1,29 @@
<?php
+/*
+ * ForceMigration.php
+ * Copyright (c) 2023 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
+use FireflyIII\Console\Commands\VerifiesAccessToken;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/System/ScanAttachments.php
similarity index 95%
rename from app/Console/Commands/ScanAttachments.php
rename to app/Console/Commands/System/ScanAttachments.php
index 747c25f0e3..231ee3ea9e 100644
--- a/app/Console/Commands/ScanAttachments.php
+++ b/app/Console/Commands/System/ScanAttachments.php
@@ -1,7 +1,7 @@
<?php
-/**
+/*
* ScanAttachments.php
- * Copyright (c) 2020 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -21,7 +21,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use Crypt;
use FireflyIII\Models\Attachment;
@@ -42,7 +42,7 @@ class ScanAttachments extends Command
*
* @var string
*/
- protected $description = 'Rescan all attachments and re-set the MD5 hash and mime.';
+ protected $description = 'Rescan all attachments and re-set the correct MD5 hash and mime.';
/**
* The name and signature of the console command.
diff --git a/app/Console/Commands/SetLatestVersion.php b/app/Console/Commands/System/SetLatestVersion.php
similarity index 94%
rename from app/Console/Commands/SetLatestVersion.php
rename to app/Console/Commands/System/SetLatestVersion.php
index f5bbdad5d5..3e880957c7 100644
--- a/app/Console/Commands/SetLatestVersion.php
+++ b/app/Console/Commands/System/SetLatestVersion.php
@@ -1,8 +1,8 @@
<?php
-/**
+/*
* SetLatestVersion.php
- * Copyright (c) 2020 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,7 +22,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use Illuminate\Console\Command;
diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/System/UpgradeFireflyInstructions.php
similarity index 96%
rename from app/Console/Commands/UpgradeFireflyInstructions.php
rename to app/Console/Commands/System/UpgradeFireflyInstructions.php
index 17f52cc165..c9cfb0b572 100644
--- a/app/Console/Commands/UpgradeFireflyInstructions.php
+++ b/app/Console/Commands/System/UpgradeFireflyInstructions.php
@@ -1,7 +1,7 @@
<?php
-/**
+/*
* UpgradeFireflyInstructions.php
- * Copyright (c) 2020 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -21,11 +21,13 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use FireflyIII\Support\System\GeneratesInstallationId;
use Illuminate\Console\Command;
+use function FireflyIII\Console\Commands\str_starts_with;
+
/**
* Class UpgradeFireflyInstructions.
*
diff --git a/app/Console/Commands/VerifySecurityAlerts.php b/app/Console/Commands/System/VerifySecurityAlerts.php
similarity index 97%
rename from app/Console/Commands/VerifySecurityAlerts.php
rename to app/Console/Commands/System/VerifySecurityAlerts.php
index bbca6a8f54..fdc3333f2c 100644
--- a/app/Console/Commands/VerifySecurityAlerts.php
+++ b/app/Console/Commands/System/VerifySecurityAlerts.php
@@ -2,7 +2,7 @@
/*
* VerifySecurityAlerts.php
- * Copyright (c) 2021 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,12 +22,12 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\System;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
-use League\Flysystem\FilesystemException;
use Illuminate\Support\Facades\Log;
+use League\Flysystem\FilesystemException;
use Storage;
/**
diff --git a/app/Console/Commands/DecryptDatabase.php b/app/Console/Commands/Upgrade/DecryptDatabase.php
similarity index 98%
rename from app/Console/Commands/DecryptDatabase.php
rename to app/Console/Commands/Upgrade/DecryptDatabase.php
index d933dc922c..45051dc6f4 100644
--- a/app/Console/Commands/DecryptDatabase.php
+++ b/app/Console/Commands/Upgrade/DecryptDatabase.php
@@ -1,8 +1,8 @@
<?php
-/**
+/*
* DecryptDatabase.php
- * Copyright (c) 2020 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,7 +22,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands;
+namespace FireflyIII\Console\Commands\Upgrade;
use Crypt;
use DB;
@@ -30,8 +30,8 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Preference;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
-use JsonException;
use Illuminate\Support\Facades\Log;
+use JsonException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use stdClass;
diff --git a/app/Console/Commands/Correction/FixPostgresSequences.php b/app/Console/Commands/Upgrade/FixPostgresSequences.php
similarity index 98%
rename from app/Console/Commands/Correction/FixPostgresSequences.php
rename to app/Console/Commands/Upgrade/FixPostgresSequences.php
index dde23f5c8d..95f7ea4127 100644
--- a/app/Console/Commands/Correction/FixPostgresSequences.php
+++ b/app/Console/Commands/Upgrade/FixPostgresSequences.php
@@ -2,7 +2,7 @@
/*
* FixPostgresSequences.php
- * Copyright (c) 2021 [email protected]
+ * Copyright (c) 2023 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
@@ -22,7 +22,7 @@
declare(strict_types=1);
-namespace FireflyIII\Console\Commands\Correction;
+namespace FireflyIII\Console\Commands\Upgrade;
use DB;
use Illuminate\Console\Command;
diff --git a/app/Console/Commands/Upgrade/UpgradeDatabase.php b/app/Console/Commands/Upgrade/UpgradeDatabase.php
index 411276367e..f2f7fa7a4d 100644
--- a/app/Console/Commands/Upgrade/UpgradeDatabase.php
+++ b/app/Console/Commands/Upgrade/UpgradeDatabase.php
@@ -57,7 +57,8 @@ class UpgradeDatabase extends Command
{
$this->callInitialCommands();
$commands = [
- // there are 14 upgrade commands.
+ 'firefly-iii:fix-pgsql-sequences',
+ 'firefly-iii:decrypt-all',
'firefly-iii:transaction-identifiers',
'firefly-iii:migrate-to-groups',
'firefly-iii:account-currencies',
@@ -75,41 +76,7 @@ class UpgradeDatabase extends Command
'firefly-iii:migrate-recurrence-type',
'firefly-iii:upgrade-liabilities',
'firefly-iii:liabilities-600',
-
- // there are 16 verify commands.
- 'firefly-iii:fix-piggies',
- 'firefly-iii:create-link-types',
- 'firefly-iii:create-access-tokens',
- 'firefly-iii:remove-bills',
- 'firefly-iii:fix-negative-limits',
- 'firefly-iii:enable-currencies',
- 'firefly-iii:fix-transfer-budgets',
- 'firefly-iii:fix-uneven-amount',
- 'firefly-iii:delete-zero-amount',
- 'firefly-iii:delete-orphaned-transactions',
- 'firefly-iii:delete-empty-journals',
- 'firefly-iii:delete-empty-groups',
- 'firefly-iii:fix-account-types',
- 'firefly-iii:fix-account-order',
- 'firefly-iii:rename-meta-fields',
- 'firefly-iii:fix-ob-currencies',
- 'firefly-iii:fix-long-descriptions',
- 'firefly-iii:fix-recurring-transactions',
- 'firefly-iii:unify-group-accounts',
- 'firefly-iii:fix-transaction-types',
- 'firefly-iii:fix-frontpage-accounts',
- 'firefly-iii:fix-ibans',
- 'firefly-iii:create-group-memberships',
- 'firefly-iii:upgrade-group-information',
-
- // two report commands
- 'firefly-iii:report-empty-objects',
- 'firefly-iii:report-sum',
- 'firefly-iii:restore-oauth-keys',
-
- // instructions
- 'firefly:instructions update',
- 'firefly-iii:verify-security-alerts',
+ 'firefly-iii:budget-limit-periods',
];
$args = [];
if ($this->option('force')) {
@@ -117,9 +84,7 @@ class UpgradeDatabase extends Command
}
foreach ($commands as $command) {
$this->line(sprintf('Now executing %s', $command));
- Artisan::call($command, $args);
- $result = Artisan::output();
- echo $result;
+ $this->call($command, $args);
}
// set new DB version.
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
@@ -129,22 +94,19 @@ class UpgradeDatabase extends Command
return 0;
}
+ /**
+ * @return void
+ */
private function callInitialCommands(): void
{
$this->line('Now seeding the database...');
- Artisan::call('migrate', ['--seed' => true, '--force' => true]);
- $result = Artisan::output();
- echo $result;
+ $this->call('migrate', ['--seed' => true, '--force' => true]);
$this->line('Fix PostgreSQL sequences.');
- Artisan::call('firefly-iii:fix-pgsql-sequences');
- $result = Artisan::output();
- echo $result;
+ $this->call('firefly-iii:fix-pgsql-sequences');
$this->line('Now decrypting the database (if necessary)...');
- Artisan::call('firefly-iii:decrypt-all');
- $result = Artisan::output();
- echo $result;
+ $this->call('firefly-iii:decrypt-all');
$this->line('Done!');
}
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index 62a5d7143a..72023adcd0 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -33,9 +33,9 @@ use FireflyIII\Support\Http\Controllers\GetConfigurationData;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use Laravel\Passport\Passport;
-use Illuminate\Support\Facades\Log;
use phpseclib3\Crypt\RSA;
/**
@@ -60,61 +60,15 @@ class InstallController extends Controller
{
// empty on purpose.
$this->upgradeCommands = [
- // there are 3 initial commands
- 'migrate' => ['--seed' => true, '--force' => true],
- 'firefly-iii:fix-pgsql-sequences' => [],
- 'firefly-iii:decrypt-all' => [],
- 'firefly-iii:restore-oauth-keys' => [],
- 'generate-keys' => [], // an exception :(
-
- // upgrade commands
- 'firefly-iii:transaction-identifiers' => [],
- 'firefly-iii:migrate-to-groups' => [],
- 'firefly-iii:account-currencies' => [],
- 'firefly-iii:transfer-currencies' => [],
- 'firefly-iii:other-currencies' => [],
- 'firefly-iii:migrate-notes' => [],
- 'firefly-iii:migrate-attachments' => [],
- 'firefly-iii:bills-to-rules' => [],
- 'firefly-iii:bl-currency' => [],
- 'firefly-iii:cc-liabilities' => [],
- 'firefly-iii:back-to-journals' => [],
- 'firefly-iii:rename-account-meta' => [],
- 'firefly-iii:migrate-recurrence-meta' => [],
- 'firefly-iii:migrate-tag-locations' => [],
- 'firefly-iii:migrate-recurrence-type' => [],
- 'firefly-iii:upgrade-liabilities' => [],
- 'firefly-iii:liabilities-600' => [],
-
- // verify commands
- 'firefly-iii:fix-piggies' => [],
- 'firefly-iii:create-link-types' => [],
- 'firefly-iii:create-access-tokens' => [],
- 'firefly-iii:remove-bills' => [],
- 'firefly-iii:fix-negative-limits' => [],
- 'firefly-iii:enable-currencies' => [],
- 'firefly-iii:fix-transfer-budgets' => [],
- 'firefly-iii:fix-uneven-amount' => [],
- 'firefly-iii:delete-zero-amount' => [],
- 'firefly-iii:delete-orphaned-transactions' => [],
- 'firefly-iii:delete-empty-journals' => [],
- 'firefly-iii:delete-empty-groups' => [],
- 'firefly-iii:fix-account-types' => [],
- 'firefly-iii:fix-account-order' => [],
- 'firefly-iii:rename-meta-fields' => [],
- 'firefly-iii:fix-ob-currencies' => [],
- 'firefly-iii:fix-long-descriptions' => [],
- 'firefly-iii:fix-recurring-transactions' => [],
- 'firefly-iii:unify-group-accounts' => [],
- 'firefly-iii:fix-transaction-types' => [],
- 'firefly-iii:fix-frontpage-accounts' => [],
- 'firefly-iii:fix-ibans' => [],
- 'firefly-iii:create-group-memberships' => [],
- 'firefly-iii:upgrade-group-information' => [],
-
- // final command to set the latest version in DB
- 'firefly-iii:set-latest-version' => ['--james-is-cool' => true],
- 'firefly-iii:verify-security-alerts' => [],
+ // there are 5 initial commands
+ // Check 4 places: InstallController, Docker image, UpgradeDatabase, composer.json
+ 'migrate' => ['--seed' => true, '--force' => true],
+ 'generate-keys' => [], // an exception :(
+ 'firefly-iii:upgrade-database' => [],
+ 'firefly-iii:correct-database' => [],
+ 'firefly-iii:report-integrity' => [],
+ 'firefly-iii:set-latest-version' => ['--james-is-cool' => true],
+ 'firefly-iii:verify-security-alerts' => [],
];
$this->lastError = '';
@@ -155,8 +109,8 @@ class InstallController extends Controller
Log::debug(sprintf('Will now run commands. Request index is %d', $requestIndex));
$indexes = array_values(array_keys($this->upgradeCommands));
- if(array_key_exists($requestIndex, $indexes)) {
- $command = $indexes[$requestIndex];
+ if (array_key_exists($requestIndex, $indexes)) {
+ $command = $indexes[$requestIndex];
$parameters = $this->upgradeCommands[$command];
Log::debug(sprintf('Will now execute command "%s" with parameters', $command), $parameters);
try {
diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.php
index 5406d86c0b..2efe78a40b 100644
--- a/app/Models/UserGroup.php
+++ b/app/Models/UserGroup.php
@@ -53,6 +53,7 @@ use Illuminate\Support\Carbon;
* @property-read int|null $accounts_count
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
+ * @property-read Collection<int, \FireflyIII\Models\Account> $accounts
* @mixin Eloquent
*/
class UserGroup extends Model
diff --git a/composer.json b/composer.json
index 529c7b5b3e..692bf85fdb 100644
--- a/composer.json
+++ b/composer.json
@@ -155,57 +155,17 @@
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
],
"post-update-cmd": [
+ "@php artisan config:clear",
+ "@php artisan route:clear",
+ "@php artisan twig:clean",
+ "@php artisan view:clear",
+ "@php artisan clear-compiled",
"@php artisan cache:clear",
- "@php artisan firefly-iii:fix-pgsql-sequences",
- "@php artisan firefly-iii:decrypt-all",
- "@php artisan firefly-iii:transaction-identifiers",
- "@php artisan firefly-iii:migrate-to-groups",
- "@php artisan firefly-iii:account-currencies",
- "@php artisan firefly-iii:transfer-currencies",
- "@php artisan firefly-iii:other-currencies",
- "@php artisan firefly-iii:migrate-notes",
- "@php artisan firefly-iii:migrate-attachments",
- "@php artisan firefly-iii:bills-to-rules",
- "@php artisan firefly-iii:bl-currency",
- "@php artisan firefly-iii:cc-liabilities",
- "@php artisan firefly-iii:back-to-journals",
- "@php artisan firefly-iii:rename-account-meta",
- "@php artisan firefly-iii:migrate-recurrence-meta",
- "@php artisan firefly-iii:migrate-tag-locations",
- "@php artisan firefly-iii:migrate-recurrence-type",
- "@php artisan firefly-iii:upgrade-liabilities",
- "@php artisan firefly-iii:liabilities-600",
- "@php artisan firefly-iii:fix-piggies",
- "@php artisan firefly-iii:create-link-types",
- "@php artisan firefly-iii:create-access-tokens",
- "@php artisan firefly-iii:remove-bills",
- "@php artisan firefly-iii:fix-negative-limits",
- "@php artisan firefly-iii:enable-currencies",
- "@php artisan firefly-iii:fix-transfer-budgets",
- "@php artisan firefly-iii:fix-uneven-amount",
- "@php artisan firefly-iii:delete-zero-amount",
- "@php artisan firefly-iii:delete-orphaned-transactions",
- "@php artisan firefly-iii:delete-empty-journals",
- "@php artisan firefly-iii:delete-empty-groups",
- "@php artisan firefly-iii:fix-account-types",
- "@php artisan firefly-iii:fix-account-order",
- "@php artisan firefly-iii:rename-meta-fields",
- "@php artisan firefly-iii:fix-ob-currencies",
- "@php artisan firefly-iii:fix-long-descriptions",
- "@php artisan firefly-iii:fix-recurring-transactions",
- "@php artisan firefly-iii:unify-group-accounts",
- "@php artisan firefly-iii:fix-transaction-types",
- "@php artisan firefly-iii:fix-frontpage-accounts",
- "@php artisan firefly-iii:fix-ibans",
- "@php artisan firefly-iii:create-group-memberships",
- "@php artisan firefly-iii:report-empty-objects",
- "@php artisan firefly-iii:report-sum",
- "@php artisan firefly-iii:restore-oauth-keys",
- "@php artisan firefly-iii:upgrade-group-information",
- "@php artisan firefly-iii:set-latest-version --james-is-cool",
- "@php artisan firefly:instructions update",
- "@php artisan firefly-iii:verify-security-alerts",
- "@php artisan passport:install"
+ "@php artisan firefly-iii:upgrade-database",
+ "@php artisan firefly-iii:correct-database",
+ "@php artisan firefly-iii:report-integrity",
+ "@php artisan passport:install",
+ "@php artisan firefly:instructions update"
],
"post-install-cmd": [
"@php artisan firefly:instructions install",
diff --git a/composer.lock b/composer.lock
index 1df45916bf..d8e2ca1096 100644
--- a/composer.lock
+++ b/composer.lock
@@ -62,26 +62,25 @@
},
{
"name": "brick/math",
- "version": "0.10.2",
+ "version": "0.11.0",
"source": {
"type": "git",
"url": "https://github.com/brick/math.git",
- "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f"
+ "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f",
- "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f",
+ "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478",
+ "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478",
"shasum": ""
},
"require": {
- "ext-json": "*",
- "php": "^7.4 || ^8.0"
+ "php": "^8.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.2",
"phpunit/phpunit": "^9.0",
- "vimeo/psalm": "4.25.0"
+ "vimeo/psalm": "5.0.0"
},
"type": "library",
"autoload": {
@@ -106,7 +105,7 @@
],
"support": {
"issues": "https://github.com/brick/math/issues",
- "source": "https://github.com/brick/math/tree/0.10.2"
+ "source": "https://github.com/brick/math/tree/0.11.0"
},
"funding": [
{
@@ -114,7 +113,7 @@
"type": "github"
}
],
- "time": "2022-08-10T22:54:19+00:00"
+ "time": "2023-01-15T23:15:59+00:00"
},
{
"name": "dasprid/enum",
@@ -5338,20 +5337,20 @@
},
{
"name": "ramsey/uuid",
- "version": "4.7.3",
+ "version": "4.7.4",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
- "reference": "433b2014e3979047db08a17a205f410ba3869cf2"
+ "reference": "60a4c63ab724854332900504274f6150ff26d286"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2",
- "reference": "433b2014e3979047db08a17a205f410ba3869cf2",
+ "url": "https://api.github.com/repos/ramsey/uuid/zipball/60a4c63ab724854332900504274f6150ff26d286",
+ "reference": "60a4c63ab724854332900504274f6150ff26d286",
"shasum": ""
},
"require": {
- "brick/math": "^0.8.8 || ^0.9 || ^0.10",
+ "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11",
"ext-json": "*",
"php": "^8.0",
"ramsey/collection": "^1.2 || ^2.0"
@@ -5414,7 +5413,7 @@
],
"support": {
"issues": "https://github.com/ramsey/uuid/issues",
- "source": "https://github.com/ramsey/uuid/tree/4.7.3"
+ "source": "https://github.com/ramsey/uuid/tree/4.7.4"
},
"funding": [
{
@@ -5426,7 +5425,7 @@
"type": "tidelift"
}
],
- "time": "2023-01-12T18:13:24+00:00"
+ "time": "2023-04-15T23:01:58+00:00"
},
{
"name": "rcrowe/twigbridge",