From 1335a52db340615abfc913996dc6b2c9cf4958b7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 8 Dec 2014 20:27:33 +0100 Subject: [PATCH 1/4] Remove packages only found in development. --- app/config/app.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index 507426a367..4771579bbb 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -37,8 +37,8 @@ return [ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider', - 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - 'Barryvdh\Debugbar\ServiceProvider', + //'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', + //'Barryvdh\Debugbar\ServiceProvider', 'FireflyIII\FF3ServiceProvider', 'DaveJamesMiller\Breadcrumbs\ServiceProvider', 'Grumpydictator\Gchart\GchartServiceProvider', From 21d5420b2ae0a73b9082abae5415ec68f1518a80 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 13 Jan 2015 20:43:54 +0100 Subject: [PATCH 2/4] Bug fix in new accounts. --- app/config/app.php | 4 +- .../FireflyIII/Database/Account/Account.php | 29 +- .../TransactionJournal/TransactionJournal.php | 13 +- app/lib/FireflyIII/Shared/Toolkit/Amount.php | 17 + composer.lock | 2301 +---------------- 5 files changed, 73 insertions(+), 2291 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index f5774a9218..ad43b45142 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -37,8 +37,8 @@ return [ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider', -// 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', -// 'Barryvdh\Debugbar\ServiceProvider', + // 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', + // 'Barryvdh\Debugbar\ServiceProvider', 'FireflyIII\FF3ServiceProvider', 'DaveJamesMiller\Breadcrumbs\ServiceProvider', 'Grumpydictator\Gchart\GchartServiceProvider', diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php index 661db8d40c..368aeecac6 100644 --- a/app/lib/FireflyIII/Database/Account/Account.php +++ b/app/lib/FireflyIII/Database/Account/Account.php @@ -7,11 +7,12 @@ use FireflyIII\Database\CommonDatabaseCallsInterface; use FireflyIII\Database\CUDInterface; use FireflyIII\Database\SwitchUser; use FireflyIII\Exception\NotImplementedException; +use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model as Eloquent; +use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Collection; use Illuminate\Support\MessageBag; -use Illuminate\Database\Query\Builder as QueryBuilder; -use Illuminate\Database\Eloquent\Builder as EloquentBuilder; + /** * Class Account * @@ -199,8 +200,26 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte // data for transaction journal: $balance = $balance < 0 ? $balance * -1 : $balance; - $opening = ['what' => 'opening', 'currency' => 'EUR', 'amount' => $balance, 'from' => $from, 'to' => $to, 'date' => $date, - 'description' => 'Opening balance for new account ' . $account->name,]; + + // find the account type: + /** @var \FireflyIII\Database\TransactionType\TransactionType $typeRepository */ + $typeRepository = \App::make('FireflyIII\Database\TransactionType\TransactionType'); + $type = $typeRepository->findByWhat('opening'); + + // find the currency. + $currency = \Amount::getDefaultCurrency(); + + $opening = [ + 'transaction_type_id' => $type->id, + 'transaction_currency_id' => $currency->id, + 'amount' => $balance, + 'from' => $from, + 'completed' => 0, + 'currency' => 'EUR', + 'what' => 'opening', + 'to' => $to, + 'date' => $date, + 'description' => 'Opening balance for new account ' . $account->name,]; $validation = $tj->validate($opening); @@ -209,6 +228,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte return true; } else { + \Log::error('Initial balance created is not valid (Database/Account)'); \Log::error($validation['errors']->all()); \App::abort(500); } @@ -314,6 +334,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte $data = array_except($data, ['_token', 'what']); $account = new \Account($data); if (!$account->isValid()) { + \Log::error('Account created is not valid (Database/Account)'); \Log::error($account->getErrors()->all()); \App::abort(500); } diff --git a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php index ff7cafa8e2..beb7b13df2 100644 --- a/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php +++ b/app/lib/FireflyIII/Database/TransactionJournal/TransactionJournal.php @@ -74,8 +74,15 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C list($fromAccount, $toAccount) = $this->storeAccounts($data); - $this->storeTransaction(['account' => $fromAccount, 'transaction_journal' => $journal, 'amount' => floatval($data['amount'] * -1)]); - $this->storeTransaction(['account' => $toAccount, 'transaction_journal' => $journal, 'amount' => floatval($data['amount'])]); + + $this->storeTransaction( + ['account_id' => $fromAccount->id, 'account' => $fromAccount, 'transaction_journal' => $journal, 'transaction_journal_id' => $journal->id, + 'amount' => floatval($data['amount'] * -1)] + ); + $this->storeTransaction( + ['account_id' => $toAccount->id, 'account' => $toAccount, 'transaction_journal' => $journal, 'transaction_journal_id' => $journal->id, + 'amount' => floatval($data['amount'])] + ); $this->storeBudget($data, $journal); $this->storeCategory($data, $journal); @@ -278,6 +285,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C $toAccount = $accountRepository->firstExpenseAccountOrCreate($data['expense_account']); break; case 'opening': + $fromAccount = $data['from']; + $toAccount = $data['to']; break; case 'deposit': $fromAccount = $accountRepository->firstRevenueAccountOrCreate($data['revenue_account']); diff --git a/app/lib/FireflyIII/Shared/Toolkit/Amount.php b/app/lib/FireflyIII/Shared/Toolkit/Amount.php index 39a1db073b..c110d8347c 100644 --- a/app/lib/FireflyIII/Shared/Toolkit/Amount.php +++ b/app/lib/FireflyIII/Shared/Toolkit/Amount.php @@ -145,4 +145,21 @@ class Amount return $currency->code; } + /** + * @return string + */ + public function getDefaultCurrency() + { + /** @var \FireflyIII\Database\TransactionCurrency\TransactionCurrency $currencies */ + $currencies = \App::make('FireflyIII\Database\TransactionCurrency\TransactionCurrency'); + + /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ + $preferences = \App::make('FireflyIII\Shared\Preferences\Preferences'); + + $currencyPreference = $preferences->get('currencyPreference', 'EUR'); + $currency = $currencies->findByCode($currencyPreference->data); + + return $currency; + } + } diff --git a/composer.lock b/composer.lock index 9ca5ceb180..0c350cd6a1 100644 --- a/composer.lock +++ b/composer.lock @@ -420,16 +420,16 @@ }, { "name": "doctrine/dbal", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "71140662c0a954602e81271667b6e03d9f53ea34" + "reference": "628c2256b646ae2417d44e063bce8aec5199d48d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/71140662c0a954602e81271667b6e03d9f53ea34", - "reference": "71140662c0a954602e81271667b6e03d9f53ea34", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/628c2256b646ae2417d44e063bce8aec5199d48d", + "reference": "628c2256b646ae2417d44e063bce8aec5199d48d", "shasum": "" }, "require": { @@ -487,7 +487,7 @@ "persistence", "queryobject" ], - "time": "2014-12-04 21:57:15" + "time": "2015-01-12 21:52:47" }, { "name": "doctrine/inflector", @@ -698,10 +698,8 @@ ], "authors": [ { - "name": "Sander Dorigo", - "email": "thegrumpydictator@gmail.com", - "homepage": "https://github.com/JC5", - "role": "Developer" + "name": "James Cole", + "email": "TheGrumpyDictator@gmail.com" } ], "description": "GChart is a small package that allows you to easily generate data for the Google Charts API.", @@ -751,16 +749,16 @@ }, { "name": "jeremeamia/SuperClosure", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/jeremeamia/super_closure.git", - "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8" + "reference": "4d89ca74994feab128ea46d5b3add92e6cb84554" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/d05400085f7d4ae6f20ba30d36550836c0d061e8", - "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8", + "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/4d89ca74994feab128ea46d5b3add92e6cb84554", + "reference": "4d89ca74994feab128ea46d5b3add92e6cb84554", "shasum": "" }, "require": { @@ -795,7 +793,7 @@ "serialize", "tokenizer" ], - "time": "2013-10-09 04:20:00" + "time": "2015-01-10 01:09:28" }, { "name": "laravel/framework", @@ -1128,16 +1126,16 @@ }, { "name": "patchwork/utf8", - "version": "v1.1.26", + "version": "v1.1.28", "source": { "type": "git", "url": "https://github.com/tchwork/utf8.git", - "reference": "6b8e46603b49ee87ad6bceb314da94cc04ffcdce" + "reference": "ffa082111aa3cb23cf2479a17e6785ace91da982" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tchwork/utf8/zipball/6b8e46603b49ee87ad6bceb314da94cc04ffcdce", - "reference": "6b8e46603b49ee87ad6bceb314da94cc04ffcdce", + "url": "https://api.github.com/repos/tchwork/utf8/zipball/ffa082111aa3cb23cf2479a17e6785ace91da982", + "reference": "ffa082111aa3cb23cf2479a17e6785ace91da982", "shasum": "" }, "require": { @@ -1150,11 +1148,6 @@ "ext-mbstring": "Use Mbstring for best performance" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, "autoload": { "psr-0": { "Patchwork": "class/", @@ -1180,7 +1173,7 @@ "utf-8", "utf8" ], - "time": "2014-11-08 10:13:25" + "time": "2015-01-12 08:05:15" }, { "name": "phpseclib/phpseclib", @@ -2302,2265 +2295,7 @@ "time": "2014-11-20 02:09:08" } ], - "packages-dev": [ - { - "name": "barryvdh/laravel-debugbar", - "version": "v1.8.5", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "548e12d45760ee66192029f4b642d2f4e3d64118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/548e12d45760ee66192029f4b642d2f4e3d64118", - "reference": "548e12d45760ee66192029f4b642d2f4e3d64118", - "shasum": "" - }, - "require": { - "laravel/framework": "4.*|5.0.*", - "maximebf/debugbar": "~1.10.2", - "php": ">=5.3.0", - "symfony/finder": "~2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8-dev" - } - }, - "autoload": { - "psr-4": { - "Barryvdh\\Debugbar\\": "src/" - }, - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "PHP Debugbar integration for Laravel", - "keywords": [ - "debug", - "debugbar", - "laravel", - "profiler", - "webprofiler" - ], - "time": "2014-12-24 08:00:07" - }, - { - "name": "barryvdh/laravel-ide-helper", - "version": "v1.11.3", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-ide-helper.git", - "reference": "9a67d9132f0e2b9ed5d668aaa8a2ebc7d4dd6d49" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-ide-helper/zipball/9a67d9132f0e2b9ed5d668aaa8a2ebc7d4dd6d49", - "reference": "9a67d9132f0e2b9ed5d668aaa8a2ebc7d4dd6d49", - "shasum": "" - }, - "require": { - "illuminate/console": "4.x", - "illuminate/filesystem": "4.x", - "illuminate/support": "4.x", - "php": ">=5.3.0", - "phpdocumentor/reflection-docblock": "2.0.x", - "symfony/class-loader": "~2.3" - }, - "require-dev": { - "doctrine/dbal": "~2.3" - }, - "suggest": { - "doctrine/dbal": "Load information from the database about models for phpdocs (~2.3)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Barryvdh\\LaravelIdeHelper\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.", - "keywords": [ - "autocomplete", - "codeintel", - "helper", - "ide", - "laravel", - "netbeans", - "phpdoc", - "phpstorm", - "sublime" - ], - "time": "2014-08-26 08:54:34" - }, - { - "name": "codeception/c3", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/Codeception/c3.git", - "reference": "9c144d5bd3a12a5e8359d38c582238c1f1253fdb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeception/c3/zipball/9c144d5bd3a12a5e8359d38c582238c1f1253fdb", - "reference": "9c144d5bd3a12a5e8359d38c582238c1f1253fdb", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Codeception\\c3\\": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Bodnarchuk", - "email": "davert.php@resend.cc", - "homepage": "http://codegyre.com" - } - ], - "description": "CodeCoverage collector for Codeception", - "homepage": "http://codeception.com/", - "keywords": [ - "code coverage", - "codecoverage" - ], - "time": "2014-10-07 22:56:24" - }, - { - "name": "codeception/codeception", - "version": "2.0.9", - "source": { - "type": "git", - "url": "https://github.com/Codeception/Codeception.git", - "reference": "0094191ac0d6e87821fba41de002103ebe79a279" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/0094191ac0d6e87821fba41de002103ebe79a279", - "reference": "0094191ac0d6e87821fba41de002103ebe79a279", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "facebook/webdriver": "~0.4", - "guzzlehttp/guzzle": "~4.0|~5.0", - "php": ">=5.4.0", - "phpunit/phpunit": "~4.0", - "symfony/browser-kit": "~2.4", - "symfony/console": "~2.4", - "symfony/css-selector": "~2.4", - "symfony/dom-crawler": "~2.4,!=2.4.5", - "symfony/event-dispatcher": "~2.4", - "symfony/finder": "~2.4", - "symfony/yaml": "~2.4" - }, - "require-dev": { - "codeception/specify": "~0.3", - "codegyre/robo-ci": "@dev", - "facebook/php-sdk": "~3.2", - "flow/jsonpath": "~0.1", - "monolog/monolog": "~1.8", - "pda/pheanstalk": "~2.0", - "phpseclib/phpseclib": "~0.3.6", - "videlalvaro/php-amqplib": "~2.4" - }, - "suggest": { - "codeception/phpbuiltinserver": "Extension to start and stop PHP built-in web server for your tests", - "codeception/specify": "BDD-style code blocks", - "codeception/verify": "BDD-style assertions", - "monolog/monolog": "Log test steps", - "phpseclib/phpseclib": "Extension required to use the SFTP option in the FTP Module." - }, - "bin": [ - "codecept" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "psr-0": { - "Codeception": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Bodnarchuk", - "email": "davert@mail.ua", - "homepage": "http://codegyre.com" - } - ], - "description": "BDD-style testing framework", - "homepage": "http://codeception.com/", - "keywords": [ - "BDD", - "TDD", - "acceptance testing", - "functional testing", - "unit testing" - ], - "time": "2014-12-19 23:54:20" - }, - { - "name": "codeception/phpbuiltinserver", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/tiger-seo/PhpBuiltinServer.git", - "reference": "730206313b7e85d9ed4838ba02a0aee24fce1239" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tiger-seo/PhpBuiltinServer/zipball/730206313b7e85d9ed4838ba02a0aee24fce1239", - "reference": "730206313b7e85d9ed4838ba02a0aee24fce1239", - "shasum": "" - }, - "require": { - "codeception/codeception": ">=2.0.2", - "php": ">=5.4.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Codeception": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "tiger-seo", - "email": "tiger.seo@gmail.com" - } - ], - "description": "PhpBuiltinServer extension for Codeception", - "keywords": [ - "codeception" - ], - "time": "2014-09-19 10:14:07" - }, - { - "name": "codeception/specify", - "version": "0.4.1", - "source": { - "type": "git", - "url": "https://github.com/Codeception/Specify.git", - "reference": "0c0ae07adfc231115b3b72ade22f44c23c199ded" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeception/Specify/zipball/0c0ae07adfc231115b3b72ade22f44c23c199ded", - "reference": "0c0ae07adfc231115b3b72ade22f44c23c199ded", - "shasum": "" - }, - "require": { - "myclabs/deep-copy": "~1.1", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Codeception\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "authors": [ - { - "name": "Michael Bodnarchuk", - "email": "davert.php@mailican.com" - } - ], - "description": "BDD code blocks for PHPUnit and Codeception", - "time": "2014-10-17 00:06:51" - }, - { - "name": "codeception/verify", - "version": "0.2.7", - "source": { - "type": "git", - "url": "https://github.com/Codeception/Verify.git", - "reference": "66e5074905f4d9590ddb805d123fe632f4baa488" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Codeception/Verify/zipball/66e5074905f4d9590ddb805d123fe632f4baa488", - "reference": "66e5074905f4d9590ddb805d123fe632f4baa488", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "files": [ - "src/Codeception/function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "authors": [ - { - "name": "Michael Bodnarchuk", - "email": "davert.php@mailican.com", - "homepage": "http://codeception.com" - } - ], - "description": "BDD assertion library for PHPUnit", - "time": "2014-01-22 14:40:33" - }, - { - "name": "doctrine/instantiator", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", - "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "2.0.*@ALPHA" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Instantiator\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2014-10-13 12:58:55" - }, - { - "name": "facebook/webdriver", - "version": "v0.5.1", - "source": { - "type": "git", - "url": "https://github.com/facebook/php-webdriver.git", - "reference": "bbcb697efb394d17bd9ec3d467e7da847cde4509" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bbcb697efb394d17bd9ec3d467e7da847cde4509", - "reference": "bbcb697efb394d17bd9ec3d467e7da847cde4509", - "shasum": "" - }, - "require": { - "php": ">=5.3.19" - }, - "require-dev": { - "phpdocumentor/phpdocumentor": "2.*", - "phpunit/phpunit": "3.7.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "lib/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "description": "A php client for WebDriver", - "homepage": "https://github.com/facebook/php-webdriver", - "keywords": [ - "facebook", - "php", - "selenium", - "webdriver" - ], - "time": "2014-11-05 20:53:09" - }, - { - "name": "fzaninotto/faker", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/010c7efedd88bf31141a02719f51fb44c732d5a0", - "reference": "010c7efedd88bf31141a02719f51fb44c732d5a0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~1.5" - }, - "type": "library", - "extra": { - "branch-alias": [] - }, - "autoload": { - "psr-0": { - "Faker": "src/", - "Faker\\PHPUnit": "test/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "time": "2014-06-04 14:43:02" - }, - { - "name": "guzzle/guzzle", - "version": "v3.9.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle3.git", - "reference": "54991459675c1a2924122afbb0e5609ade581155" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155", - "reference": "54991459675c1a2924122afbb0e5609ade581155", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "~1.3", - "monolog/monolog": "~1.0", - "phpunit/phpunit": "3.7.*", - "psr/log": "~1.0", - "symfony/class-loader": "~2.1", - "zendframework/zend-cache": "2.*,<2.3", - "zendframework/zend-log": "2.*,<2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.9-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2014-08-11 04:32:36" - }, - { - "name": "guzzlehttp/guzzle", - "version": "5.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "f1085bb4e023766a66b7b051914ec73bdf7202b5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f1085bb4e023766a66b7b051914ec73bdf7202b5", - "reference": "f1085bb4e023766a66b7b051914ec73bdf7202b5", - "shasum": "" - }, - "require": { - "guzzlehttp/ringphp": "~1.0", - "php": ">=5.4.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2014-12-19 20:27:15" - }, - { - "name": "guzzlehttp/ringphp", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/guzzle/RingPHP.git", - "reference": "a903f51b692427318bc813217c0e6505287e79a4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a903f51b692427318bc813217c0e6505287e79a4", - "reference": "a903f51b692427318bc813217c0e6505287e79a4", - "shasum": "" - }, - "require": { - "guzzlehttp/streams": "~3.0", - "php": ">=5.4.0", - "react/promise": "~2.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Ring\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "time": "2014-12-11 05:50:32" - }, - { - "name": "guzzlehttp/streams", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple abstraction over streams of data", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "Guzzle", - "stream" - ], - "time": "2014-10-12 19:18:40" - }, - { - "name": "league/factory-muffin", - "version": "v2.1.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/factory-muffin.git", - "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/factory-muffin/zipball/91f0adcdac6b5f7bf2277ac2c90f94352afe65de", - "reference": "91f0adcdac6b5f7bf2277ac2c90f94352afe65de", - "shasum": "" - }, - "require": { - "fzaninotto/faker": "1.4.*", - "php": ">=5.3.3" - }, - "replace": { - "zizaco/factory-muff": "self.version" - }, - "require-dev": { - "illuminate/database": "~4.1", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "illuminate/database": "Factory Muffin works well with eloquent models." - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\FactoryMuffin\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "graham@mineuk.com" - }, - { - "name": "Zizaco Zizuini", - "email": "zizaco@gmail.com" - }, - { - "name": "Scott Robertson", - "email": "scottymeuk@gmail.com" - } - ], - "description": "The goal of this package is to enable the rapid creation of objects for the purpose of testing.", - "homepage": "http://factory-muffin.thephpleague.com/", - "keywords": [ - "factory", - "laravel", - "testing" - ], - "time": "2014-09-18 18:29:06" - }, - { - "name": "maximebf/debugbar", - "version": "v1.10.2", - "source": { - "type": "git", - "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "4971283c1fa8da051e97d1fa62e053d49259f7ef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/4971283c1fa8da051e97d1fa62e053d49259f7ef", - "reference": "4971283c1fa8da051e97d1fa62e053d49259f7ef", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0", - "symfony/var-dumper": "~2.6" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "kriswallsmith/assetic": "The best way to manage assets", - "monolog/monolog": "Log using Monolog", - "predis/predis": "Redis storage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-0": { - "DebugBar": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Maxime Bouroumeau-Fuseau", - "email": "maxime.bouroumeau@gmail.com", - "homepage": "http://maximebf.com" - } - ], - "description": "Debug bar in the browser for php application", - "homepage": "https://github.com/maximebf/php-debugbar", - "keywords": [ - "debug" - ], - "time": "2014-12-17 08:39:39" - }, - { - "name": "mockery/mockery", - "version": "0.9.3", - "source": { - "type": "git", - "url": "https://github.com/padraic/mockery.git", - "reference": "686f85fa5b3b079cc0157d7cd3e9adb97f0b41e1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/mockery/zipball/686f85fa5b3b079cc0157d7cd3e9adb97f0b41e1", - "reference": "686f85fa5b3b079cc0157d7cd3e9adb97f0b41e1", - "shasum": "" - }, - "require": { - "lib-pcre": ">=7.0", - "php": ">=5.3.2" - }, - "require-dev": { - "hamcrest/hamcrest-php": "~1.1", - "phpunit/phpunit": "~4.0", - "satooshi/php-coveralls": "~0.7@dev" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9.x-dev" - } - }, - "autoload": { - "psr-0": { - "Mockery": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Dave Marshall", - "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" - } - ], - "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "http://github.com/padraic/mockery", - "keywords": [ - "BDD", - "TDD", - "library", - "mock", - "mock objects", - "mockery", - "stub", - "test", - "test double", - "testing" - ], - "time": "2014-12-22 10:06:19" - }, - { - "name": "myclabs/deep-copy", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "d93c485e71bcd22df0a994e9e3e03a3ef3a3e3f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/d93c485e71bcd22df0a994e9e3e03a3ef3a3e3f3", - "reference": "d93c485e71bcd22df0a994e9e3e03a3ef3a3e3f3", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "time": "2014-11-20 05:11:17" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.3", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "38743b677965c48a637097b2746a281264ae2347" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/38743b677965c48a637097b2746a281264ae2347", - "reference": "38743b677965c48a637097b2746a281264ae2347", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*@stable" - }, - "suggest": { - "dflydev/markdown": "1.0.*", - "erusev/parsedown": "~0.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2014-08-09 10:27:07" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.0.14", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ca158276c1200cc27f5409a5e338486bc0b4fc94" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca158276c1200cc27f5409a5e338486bc0b4fc94", - "reference": "ca158276c1200cc27f5409a5e338486bc0b4fc94", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "~1.0", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4.1" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2014-12-26 13:28:33" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.3.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "File/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2013-10-10 15:34:57" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "Text/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2014-01-30 17:20:04" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2013-08-02 07:42:54" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", - "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2014-08-31 06:12:13" - }, - { - "name": "phpunit/phpunit", - "version": "4.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6a5e49a86ce5e33b8d0657abe145057fc513543a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6a5e49a86ce5e33b8d0657abe145057fc513543a", - "reference": "6a5e49a86ce5e33b8d0657abe145057fc513543a", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.2", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "~1.0.2", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.0", - "sebastian/diff": "~1.1", - "sebastian/environment": "~1.1", - "sebastian/exporter": "~1.0", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2014-12-28 07:57:05" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "c63d2367247365f688544f0d500af90a11a44c65" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", - "reference": "c63d2367247365f688544f0d500af90a11a44c65", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "~1.0,>=1.0.1", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.3" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2014-10-03 05:12:11" - }, - { - "name": "react/promise", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@googlemail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "time": "2014-12-30 13:32:42" - }, - { - "name": "satooshi/php-coveralls", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/satooshi/php-coveralls.git", - "reference": "2fbf803803d179ab1082807308a67bbd5a760c70" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/2fbf803803d179ab1082807308a67bbd5a760c70", - "reference": "2fbf803803d179ab1082807308a67bbd5a760c70", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-simplexml": "*", - "guzzle/guzzle": ">=2.7", - "php": ">=5.3", - "psr/log": "1.0.0", - "symfony/config": ">=2.0", - "symfony/console": ">=2.0", - "symfony/stopwatch": ">=2.2", - "symfony/yaml": ">=2.0" - }, - "require-dev": { - "apigen/apigen": "2.8.*@stable", - "pdepend/pdepend": "dev-master as 2.0.0", - "phpmd/phpmd": "dev-master", - "phpunit/php-invoker": ">=1.1.0,<1.2.0", - "phpunit/phpunit": "3.7.*@stable", - "sebastian/finder-facade": "dev-master", - "sebastian/phpcpd": "1.4.*@stable", - "squizlabs/php_codesniffer": "1.4.*@stable", - "theseer/fdomdocument": "dev-master" - }, - "suggest": { - "symfony/http-kernel": "Allows Symfony integration" - }, - "bin": [ - "composer/bin/coveralls" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.7-dev" - } - }, - "autoload": { - "psr-0": { - "Satooshi\\Component": "src/", - "Satooshi\\Bundle": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kitamura Satoshi", - "email": "with.no.parachute@gmail.com", - "homepage": "https://www.facebook.com/satooshi.jp" - } - ], - "description": "PHP client library for Coveralls API", - "homepage": "https://github.com/satooshi/php-coveralls", - "keywords": [ - "ci", - "coverage", - "github", - "test" - ], - "time": "2014-11-11 15:35:34" - }, - { - "name": "sebastian/comparator", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "c484a80f97573ab934e37826dba0135a3301b26a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/c484a80f97573ab934e37826dba0135a3301b26a", - "reference": "c484a80f97573ab934e37826dba0135a3301b26a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.1", - "sebastian/exporter": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2014-11-16 21:32:38" - }, - { - "name": "sebastian/diff", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", - "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "http://www.github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2014-08-15 10:29:00" - }, - { - "name": "sebastian/environment", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7", - "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2014-10-25 08:00:45" - }, - { - "name": "sebastian/exporter", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", - "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2014-09-10 00:51:36" - }, - { - "name": "sebastian/finder-facade", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/finder-facade.git", - "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/1e396fda3449fce9df032749fa4fa2619e0347e0", - "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0", - "shasum": "" - }, - "require": { - "symfony/finder": ">=2.2.0", - "theseer/fdomdocument": ">=1.3.1" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.", - "homepage": "https://github.com/sebastianbergmann/finder-facade", - "time": "2013-05-28 06:10:03" - }, - { - "name": "sebastian/global-state", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", - "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2014-10-06 09:23:50" - }, - { - "name": "sebastian/phpcpd", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpcpd.git", - "reference": "a9462153f2dd90466a010179901d31fbff598365" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/a9462153f2dd90466a010179901d31fbff598365", - "reference": "a9462153f2dd90466a010179901d31fbff598365", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-timer": ">=1.0.4", - "sebastian/finder-facade": ">=1.1.0", - "sebastian/version": ">=1.0.3", - "symfony/console": ">=2.2.0", - "theseer/fdomdocument": "~1.4" - }, - "bin": [ - "phpcpd" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Copy/Paste Detector (CPD) for PHP code.", - "homepage": "https://github.com/sebastianbergmann/phpcpd", - "time": "2014-03-31 09:25:30" - }, - { - "name": "sebastian/phpdcd", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpdcd.git", - "reference": "10246f167713d0bd0b74540ca81e4caf30b72157" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpdcd/zipball/10246f167713d0bd0b74540ca81e4caf30b72157", - "reference": "10246f167713d0bd0b74540ca81e4caf30b72157", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-timer": ">=1.0.4", - "phpunit/php-token-stream": ">=1.1.3", - "sebastian/finder-facade": ">=1.1.0", - "sebastian/version": ">=1.0.3", - "symfony/console": ">=2.2.0" - }, - "require-dev": { - "phpunit/phpunit": "~3.7" - }, - "bin": [ - "phpdcd" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Dead Code Detector (DCD) for PHP code.", - "homepage": "https://github.com/sebastianbergmann/phpdcd", - "time": "2014-04-27 06:42:32" - }, - { - "name": "sebastian/version", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a77d9123f8e809db3fbdea15038c27a95da4058b", - "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2014-12-15 14:25:24" - }, - { - "name": "symfony/class-loader", - "version": "v2.6.3", - "target-dir": "Symfony/Component/ClassLoader", - "source": { - "type": "git", - "url": "https://github.com/symfony/ClassLoader.git", - "reference": "deac802f76910708ab50d039806cfd1866895b52" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/ClassLoader/zipball/deac802f76910708ab50d039806cfd1866895b52", - "reference": "deac802f76910708ab50d039806cfd1866895b52", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/finder": "~2.0,>=2.0.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\ClassLoader\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony ClassLoader Component", - "homepage": "http://symfony.com", - "time": "2015-01-05 14:28:40" - }, - { - "name": "symfony/config", - "version": "v2.6.3", - "target-dir": "Symfony/Component/Config", - "source": { - "type": "git", - "url": "https://github.com/symfony/Config.git", - "reference": "d94f222eff99a22ce313555b78642b4873418d56" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/d94f222eff99a22ce313555b78642b4873418d56", - "reference": "d94f222eff99a22ce313555b78642b4873418d56", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/filesystem": "~2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Config\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Config Component", - "homepage": "http://symfony.com", - "time": "2015-01-03 08:01:59" - }, - { - "name": "symfony/stopwatch", - "version": "v2.6.3", - "target-dir": "Symfony/Component/Stopwatch", - "source": { - "type": "git", - "url": "https://github.com/symfony/Stopwatch.git", - "reference": "e8da5286132ba75ce4b4275fbf0f4cd369bfd71c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/e8da5286132ba75ce4b4275fbf0f4cd369bfd71c", - "reference": "e8da5286132ba75ce4b4275fbf0f4cd369bfd71c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Stopwatch\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "http://symfony.com", - "time": "2015-01-03 08:01:59" - }, - { - "name": "symfony/var-dumper", - "version": "v2.6.3", - "target-dir": "Symfony/Component/VarDumper", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "36af986811340fd4c1bc39cf848da388bbdd8473" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/36af986811340fd4c1bc39cf848da388bbdd8473", - "reference": "36af986811340fd4c1bc39cf848da388bbdd8473", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-symfony_debug": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-0": { - "Symfony\\Component\\VarDumper\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - } - ], - "description": "Symfony mechanism for exploring and dumping PHP variables", - "homepage": "http://symfony.com", - "keywords": [ - "debug", - "dump" - ], - "time": "2015-01-01 13:28:01" - }, - { - "name": "symfony/yaml", - "version": "v2.6.3", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "82462a90848a52c2533aa6b598b107d68076b018" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/82462a90848a52c2533aa6b598b107d68076b018", - "reference": "82462a90848a52c2533aa6b598b107d68076b018", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2015-01-03 15:33:07" - }, - { - "name": "theseer/fdomdocument", - "version": "1.6.0", - "source": { - "type": "git", - "url": "https://github.com/theseer/fDOMDocument.git", - "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/d08cf070350f884c63fc9078d27893c2ab6c7cef", - "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "lib-libxml": "*", - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "lead" - } - ], - "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.", - "homepage": "https://github.com/theseer/fDOMDocument", - "time": "2014-09-13 10:57:19" - } - ], + "packages-dev": null, "aliases": [], "minimum-stability": "stable", "stability-flags": { From d3e8ceee005e76e03062fc5ed06a121390f38249 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 14 Jan 2015 12:24:08 +0100 Subject: [PATCH 3/4] Cleanup in preparation of an overhaul. --- app/controllers/AccountController.php | 46 ++-- app/controllers/GoogleChartController.php | 2 +- app/controllers/HomeController.php | 4 +- app/controllers/JsonController.php | 4 +- app/controllers/PiggybankController.php | 4 +- app/controllers/PreferencesController.php | 2 +- app/controllers/RepeatedExpenseController.php | 4 +- .../FireflyIII/Database/Account/Account.php | 236 ++---------------- .../Database/Account/AccountInterface.php | 46 ---- .../Database/AccountMeta/AccountMeta.php | 66 +++++ .../Database/Scope/AccountScope.php | 52 ++++ .../Database/Scope/AccountScopeTrait.php | 22 ++ .../Exception/DeprecatedException.php | 13 + .../Helper/TransactionJournal/Helper.php | 2 +- app/lib/FireflyIII/Report/Report.php | 2 +- app/lib/FireflyIII/Validation/Account.php | 62 +++++ app/lib/FireflyIII/Validation/Validation.php | 44 ++++ app/models/Account.php | 26 +- app/models/AccountMeta.php | 6 +- app/views/accounts/create.blade.php | 4 +- 20 files changed, 337 insertions(+), 310 deletions(-) create mode 100644 app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php create mode 100644 app/lib/FireflyIII/Database/Scope/AccountScope.php create mode 100644 app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php create mode 100644 app/lib/FireflyIII/Exception/DeprecatedException.php create mode 100644 app/lib/FireflyIII/Validation/Account.php create mode 100644 app/lib/FireflyIII/Validation/Validation.php diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index b09766ed02..d9b907fe7f 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -140,8 +140,7 @@ class AccountController extends BaseController { $subTitle = $this->_subTitlesByIdentifier[$what]; $subTitleIcon = $this->_subIconsByIdentifier[$what]; - - $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]); + $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]); return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts')); } @@ -169,21 +168,23 @@ class AccountController extends BaseController public function store() { - $data = Input::except('_token'); - - // always validate: - $messages = $this->_repository->validate($data); + /* + * always validate using the account validator: + * TODO move to constructor. + */ + /** @var \FireflyIII\Validation\Account $validator */ + $validator = App::make('FireflyIII\Validation\Account'); + $data = Input::except('_token', 'post_submit_action'); + $errors = $validator->store($data); // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not store account: ' . $messages['errors']->first()); + Session::flash('errors', $errors); + if ($errors->count() > 0) { + Session::flash('error', 'Could not store account: ' . $errors->first()); } // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) { return Redirect::route('accounts.create', e($data['what']))->withInput(); } @@ -205,23 +206,24 @@ class AccountController extends BaseController */ public function update(Account $account) { + /* + * always validate using the account validator: + * TODO move to constructor. + */ + /** @var \FireflyIII\Validation\Account $validator */ + $validator = App::make('FireflyIII\Validation\Account'); $data = Input::except('_token'); $data['what'] = $this->_shortNamesByFullName[$account->accountType->type]; - - - // always validate: - $messages = $this->_repository->validate($data); + $errors = $validator->update($data, $account); // flash messages: - Session::flash('warnings', $messages['warnings']); - Session::flash('successes', $messages['successes']); - Session::flash('errors', $messages['errors']); - if ($messages['errors']->count() > 0) { - Session::flash('error', 'Could not update account: ' . $messages['errors']->first()); + Session::flash('errors', $errors); + if ($errors->count() > 0) { + Session::flash('error', 'Could not update account: ' . $errors->first()); } // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { + if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) { return Redirect::route('accounts.edit', $account->id)->withInput(); } diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index f413c9c5a3..98696a972f 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -88,7 +88,7 @@ class GoogleChartController extends BaseController /** @var \FireflyIII\Database\Account\Account $acct */ $acct = App::make('FireflyIII\Database\Account\Account'); - $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts(); + $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']); /** @var Account $account */ foreach ($accounts as $account) { diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 33bd974e5e..485f71cb15 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -33,7 +33,7 @@ class HomeController extends BaseController /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */ $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface'); - $count = $acct->countAssetAccounts(); + $count = $acct->countAccountsByType(['Default account', 'Asset account']); $start = Session::get('start', Carbon::now()->startOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth()); @@ -42,7 +42,7 @@ class HomeController extends BaseController // get the preference for the home accounts to show: $frontPage = $preferences->get('frontPageAccounts', []); if ($frontPage->data == []) { - $accounts = $acct->getAssetAccounts(); + $accounts = $acct->getAccountsByType(['Default account', 'Asset account']); } else { $accounts = $acct->getByIds($frontPage->data); } diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php index fedc5768d2..a0e6f08262 100644 --- a/app/controllers/JsonController.php +++ b/app/controllers/JsonController.php @@ -36,7 +36,7 @@ class JsonController extends BaseController { /** @var \FireflyIII\Database\Account\Account $accounts */ $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getExpenseAccounts(); + $list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']); $return = []; foreach ($list as $entry) { $return[] = $entry->name; @@ -53,7 +53,7 @@ class JsonController extends BaseController { /** @var \FireflyIII\Database\Account\Account $accounts */ $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getRevenueAccounts(); + $list = $accounts->getAccountsByType(['Revenue account']); $return = []; foreach ($list as $entry) { $return[] = $entry->name; diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index 69222f22fa..16089486f2 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -62,7 +62,7 @@ class PiggyBankController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); + $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); $subTitle = 'Create new piggy bank'; $subTitleIcon = 'fa-plus'; @@ -107,7 +107,7 @@ class PiggyBankController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); + $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); $subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"'; $subTitleIcon = 'fa-pencil'; diff --git a/app/controllers/PreferencesController.php b/app/controllers/PreferencesController.php index b1a5ca0fc7..ab4b81f717 100644 --- a/app/controllers/PreferencesController.php +++ b/app/controllers/PreferencesController.php @@ -29,7 +29,7 @@ class PreferencesController extends BaseController /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - $accounts = $acct->getAssetAccounts(); + $accounts = $acct->getAccountsByType(['Default account', 'Asset account']); $viewRange = $preferences->get('viewRange', '1M'); $viewRangeValue = $viewRange->data; $frontPage = $preferences->get('frontPageAccounts', []); diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.php index 652e255578..78272a9453 100644 --- a/app/controllers/RepeatedExpenseController.php +++ b/app/controllers/RepeatedExpenseController.php @@ -34,7 +34,7 @@ class RepeatedExpenseController extends BaseController /** @var \FireflyIII\Database\Account\Account $acct */ $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); + $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with( 'subTitleIcon', 'fa-plus' @@ -79,7 +79,7 @@ class RepeatedExpenseController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); + $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); $subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"'; $subTitleIcon = 'fa-pencil'; diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php index 368aeecac6..69b286d744 100644 --- a/app/lib/FireflyIII/Database/Account/Account.php +++ b/app/lib/FireflyIII/Database/Account/Account.php @@ -6,12 +6,11 @@ use Carbon\Carbon; use FireflyIII\Database\CommonDatabaseCallsInterface; use FireflyIII\Database\CUDInterface; use FireflyIII\Database\SwitchUser; -use FireflyIII\Exception\NotImplementedException; +use FireflyIII\Exception\DeprecatedException; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Collection; -use Illuminate\Support\MessageBag; /** * Class Account @@ -41,47 +40,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte return $this->getUser()->accounts()->accountTypeIn($types)->count(); } - /** - * @return int - */ - public function countAssetAccounts() - { - return $this->countAccountsByType(['Default account', 'Asset account']); - } - - /** - * @return int - */ - public function countExpenseAccounts() - { - return $this->countAccountsByType(['Expense account', 'Beneficiary account']); - } - - /** - * Counts the number of total revenue accounts. Useful for DataTables. - * - * @return int - */ - public function countRevenueAccounts() - { - return $this->countAccountsByType(['Revenue account']); - } - - /** - * @param \Account $account - * - * @return \Account|null - */ - public function findInitialBalanceAccount(\Account $account) - { - /** @var \FireflyIII\Database\AccountType\AccountType $acctType */ - $acctType = \App::make('FireflyIII\Database\AccountType\AccountType'); - - $accountType = $acctType->findByWhat('initial'); - - return $this->getUser()->accounts()->where('account_type_id', $accountType->id)->where('name', 'LIKE', $account->name . '%')->first(); - } - /** * @param array $types * @@ -92,14 +50,11 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte /* * Basic query: */ - $query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');; - $set = $query->get(['accounts.*']); + $query = $this->getUser()->accounts()->accountTypeIn($types)->orderBy('name', 'ASC');; + $set = $query->get(['accounts.*','account_role.data as account_role']); $set->each( function (\Account $account) { - /* - * Get last activity date. - */ $account->lastActivityDate = $this->getLastActivity($account); } ); @@ -107,57 +62,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte return $set; } - /** - * Get all asset accounts. Optional JSON based parameters. - * - * @param array $metaFilter - * - * @return Collection - */ - public function getAssetAccounts($metaFilter = []) - { - $list = $this->getAccountsByType(['Default account', 'Asset account']); - $list->each( - function (\Account $account) { - - // get accountRole: - - /** @var \AccountMeta $entry */ - $accountRole = $account->accountmeta()->whereName('accountRole')->first(); - if (!$accountRole) { - $accountRole = new \AccountMeta; - $accountRole->account_id = $account->id; - $accountRole->name = 'accountRole'; - $accountRole->data = 'defaultExpense'; - $accountRole->save(); - - } - $account->accountRole = $accountRole->data; - } - ); - - return $list; - - } - - /** - * @return Collection - */ - public function getExpenseAccounts() - { - return $this->getAccountsByType(['Expense account', 'Beneficiary account']); - } - - /** - * Get all revenue accounts. - * - * @return Collection - */ - public function getRevenueAccounts() - { - return $this->getAccountsByType(['Revenue account']); - } - /** * @param \Account $account * @@ -184,8 +88,8 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte /* * Create a journal from opposing to account or vice versa. */ - $balance = floatval($data['openingbalance']); - $date = new Carbon($data['openingbalancedate']); + $balance = floatval($data['openingBalance']); + $date = new Carbon($data['openingBalanceDate']); /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $tj */ $tj = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal'); if ($balance < 0) { @@ -339,7 +243,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte \App::abort(500); } $account->save(); - if (isset($data['openingbalance']) && floatval($data['openingbalance']) != 0) { + if (isset($data['openingBalance']) && floatval($data['openingBalance']) != 0) { $this->storeInitialBalance($account, $data); } @@ -405,78 +309,18 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } /** - * Validates a model. Returns an array containing MessageBags + * Validates an array. Returns an array containing MessageBags * errors/warnings/successes. * * @param array $model * + * @throws DeprecatedException + * * @return array */ public function validate(array $model) { - $warnings = new MessageBag; - $successes = new MessageBag; - $errors = new MessageBag; - - /* - * Name validation: - */ - if (!isset($model['name'])) { - $errors->add('name', 'Name is mandatory'); - } - - if (isset($model['name']) && strlen($model['name']) == 0) { - $errors->add('name', 'Name is too short'); - } - if (isset($model['name']) && strlen($model['name']) > 100) { - $errors->add('name', 'Name is too long'); - } - $validator = \Validator::make([$model], \Account::$rules); - if ($validator->invalid()) { - $errors->merge($errors); - } - - if (isset($model['account_role']) && !in_array($model['account_role'], array_keys(\Config::get('firefly.accountRoles')))) { - $errors->add('account_role', 'Invalid account role'); - } else { - $successes->add('account_role', 'OK'); - } - - /* - * type validation. - */ - if (!isset($model['what'])) { - $errors->add('name', 'Internal error: need to know type of account!'); - } - - /* - * Opening balance and opening balance date. - */ - if (isset($model['what']) && $model['what'] == 'asset') { - if (isset($model['openingbalance']) && strlen($model['openingbalance']) > 0 && !is_numeric($model['openingbalance'])) { - $errors->add('openingbalance', 'This is not a number.'); - } - if (isset($model['openingbalancedate']) && strlen($model['openingbalancedate']) > 0) { - try { - new Carbon($model['openingbalancedate']); - } catch (\Exception $e) { - $errors->add('openingbalancedate', 'This date is invalid.'); - } - } - } - - - if (!$errors->has('name')) { - $successes->add('name', 'OK'); - } - if (!$errors->has('openingbalance')) { - $successes->add('openingbalance', 'OK'); - } - if (!$errors->has('openingbalancedate')) { - $successes->add('openingbalancedate', 'OK'); - } - - return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes]; + throw new DeprecatedException; } /** @@ -492,25 +336,30 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } /** + * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc. + * * @param $what * - * @throws NotImplementedException + * @throws DeprecatedException + * * @return \AccountType|null */ public function findByWhat($what) { - throw new NotImplementedException; + throw new DeprecatedException; } /** * Returns all objects. * + * @throws DeprecatedException + * + * * @return Collection - * @throws NotImplementedException */ public function get() { - throw new NotImplementedException; + throw new DeprecatedException; } /** @@ -571,32 +420,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } - /** - * @param \Account $account - * @param int $limit - * - * @return \Illuminate\Pagination\Paginator - */ - public function getAllTransactionJournals(\Account $account, $limit = 50) - { - $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; - $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin( - 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' - )->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get( - ['transaction_journals.*'] - ); - $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') - ->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count(); - $items = []; - foreach ($set as $entry) { - $items[] = $entry; - } - - return \Paginator::make($items, $count, $limit); - - - } - /** * @param \Account $account * @@ -655,25 +478,4 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } - - /** - * @param \Account $account - * @param Carbon $start - * @param Carbon $end - * - * @return \Illuminate\Pagination\Paginator - */ - public function getTransactionJournalsInRange(\Account $account, Carbon $start, Carbon $end) - { - $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin( - 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' - )->where('transactions.account_id', $account->id)->before($end)->after($start)->orderBy('date', 'DESC')->get( - ['transaction_journals.*'] - ); - - return $set; - - } - - } diff --git a/app/lib/FireflyIII/Database/Account/AccountInterface.php b/app/lib/FireflyIII/Database/Account/AccountInterface.php index 336df90401..c9d21ba229 100644 --- a/app/lib/FireflyIII/Database/Account/AccountInterface.php +++ b/app/lib/FireflyIII/Database/Account/AccountInterface.php @@ -21,34 +21,6 @@ interface AccountInterface */ public function countAccountsByType(array $types); - /** - * Counts the number of total asset accounts. Useful for DataTables. - * - * @return int - */ - public function countAssetAccounts(); - - /** - * Counts the number of total expense accounts. Useful for DataTables. - * - * @return int - */ - public function countExpenseAccounts(); - - /** - * Counts the number of total revenue accounts. Useful for DataTables. - * - * @return int - */ - public function countRevenueAccounts(); - - /** - * @param \Account $account - * - * @return \Account|null - */ - public function findInitialBalanceAccount(\Account $account); - /** * Get all accounts of the selected types. Is also capable of handling DataTables' parameters. * @@ -58,24 +30,6 @@ interface AccountInterface */ public function getAccountsByType(array $types); - /** - * Get all asset accounts. The parameters are optional and are provided by the DataTables plugin. - * - * @return Collection - */ - public function getAssetAccounts(); - - /** - * @return Collection - */ - public function getExpenseAccounts(); - - /** - * Get all revenue accounts. - * - * @return Collection - */ - public function getRevenueAccounts(); /** * @param \Account $account diff --git a/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php b/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php new file mode 100644 index 0000000000..a3d1d6a39e --- /dev/null +++ b/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php @@ -0,0 +1,66 @@ +isValid(); + + return ['errors' => $model->getErrors()]; + } +} \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/Scope/AccountScope.php b/app/lib/FireflyIII/Database/Scope/AccountScope.php new file mode 100644 index 0000000000..4028fdf329 --- /dev/null +++ b/app/lib/FireflyIII/Database/Scope/AccountScope.php @@ -0,0 +1,52 @@ + 'account_role']; + + /** + * Apply the scope to a given Eloquent query builder. + * + * @param \Illuminate\Database\Eloquent\Builder $builder + * + * @return void + */ + public function apply(Builder $builder) + { + foreach (self::$fields as $name => $field) { + $builder->leftJoin( + 'account_meta AS ' . $field, function (JoinClause $join) use ($field, $name) { + $join->on($field . '.account_id', '=', 'accounts.id')->where($field . '.name', '=', $name); + } + ); + } + + //$builder->whereNull($model->getQualifiedDeletedAtColumn()); + } + + /** + * Remove the scope from the given Eloquent query builder. + * + * @param \Illuminate\Database\Eloquent\Builder $builder + * + * @return void + */ + public function remove(Builder $builder) + { + foreach ($builder->joins as $join) { + var_dump($join); + exit; + } + } +} \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php b/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php new file mode 100644 index 0000000000..d0ec9b77c6 --- /dev/null +++ b/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php @@ -0,0 +1,22 @@ +getAssetAccounts(); + return $accountRepository->getAccountsByType(['Default account', 'Asset account']); } /** diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php index 56deca08ec..f3040fe30f 100644 --- a/app/lib/FireflyIII/Report/Report.php +++ b/app/lib/FireflyIII/Report/Report.php @@ -387,7 +387,7 @@ class Report implements ReportInterface $sharedAccounts[] = $account->id; } - $accounts = $this->_accounts->getAssetAccounts()->filter( + $accounts = $this->_accounts->getAccountsByType(['Default account', 'Asset account'])->filter( function (\Account $account) use ($sharedAccounts) { if (!in_array($account->id, $sharedAccounts)) { return $account; diff --git a/app/lib/FireflyIII/Validation/Account.php b/app/lib/FireflyIII/Validation/Account.php new file mode 100644 index 0000000000..9eda3a0743 --- /dev/null +++ b/app/lib/FireflyIII/Validation/Account.php @@ -0,0 +1,62 @@ + 'required|in:asset,expense,revenue', + 'name' => 'required|between:1,100', + 'openingBalance' => 'numeric', + 'openingBalanceDate' => 'date', + 'active' => 'required|boolean', + 'account_role' => 'in:' . $meta, + ]; + $validator = \Validator::make($data, $rules); + $validator->valid(); + + return $validator->messages(); + } + + /** + * Every time an [object or set of objects] is updated this method will validate the new + * values in the context of the existing object (or set of objects). Since most forms + * only have one [object] to validate and at least always one main [object] to validate + * this method will accept an array of data to validate and an optional model to validate + * against. + * + * @param array $data + * @param \Eloquent $model + * + * @return MessageBag + */ + public function update(array $data = [], \Eloquent $model = null) + { + // this method simply returns the validation done by "store": + return $this->store($data); + } +} \ No newline at end of file diff --git a/app/lib/FireflyIII/Validation/Validation.php b/app/lib/FireflyIII/Validation/Validation.php new file mode 100644 index 0000000000..07e7784898 --- /dev/null +++ b/app/lib/FireflyIII/Validation/Validation.php @@ -0,0 +1,44 @@ + ['required', 'between:1,100'], 'user_id' => 'required|exists:users,id', @@ -25,8 +27,6 @@ class Account extends Eloquent 'active' => 'required|boolean' ]; - protected $dates = ['deleted_at', 'created_at', 'updated_at']; - protected $fillable = ['name', 'user_id', 'account_type_id', 'active']; /** * Account type. @@ -67,7 +67,7 @@ class Account extends Eloquent /** * * @param EloquentBuilder $query - * @param array $types + * @param array $types */ public function scopeAccountTypeIn(EloquentBuilder $query, array $types) { @@ -97,6 +97,16 @@ class Account extends Eloquent return $this->hasMany('Transaction'); } + /** + * @param $value + * + * @return mixed + */ + public function getAccountRoleAttribute($value) + { + return json_decode($value); + } + /** * @param $fieldName * @param $fieldValue diff --git a/app/models/AccountMeta.php b/app/models/AccountMeta.php index 5a481a2c90..36a1462149 100644 --- a/app/models/AccountMeta.php +++ b/app/models/AccountMeta.php @@ -10,16 +10,16 @@ class AccountMeta extends Eloquent /** * @var array */ - public static $rules + protected $rules = [ - 'account_id' => 'numeric|required|exists:accounts,id', + 'account_id' => 'numeric|exists:accounts,id', 'name' => 'required|between:1,250', 'data' => 'required' ]; /** * @var array */ - protected $fillable = ['account_id', 'name', 'date']; + protected $fillable = ['account_id', 'name', 'data']; protected $table = 'account_meta'; /** diff --git a/app/views/accounts/create.blade.php b/app/views/accounts/create.blade.php index 8fc3f78c5a..260f1b3fb6 100644 --- a/app/views/accounts/create.blade.php +++ b/app/views/accounts/create.blade.php @@ -29,8 +29,8 @@
@if($what == 'asset') - {{Form::ffBalance('openingbalance')}} - {{Form::ffDate('openingbalancedate', date('Y-m-d'))}} + {{Form::ffBalance('openingBalance')}} + {{Form::ffDate('openingBalanceDate', date('Y-m-d'))}} @endif {{Form::ffCheckbox('active','1',true)}} {{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}} From 9735ef6d41e5a8af3ac1f38c2f869f49ebdbb67b Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 16 Jan 2015 07:07:57 +0100 Subject: [PATCH 4/4] Revert "Cleanup in preparation of an overhaul." This reverts commit 5662a02a36195e6433ec95f261412ce85bc5019f. --- app/controllers/AccountController.php | 46 ++-- app/controllers/GoogleChartController.php | 2 +- app/controllers/HomeController.php | 4 +- app/controllers/JsonController.php | 4 +- app/controllers/PiggybankController.php | 4 +- app/controllers/PreferencesController.php | 2 +- app/controllers/RepeatedExpenseController.php | 4 +- .../FireflyIII/Database/Account/Account.php | 236 ++++++++++++++++-- .../Database/Account/AccountInterface.php | 46 ++++ .../Database/AccountMeta/AccountMeta.php | 66 ----- .../Database/Scope/AccountScope.php | 52 ---- .../Database/Scope/AccountScopeTrait.php | 22 -- .../Exception/DeprecatedException.php | 13 - .../Helper/TransactionJournal/Helper.php | 2 +- app/lib/FireflyIII/Report/Report.php | 2 +- app/lib/FireflyIII/Validation/Account.php | 62 ----- app/lib/FireflyIII/Validation/Validation.php | 44 ---- app/models/Account.php | 26 +- app/models/AccountMeta.php | 6 +- app/views/accounts/create.blade.php | 4 +- 20 files changed, 310 insertions(+), 337 deletions(-) delete mode 100644 app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php delete mode 100644 app/lib/FireflyIII/Database/Scope/AccountScope.php delete mode 100644 app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php delete mode 100644 app/lib/FireflyIII/Exception/DeprecatedException.php delete mode 100644 app/lib/FireflyIII/Validation/Account.php delete mode 100644 app/lib/FireflyIII/Validation/Validation.php diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index d9b907fe7f..b09766ed02 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -140,7 +140,8 @@ class AccountController extends BaseController { $subTitle = $this->_subTitlesByIdentifier[$what]; $subTitleIcon = $this->_subIconsByIdentifier[$what]; - $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]); + + $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]); return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts')); } @@ -168,23 +169,21 @@ class AccountController extends BaseController public function store() { - /* - * always validate using the account validator: - * TODO move to constructor. - */ - /** @var \FireflyIII\Validation\Account $validator */ - $validator = App::make('FireflyIII\Validation\Account'); - $data = Input::except('_token', 'post_submit_action'); - $errors = $validator->store($data); + $data = Input::except('_token'); + + // always validate: + $messages = $this->_repository->validate($data); // flash messages: - Session::flash('errors', $errors); - if ($errors->count() > 0) { - Session::flash('error', 'Could not store account: ' . $errors->first()); + Session::flash('warnings', $messages['warnings']); + Session::flash('successes', $messages['successes']); + Session::flash('errors', $messages['errors']); + if ($messages['errors']->count() > 0) { + Session::flash('error', 'Could not store account: ' . $messages['errors']->first()); } // return to create screen: - if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) { + if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { return Redirect::route('accounts.create', e($data['what']))->withInput(); } @@ -206,24 +205,23 @@ class AccountController extends BaseController */ public function update(Account $account) { - /* - * always validate using the account validator: - * TODO move to constructor. - */ - /** @var \FireflyIII\Validation\Account $validator */ - $validator = App::make('FireflyIII\Validation\Account'); $data = Input::except('_token'); $data['what'] = $this->_shortNamesByFullName[$account->accountType->type]; - $errors = $validator->update($data, $account); + + + // always validate: + $messages = $this->_repository->validate($data); // flash messages: - Session::flash('errors', $errors); - if ($errors->count() > 0) { - Session::flash('error', 'Could not update account: ' . $errors->first()); + Session::flash('warnings', $messages['warnings']); + Session::flash('successes', $messages['successes']); + Session::flash('errors', $messages['errors']); + if ($messages['errors']->count() > 0) { + Session::flash('error', 'Could not update account: ' . $messages['errors']->first()); } // return to update screen: - if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) { + if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { return Redirect::route('accounts.edit', $account->id)->withInput(); } diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index 98696a972f..f413c9c5a3 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -88,7 +88,7 @@ class GoogleChartController extends BaseController /** @var \FireflyIII\Database\Account\Account $acct */ $acct = App::make('FireflyIII\Database\Account\Account'); - $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']); + $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts(); /** @var Account $account */ foreach ($accounts as $account) { diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 485f71cb15..33bd974e5e 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -33,7 +33,7 @@ class HomeController extends BaseController /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */ $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface'); - $count = $acct->countAccountsByType(['Default account', 'Asset account']); + $count = $acct->countAssetAccounts(); $start = Session::get('start', Carbon::now()->startOfMonth()); $end = Session::get('end', Carbon::now()->endOfMonth()); @@ -42,7 +42,7 @@ class HomeController extends BaseController // get the preference for the home accounts to show: $frontPage = $preferences->get('frontPageAccounts', []); if ($frontPage->data == []) { - $accounts = $acct->getAccountsByType(['Default account', 'Asset account']); + $accounts = $acct->getAssetAccounts(); } else { $accounts = $acct->getByIds($frontPage->data); } diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php index a0e6f08262..fedc5768d2 100644 --- a/app/controllers/JsonController.php +++ b/app/controllers/JsonController.php @@ -36,7 +36,7 @@ class JsonController extends BaseController { /** @var \FireflyIII\Database\Account\Account $accounts */ $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']); + $list = $accounts->getExpenseAccounts(); $return = []; foreach ($list as $entry) { $return[] = $entry->name; @@ -53,7 +53,7 @@ class JsonController extends BaseController { /** @var \FireflyIII\Database\Account\Account $accounts */ $accounts = App::make('FireflyIII\Database\Account\Account'); - $list = $accounts->getAccountsByType(['Revenue account']); + $list = $accounts->getRevenueAccounts(); $return = []; foreach ($list as $entry) { $return[] = $entry->name; diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php index 16089486f2..69222f22fa 100644 --- a/app/controllers/PiggybankController.php +++ b/app/controllers/PiggybankController.php @@ -62,7 +62,7 @@ class PiggyBankController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); + $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); $subTitle = 'Create new piggy bank'; $subTitleIcon = 'fa-plus'; @@ -107,7 +107,7 @@ class PiggyBankController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); + $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); $subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"'; $subTitleIcon = 'fa-pencil'; diff --git a/app/controllers/PreferencesController.php b/app/controllers/PreferencesController.php index ab4b81f717..b1a5ca0fc7 100644 --- a/app/controllers/PreferencesController.php +++ b/app/controllers/PreferencesController.php @@ -29,7 +29,7 @@ class PreferencesController extends BaseController /** @var \FireflyIII\Shared\Preferences\Preferences $preferences */ $preferences = App::make('FireflyIII\Shared\Preferences\Preferences'); - $accounts = $acct->getAccountsByType(['Default account', 'Asset account']); + $accounts = $acct->getAssetAccounts(); $viewRange = $preferences->get('viewRange', '1M'); $viewRangeValue = $viewRange->data; $frontPage = $preferences->get('frontPageAccounts', []); diff --git a/app/controllers/RepeatedExpenseController.php b/app/controllers/RepeatedExpenseController.php index 78272a9453..652e255578 100644 --- a/app/controllers/RepeatedExpenseController.php +++ b/app/controllers/RepeatedExpenseController.php @@ -34,7 +34,7 @@ class RepeatedExpenseController extends BaseController /** @var \FireflyIII\Database\Account\Account $acct */ $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); + $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with( 'subTitleIcon', 'fa-plus' @@ -79,7 +79,7 @@ class RepeatedExpenseController extends BaseController $acct = App::make('FireflyIII\Database\Account\Account'); $periods = Config::get('firefly.piggy_bank_periods'); - $accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account'])); + $accounts = FFForm::makeSelectList($acct->getAssetAccounts()); $subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"'; $subTitleIcon = 'fa-pencil'; diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php index 69b286d744..368aeecac6 100644 --- a/app/lib/FireflyIII/Database/Account/Account.php +++ b/app/lib/FireflyIII/Database/Account/Account.php @@ -6,11 +6,12 @@ use Carbon\Carbon; use FireflyIII\Database\CommonDatabaseCallsInterface; use FireflyIII\Database\CUDInterface; use FireflyIII\Database\SwitchUser; -use FireflyIII\Exception\DeprecatedException; +use FireflyIII\Exception\NotImplementedException; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Support\Collection; +use Illuminate\Support\MessageBag; /** * Class Account @@ -40,6 +41,47 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte return $this->getUser()->accounts()->accountTypeIn($types)->count(); } + /** + * @return int + */ + public function countAssetAccounts() + { + return $this->countAccountsByType(['Default account', 'Asset account']); + } + + /** + * @return int + */ + public function countExpenseAccounts() + { + return $this->countAccountsByType(['Expense account', 'Beneficiary account']); + } + + /** + * Counts the number of total revenue accounts. Useful for DataTables. + * + * @return int + */ + public function countRevenueAccounts() + { + return $this->countAccountsByType(['Revenue account']); + } + + /** + * @param \Account $account + * + * @return \Account|null + */ + public function findInitialBalanceAccount(\Account $account) + { + /** @var \FireflyIII\Database\AccountType\AccountType $acctType */ + $acctType = \App::make('FireflyIII\Database\AccountType\AccountType'); + + $accountType = $acctType->findByWhat('initial'); + + return $this->getUser()->accounts()->where('account_type_id', $accountType->id)->where('name', 'LIKE', $account->name . '%')->first(); + } + /** * @param array $types * @@ -50,11 +92,14 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte /* * Basic query: */ - $query = $this->getUser()->accounts()->accountTypeIn($types)->orderBy('name', 'ASC');; - $set = $query->get(['accounts.*','account_role.data as account_role']); + $query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');; + $set = $query->get(['accounts.*']); $set->each( function (\Account $account) { + /* + * Get last activity date. + */ $account->lastActivityDate = $this->getLastActivity($account); } ); @@ -62,6 +107,57 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte return $set; } + /** + * Get all asset accounts. Optional JSON based parameters. + * + * @param array $metaFilter + * + * @return Collection + */ + public function getAssetAccounts($metaFilter = []) + { + $list = $this->getAccountsByType(['Default account', 'Asset account']); + $list->each( + function (\Account $account) { + + // get accountRole: + + /** @var \AccountMeta $entry */ + $accountRole = $account->accountmeta()->whereName('accountRole')->first(); + if (!$accountRole) { + $accountRole = new \AccountMeta; + $accountRole->account_id = $account->id; + $accountRole->name = 'accountRole'; + $accountRole->data = 'defaultExpense'; + $accountRole->save(); + + } + $account->accountRole = $accountRole->data; + } + ); + + return $list; + + } + + /** + * @return Collection + */ + public function getExpenseAccounts() + { + return $this->getAccountsByType(['Expense account', 'Beneficiary account']); + } + + /** + * Get all revenue accounts. + * + * @return Collection + */ + public function getRevenueAccounts() + { + return $this->getAccountsByType(['Revenue account']); + } + /** * @param \Account $account * @@ -88,8 +184,8 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte /* * Create a journal from opposing to account or vice versa. */ - $balance = floatval($data['openingBalance']); - $date = new Carbon($data['openingBalanceDate']); + $balance = floatval($data['openingbalance']); + $date = new Carbon($data['openingbalancedate']); /** @var \FireflyIII\Database\TransactionJournal\TransactionJournal $tj */ $tj = \App::make('FireflyIII\Database\TransactionJournal\TransactionJournal'); if ($balance < 0) { @@ -243,7 +339,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte \App::abort(500); } $account->save(); - if (isset($data['openingBalance']) && floatval($data['openingBalance']) != 0) { + if (isset($data['openingbalance']) && floatval($data['openingbalance']) != 0) { $this->storeInitialBalance($account, $data); } @@ -309,18 +405,78 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } /** - * Validates an array. Returns an array containing MessageBags + * Validates a model. Returns an array containing MessageBags * errors/warnings/successes. * * @param array $model * - * @throws DeprecatedException - * * @return array */ public function validate(array $model) { - throw new DeprecatedException; + $warnings = new MessageBag; + $successes = new MessageBag; + $errors = new MessageBag; + + /* + * Name validation: + */ + if (!isset($model['name'])) { + $errors->add('name', 'Name is mandatory'); + } + + if (isset($model['name']) && strlen($model['name']) == 0) { + $errors->add('name', 'Name is too short'); + } + if (isset($model['name']) && strlen($model['name']) > 100) { + $errors->add('name', 'Name is too long'); + } + $validator = \Validator::make([$model], \Account::$rules); + if ($validator->invalid()) { + $errors->merge($errors); + } + + if (isset($model['account_role']) && !in_array($model['account_role'], array_keys(\Config::get('firefly.accountRoles')))) { + $errors->add('account_role', 'Invalid account role'); + } else { + $successes->add('account_role', 'OK'); + } + + /* + * type validation. + */ + if (!isset($model['what'])) { + $errors->add('name', 'Internal error: need to know type of account!'); + } + + /* + * Opening balance and opening balance date. + */ + if (isset($model['what']) && $model['what'] == 'asset') { + if (isset($model['openingbalance']) && strlen($model['openingbalance']) > 0 && !is_numeric($model['openingbalance'])) { + $errors->add('openingbalance', 'This is not a number.'); + } + if (isset($model['openingbalancedate']) && strlen($model['openingbalancedate']) > 0) { + try { + new Carbon($model['openingbalancedate']); + } catch (\Exception $e) { + $errors->add('openingbalancedate', 'This date is invalid.'); + } + } + } + + + if (!$errors->has('name')) { + $successes->add('name', 'OK'); + } + if (!$errors->has('openingbalance')) { + $successes->add('openingbalance', 'OK'); + } + if (!$errors->has('openingbalancedate')) { + $successes->add('openingbalancedate', 'OK'); + } + + return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes]; } /** @@ -336,30 +492,25 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } /** - * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc. - * * @param $what * - * @throws DeprecatedException - * + * @throws NotImplementedException * @return \AccountType|null */ public function findByWhat($what) { - throw new DeprecatedException; + throw new NotImplementedException; } /** * Returns all objects. * - * @throws DeprecatedException - * - * * @return Collection + * @throws NotImplementedException */ public function get() { - throw new DeprecatedException; + throw new NotImplementedException; } /** @@ -420,6 +571,32 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } + /** + * @param \Account $account + * @param int $limit + * + * @return \Illuminate\Pagination\Paginator + */ + public function getAllTransactionJournals(\Account $account, $limit = 50) + { + $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; + $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin( + 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' + )->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->orderBy('date', 'DESC')->get( + ['transaction_journals.*'] + ); + $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count(); + $items = []; + foreach ($set as $entry) { + $items[] = $entry; + } + + return \Paginator::make($items, $count, $limit); + + + } + /** * @param \Account $account * @@ -478,4 +655,25 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte } + + /** + * @param \Account $account + * @param Carbon $start + * @param Carbon $end + * + * @return \Illuminate\Pagination\Paginator + */ + public function getTransactionJournalsInRange(\Account $account, Carbon $start, Carbon $end) + { + $set = $this->getUser()->transactionJournals()->transactionTypes(['Withdrawal'])->withRelevantData()->leftJoin( + 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id' + )->where('transactions.account_id', $account->id)->before($end)->after($start)->orderBy('date', 'DESC')->get( + ['transaction_journals.*'] + ); + + return $set; + + } + + } diff --git a/app/lib/FireflyIII/Database/Account/AccountInterface.php b/app/lib/FireflyIII/Database/Account/AccountInterface.php index c9d21ba229..336df90401 100644 --- a/app/lib/FireflyIII/Database/Account/AccountInterface.php +++ b/app/lib/FireflyIII/Database/Account/AccountInterface.php @@ -21,6 +21,34 @@ interface AccountInterface */ public function countAccountsByType(array $types); + /** + * Counts the number of total asset accounts. Useful for DataTables. + * + * @return int + */ + public function countAssetAccounts(); + + /** + * Counts the number of total expense accounts. Useful for DataTables. + * + * @return int + */ + public function countExpenseAccounts(); + + /** + * Counts the number of total revenue accounts. Useful for DataTables. + * + * @return int + */ + public function countRevenueAccounts(); + + /** + * @param \Account $account + * + * @return \Account|null + */ + public function findInitialBalanceAccount(\Account $account); + /** * Get all accounts of the selected types. Is also capable of handling DataTables' parameters. * @@ -30,6 +58,24 @@ interface AccountInterface */ public function getAccountsByType(array $types); + /** + * Get all asset accounts. The parameters are optional and are provided by the DataTables plugin. + * + * @return Collection + */ + public function getAssetAccounts(); + + /** + * @return Collection + */ + public function getExpenseAccounts(); + + /** + * Get all revenue accounts. + * + * @return Collection + */ + public function getRevenueAccounts(); /** * @param \Account $account diff --git a/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php b/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php deleted file mode 100644 index a3d1d6a39e..0000000000 --- a/app/lib/FireflyIII/Database/AccountMeta/AccountMeta.php +++ /dev/null @@ -1,66 +0,0 @@ -isValid(); - - return ['errors' => $model->getErrors()]; - } -} \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/Scope/AccountScope.php b/app/lib/FireflyIII/Database/Scope/AccountScope.php deleted file mode 100644 index 4028fdf329..0000000000 --- a/app/lib/FireflyIII/Database/Scope/AccountScope.php +++ /dev/null @@ -1,52 +0,0 @@ - 'account_role']; - - /** - * Apply the scope to a given Eloquent query builder. - * - * @param \Illuminate\Database\Eloquent\Builder $builder - * - * @return void - */ - public function apply(Builder $builder) - { - foreach (self::$fields as $name => $field) { - $builder->leftJoin( - 'account_meta AS ' . $field, function (JoinClause $join) use ($field, $name) { - $join->on($field . '.account_id', '=', 'accounts.id')->where($field . '.name', '=', $name); - } - ); - } - - //$builder->whereNull($model->getQualifiedDeletedAtColumn()); - } - - /** - * Remove the scope from the given Eloquent query builder. - * - * @param \Illuminate\Database\Eloquent\Builder $builder - * - * @return void - */ - public function remove(Builder $builder) - { - foreach ($builder->joins as $join) { - var_dump($join); - exit; - } - } -} \ No newline at end of file diff --git a/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php b/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php deleted file mode 100644 index d0ec9b77c6..0000000000 --- a/app/lib/FireflyIII/Database/Scope/AccountScopeTrait.php +++ /dev/null @@ -1,22 +0,0 @@ -getAccountsByType(['Default account', 'Asset account']); + return $accountRepository->getAssetAccounts(); } /** diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php index f3040fe30f..56deca08ec 100644 --- a/app/lib/FireflyIII/Report/Report.php +++ b/app/lib/FireflyIII/Report/Report.php @@ -387,7 +387,7 @@ class Report implements ReportInterface $sharedAccounts[] = $account->id; } - $accounts = $this->_accounts->getAccountsByType(['Default account', 'Asset account'])->filter( + $accounts = $this->_accounts->getAssetAccounts()->filter( function (\Account $account) use ($sharedAccounts) { if (!in_array($account->id, $sharedAccounts)) { return $account; diff --git a/app/lib/FireflyIII/Validation/Account.php b/app/lib/FireflyIII/Validation/Account.php deleted file mode 100644 index 9eda3a0743..0000000000 --- a/app/lib/FireflyIII/Validation/Account.php +++ /dev/null @@ -1,62 +0,0 @@ - 'required|in:asset,expense,revenue', - 'name' => 'required|between:1,100', - 'openingBalance' => 'numeric', - 'openingBalanceDate' => 'date', - 'active' => 'required|boolean', - 'account_role' => 'in:' . $meta, - ]; - $validator = \Validator::make($data, $rules); - $validator->valid(); - - return $validator->messages(); - } - - /** - * Every time an [object or set of objects] is updated this method will validate the new - * values in the context of the existing object (or set of objects). Since most forms - * only have one [object] to validate and at least always one main [object] to validate - * this method will accept an array of data to validate and an optional model to validate - * against. - * - * @param array $data - * @param \Eloquent $model - * - * @return MessageBag - */ - public function update(array $data = [], \Eloquent $model = null) - { - // this method simply returns the validation done by "store": - return $this->store($data); - } -} \ No newline at end of file diff --git a/app/lib/FireflyIII/Validation/Validation.php b/app/lib/FireflyIII/Validation/Validation.php deleted file mode 100644 index 07e7784898..0000000000 --- a/app/lib/FireflyIII/Validation/Validation.php +++ /dev/null @@ -1,44 +0,0 @@ - ['required', 'between:1,100'], 'user_id' => 'required|exists:users,id', @@ -27,6 +25,8 @@ class Account extends Eloquent 'active' => 'required|boolean' ]; + protected $dates = ['deleted_at', 'created_at', 'updated_at']; + protected $fillable = ['name', 'user_id', 'account_type_id', 'active']; /** * Account type. @@ -67,7 +67,7 @@ class Account extends Eloquent /** * * @param EloquentBuilder $query - * @param array $types + * @param array $types */ public function scopeAccountTypeIn(EloquentBuilder $query, array $types) { @@ -97,16 +97,6 @@ class Account extends Eloquent return $this->hasMany('Transaction'); } - /** - * @param $value - * - * @return mixed - */ - public function getAccountRoleAttribute($value) - { - return json_decode($value); - } - /** * @param $fieldName * @param $fieldValue diff --git a/app/models/AccountMeta.php b/app/models/AccountMeta.php index 36a1462149..5a481a2c90 100644 --- a/app/models/AccountMeta.php +++ b/app/models/AccountMeta.php @@ -10,16 +10,16 @@ class AccountMeta extends Eloquent /** * @var array */ - protected $rules + public static $rules = [ - 'account_id' => 'numeric|exists:accounts,id', + 'account_id' => 'numeric|required|exists:accounts,id', 'name' => 'required|between:1,250', 'data' => 'required' ]; /** * @var array */ - protected $fillable = ['account_id', 'name', 'data']; + protected $fillable = ['account_id', 'name', 'date']; protected $table = 'account_meta'; /** diff --git a/app/views/accounts/create.blade.php b/app/views/accounts/create.blade.php index 260f1b3fb6..8fc3f78c5a 100644 --- a/app/views/accounts/create.blade.php +++ b/app/views/accounts/create.blade.php @@ -29,8 +29,8 @@
@if($what == 'asset') - {{Form::ffBalance('openingBalance')}} - {{Form::ffDate('openingBalanceDate', date('Y-m-d'))}} + {{Form::ffBalance('openingbalance')}} + {{Form::ffDate('openingbalancedate', date('Y-m-d'))}} @endif {{Form::ffCheckbox('active','1',true)}} {{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}