Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Reformatted and checked everything. [skip ci]
James Cole30d5b88769ab
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.phpindex 2e85ab7fd3..c49c154736 100644--- a/app/controllers/AccountController.php+++ b/app/controllers/AccountController.php@@ -94,7 +94,7 @@ class AccountController extends \BaseController*/public function show($accountId){-+ return $accountId;}////diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.phpindex 5dc1159a2e..c95daffa2f 100644--- a/app/controllers/BudgetController.php+++ b/app/controllers/BudgetController.php@@ -2,17 +2,27 @@use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;+/**+ * Class BudgetController+ */class BudgetController extends BaseController{protected $_budgets;+ /**+ * @param BRI $budgets+ */public function __construct(BRI $budgets){$this->_budgets = $budgets;View::share('menu', 'budgets');}+ /**+ * @return $this|\Illuminate\View\View+ * @throws Firefly\Exception\FireflyException+ */public function indexByDate(){// get a list of dates by getting all repetitions:@@ -21,8 +31,8 @@ class BudgetController extends BaseControllerforeach ($budgets as $budget) {foreach ($budget->limits as $limit) {$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);- if(is_null($dateFormats)) {- die('No date formats for ' . $limit->repeat_freq);+ if (is_null($dateFormats)) {+ throw new \Firefly\Exception\FireflyException('No date formats for ' . $limit->repeat_freq);}foreach ($limit->limitrepetitions as $rep) {@@ -37,9 +47,6 @@ class BudgetController extends BaseControllerforeach ($budgets as $budget) {foreach ($budget->limits as $limit) {$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);- if(is_null($dateFormats)) {- die('No date formats for ' . $limit->repeat_freq);- }foreach ($limit->limitrepetitions as $rep) {$month = $rep->startdate->format($dateFormats['group_date']);@@ -53,6 +60,9 @@ class BudgetController extends BaseController}+ /**+ * @return $this|\Illuminate\View\View+ */public function indexByBudget(){$budgets = $this->_budgets->get();@@ -61,12 +71,18 @@ class BudgetController extends BaseController}+ /**+ * @return $this|\Illuminate\View\View+ */public function create(){$periods = \Config::get('firefly.periods_to_text');return View::make('budgets.create')->with('periods', $periods);}+ /**+ * @return \Illuminate\Http\RedirectResponse+ */public function store(){@@ -84,6 +100,7 @@ class BudgetController extends BaseController/*** TODO actual view, actual content.+ ** @param $budgetId** @return stringdiff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.phpindex 3b2f15322f..42d8a33f39 100644--- a/app/controllers/ChartController.php+++ b/app/controllers/ChartController.php@@ -19,9 +19,13 @@ class ChartController extends BaseControllerprotected $_preferences;protected $_budgets;+/*** @param ARI $accounts* @param TJRI $journals+ * @param PHI $preferences+ * @param tk $toolkit+ * @param BRI $budgets*/public function __construct(ARI $accounts, TJRI $journals, PHI $preferences, tk $toolkit, BRI $budgets){@@ -42,13 +46,9 @@ class ChartController extends BaseControllerlist($start, $end) = $this->_tk->getDateRangeDates();$current = clone $start;$return = [];- $account = null;- $today = new Carbon\Carbon;- if (!is_null($accountId)) {- /** @var \Account $account */- $account = $this->_accounts->find($accountId);- }+ $account = !is_null($accountId) ? $this->_accounts->find($accountId) : null;+ $today = new Carbon\Carbon;if (is_null($account)) {@@ -65,8 +65,6 @@ class ChartController extends BaseControllerwhile ($current <= $end) {// loop accounts:foreach ($accounts as $index => $account) {--if ($current > $today) {$return[$index]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)];} else {@@ -97,6 +95,8 @@ class ChartController extends BaseController* @param $day* @param $month* @param $year+ *+ * @return $this|\Illuminate\View\View*/public function homeAccountInfo($name, $day, $month, $year){@@ -122,15 +122,17 @@ class ChartController extends BaseControllerreturn View::make('charts.info')->with('rows', $result)->with('sum', $sum);}+ /**+ * @return \Illuminate\Http\JsonResponse+ * @throws Firefly\Exception\FireflyException+ */public function homeCategories(){list($start, $end) = $this->_tk->getDateRangeDates();- $account = null;$result = [];// grab all transaction journals in this period:$journals = $this->_journals->getByDateRange($start, $end);- $result = [];foreach ($journals as $journal) {// has to be one:@@ -163,16 +165,20 @@ class ChartController extends BaseController}+ /**+ * @return \Illuminate\Http\JsonResponse+ * @throws Firefly\Exception\FireflyException+ */public function homeBudgets(){// grab all budgets in the time period, like the index does:// get the budgets for this period:$data = [];- list($start, $end) = $this->_tk->getDateRangeDates();+ list($start) = $this->_tk->getDateRangeDates();$budgets = $this->_budgets->getWithRepetitionsInPeriod($start, \Session::get('range'));- $repeatFreq = Config::get('firefly.range_to_repeat_freq.'.Session::get('range'));+ $repeatFreq = Config::get('firefly.range_to_repeat_freq.' . Session::get('range'));$dateFormats = Config::get('firefly.date_formats_by_period.' . $repeatFreq);if (is_null($dateFormats)) {@@ -210,8 +216,5 @@ class ChartController extends BaseController}return Response::json($data);- echo '<pre>';- print_r($data);-}}\ No newline at end of filediff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.phpindex 74e0c0a1b9..9ba298ce3c 100644--- a/app/controllers/HomeController.php+++ b/app/controllers/HomeController.php@@ -17,9 +17,11 @@ class HomeController extends BaseControllerprotected $_tk;/**- * @param ARI $accounts- * @param PHI $preferences- * @param TJRI $journal+ * @param ARI $accounts+ * @param PHI $preferences+ * @param TJRI $journal+ * @param Toolkit $toolkit+ * @param BRI $budgets*/public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets){@@ -76,6 +78,9 @@ class HomeController extends BaseController);}+ /**+ * @return \Illuminate\Http\RedirectResponse+ */public function flush(){Cache::flush();diff --git a/app/controllers/LimitController.php b/app/controllers/LimitController.phpindex 02aa07e789..0413f96c6a 100644--- a/app/controllers/LimitController.php+++ b/app/controllers/LimitController.php@@ -3,12 +3,19 @@use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;use Firefly\Storage\Limit\LimitRepositoryInterface as LRI;+/**+ * Class LimitController+ */class LimitController extends BaseController{protected $_budgets;protected $_limits;+ /**+ * @param BRI $budgets+ * @param LRI $limits+ */public function __construct(BRI $budgets, LRI $limits){$this->_budgets = $budgets;@@ -17,6 +24,11 @@ class LimitController extends BaseController}+ /**+ * @param null $budgetId+ *+ * @return $this|\Illuminate\View\View+ */public function create($budgetId = null){$periods = \Config::get('firefly.periods_to_text');@@ -31,6 +43,11 @@ class LimitController extends BaseController)->with('prefilled', $prefilled);}+ /**+ * @param null $limitId+ *+ * @return $this|\Illuminate\View\View+ */public function edit($limitId = null){$limit = $this->_limits->find($limitId);@@ -50,9 +67,15 @@ class LimitController extends BaseController'periods', $periods);}+ return View::make('error')->with('message', 'No such limit.');}+ /**+ * @param null $limitId+ *+ * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\View\View+ */public function update($limitId = null){/** @var \Limit $limit */@@ -77,6 +100,9 @@ class LimitController extends BaseController}+ /**+ * @return \Illuminate\Http\RedirectResponse+ */public function store(){// find a limit with these properties, as we might already have one:@@ -88,6 +114,11 @@ class LimitController extends BaseController}}+ /**+ * @param $limitId+ *+ * @return $this|\Illuminate\View\View+ */public function delete($limitId){$limit = $this->_limits->find($limitId);@@ -100,6 +131,11 @@ class LimitController extends BaseController}}+ /**+ * @param $limitId+ *+ * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\View\View+ */public function destroy($limitId){$limit = $this->_limits->find($limitId);diff --git a/app/controllers/MigrationController.php b/app/controllers/MigrationController.phpindex 2cf628ab98..40d5bb9332 100644--- a/app/controllers/MigrationController.php+++ b/app/controllers/MigrationController.php@@ -1,6 +1,5 @@<?php-use Carbon\Carbon as Carbon;use Firefly\Helper\Migration\MigrationHelperInterface as MHI;/**@@ -37,125 +36,10 @@ class MigrationController extends BaseControllerif ($migration->validFile()) {$migration->migrate();} else {- echo 'Invalid file.';- exit();+ throw new \Firefly\Exception\FireflyException('Invalid file.');}}- echo '<a href="' . route('index') . '">home</a>';- exit();- }-- public function limit()- {- $user = User::find(1);- $budgets = [];- // new budget- for ($i = 0; $i < 7; $i++) {- $budget = new Budget();- $budget->user()->associate($user);- $budget->name = 'Some budget #' . rand(1, 2000);- $budget->save();- $budgets[] = $budget;- }-- // create a non-repeating limit for this week:- $today = new Carbon('01-07-2014');-- $limit = new Limit;- $limit->budget()->associate($budgets[0]);- $limit->amount = 100;- $limit->startdate = $today;- $limit->amount = 100;- $limit->repeats = 0;- $limit->repeat_freq = 'weekly';-- var_dump($limit->save());- var_dump($limit->errors()->all());--- // create a repeating daily limit:- $day = new Limit;- $day->budget()->associate($budgets[1]);- $day->amount = 100;- $day->startdate = $today;- $day->amount = 100;- $day->repeats = 1;- $day->repeat_freq = 'daily';- $day->save();-- // repeating weekly limit.- $week = new Limit;- $week->budget()->associate($budgets[2]);- $week->amount = 100;- $week->startdate = $today;- $week->amount = 100;- $week->repeats = 1;- $week->repeat_freq = 'weekly';- $week->save();-- // repeating monthly limit- $month = new Limit;- $month->budget()->associate($budgets[3]);- $month->amount = 100;- $month->startdate = $today;- $month->amount = 100;- $month->repeats = 1;- $month->repeat_freq = 'monthly';- $month->save();-- // quarter- $quarter = new Limit;- $quarter->budget()->associate($budgets[4]);- $quarter->amount = 100;- $quarter->startdate = $today;- $quarter->amount = 100;- $quarter->repeats = 1;- $quarter->repeat_freq = 'quarterly';- $quarter->save();-- // six months- $six = new Limit;- $six->budget()->associate($budgets[5]);- $six->amount = 100;- $six->startdate = $today;- $six->amount = 100;- $six->repeats = 1;- $six->repeat_freq = 'half-year';- $six->save();-- // year- $yearly = new Limit;- $yearly->budget()->associate($budgets[6]);- $yearly->amount = 100;- $yearly->startdate = $today;- $yearly->amount = 100;- $yearly->repeats = 1;- $yearly->repeat_freq = 'yearly';- $yearly->save();--- // create a repeating weekly limit:- // create a repeating monthly limit:-- foreach ($budgets as $budget) {-- echo '#' . $budget->id . ': ' . $budget->name . ':<br />';- foreach ($budget->limits()->get() as $limit) {- echo ' Limit #' . $limit->id . ', amount: ' . $limit->amount . ', start: '- . $limit->startdate->format('D d-m-Y') . ', repeats: '- . $limit->repeats . ', repeat_freq: ' . $limit->repeat_freq . '<br />';-- foreach ($limit->limitrepetitions()->get() as $rep) {- echo ' rep: #' . $rep->id . ', from ' . $rep->startdate->format('D d-m-Y')- . ' to '- . $rep->enddate->format('D d-m-Y') . '<br>';-- }- }- }--- return '';+ return '<a href="' . route('index') . '">home</a>';}/**diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.phpindex 5640c3c004..33ed5e1e32 100644--- a/app/controllers/TransactionController.php+++ b/app/controllers/TransactionController.php@@ -34,6 +34,11 @@ class TransactionController extends BaseControllerView::share('menu', 'home');}+ /**+ * @param $what+ *+ * @return $this|\Illuminate\View\View+ */public function create($what){// get accounts with names and id's.@@ -44,12 +49,16 @@ class TransactionController extends BaseController$budgets[0] = '(no budget)';-return View::make('transactions.create')->with('accounts', $accounts)->with('budgets', $budgets)->with('what', $what);}+ /**+ * @param $what+ *+ * @return \Illuminate\Http\RedirectResponse+ */public function store($what){// $fromAccount and $toAccount are found@@ -73,12 +82,8 @@ class TransactionController extends BaseControllerbreak;}// fall back to cash if necessary:- if (is_null($fromAccount)) {- $fromAccount = $this->_accounts->getCashAccount();- }- if (is_null($toAccount)) {- $toAccount = $this->_accounts->getCashAccount();- }+ $fromAccount = is_null($fromAccount) ? $fromAccount = $this->_accounts->getCashAccount() : $fromAccount;+ $toAccount = is_null($toAccount) ? $toAccount = $this->_accounts->getCashAccount() : $toAccount;// create or find category:$category = $this->_categories->createOrFind(Input::get('category'));@@ -109,24 +114,29 @@ class TransactionController extends BaseControllerSession::flash('success', 'Transaction saved');- if(Input::get('create') == '1') {- return Redirect::route('transactions.create',$what)->withInput();+ if (Input::get('create') == '1') {+ return Redirect::route('transactions.create', $what)->withInput();} else {return Redirect::route('index');}---}+ /**+ * @return $this|\Illuminate\View\View+ */public function index(){$transactions = $this->_journal->paginate(25);return View::make('transactions.index')->with('transactions', $transactions);}+ /**+ * @param $journalId+ *+ * @return $this|\Illuminate\View\View+ */public function show($journalId){$journal = $this->_journal->find($journalId);@@ -136,6 +146,11 @@ class TransactionController extends BaseControllerreturn View::make('error')->with('message', 'Invalid journal');}+ /**+ * @param $journalId+ *+ * @return $this|\Illuminate\View\View+ */public function edit($journalId){$journal = $this->_journal->find($journalId);diff --git a/app/lib/Firefly/Database/SingleTableInheritanceEntity.php b/app/lib/Firefly/Database/SingleTableInheritanceEntity.phpindex 11b6f81eea..7a6df521b4 100644--- a/app/lib/Firefly/Database/SingleTableInheritanceEntity.php+++ b/app/lib/Firefly/Database/SingleTableInheritanceEntity.php@@ -4,8 +4,14 @@namespace Firefly\Database;--abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardent+use LaravelBook\Ardent\Ardent;++/**+ * Class SingleTableInheritanceEntity+ *+ * @package Firefly\Database+ */+abstract class SingleTableInheritanceEntity extends Ardent{/*** The field that stores the subclass@@ -20,15 +26,26 @@ abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardent*/protected $isSubclass = false;- public function newFromBuilder($attributes = array())+ /**+ * @param array $attributes+ *+ * @return \Illuminate\Database\Eloquent\Model|static+ */+ public function newFromBuilder($attributes = []){- $instance = $this->mapData((array)$attributes)->newInstance(array(), true);+ $instance = $this->mapData((array)$attributes)->newInstance([], true);$instance->setRawAttributes((array)$attributes, true);return $instance;}- // if no subclass is defined, function as normal+ /**+ * if no subclass is defined, function as normal+ *+ * @param array $attributes+ *+ * @return \Illuminate\Database\Eloquent\Model|static+ */public function mapData(array $attributes){if (!$this->subclassField) {@@ -38,9 +55,16 @@ abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardentreturn new $attributes[$this->subclassField];}- // instead of using $this->newInstance(), call- // newInstance() on the object from mapData+ /**+ *+ * instead of using $this->newInstance(), call+ * newInstance() on the object from mapData+ *+ * @param bool $excludeDeleted+ *+ * @return \Illuminate\Database\Eloquent\Builder|static+ */public function newQuery($excludeDeleted = true){// If using Laravel 4.0.x then use the following commented version of this command@@ -64,16 +88,29 @@ abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardentreturn $builder;}+ /**+ * @return bool+ */public function isSubclass(){return $this->isSubclass;}- // ensure that the subclass field is assigned on save+ /**+ * ensure that the subclass field is assigned on save+ *+ * @param array $rules+ * @param array $customMessages+ * @param array $options+ * @param callable $beforeSave+ * @param callable $afterSave+ *+ * @return bool+ */public function save(- array $rules = array(),- array $customMessages = array(),- array $options = array(),+ array $rules = [],+ array $customMessages = [],+ array $options = [],\Closure $beforeSave = null,\Closure $afterSave = null) {diff --git a/app/lib/Firefly/Exception/FireflyException.php b/app/lib/Firefly/Exception/FireflyException.phpindex 89f0ff939c..eb0f038fa3 100644--- a/app/lib/Firefly/Exception/FireflyException.php+++ b/app/lib/Firefly/Exception/FireflyException.php@@ -3,6 +3,11 @@namespace Firefly\Exception;+/**+ * Class FireflyException+ *+ * @package Firefly\Exception+ */class FireflyException extends \Exception{diff --git a/app/lib/Firefly/Exception/MigrationException.php b/app/lib/Firefly/Exception/MigrationException.phpindex 2a31c70474..f6d85835a0 100644--- a/app/lib/Firefly/Exception/MigrationException.php+++ b/app/lib/Firefly/Exception/MigrationException.php@@ -3,6 +3,11 @@namespace Firefly\Helper;+/**+ * Class MigrationException+ *+ * @package Firefly\Helper+ */class MigrationException extends \Exception{diff --git a/app/lib/Firefly/Helper/Email/EmailHelper.php b/app/lib/Firefly/Helper/Email/EmailHelper.phpindex b2e2c348c2..26a31892ad 100644--- a/app/lib/Firefly/Helper/Email/EmailHelper.php+++ b/app/lib/Firefly/Helper/Email/EmailHelper.php@@ -1,8 +1,18 @@<?phpnamespace Firefly\Helper\Email;+/**+ * Class EmailHelper+ *+ * @package Firefly\Helper\Email+ */class EmailHelper implements EmailHelperInterface{+ /**+ * @param \User $user+ *+ * @return mixed|void+ */public function sendVerificationMail(\User $user){@@ -19,6 +29,11 @@ class EmailHelper implements EmailHelperInterface);}+ /**+ * @param \User $user+ *+ * @return mixed|void+ */public function sendPasswordMail(\User $user){@@ -37,6 +52,11 @@ class EmailHelper implements EmailHelperInterface);}+ /**+ * @param \User $user+ *+ * @return mixed|void+ */public function sendResetVerification(\User $user){$reset = \Str::random(32);diff --git a/app/lib/Firefly/Helper/Email/EmailHelperInterface.php b/app/lib/Firefly/Helper/Email/EmailHelperInterface.phpindex 43fe7ee52d..48a49d0d02 100644--- a/app/lib/Firefly/Helper/Email/EmailHelperInterface.php+++ b/app/lib/Firefly/Helper/Email/EmailHelperInterface.php@@ -2,13 +2,33 @@namespace Firefly\Helper\Email;+/**+ * Interface EmailHelperInterface+ *+ * @package Firefly\Helper\Email+ */interface EmailHelperInterface{+ /**+ * @param \User $user+ *+ * @return mixed+ */public function sendVerificationMail(\User $user);+ /**+ * @param \User $user+ *+ * @return mixed+ */public function sendPasswordMail(\User $user);+ /**+ * @param \User $user+ *+ * @return mixed+ */public function sendResetVerification(\User $user);}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/HelperServiceProvider.php b/app/lib/Firefly/Helper/HelperServiceProvider.phpindex 06431f8d3f..5fb40fcd9d 100644--- a/app/lib/Firefly/Helper/HelperServiceProvider.php+++ b/app/lib/Firefly/Helper/HelperServiceProvider.php@@ -3,11 +3,18 @@ namespace Firefly\Helper;use Illuminate\Support\ServiceProvider;+/**+ * Class HelperServiceProvider+ *+ * @package Firefly\Helper+ */class HelperServiceProvider extends ServiceProvider{- // Triggered automatically by Laravel+ /**+ * Triggered automatically by Laravel+ */public function register(){// mail:diff --git a/app/lib/Firefly/Helper/Migration/MigrationHelper.php b/app/lib/Firefly/Helper/Migration/MigrationHelper.phpindex fa68887a22..32416ff4d6 100644--- a/app/lib/Firefly/Helper/Migration/MigrationHelper.php+++ b/app/lib/Firefly/Helper/Migration/MigrationHelper.php@@ -3,19 +3,33 @@namespace Firefly\Helper\Migration;-use Firefly\Helper\MigrationException;-+use Carbon\Carbon;+use Firefly\Exception\FireflyException;++/**+ * Class MigrationHelper+ *+ * @package Firefly\Helper\Migration+ */class MigrationHelper implements MigrationHelperInterface{protected $path;protected $JSON;protected $map = [];+ /**+ * @param $path+ *+ * @return mixed|void+ */public function loadFile($path){$this->path = $path;}+ /**+ * @return bool+ */public function validFile(){// file does not exist:@@ -39,6 +53,9 @@ class MigrationHelper implements MigrationHelperInterfacereturn true;}+ /**+ * @return bool+ */public function migrate(){\Log::info('Start of migration.');@@ -62,7 +79,7 @@ class MigrationHelper implements MigrationHelperInterface$this->_importLimits();- } catch (\Firefly\Exception\FireflyException $e) {+ } catch (FireflyException $e) {\DB::rollBack();\Log::error('Rollback because of error!');\Log::error($e->getMessage());@@ -74,6 +91,9 @@ class MigrationHelper implements MigrationHelperInterfacereturn true;}+ /**+ *+ */protected function _createCashAccount(){$cashAT = \AccountType::where('description', 'Cash account')->first();@@ -84,6 +104,9 @@ class MigrationHelper implements MigrationHelperInterface$this->map['cash'] = $cash;}+ /**+ *+ */protected function _importAccounts(){@@ -97,7 +120,7 @@ class MigrationHelper implements MigrationHelperInterface} else {$account = $accounts->storeWithInitialBalance(['name' => $entry->name],- new \Carbon\Carbon($entry->openingbalancedate),+ new Carbon($entry->openingbalancedate),floatval($entry->openingbalance));}@@ -106,6 +129,9 @@ class MigrationHelper implements MigrationHelperInterface}}+ /**+ *+ */protected function _importComponents(){$beneficiaryAT = \AccountType::where('description', 'Beneficiary account')->first();@@ -128,6 +154,12 @@ class MigrationHelper implements MigrationHelperInterface}}+ /**+ * @param $component+ * @param \AccountType $beneficiaryAT+ *+ * @return mixed+ */protected function _importBeneficiary($component, \AccountType $beneficiaryAT){/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accounts */@@ -140,6 +172,11 @@ class MigrationHelper implements MigrationHelperInterface);}+ /**+ * @param $component+ *+ * @return mixed+ */protected function _importCategory($component){/** @var \Firefly\Storage\Component\ComponentRepositoryInterface $components */@@ -147,6 +184,11 @@ class MigrationHelper implements MigrationHelperInterfacereturn $components->store(['name' => $component->name, 'class' => 'Category']);}+ /**+ * @param $component+ *+ * @return mixed+ */protected function _importBudget($component){/** @var \Firefly\Storage\Component\ComponentRepositoryInterface $components */@@ -154,39 +196,9 @@ class MigrationHelper implements MigrationHelperInterfacereturn $components->store(['name' => $component->name, 'class' => 'Budget']);}- protected function _importLimits()- {- \Log::info('Importing limits');- foreach ($this->JSON->limits as $entry) {- \Log::debug(- 'Now at #' . $entry->id . ': EUR ' . $entry->amount . ' for month ' . $entry->date- . ' and componentID: ' . $entry->component_id- );- $budget = isset($this->map['budgets'][$entry->component_id]) ? $this->map['budgets'][$entry->component_id]- : null;- if (!is_null($budget)) {- \Log::debug('Found budget for this limit: #' . $budget->id . ', ' . $budget->name);-- $limit = new \Limit;- $limit->budget()->associate($budget);- $limit->startdate = new \Carbon\Carbon($entry->date);- $limit->amount = floatval($entry->amount);- $limit->repeats = 0;- $limit->repeat_freq = 'monthly';- try {- $limit->save();- } catch (\Exception $e) {- }- } else {- \Log::warning('No budget for this limit!');- }--- // create repeat thing should not be necessary.-- }- }-+ /**+ *+ */protected function _importTransactions(){@@ -215,7 +227,6 @@ class MigrationHelper implements MigrationHelperInterface}foreach ($this->JSON->transactions as $entry) {- $id = $entry->id;// to properly save the amount, do it times -1:$amount = $entry->amount * -1;@@ -227,7 +238,7 @@ class MigrationHelper implements MigrationHelperInterface/** @var \Account $toAccount */$toAccount = isset($beneficiaries[$entry->id]) ? $beneficiaries[$entry->id] : $this->map['cash'];- $date = new \Carbon\Carbon($entry->date);+ $date = new Carbon($entry->date);$journal = $journals->createSimpleJournal($fromAccount, $toAccount, $entry->description, $amount, $date);// save budgets and categories, on the journal@@ -243,13 +254,15 @@ class MigrationHelper implements MigrationHelperInterface}}+ /**+ *+ */protected function _importTransfers(){/** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $journals */$journals = \App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');foreach ($this->JSON->transfers as $entry) {- $id = $entry->id;// to properly save the amount, do it times 1 (?):$amount = $entry->amount * -1;@@ -262,9 +275,45 @@ class MigrationHelper implements MigrationHelperInterface$toAccount = isset($this->map['accounts'][$entry->accountto_id])? $this->map['accounts'][$entry->accountfrom_id] : false;- $date = new \Carbon\Carbon($entry->date);+ $date = new Carbon($entry->date);$journals->createSimpleJournal($fromAccount, $toAccount, $entry->description, $amount, $date);}}++ /**+ *+ */+ protected function _importLimits()+ {+ \Log::info('Importing limits');+ foreach ($this->JSON->limits as $entry) {+ \Log::debug(+ 'Now at #' . $entry->id . ': EUR ' . $entry->amount . ' for month ' . $entry->date+ . ' and componentID: ' . $entry->component_id+ );+ $budget = isset($this->map['budgets'][$entry->component_id]) ? $this->map['budgets'][$entry->component_id]+ : null;+ if (!is_null($budget)) {+ \Log::debug('Found budget for this limit: #' . $budget->id . ', ' . $budget->name);++ $limit = new \Limit;+ $limit->budget()->associate($budget);+ $limit->startdate = new Carbon($entry->date);+ $limit->amount = floatval($entry->amount);+ $limit->repeats = 0;+ $limit->repeat_freq = 'monthly';+ try {+ $limit->save();+ } catch (\Exception $e) {+ }+ } else {+ \Log::warning('No budget for this limit!');+ }+++ // create repeat thing should not be necessary.++ }+ }}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/Migration/MigrationHelperInterface.php b/app/lib/Firefly/Helper/Migration/MigrationHelperInterface.phpindex bc586793f3..2c962bd815 100644--- a/app/lib/Firefly/Helper/Migration/MigrationHelperInterface.php+++ b/app/lib/Firefly/Helper/Migration/MigrationHelperInterface.php@@ -2,13 +2,28 @@namespace Firefly\Helper\Migration;-+/**+ * Interface MigrationHelperInterface+ *+ * @package Firefly\Helper\Migration+ */interface MigrationHelperInterface{+ /**+ * @param $path+ *+ * @return mixed+ */public function loadFile($path);+ /**+ * @return mixed+ */public function validFile();+ /**+ * @return mixed+ */public function migrate();}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/Preferences/PreferencesHelper.php b/app/lib/Firefly/Helper/Preferences/PreferencesHelper.phpindex 64aeb8e5cc..2dc2fa2f25 100644--- a/app/lib/Firefly/Helper/Preferences/PreferencesHelper.php+++ b/app/lib/Firefly/Helper/Preferences/PreferencesHelper.php@@ -1,8 +1,19 @@<?phpnamespace Firefly\Helper\Preferences;+/**+ * Class PreferencesHelper+ *+ * @package Firefly\Helper\Preferences+ */class PreferencesHelper implements PreferencesHelperInterface{+ /**+ * @param $name+ * @param null $default+ *+ * @return mixed|null|\Preference+ */public function get($name, $default = null){$pref = \Preference::where('user_id', \Auth::user()->id)->where('name', $name)->first();@@ -17,9 +28,16 @@ class PreferencesHelper implements PreferencesHelperInterface// create preference, return that:return $this->set($name, $default);}+ return null;}+ /**+ * @param $name+ * @param $value+ *+ * @return mixed|\Preference+ */public function set($name, $value){$pref = \Preference::where('user_id', \Auth::user()->id)->where('name', $name)->first();diff --git a/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php b/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.phpindex 1e80350432..cb6d279825 100644--- a/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php+++ b/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php@@ -1,10 +1,29 @@<?phpnamespace Firefly\Helper\Preferences;++/**+ * Interface PreferencesHelperInterface+ *+ * @package Firefly\Helper\Preferences+ */interface PreferencesHelperInterface{++ /**+ * @param $name+ * @param $value+ *+ * @return mixed+ */public function set($name, $value);+ /**+ * @param $name+ * @param null $default+ *+ * @return mixed+ */public function get($name, $default = null);}\ No newline at end of filediff --git a/app/lib/Firefly/Helper/Toolkit/Toolkit.php b/app/lib/Firefly/Helper/Toolkit/Toolkit.phpindex 66a4c29770..bdf398fd35 100644--- a/app/lib/Firefly/Helper/Toolkit/Toolkit.php+++ b/app/lib/Firefly/Helper/Toolkit/Toolkit.php@@ -2,6 +2,8 @@namespace Firefly\Helper\Toolkit;+use Carbon\Carbon;+/*** Class Toolkit*@@ -37,10 +39,10 @@ class Toolkit implements ToolkitInterface}// switch $range, update range or something:- $start = \Session::has('start') ? \Session::get('start') : new \Carbon\Carbon();- $end = \Session::has('end') ? \Session::get('end') : new \Carbon\Carbon();- $today = new \Carbon\Carbon;- \Log::debug('Start: ' . $start.' ('.\Session::has('start').')');+ $start = \Session::has('start') ? \Session::get('start') : new Carbon;+ $end = \Session::has('end') ? \Session::get('end') : new Carbon;+ $today = new Carbon;+ \Log::debug('Start: ' . $start . ' (' . \Session::has('start') . ')');\Log::debug('End: ' . $end);// see if we have to do a prev / next thing:@@ -58,8 +60,8 @@ class Toolkit implements ToolkitInterfacecase 'custom':// when range is custom AND input, we ignore $todayif (\Input::get('start') && \Input::get('end')) {- $start = new \Carbon\Carbon(\Input::get('start'));- $end = new \Carbon\Carbon(\Input::get('end'));+ $start = new Carbon(\Input::get('start'));+ $end = new Carbon(\Input::get('end'));} else {$start = \Session::get('start');$end = \Session::get('end');@@ -147,11 +149,14 @@ class Toolkit implements ToolkitInterfacereturn \Redirect::route('index');}- return;+ return null;}+ /**+ * @return array+ */public function getDateRangeDates(){return [\Session::get('start'), \Session::get('end')];diff --git a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.phpindex a58679d200..347483b889 100644--- a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php+++ b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php@@ -2,11 +2,21 @@namespace Firefly\Helper\Toolkit;-+/**+ * Interface ToolkitInterface+ *+ * @package Firefly\Helper\Toolkit+ */interface ToolkitInterface{+ /**+ * @return mixed+ */public function getDateRange();+ /**+ * @return mixed+ */public function getDateRangeDates();}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.phpindex c508165ece..c1f8ddd2ac 100644--- a/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Account/AccountRepositoryInterface.php@@ -3,36 +3,101 @@namespace Firefly\Storage\Account;+use Carbon\Carbon;+/**+ * Interface AccountRepositoryInterface+ *+ * @package Firefly\Storage\Account+ */interface AccountRepositoryInterface{+ /**+ * @return mixed+ */public function count();+ /**+ * @return mixed+ */public function get();+ /**+ * @return mixed+ */public function getBeneficiaries();- public function find($id);-+ /**+ * @param $accountId+ *+ * @return mixed+ */+ public function find($accountId);++ /**+ * @param $name+ *+ * @return mixed+ */public function findByName($name);+ /**+ * @return mixed+ */public function getCashAccount();+ /**+ * @param $ids+ *+ * @return mixed+ */public function getByIds($ids);+ /**+ * @return mixed+ */public function getDefault();+ /**+ * @return mixed+ */public function getActiveDefault();+ /**+ * @return mixed+ */public function getActiveDefaultAsSelectList();+ /**+ * @param $data+ *+ * @return mixed+ */public function store($data);- public function storeWithInitialBalance($data, \Carbon\Carbon $date, $amount = 0);-+ /**+ * @param $data+ * @param Carbon $date+ * @param int $amount+ *+ * @return mixed+ */+ public function storeWithInitialBalance($data, Carbon $date, $amount = 0);++ /**+ * @param $name+ *+ * @return mixed+ */public function createOrFindBeneficiary($name);+ /**+ * @param $name+ * @param \AccountType $type+ *+ * @return mixed+ */public function createOrFind($name, \AccountType $type);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.phpindex 695ff609a5..3bf6d14ee9 100644--- a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php+++ b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php@@ -3,19 +3,37 @@namespace Firefly\Storage\Account;+use Carbon\Carbon;+use Firefly\Exception\FireflyException;+use Illuminate\Database\QueryException;++/**+ * Class EloquentAccountRepository+ *+ * @package Firefly\Storage\Account+ */class EloquentAccountRepository implements AccountRepositoryInterface{public $validator;+ /**+ *+ */public function __construct(){}+ /**+ * @return mixed+ */public function get(){return \Auth::user()->accounts()->with('accounttype')->orderBy('name', 'ASC')->get();}+ /**+ * @return mixed+ */public function getBeneficiaries(){$list = \Auth::user()->accounts()->leftJoin(@@ -27,11 +45,21 @@ class EloquentAccountRepository implements AccountRepositoryInterfacereturn $list;}- public function find($id)+ /**+ * @param $accountId+ *+ * @return mixed+ */+ public function find($accountId){- return \Auth::user()->accounts()->where('id', $id)->first();+ return \Auth::user()->accounts()->where('id', $accountId)->first();}+ /**+ * @param $ids+ *+ * @return array|mixed+ */public function getByIds($ids){if (count($ids) > 0) {@@ -41,6 +69,9 @@ class EloquentAccountRepository implements AccountRepositoryInterface}}+ /**+ * @return mixed+ */public function getDefault(){return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')@@ -49,6 +80,9 @@ class EloquentAccountRepository implements AccountRepositoryInterface->orderBy('accounts.name', 'ASC')->get(['accounts.*']);}+ /**+ * @return mixed+ */public function getActiveDefault(){return \Auth::user()->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')@@ -57,6 +91,9 @@ class EloquentAccountRepository implements AccountRepositoryInterface->get(['accounts.*']);}+ /**+ * @return array|mixed+ */public function getActiveDefaultAsSelectList(){$list = \Auth::user()->accounts()->leftJoin(@@ -72,13 +109,24 @@ class EloquentAccountRepository implements AccountRepositoryInterfacereturn $return;}+ /**+ * @return mixed+ */public function count(){return \Auth::user()->accounts()->count();}- public function storeWithInitialBalance($data, \Carbon\Carbon $date, $amount = 0)+ /**+ * @param $data+ * @param Carbon $date+ * @param int $amount+ *+ * @return \Account|mixed+ * @throws \Firefly\Exception\FireflyException+ */+ public function storeWithInitialBalance($data, Carbon $date, $amount = 0){$account = $this->store($data);@@ -91,7 +139,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface$initial->active = 0;try {$initial->save();- } catch (\Illuminate\Database\QueryException $e) {+ } catch (QueryException $e) {\Log::error('DB ERROR: ' . $e->getMessage());throw new FireflyException('Could not save counterbalance account for ' . $data['name']);}@@ -110,6 +158,12 @@ class EloquentAccountRepository implements AccountRepositoryInterface}+ /**+ * @param $data+ *+ * @return \Account|mixed+ * @throws \Firefly\Exception\FireflyException+ */public function store($data){$defaultAT = \AccountType::where('description', 'Default account')->first();@@ -123,14 +177,19 @@ class EloquentAccountRepository implements AccountRepositoryInterface$account->active = isset($data['active']) ? $data['active'] : 1;try {$account->save();- } catch (\Illuminate\Database\QueryException $e) {+ } catch (QueryException $e) {\Log::error('DB ERROR: ' . $e->getMessage());- throw new \Firefly\Exception\FireflyException('Could not save account ' . $data['name']);+ throw new FireflyException('Could not save account ' . $data['name']);}return $account;}+ /**+ * @param $name+ *+ * @return \Account|mixed|null+ */public function createOrFindBeneficiary($name){if (is_null($name) || strlen($name) == 0) {@@ -140,6 +199,12 @@ class EloquentAccountRepository implements AccountRepositoryInterfacereturn $this->createOrFind($name, $type);}+ /**+ * @param $name+ * @param \AccountType $type+ *+ * @return \Account|mixed+ */public function createOrFind($name, \AccountType $type){$beneficiary = $this->findByName($name);@@ -153,11 +218,19 @@ class EloquentAccountRepository implements AccountRepositoryInterfacereturn $beneficiary;}+ /**+ * @param $name+ *+ * @return mixed+ */public function findByName($name){return \Auth::user()->accounts()->where('name', 'like', '%' . $name . '%')->first();}+ /**+ * @return mixed+ */public function getCashAccount(){$type = \AccountType::where('description', 'Cash account')->first();diff --git a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.phpindex 3af17ffe4f..0a81e83551 100644--- a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php@@ -2,16 +2,45 @@namespace Firefly\Storage\Budget;+use Carbon\Carbon;+/**+ * Interface BudgetRepositoryInterface+ *+ * @package Firefly\Storage\Budget+ */interface BudgetRepositoryInterface{+ /**+ * @return mixed+ */public function getAsSelectList();++ /**+ * @return mixed+ */public function get();+ /**+ * @param $data+ *+ * @return mixed+ */public function store($data);- public function find($id);+ /**+ * @param $budgetId+ *+ * @return mixed+ */+ public function find($budgetId);- public function getWithRepetitionsInPeriod(\Carbon\Carbon $date, $range);+ /**+ * @param Carbon $date+ * @param $range+ *+ * @return mixed+ */+ public function getWithRepetitionsInPeriod(Carbon $date, $range);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.phpindex 944f9e265a..c3945e10cb 100644--- a/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php+++ b/app/lib/Firefly/Storage/Budget/EloquentBudgetRepository.php@@ -2,10 +2,19 @@namespace Firefly\Storage\Budget;+use Carbon\Carbon;+/**+ * Class EloquentBudgetRepository+ *+ * @package Firefly\Storage\Budget+ */class EloquentBudgetRepository implements BudgetRepositoryInterface{+ /**+ * @return array|mixed+ */public function getAsSelectList(){$list = \Auth::user()->budgets()->with(@@ -18,20 +27,18 @@ class EloquentBudgetRepository implements BudgetRepositoryInterfacereturn $return;}- public function getWithRepetitionsInPeriod(\Carbon\Carbon $date, $range)+ /**+ * @param Carbon $date+ * @param $range+ *+ * @return mixed+ */+ public function getWithRepetitionsInPeriod(Carbon $date, $range){- /** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */- $toolkit = \App::make('Firefly\Helper\Toolkit\ToolkitInterface');- $dates = $toolkit->getDateRangeDates();- $start = $dates[0];- $result = [];--$set = \Auth::user()->budgets()->with(['limits' => function ($q) use ($date) {$q->orderBy('limits.startdate', 'ASC');-// $q->where('startdate',$date->format('Y-m-d'));}, 'limits.limitrepetitions' => function ($q) use ($date) {$q->orderBy('limit_repetitions.startdate', 'ASC');$q->where('startdate', $date->format('Y-m-d'));@@ -65,6 +72,11 @@ class EloquentBudgetRepository implements BudgetRepositoryInterfacereturn $set;}+ /**+ * @param $data+ *+ * @return \Budget|mixed+ */public function store($data){$budget = new \Budget;@@ -76,7 +88,7 @@ class EloquentBudgetRepository implements BudgetRepositoryInterfaceif ($data['amount'] > 0) {$limit = new \Limit;$limit->budget()->associate($budget);- $startDate = new \Carbon\Carbon;+ $startDate = new Carbon;switch ($data['repeat_freq']) {case 'daily':$startDate->startOfDay();@@ -111,6 +123,10 @@ class EloquentBudgetRepository implements BudgetRepositoryInterfacereturn $budget;}++ /**+ * @return mixed+ */public function get(){return \Auth::user()->budgets()->with(@@ -122,10 +138,15 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface)->orderBy('name', 'ASC')->get();}- public function find($id)+ /**+ * @param $budgetId+ *+ * @return mixed+ */+ public function find($budgetId){- return \Auth::user()->budgets()->find($id);+ return \Auth::user()->budgets()->find($budgetId);}}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Category/CategoryRepositoryInterface.php b/app/lib/Firefly/Storage/Category/CategoryRepositoryInterface.phpindex b64a7531de..efffd51d64 100644--- a/app/lib/Firefly/Storage/Category/CategoryRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Category/CategoryRepositoryInterface.php@@ -2,16 +2,38 @@namespace Firefly\Storage\Category;-+/**+ * Interface CategoryRepositoryInterface+ *+ * @package Firefly\Storage\Category+ */interface CategoryRepositoryInterface{+ /**+ * @return mixed+ */public function get();+ /**+ * @param $name+ *+ * @return mixed+ */public function createOrFind($name);+ /**+ * @param $name+ *+ * @return mixed+ */public function findByName($name);+ /**+ * @param $name+ *+ * @return mixed+ */public function store($name);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php b/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.phpindex 6d1950a46a..a21a9dbd7d 100644--- a/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php+++ b/app/lib/Firefly/Storage/Category/EloquentCategoryRepository.php@@ -2,14 +2,26 @@namespace Firefly\Storage\Category;-+/**+ * Class EloquentCategoryRepository+ *+ * @package Firefly\Storage\Category+ */class EloquentCategoryRepository implements CategoryRepositoryInterface{+ /**+ * @return mixed+ */public function get(){return \Auth::user()->categories()->get();}+ /**+ * @param $name+ *+ * @return \Category|mixed+ */public function createOrFind($name){$category = $this->findByName($name);@@ -21,12 +33,22 @@ class EloquentCategoryRepository implements CategoryRepositoryInterface}+ /**+ * @param $name+ *+ * @return mixed+ */public function findByName($name){return \Auth::user()->categories()->where('name', 'LIKE', '%' . $name . '%')->first();}+ /**+ * @param $name+ *+ * @return \Category|mixed+ */public function store($name){$category = new \Category();diff --git a/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php b/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.phpindex 7a1a801527..bfe2eabb0b 100644--- a/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Component/ComponentRepositoryInterface.php@@ -3,14 +3,29 @@namespace Firefly\Storage\Component;-+/**+ * Interface ComponentRepositoryInterface+ *+ * @package Firefly\Storage\Component+ */interface ComponentRepositoryInterface{+ /**+ * @return mixed+ */public function count();+ /**+ * @return mixed+ */public function get();+ /**+ * @param $data+ *+ * @return mixed+ */public function store($data);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php b/app/lib/Firefly/Storage/Component/EloquentComponentRepository.phpindex 631e234260..5a09cef1e8 100644--- a/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php+++ b/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php@@ -3,32 +3,56 @@namespace Firefly\Storage\Component;+use Firefly\Exception\FireflyException;+use Illuminate\Database\QueryException;++/**+ * Class EloquentComponentRepository+ *+ * @package Firefly\Storage\Component+ */class EloquentComponentRepository implements ComponentRepositoryInterface{public $validator;+ /**+ *+ */public function __construct(){}+ /**+ * @return mixed+ */public function count(){return \Auth::user()->components()->count();}+ /**+ * @return mixed|void+ * @throws \Firefly\Exception\FireflyException+ */public function get(){- die('no impl');+ throw new FireflyException('No implementation.');}-+ /**+ * @param $data+ *+ * @return \Budget|\Category|mixed+ * @throws \Firefly\Exception\FireflyException+ */public function store($data){if (!isset($data['class'])) {- throw new \Firefly\Exception\FireflyException('No class type present.');+ throw new FireflyException('No class type present.');}switch ($data['class']) {+ default:case 'Budget':$component = new \Budget;break;@@ -41,9 +65,9 @@ class EloquentComponentRepository implements ComponentRepositoryInterface$component->user()->associate(\Auth::user());try {$component->save();- } catch (\Illuminate\Database\QueryException $e) {+ } catch (QueryException $e) {\Log::error('DB ERROR: ' . $e->getMessage());- throw new \Firefly\Exception\FireflyException('Could not save component ' . $data['name'] . ' of type'+ throw new FireflyException('Could not save component ' . $data['name'] . ' of type'. $data['class']);}diff --git a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.phpindex 87619a595c..b241aef92d 100644--- a/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php+++ b/app/lib/Firefly/Storage/Limit/EloquentLimitRepository.php@@ -1,17 +1,24 @@<?php-/**- * Created by PhpStorm.- * User: sander- * Date: 20/07/14- * Time: 13:43- */namespace Firefly\Storage\Limit;+use Carbon\Carbon;++/**+ * Class EloquentLimitRepository+ *+ * @package Firefly\Storage\Limit+ */class EloquentLimitRepository implements LimitRepositoryInterface{++ /**+ * @param $limitId+ *+ * @return mixed+ */public function find($limitId){return \Limit::with('limitrepetitions')->where('limits.id', $limitId)->leftJoin(@@ -20,6 +27,11 @@ class EloquentLimitRepository implements LimitRepositoryInterface->where('components.user_id', \Auth::user()->id)->first(['limits.*']);}+ /**+ * @param $data+ *+ * @return \Limit+ */public function store($data){$budget = \Budget::find($data['budget_id']);@@ -28,7 +40,7 @@ class EloquentLimitRepository implements LimitRepositoryInterfacereturn new \Limit;}// set the date to the correct start period:- $date = new \Carbon\Carbon($data['startdate']);+ $date = new Carbon($data['startdate']);switch ($data['period']) {case 'daily':$date->startOfDay();@@ -79,10 +91,15 @@ class EloquentLimitRepository implements LimitRepositoryInterfacereturn $limit;}- public function getTJByBudgetAndDateRange(\Budget $budget, \Carbon\Carbon $start, \Carbon\Carbon $end)+ /**+ * @param \Budget $budget+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getTJByBudgetAndDateRange(\Budget $budget, Carbon $start, Carbon $end){- $type = \TransactionType::where('type', 'Withdrawal')->first();-$result = $budget->transactionjournals()->after($start)->before($end)->get();return $result;diff --git a/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php b/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.phpindex dda40f2d39..511a276a2b 100644--- a/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Limit/LimitRepositoryInterface.php@@ -2,13 +2,36 @@namespace Firefly\Storage\Limit;+use Carbon\Carbon;+/**+ * Interface LimitRepositoryInterface+ *+ * @package Firefly\Storage\Limit+ */interface LimitRepositoryInterface{+ /**+ * @param $data+ *+ * @return mixed+ */public function store($data);- public function getTJByBudgetAndDateRange(\Budget $budget, \Carbon\Carbon $start, \Carbon\Carbon $end);+ /**+ * @param \Budget $budget+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getTJByBudgetAndDateRange(\Budget $budget, Carbon $start, Carbon $end);+ /**+ * @param $limitId+ *+ * @return mixed+ */public function find($limitId);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/StorageServiceProvider.php b/app/lib/Firefly/Storage/StorageServiceProvider.phpindex 630a6c33d4..9d032a4e52 100644--- a/app/lib/Firefly/Storage/StorageServiceProvider.php+++ b/app/lib/Firefly/Storage/StorageServiceProvider.php@@ -3,11 +3,18 @@ namespace Firefly\Storage;use Illuminate\Support\ServiceProvider;+/**+ * Class StorageServiceProvider+ *+ * @package Firefly\Storage+ */class StorageServiceProvider extends ServiceProvider{- // Triggered automatically by Laravel+ /**+ * Triggered automatically by Laravel+ */public function register(){$this->app->bind(diff --git a/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php b/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.phpindex 32b485a04f..3b4fac8e2e 100644--- a/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php+++ b/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php@@ -2,7 +2,11 @@namespace Firefly\Storage\Transaction;-+/**+ * Class EloquentTransactionRepository+ *+ * @package Firefly\Storage\Transaction+ */class EloquentTransactionRepository implements TransactionRepositoryInterface{diff --git a/app/lib/Firefly/Storage/Transaction/TransactionRepositoryInterface.php b/app/lib/Firefly/Storage/Transaction/TransactionRepositoryInterface.phpindex a597deaf9d..8c1b41bc1d 100644--- a/app/lib/Firefly/Storage/Transaction/TransactionRepositoryInterface.php+++ b/app/lib/Firefly/Storage/Transaction/TransactionRepositoryInterface.php@@ -2,7 +2,11 @@namespace Firefly\Storage\Transaction;-+/**+ * Interface TransactionRepositoryInterface+ *+ * @package Firefly\Storage\Transaction+ */interface TransactionRepositoryInterface{diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.phpindex 2ebe1d4084..89447e5a28 100644--- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php+++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php@@ -3,10 +3,22 @@namespace Firefly\Storage\TransactionJournal;+use Carbon\Carbon;+use Firefly\Exception\FireflyException;+/**+ * Class EloquentTransactionJournalRepository+ *+ * @package Firefly\Storage\TransactionJournal+ */class EloquentTransactionJournalRepository implements TransactionJournalRepositoryInterface{+ /**+ * @param $journalId+ *+ * @return mixed+ */public function find($journalId){return \Auth::user()->transactionjournals()->with(@@ -41,7 +53,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito* B loses 200 (-200). * 1** @param \Account $from- * @param \Account $to+ * @param \Account $toAccount* @param $description* @param $amount* @param \Carbon\Carbon $date@@ -49,7 +61,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito* @return \TransactionJournal* @throws \Firefly\Exception\FireflyException*/- public function createSimpleJournal(\Account $from, \Account $to, $description, $amount, \Carbon\Carbon $date)+ public function createSimpleJournal(\Account $from, \Account $toAccount, $description, $amount, Carbon $date){\Log::debug('Creating tranaction "' . $description . '".');@@ -59,23 +71,23 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoif (round(floatval($amount), 2) == 0.00) {\Log::error('Transaction will never save: amount = 0');\Session::flash('error', 'The amount should not be empty or zero.');- throw new \Firefly\Exception\FireflyException('Could not figure out transaction type.');+ throw new FireflyException('Could not figure out transaction type.');}// same account:- if ($from->id == $to->id) {+ if ($from->id == $toAccount->id) {\Log::error('Accounts cannot be equal');\Session::flash('error', 'Select two different accounts.');- throw new \Firefly\Exception\FireflyException('Select two different accounts.');+ throw new FireflyException('Select two different accounts.');}// account types for both:- $toAT = $to->accountType->description;+ $toAT = $toAccount->accountType->description;$fromAT = $from->accountType->description;$journalType = null;switch (true) {- case ($from->transactions()->count() == 0 && $to->transactions()->count() == 0):+ case ($from->transactions()->count() == 0 && $toAccount->transactions()->count() == 0):$journalType = \TransactionType::where('type', 'Opening balance')->first();break;@@ -99,19 +111,19 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito// some debug information:\Log::debug($journalType->type . ': AccountFrom "' . $from->name . '" will gain/lose ' . $amountFrom- . ' and AccountTo "' . $to->name . '" will gain/lose ' . $amountTo+ . ' and AccountTo "' . $toAccount->name . '" will gain/lose ' . $amountTo);if (is_null($journalType)) {\Log::error('Could not figure out transacion type!');- throw new \Firefly\Exception\FireflyException('Could not figure out transaction type.');+ throw new FireflyException('Could not figure out transaction type.');}// always the same currency:$currency = \TransactionCurrency::where('code', 'EUR')->first();if (is_null($currency)) {\Log::error('No currency for journal!');- throw new \Firefly\Exception\FireflyException('No currency for journal!');+ throw new FireflyException('No currency for journal!');}// new journal:@@ -126,7 +138,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito\Log::error('Cannot create valid journal.');\Log::error('Errors: ' . print_r($journal->errors()->all(), true));\Session::flash('error', 'Could not create journal: ' . $journal->errors()->first());- throw new \Firefly\Exception\FireflyException('Cannot create valid journal.');+ throw new FireflyException('Cannot create valid journal.');}$journal->save();@@ -139,19 +151,19 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoif (!$fromTransaction->save()) {\Log::error('Cannot create valid transaction (from) for journal #' . $journal->id);\Log::error('Errors: ' . print_r($fromTransaction->errors()->all(), true));- throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (from).');+ throw new FireflyException('Cannot create valid transaction (from).');}$fromTransaction->save();$toTransaction = new \Transaction;- $toTransaction->account()->associate($to);+ $toTransaction->account()->associate($toAccount);$toTransaction->transactionJournal()->associate($journal);$toTransaction->description = null;$toTransaction->amount = $amountTo;if (!$toTransaction->save()) {\Log::error('Cannot create valid transaction (to) for journal #' . $journal->id);\Log::error('Errors: ' . print_r($toTransaction->errors()->all(), true));- throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (to).');+ throw new FireflyException('Cannot create valid transaction (to).');}$toTransaction->save();@@ -160,12 +172,23 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoreturn $journal;}+ /**+ *+ */public function get(){}- public function getByAccountInDateRange(\Account $account, $count = 25, \Carbon\Carbon $start, \Carbon\Carbon $end)+ /**+ * @param \Account $account+ * @param int $count+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end){$accountID = $account->id;$query = \Auth::user()->transactionjournals()->with(@@ -187,6 +210,11 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoreturn $query;}+ /**+ * @param int $count+ *+ * @return mixed+ */public function paginate($count = 25){$query = \Auth::user()->transactionjournals()->with(@@ -207,7 +235,13 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoreturn $query;}- public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end)+ /**+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getByDateRange(Carbon $start, Carbon $end){// lets make this simple.$types = [];@@ -231,7 +265,13 @@ class EloquentTransactionJournalRepository implements TransactionJournalRepositoreturn $journals;}- public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date)+ /**+ * @param \Account $account+ * @param Carbon $date+ *+ * @return mixed+ */+ public function getByAccountAndDate(\Account $account, Carbon $date){$accountID = $account->id;$query = \Auth::user()->transactionjournals()->with(diff --git a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.phpindex 3ecef61f5a..6bf727d259 100644--- a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php+++ b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php@@ -2,21 +2,69 @@namespace Firefly\Storage\TransactionJournal;+use Carbon\Carbon;+/**+ * Interface TransactionJournalRepositoryInterface+ *+ * @package Firefly\Storage\TransactionJournal+ */interface TransactionJournalRepositoryInterface{- public function createSimpleJournal(\Account $from, \Account $to, $description, $amount, \Carbon\Carbon $date);+ /**+ * @param \Account $from+ * @param \Account $toAccount+ * @param $description+ * @param $amount+ * @param Carbon $date+ *+ * @return mixed+ */+ public function createSimpleJournal(\Account $from, \Account $toAccount, $description, $amount, Carbon $date);+ /**+ * @return mixed+ */public function get();+ /**+ * @param $journalId+ *+ * @return mixed+ */public function find($journalId);- public function getByAccountInDateRange(\Account $account, $count = 25, \Carbon\Carbon $start, \Carbon\Carbon $end);+ /**+ * @param \Account $account+ * @param int $count+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getByAccountInDateRange(\Account $account, $count = 25, Carbon $start, Carbon $end);- public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date);+ /**+ * @param \Account $account+ * @param Carbon $date+ *+ * @return mixed+ */+ public function getByAccountAndDate(\Account $account, Carbon $date);- public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end);+ /**+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return mixed+ */+ public function getByDateRange(Carbon $start, Carbon $end);+ /**+ * @param int $count+ *+ * @return mixed+ */public function paginate($count = 25);}\ No newline at end of filediff --git a/app/lib/Firefly/Storage/User/EloquentUserRepository.php b/app/lib/Firefly/Storage/User/EloquentUserRepository.phpindex 2a502cd2e3..a63f4046e3 100644--- a/app/lib/Firefly/Storage/User/EloquentUserRepository.php+++ b/app/lib/Firefly/Storage/User/EloquentUserRepository.php@@ -3,12 +3,25 @@namespace Firefly\Storage\User;+/**+ * Class EloquentUserRepository+ *+ * @package Firefly\Storage\User+ */class EloquentUserRepository implements UserRepositoryInterface{+ /**+ *+ */public function __construct(){}+ /**+ * @param $array+ *+ * @return bool|\User+ */public function register($array){$user = new \User;@@ -26,6 +39,11 @@ class EloquentUserRepository implements UserRepositoryInterfacereturn $user;}+ /**+ * @param $array+ *+ * @return bool+ */public function auth($array){$user = \User::where('email', $array['email'])->first();@@ -36,16 +54,32 @@ class EloquentUserRepository implements UserRepositoryInterfacereturn false;}+ /**+ * @param $reset+ *+ * @return mixed+ */public function findByReset($reset){return \User::where('reset', $reset)->first();}+ /**+ * @param $email+ *+ * @return mixed+ */public function findByEmail($email){return \User::where('email', $email)->first();}+ /**+ * @param \User $user+ * @param $password+ *+ * @return bool+ */public function updatePassword(\User $user, $password){$password = \Hash::make($password);diff --git a/app/lib/Firefly/Storage/User/UserRepositoryInterface.php b/app/lib/Firefly/Storage/User/UserRepositoryInterface.phpindex b092658bcf..d1192466e3 100644--- a/app/lib/Firefly/Storage/User/UserRepositoryInterface.php+++ b/app/lib/Firefly/Storage/User/UserRepositoryInterface.php@@ -3,17 +3,47 @@namespace Firefly\Storage\User;-+/**+ * Interface UserRepositoryInterface+ *+ * @package Firefly\Storage\User+ */interface UserRepositoryInterface{+ /**+ * @param $array+ *+ * @return mixed+ */public function register($array);+ /**+ * @param $array+ *+ * @return mixed+ */public function auth($array);+ /**+ * @param $reset+ *+ * @return mixed+ */public function findByReset($reset);+ /**+ * @param $email+ *+ * @return mixed+ */public function findByEmail($email);+ /**+ * @param \User $user+ * @param $password+ *+ * @return mixed+ */public function updatePassword(\User $user, $password);diff --git a/app/lib/Firefly/Trigger/Limits/EloquentLimitTrigger.php b/app/lib/Firefly/Trigger/Limits/EloquentLimitTrigger.phpindex 5ebc75ca89..7e813fc5a8 100644--- a/app/lib/Firefly/Trigger/Limits/EloquentLimitTrigger.php+++ b/app/lib/Firefly/Trigger/Limits/EloquentLimitTrigger.php@@ -2,6 +2,10 @@namespace Firefly\Trigger\Limits;+use Carbon\Carbon;+use Illuminate\Database\QueryException;+use Illuminate\Events\Dispatcher;+/*** Class EloquentLimitTrigger*@@ -64,14 +68,14 @@ class EloquentLimitTriggertry {$repetition->save();- } catch (\Illuminate\Database\QueryException $e) {+ } catch (QueryException $e) {// do nothing\Log::error($e->getMessage());}} else {// there are limits already, do they// fall into the range surrounding today?- $today = new \Carbon\Carbon;+ $today = new Carbon;$today->addMonths(2);if ($limit->repeats == 1 && $today >= $limit->startdate) {@@ -141,7 +145,7 @@ class EloquentLimitTrigger$repetition->limit()->associate($limit);try {$repetition->save();- } catch (\Illuminate\Database\QueryException $e) {+ } catch (QueryException $e) {// do nothing\Log::error($e->getMessage());}@@ -153,7 +157,10 @@ class EloquentLimitTrigger}}- public function subscribe(\Illuminate\Events\Dispatcher $events)+ /**+ * @param Dispatcher $events+ */+ public function subscribe(Dispatcher $events){$events->listen('app.before', 'Firefly\Trigger\Limits\EloquentLimitTrigger@updateLimitRepetitions');diff --git a/app/tests/controllers/AccountControllerTest.php b/app/tests/controllers/AccountControllerTest.phpindex d45fe58ca9..7f1bfd6a3b 100644--- a/app/tests/controllers/AccountControllerTest.php+++ b/app/tests/controllers/AccountControllerTest.php@@ -15,17 +15,16 @@ class AccountControllerTest extends TestCase{// mock account type(s):$personal = $this->mock('AccountType');- $personal->shouldReceive('getAttribute','description')->andReturn('Default account');+ $personal->shouldReceive('getAttribute', 'description')->andReturn('Default account');$bene = $this->mock('AccountType');- $bene->shouldReceive('getAttribute','description')->andReturn('Beneficiary account');+ $bene->shouldReceive('getAttribute', 'description')->andReturn('Beneficiary account');$initial = $this->mock('AccountType');- $initial->shouldReceive('getAttribute','description')->andReturn('Initial balance account');+ $initial->shouldReceive('getAttribute', 'description')->andReturn('Initial balance account');$cash = $this->mock('AccountType');- $cash->shouldReceive('getAttribute','description')->andReturn('Cash account');-+ $cash->shouldReceive('getAttribute', 'description')->andReturn('Cash account');// mock account(s)@@ -40,16 +39,13 @@ class AccountControllerTest extends TestCase$four = $this->mock('Account');$four->shouldReceive('getAttribute')->andReturn($cash);- $c = new \Illuminate\Database\Eloquent\Collection([$one,$two,$three,$four]);+ $c = new \Illuminate\Database\Eloquent\Collection([$one, $two, $three, $four]);// mock account repository:$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');$accounts->shouldReceive('get')->andReturn($c);---$list = ['personal' => [$one],'beneficiaries' => [$two],@@ -60,11 +56,10 @@ class AccountControllerTest extends TestCase// mock:View::shouldReceive('share');View::shouldReceive('make')->with('accounts.index')->once()->andReturn(\Mockery::self())- ->shouldReceive('with')->once()->with('accounts',$list)->andReturn(\Mockery::self())+ ->shouldReceive('with')->once()->with('accounts', $list)->andReturn(\Mockery::self())->shouldReceive('with')->once()->with('total', 4)->andReturn(\Mockery::self());-// call$this->call('GET', '/accounts');diff --git a/app/tests/controllers/BudgetControllerTest.php b/app/tests/controllers/BudgetControllerTest.phpindex b48e620f1c..15816a8d75 100644--- a/app/tests/controllers/BudgetControllerTest.php+++ b/app/tests/controllers/BudgetControllerTest.php@@ -1,7 +1,8 @@<?php-use \League\FactoryMuffin\Facade\FactoryMuffin;+use League\FactoryMuffin\Facade\FactoryMuffin;+/*** Class BudgetControllerTest*/@@ -24,7 +25,6 @@ class BudgetControllerTest extends TestCase$budget->limits()->save($limit);-// mock budget repository:$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');$budgets->shouldReceive('get')->once()->andReturn([$budget]);@@ -46,7 +46,6 @@ class BudgetControllerTest extends TestCase$budget->limits()->save($limit);-// mock budget repository:$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');$budgets->shouldReceive('get')->once()->andReturn([$budget]);@@ -70,10 +69,10 @@ class BudgetControllerTest extends TestCasepublic function testStore(){$data = [- 'name' => 'X',- 'amount' => 100,- 'period' => 'monthly',- 'repeats' => 0+ 'name' => 'X',+ 'amount' => 100,+ 'period' => 'monthly',+ 'repeats' => 0];$return = $data;$return['repeat_freq'] = 'monthly';@@ -84,7 +83,7 @@ class BudgetControllerTest extends TestCase$budgets->shouldReceive('store')->with($return)->once()->andReturn(true);// call- $this->call('POST', '/budget/store',$data);+ $this->call('POST', '/budget/store', $data);// test$this->assertResponseStatus(302);@@ -106,7 +105,7 @@ class BudgetControllerTest extends TestCase// call- $this->call('GET', '/budget/show/'.$budget->id);+ $this->call('GET', '/budget/show/' . $budget->id);// test$this->assertResponseOk();diff --git a/app/tests/controllers/ChartControllerTest.php b/app/tests/controllers/ChartControllerTest.phpindex ad67fa479c..a324114086 100644--- a/app/tests/controllers/ChartControllerTest.php+++ b/app/tests/controllers/ChartControllerTest.php@@ -181,7 +181,7 @@ class ChartControllerTest extends TestCase{$account = FactoryMuffin::create('Account');$second = FactoryMuffin::create('Account');- $date = \Carbon\Carbon::createFromDate('2012','01','01');+ $date = \Carbon\Carbon::createFromDate('2012', '01', '01');$transaction = FactoryMuffin::create('Transaction');$transaction->account()->associate($second);$journal = FactoryMuffin::create('TransactionJournal');@@ -196,13 +196,8 @@ class ChartControllerTest extends TestCase$tj->shouldReceive('getByAccountAndDate')->once()->andReturn([$journal]);-----// call- $this->call('GET', '/chart/home/info/'.$account->name.'/'.$date->format('d/m/Y'));+ $this->call('GET', '/chart/home/info/' . $account->name . '/' . $date->format('d/m/Y'));// test$this->assertResponseOk();diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.phpindex b76498563c..c37825c92f 100644--- a/app/tests/controllers/HomeControllerTest.php+++ b/app/tests/controllers/HomeControllerTest.php@@ -71,7 +71,7 @@ class HomeControllerTest extends TestCase// mock transaction journal repository:$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');- $tj->shouldReceive('getByAccount')->with($account,15)->andReturn([]);+ $tj->shouldReceive('getByAccount')->with($account, 15)->andReturn([]);// mock preferences & pref:$pref = $this->mock('Preference');diff --git a/app/tests/controllers/JsonControllerTest.php b/app/tests/controllers/JsonControllerTest.phpindex dc83780976..100a0fe70f 100644--- a/app/tests/controllers/JsonControllerTest.php+++ b/app/tests/controllers/JsonControllerTest.php@@ -1,12 +1,14 @@<?php-class JsonControllerTest extends TestCase {+class JsonControllerTest extends TestCase+{public function setUp(){parent::setUp();}- public function testBeneficiaries() {+ public function testBeneficiaries()+ {$obj = new stdClass;$obj->name = 'Bla bla';@@ -22,7 +24,8 @@ class JsonControllerTest extends TestCase {}- public function testCategories() {+ public function testCategories()+ {$obj = new stdClass;$obj->name = 'Bla bla';@@ -35,6 +38,7 @@ class JsonControllerTest extends TestCase {// test$this->assertResponseOk();}+public function tearDown(){Mockery::close();diff --git a/app/tests/controllers/PreferencesControllerTest.php b/app/tests/controllers/PreferencesControllerTest.phpindex e644905635..d514484e2b 100644--- a/app/tests/controllers/PreferencesControllerTest.php+++ b/app/tests/controllers/PreferencesControllerTest.php@@ -57,6 +57,7 @@ class PreferencesControllerTest extends TestCase$this->assertSessionHas('success');$this->assertRedirectedToRoute('preferences');}+public function tearDown(){Mockery::close();diff --git a/app/tests/controllers/TransactionControllerTest.php b/app/tests/controllers/TransactionControllerTest.phpindex 8d042eb81a..7eb5137a92 100644--- a/app/tests/controllers/TransactionControllerTest.php+++ b/app/tests/controllers/TransactionControllerTest.php@@ -30,7 +30,7 @@ class TransactionControllerTest extends TestCaseView::shouldReceive('share');View::shouldReceive('make')->with('transactions.create')->andReturn(\Mockery::self())->shouldReceive('with')->once()- ->with('what','withdrawal')+ ->with('what', 'withdrawal')->andReturn(Mockery::self())->shouldReceive('with')->once()->with('accounts', [])@@ -61,7 +61,7 @@ class TransactionControllerTest extends TestCaseView::shouldReceive('share');View::shouldReceive('make')->with('transactions.create')->andReturn(\Mockery::self())->shouldReceive('with')->once()- ->with('what','deposit')+ ->with('what', 'deposit')->andReturn(Mockery::self())->shouldReceive('with')->once()@@ -393,7 +393,7 @@ class TransactionControllerTest extends TestCase$this->call('POST', '/transactions/store/withdrawal', $data);// test- $this->assertRedirectedToRoute('transactions.create',['what' => 'withdrawal']);+ $this->assertRedirectedToRoute('transactions.create', ['what' => 'withdrawal']);}/**@@ -443,7 +443,7 @@ class TransactionControllerTest extends TestCase$this->call('POST', '/transactions/store/deposit', $data);// test- $this->assertRedirectedToRoute('transactions.create',['what' => 'deposit']);+ $this->assertRedirectedToRoute('transactions.create', ['what' => 'deposit']);}/**@@ -488,10 +488,11 @@ class TransactionControllerTest extends TestCase$this->call('POST', '/transactions/store/transfer', $data);// test- $this->assertRedirectedToRoute('transactions.create',['what' => 'transfer']);+ $this->assertRedirectedToRoute('transactions.create', ['what' => 'transfer']);}- public function testShow() {+ public function testShow()+ {$journal = FactoryMuffin::create('TransactionJournal');// mock transaction journal:@@ -499,7 +500,6 @@ class TransactionControllerTest extends TestCase$tj->shouldReceive('find')->with($journal->id)->andReturn($journal);-// call$this->call('GET', '/transaction/show/' . $journal->id);@@ -507,7 +507,8 @@ class TransactionControllerTest extends TestCase$this->assertResponseOk();}- public function testShowError() {+ public function testShowError()+ {// mock transaction journal:$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');@@ -521,7 +522,8 @@ class TransactionControllerTest extends TestCase$this->assertViewHas('message');}- public function testEdit() {+ public function testEdit()+ {$journal = FactoryMuffin::create('TransactionJournal');// mock transaction journal:@@ -533,7 +535,6 @@ class TransactionControllerTest extends TestCase$accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);-// call$this->call('GET', '/transaction/edit/' . $journal->id);@@ -541,7 +542,8 @@ class TransactionControllerTest extends TestCase$this->assertResponseOk();}- public function testEditError() {+ public function testEditError()+ {// mock transaction journal:$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');$tj->shouldReceive('find')->with(1)->andReturn(null);diff --git a/app/tests/controllers/UserControllerTest.php b/app/tests/controllers/UserControllerTest.phpindex bed7d1fc54..e2687e2d7b 100644--- a/app/tests/controllers/UserControllerTest.php+++ b/app/tests/controllers/UserControllerTest.php@@ -64,7 +64,7 @@ class UserControllerTest extends TestCase// test$this->call('GET', '/register');$this->assertResponseStatus(200);- $this->assertViewHas('message','Not possible');+ $this->assertViewHas('message', 'Not possible');}/**@@ -94,7 +94,6 @@ class UserControllerTest extends TestCase}-/*** Register and verify FAILED:*/@@ -189,7 +188,7 @@ class UserControllerTest extends TestCase$this->call('POST', '/remindme');$this->assertResponseOk();- $this->assertSessionHas('error','No good!');+ $this->assertSessionHas('error', 'No good!');}public function testPostRegisterNotAllowed()@@ -207,7 +206,7 @@ class UserControllerTest extends TestCase// test$this->call('POST', '/register', $data);$this->assertResponseStatus(200);- $this->assertViewHas('message','Not possible');+ $this->assertViewHas('message', 'Not possible');}