Skip to content

Firefly III: a personal finances manager

Some minor code fixes.

James Cole22d2a523fbd9
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.php
index 0bf65903fa..830ce56903 100644
--- a/app/Console/Commands/CreateImport.php
+++ b/app/Console/Commands/CreateImport.php
@@ -50,9 +50,7 @@ class CreateImport extends Command
}
/**
- * Execute the console command.
- *
- * @return mixed
+ *
*/
public function handle()
{
diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php
index 09a1f5bec9..2e36d3d417 100644
--- a/app/Console/Commands/Import.php
+++ b/app/Console/Commands/Import.php
@@ -51,9 +51,7 @@ class Import extends Command
}
/**
- * Execute the console command.
*
- * @return mixed
*/
public function handle()
{
diff --git a/app/Console/Commands/VerifyDatabase.php b/app/Console/Commands/VerifyDatabase.php
index 74668f4c24..61c27a48bd 100644
--- a/app/Console/Commands/VerifyDatabase.php
+++ b/app/Console/Commands/VerifyDatabase.php
@@ -25,6 +25,7 @@ use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Console\Command;
+use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Builder;
use Schema;
use stdClass;
@@ -67,16 +68,18 @@ class VerifyDatabase extends Command
return;
}
+ $this->reportObject('budget');
+ $this->reportObject('category');
+ $this->reportObject('tag');
+
+ return;
+
// accounts with no transactions.
$this->reportAccounts();
// budgets with no limits
$this->reportBudgetLimits();
// budgets with no transactions
- $this->reportBudgets();
- // categories with no transactions
- $this->reportCategories();
- // tags with no transactions
- $this->reportTags();
+
// sum of transactions is not zero.
$this->reportSum();
// any deleted transaction journals that have transactions that are NOT deleted:
@@ -142,48 +145,6 @@ class VerifyDatabase extends Command
}
}
- /**
- * Reports on budgets without any transactions.
- */
- private function reportBudgets()
- {
- $set = Budget
- ::leftJoin('budget_transaction_journal', 'budgets.id', '=', 'budget_transaction_journal.budget_id')
- ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('budget_transaction_journal.budget_id')
- ->whereNull('budgets.deleted_at')
- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
-
- /** @var stdClass $entry */
- foreach ($set as $entry) {
- $line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has budget #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
- . '") which has no transactions.';
- $this->line($line);
- }
- }
-
- /**
- * Reports on categories without any transactions.
- */
- private function reportCategories()
- {
- $set = Category
- ::leftJoin('category_transaction_journal', 'categories.id', '=', 'category_transaction_journal.category_id')
- ->leftJoin('users', 'categories.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('category_transaction_journal.category_id')
- ->whereNull('categories.deleted_at')
- ->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email']);
-
- /** @var stdClass $entry */
- foreach ($set as $entry) {
- $line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has category #' . $entry->id . ' ("' . Crypt::decrypt($entry->name)
- . '") which has no transactions.';
- $this->line($line);
- }
- }
-
/**
* Reports on deleted accounts that still have not deleted transactions or journals attached to them.
*/
@@ -300,6 +261,40 @@ class VerifyDatabase extends Command
}
+ /**
+ * @param string $name
+ */
+ private function reportObject(string $name)
+ {
+ $plural = str_plural($name);
+ $class = sprintf('FireflyIII\Models\%s', ucfirst($name));
+ $field = $name == 'tag' ? 'tag' : 'name';
+ $set = $class
+ ::leftJoin($name . '_transaction_journal', $plural . '.id', '=', $name . '_transaction_journal.' . $name . '_id')
+ ->leftJoin('users', $plural . '.user_id', '=', 'users.id')
+ ->distinct()
+ ->whereNull($name . '_transaction_journal.' . $name . '_id')
+ ->whereNull($plural . '.deleted_at')
+ ->get([$plural . '.id', $plural . '.' . $field . ' as name', $plural . '.user_id', 'users.email']);
+
+ /** @var stdClass $entry */
+ foreach ($set as $entry) {
+
+ $objName = $entry->name;
+ try {
+ $objName = Crypt::decrypt($objName);
+ } catch (DecryptException $e) {
+
+ }
+
+ $line = sprintf(
+ 'Notice: User #%d (%s) has %s #%d ("%s") which has no transactions.',
+ $entry->user_id, $entry->email, $name, $entry->id, $objName
+ );
+ $this->line($line);
+ }
+ }
+
/**
* Reports for each user when the sum of their transactions is not zero.
*/
@@ -317,27 +312,6 @@ class VerifyDatabase extends Command
}
}
- /**
- * Reports on tags without any transactions.
- */
- private function reportTags()
- {
- $set = Tag
- ::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')
- ->leftJoin('users', 'tags.user_id', '=', 'users.id')
- ->distinct()
- ->whereNull('tag_transaction_journal.tag_id')
- ->whereNull('tags.deleted_at')
- ->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email']);
-
- /** @var stdClass $entry */
- foreach ($set as $entry) {
- $line = 'Notice: User #' . $entry->user_id . ' (' . $entry->email . ') has tag #' . $entry->id . ' ("' . $entry->tag
- . '") which has no transactions.';
- $this->line($line);
- }
- }
-
/**
* Reports on deleted transactions that are connected to a not deleted journal.
*/
diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php
index d2d32751fb..fa798ef248 100644
--- a/app/Http/Controllers/Admin/HomeController.php
+++ b/app/Http/Controllers/Admin/HomeController.php
@@ -24,7 +24,7 @@ use FireflyIII\Http\Controllers\Controller;
class HomeController extends Controller
{
/**
- * @return mixed
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index e68a40ad8b..126a689b3d 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -57,7 +57,7 @@ class AttachmentController extends Controller
/**
* @param Attachment $attachment
*
- * @return View
+ * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
*/
public function delete(Attachment $attachment)
{
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index 7deaae0f59..35920e268f 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -56,7 +56,7 @@ class ExportController extends Controller
/**
* @param ExportJob $job
*
- * @return mixed
+ * @return \Symfony\Component\HttpFoundation\Response|\Illuminate\Contracts\Routing\ResponseFactory
* @throws FireflyException
*/
public function download(ExportJob $job)