Update composer, improve verify routine.

This commit is contained in:
James Cole
2016-09-23 22:31:01 +02:00
parent 258e87e127
commit 1f34e33d8c
3 changed files with 142 additions and 60 deletions

View File

@@ -12,13 +12,13 @@ declare(strict_types = 1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use Crypt; use Crypt;
use DB;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@@ -79,6 +79,9 @@ class VerifyDatabase extends Command
// report on journals with no transactions at all. // report on journals with no transactions at all.
$this->reportNoTransactions(); $this->reportNoTransactions();
// transfers with budgets.
$this->reportTransfersBudgets();
} }
/** /**
@@ -89,11 +92,10 @@ class VerifyDatabase extends Command
$set = Account $set = Account
::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id') ::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')
->leftJoin('users', 'accounts.user_id', '=', 'users.id') ->leftJoin('users', 'accounts.user_id', '=', 'users.id')
->groupBy('accounts.id') ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])
->having('transaction_count', '=', 0) ->whereNull('transactions.account_id')
->get( ->get(
['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email', ['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']
DB::raw('COUNT(`transactions`.`id`) AS `transaction_count`')]
); );
/** @var stdClass $entry */ /** @var stdClass $entry */
@@ -113,9 +115,9 @@ class VerifyDatabase extends Command
$set = Budget $set = Budget
::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id') ::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id') ->leftJoin('users', 'budgets.user_id', '=', 'users.id')
->groupBy('budgets.id') ->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
->having('budget_limit_count', '=', 0) ->whereNull('budget_limits.id')
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email', DB::raw('COUNT(`budget_limits`.`id`) AS `budget_limit_count`')]); ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
/** @var stdClass $entry */ /** @var stdClass $entry */
foreach ($set as $entry) { foreach ($set as $entry) {
@@ -225,19 +227,16 @@ class VerifyDatabase extends Command
} }
} }
/**
*
*/
private function reportNoTransactions() private function reportNoTransactions()
{ {
/*
* select transaction_journals.id, count(transactions.id) as transaction_count from transaction_journals
left join transactions ON transaction_journals.id = transactions.transaction_journal_id
group by transaction_journals.id
having transaction_count = 0
*/
$set = TransactionJournal $set = TransactionJournal
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->groupBy('transaction_journals.id') ->groupBy('transaction_journals.id')
->having('transaction_count', '=', 0) ->whereNull('transactions.transaction_journal_id')
->get(['transaction_journals.id', DB::raw('COUNT(`transactions`.`id`) as `transaction_count`')]); ->get(['transaction_journals.id']);
foreach ($set as $entry) { foreach ($set as $entry) {
$this->error( $this->error(
@@ -306,4 +305,29 @@ having transaction_count = 0
); );
} }
} }
/**
*
*/
private function reportTransfersBudgets()
{
$set = TransactionJournal
::distinct()
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')
->where('transaction_types.type', TransactionType::TRANSFER)
->whereNotNull('budget_transaction_journal.budget_id')->get(['transaction_journals.id']);
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$this->error(
sprintf(
'Error: Transaction journal #%d is a transfer, but has a budget. Edit it without changing anything, so the budget will be removed.',
$entry->id
)
);
}
}
} }

View File

@@ -38,7 +38,8 @@
"rmccue/requests": "^1.6", "rmccue/requests": "^1.6",
"pragmarx/google2fa": "^1.0", "pragmarx/google2fa": "^1.0",
"barryvdh/laravel-debugbar": "^2.2", "barryvdh/laravel-debugbar": "^2.2",
"barryvdh/laravel-ide-helper": "^2.2" "barryvdh/laravel-ide-helper": "^2.2",
"bacon/bacon-qr-code": "^1.0"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",

143
composer.lock generated
View File

@@ -4,33 +4,75 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "e85564217ea6463d7035a0f53a50f221", "hash": "f48992f1aad4a7b781ae1d6c43bddcf3",
"content-hash": "927d3ed3073f45b9e9de6dd6f28dde88", "content-hash": "8a35f78c306f3ddd1080d7c1b687f77d",
"packages": [ "packages": [
{ {
"name": "barryvdh/laravel-debugbar", "name": "bacon/bacon-qr-code",
"version": "V2.2.3", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git", "url": "https://github.com/Bacon/BaconQrCode.git",
"reference": "ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd" "reference": "031a2ce68c5794064b49d11775b2daf45c96e21c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd", "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/031a2ce68c5794064b49d11775b2daf45c96e21c",
"reference": "ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd", "reference": "031a2ce68c5794064b49d11775b2daf45c96e21c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-gd": "to generate QR code images"
},
"type": "library",
"autoload": {
"psr-0": {
"BaconQrCode": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Ben Scholzen 'DASPRiD'",
"email": "mail@dasprids.de",
"homepage": "http://www.dasprids.de",
"role": "Developer"
}
],
"description": "BaconQrCode is a QR code generator for PHP.",
"homepage": "https://github.com/Bacon/BaconQrCode",
"time": "2016-01-09 22:55:35"
},
{
"name": "barryvdh/laravel-debugbar",
"version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "0c87981df959c7c1943abe227baf607c92f204f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/0c87981df959c7c1943abe227baf607c92f204f9",
"reference": "0c87981df959c7c1943abe227baf607c92f204f9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/support": "5.1.*|5.2.*|5.3.*", "illuminate/support": "5.1.*|5.2.*|5.3.*",
"maximebf/debugbar": "~1.11.0|~1.12.0", "maximebf/debugbar": "~1.13.0",
"php": ">=5.5.9", "php": ">=5.5.9",
"symfony/finder": "~2.7|~3.0" "symfony/finder": "~2.7|~3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.2-dev" "dev-master": "2.3-dev"
} }
}, },
"autoload": { "autoload": {
@@ -59,7 +101,7 @@
"profiler", "profiler",
"webprofiler" "webprofiler"
], ],
"time": "2016-07-29 15:00:36" "time": "2016-09-15 14:05:56"
}, },
{ {
"name": "barryvdh/laravel-ide-helper", "name": "barryvdh/laravel-ide-helper",
@@ -982,16 +1024,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.3.9", "version": "v5.3.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec" "reference": "6febb0ee61999cde3bc7b2963c8903032bb22691"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec", "url": "https://api.github.com/repos/laravel/framework/zipball/6febb0ee61999cde3bc7b2963c8903032bb22691",
"reference": "f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec", "reference": "6febb0ee61999cde3bc7b2963c8903032bb22691",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1039,6 +1081,7 @@
"illuminate/http": "self.version", "illuminate/http": "self.version",
"illuminate/log": "self.version", "illuminate/log": "self.version",
"illuminate/mail": "self.version", "illuminate/mail": "self.version",
"illuminate/notifications": "self.version",
"illuminate/pagination": "self.version", "illuminate/pagination": "self.version",
"illuminate/pipeline": "self.version", "illuminate/pipeline": "self.version",
"illuminate/queue": "self.version", "illuminate/queue": "self.version",
@@ -1105,7 +1148,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2016-09-12 14:08:29" "time": "2016-09-20 13:46:16"
}, },
{ {
"name": "laravelcollective/html", "name": "laravelcollective/html",
@@ -1372,16 +1415,16 @@
}, },
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
"version": "v1.12.0", "version": "v1.13.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/maximebf/php-debugbar.git", "url": "https://github.com/maximebf/php-debugbar.git",
"reference": "e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988" "reference": "5f49a5ed6cfde81d31d89378806670d77462526e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988", "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/5f49a5ed6cfde81d31d89378806670d77462526e",
"reference": "e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988", "reference": "5f49a5ed6cfde81d31d89378806670d77462526e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1400,7 +1443,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.12-dev" "dev-master": "1.13-dev"
} }
}, },
"autoload": { "autoload": {
@@ -1429,7 +1472,7 @@
"debug", "debug",
"debugbar" "debugbar"
], ],
"time": "2016-05-15 13:11:34" "time": "2016-09-15 14:01:59"
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
@@ -1762,22 +1805,30 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.0.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" "reference": "5277094ed527a1c4477177d102fe4c53551953e0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", "reference": "5277094ed527a1c4477177d102fe4c53551953e0",
"shasum": "" "shasum": ""
}, },
"require": {
"php": ">=5.3.0"
},
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Psr\\Log\\": "" "Psr\\Log\\": "Psr/Log/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@@ -1791,12 +1842,13 @@
} }
], ],
"description": "Common interface for logging libraries", "description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [ "keywords": [
"log", "log",
"psr", "psr",
"psr-3" "psr-3"
], ],
"time": "2012-12-21 11:40:51" "time": "2016-09-19 16:02:08"
}, },
{ {
"name": "psy/psysh", "name": "psy/psysh",
@@ -2953,16 +3005,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.24.2", "version": "v1.25.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "33093f6e310e6976baeac7b14f3a6ec02f2d79b7" "reference": "f16a634ab08d87e520da5671ec52153d627f10f6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/33093f6e310e6976baeac7b14f3a6ec02f2d79b7", "url": "https://api.github.com/repos/twigphp/Twig/zipball/f16a634ab08d87e520da5671ec52153d627f10f6",
"reference": "33093f6e310e6976baeac7b14f3a6ec02f2d79b7", "reference": "f16a634ab08d87e520da5671ec52153d627f10f6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2975,7 +3027,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.24-dev" "dev-master": "1.25-dev"
} }
}, },
"autoload": { "autoload": {
@@ -3010,7 +3062,7 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2016-09-01 17:50:53" "time": "2016-09-21 23:05:12"
}, },
{ {
"name": "vlucas/phpdotenv", "name": "vlucas/phpdotenv",
@@ -3827,24 +3879,24 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "5.5.4", "version": "5.5.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5" "reference": "a57126dc681b08289fef6ac96a48e30656f84350"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6e88e56c912133de6e99b87728cca7ed70c5f5", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a57126dc681b08289fef6ac96a48e30656f84350",
"reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5", "reference": "a57126dc681b08289fef6ac96a48e30656f84350",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-json": "*", "ext-json": "*",
"ext-pcre": "*", "ext-libxml": "*",
"ext-reflection": "*", "ext-mbstring": "*",
"ext-spl": "*", "ext-xml": "*",
"myclabs/deep-copy": "~1.3", "myclabs/deep-copy": "~1.3",
"php": "^5.6 || ^7.0", "php": "^5.6 || ^7.0",
"phpspec/prophecy": "^1.3.1", "phpspec/prophecy": "^1.3.1",
@@ -3866,7 +3918,12 @@
"conflict": { "conflict": {
"phpdocumentor/reflection-docblock": "3.0.2" "phpdocumentor/reflection-docblock": "3.0.2"
}, },
"require-dev": {
"ext-pdo": "*"
},
"suggest": { "suggest": {
"ext-tidy": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "~1.1" "phpunit/php-invoker": "~1.1"
}, },
"bin": [ "bin": [
@@ -3901,7 +3958,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2016-08-26 07:11:44" "time": "2016-09-21 14:40:13"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",