Cleanup controllers and small bug fixes.

This commit is contained in:
James Cole
2014-09-09 20:00:04 +02:00
parent 309177ca9c
commit f9dc627d84
15 changed files with 143 additions and 98 deletions

View File

@@ -8,8 +8,6 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
* *
* @SuppressWarnings(PHPMD.CamelCasePropertyName) * @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class AccountController extends \BaseController class AccountController extends \BaseController
{ {
@@ -18,7 +16,7 @@ class AccountController extends \BaseController
/** /**
* @param ARI $repository * @param ARI $repository
* @param AI $accounts * @param AI $accounts
*/ */
public function __construct(ARI $repository, AI $accounts) public function __construct(ARI $repository, AI $accounts)
{ {
@@ -42,7 +40,7 @@ class AccountController extends \BaseController
public function delete(Account $account) public function delete(Account $account)
{ {
return View::make('accounts.delete')->with('account', $account) return View::make('accounts.delete')->with('account', $account)
->with('title', 'Delete account "' . $account->name . '"'); ->with('title', 'Delete account "' . $account->name . '"');
} }
/** /**
@@ -69,7 +67,7 @@ class AccountController extends \BaseController
{ {
$openingBalance = $this->_accounts->openingBalanceTransaction($account); $openingBalance = $this->_accounts->openingBalanceTransaction($account);
return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance) return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance)
->with('title', 'Edit account "' . $account->name . '"'); ->with('title', 'Edit account "' . $account->name . '"');
} }
/** /**
@@ -105,8 +103,10 @@ class AccountController extends \BaseController
{ {
$data = $this->_accounts->show($account, 40); $data = $this->_accounts->show($account, 40);
return View::make('accounts.show')->with('account', $account)->with('show', $data)->with('title', return View::make('accounts.show')->with('account', $account)->with('show', $data)->with(
'Details for account "' . $account->name . '"'); 'title',
'Details for account "' . $account->name . '"'
);
} }
/** /**

View File

@@ -1,6 +1,6 @@
<?php <?php
use \Illuminate\Routing\Controller; use Illuminate\Routing\Controller;
/** /**
* Class BaseController * Class BaseController
@@ -13,10 +13,6 @@ class BaseController extends Controller
*/ */
public function __construct() public function __construct()
{ {
\Event::fire('limits.check');
\Event::fire('piggybanks.check');
\Event::fire('recurring.check');
} }
/** /**

View File

@@ -8,6 +8,7 @@ use Firefly\Storage\Budget\BudgetRepositoryInterface as BRI;
* Class BudgetController * Class BudgetController
* *
* @SuppressWarnings(PHPMD.CamelCasePropertyName) * @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* *
*/ */
class BudgetController extends BaseController class BudgetController extends BaseController
@@ -17,7 +18,7 @@ class BudgetController extends BaseController
protected $_repository; protected $_repository;
/** /**
* @param BI $budgets * @param BI $budgets
* @param BRI $repository * @param BRI $repository
*/ */
public function __construct(BI $budgets, BRI $repository) public function __construct(BI $budgets, BRI $repository)
@@ -44,7 +45,7 @@ class BudgetController extends BaseController
public function delete(Budget $budget) public function delete(Budget $budget)
{ {
return View::make('budgets.delete')->with('budget', $budget) return View::make('budgets.delete')->with('budget', $budget)
->with('title', 'Delete budget "' . $budget->name . '"'); ->with('title', 'Delete budget "' . $budget->name . '"');
} }
/** /**
@@ -75,7 +76,7 @@ class BudgetController extends BaseController
public function edit(Budget $budget) public function edit(Budget $budget)
{ {
return View::make('budgets.edit')->with('budget', $budget) return View::make('budgets.edit')->with('budget', $budget)
->with('title', 'Edit budget "' . $budget->name . '"'); ->with('title', 'Edit budget "' . $budget->name . '"');
} }
@@ -87,7 +88,7 @@ class BudgetController extends BaseController
$budgets = $this->_repository->get(); $budgets = $this->_repository->get();
return View::make('budgets.indexByBudget')->with('budgets', $budgets)->with('today', new Carbon) return View::make('budgets.indexByBudget')->with('budgets', $budgets)->with('today', new Carbon)
->with('title', 'All your budgets grouped by budget'); ->with('title', 'All your budgets grouped by budget');
} }
@@ -101,7 +102,7 @@ class BudgetController extends BaseController
$budgets = $this->_budgets->organizeByDate($set); $budgets = $this->_budgets->organizeByDate($set);
return View::make('budgets.indexByDate')->with('budgets', $budgets) return View::make('budgets.indexByDate')->with('budgets', $budgets)
->with('title', 'All your budgets grouped by date'); ->with('title', 'All your budgets grouped by date');
} }
@@ -113,7 +114,7 @@ class BudgetController extends BaseController
* - Show a specific repetition. * - Show a specific repetition.
* - Show everything shows NO repetition. * - Show everything shows NO repetition.
* *
* @param Budget $budget * @param Budget $budget
* @param LimitRepetition $repetition * @param LimitRepetition $repetition
* *
* @return int * @return int
@@ -128,8 +129,10 @@ class BudgetController extends BaseController
case (!is_null($repetition)): case (!is_null($repetition)):
$data = $this->_budgets->organizeRepetition($repetition); $data = $this->_budgets->organizeRepetition($repetition);
$view = 1; $view = 1;
$title = $budget->name . ', ' . $repetition->periodShow() . ', ' . mf($repetition->limit->amount, $title = $budget->name . ', ' . $repetition->periodShow() . ', ' . mf(
false); $repetition->limit->amount,
false
);
break; break;
case (Input::get('noenvelope') == 'true'): case (Input::get('noenvelope') == 'true'):
$data = $this->_budgets->outsideRepetitions($budget); $data = $this->_budgets->outsideRepetitions($budget);
@@ -144,12 +147,12 @@ class BudgetController extends BaseController
} }
return View::make('budgets.show') return View::make('budgets.show')
->with('budget', $budget) ->with('budget', $budget)
->with('repetitions', $data) ->with('repetitions', $data)
->with('view', $view) ->with('view', $view)
->with('highlight', Input::get('highlight')) ->with('highlight', Input::get('highlight'))
->with('useSessionDates', $useSessionDates) ->with('useSessionDates', $useSessionDates)
->with('title', $title); ->with('title', $title);
} }
/** /**

View File

@@ -5,6 +5,8 @@ use Firefly\Storage\Category\CategoryRepositoryInterface as CRI;
/** /**
* Class CategoryController * Class CategoryController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class CategoryController extends BaseController class CategoryController extends BaseController
{ {
@@ -13,7 +15,7 @@ class CategoryController extends BaseController
/** /**
* @param CRI $repository * @param CRI $repository
* @param CI $category * @param CI $category
*/ */
public function __construct(CRI $repository, CI $category) public function __construct(CRI $repository, CI $category)
{ {
@@ -37,7 +39,7 @@ class CategoryController extends BaseController
public function delete(Category $category) public function delete(Category $category)
{ {
return View::make('categories.delete')->with('category', $category) return View::make('categories.delete')->with('category', $category)
->with('title', 'Delete category "' . $category->name . '"'); ->with('title', 'Delete category "' . $category->name . '"');
} }
/** /**
@@ -88,8 +90,8 @@ class CategoryController extends BaseController
$journals = $this->_category->journalsInRange($category, $start, $end); $journals = $this->_category->journalsInRange($category, $start, $end);
return View::make('categories.show')->with('category', $category)->with('journals', $journals)->with( return View::make('categories.show')->with('category', $category)->with('journals', $journals)->with(
'highlight', Input::get('highlight') 'highlight', Input::get('highlight')
)->with('title', 'Overview for category "'.$category->name.'"');; )->with('title', 'Overview for category "' . $category->name . '"');
} }
/** /**

View File

@@ -6,6 +6,9 @@ use Firefly\Storage\Account\AccountRepositoryInterface;
/** /**
* Class ChartController * Class ChartController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class ChartController extends BaseController class ChartController extends BaseController
{ {
@@ -143,15 +146,15 @@ class ChartController extends BaseController
public function budgetNoLimits(\Budget $budget) public function budgetNoLimits(\Budget $budget)
{ {
/* /*
* We can go about this two ways. Either we find all transactions which definitely are IN an envelope * Firefly can go about this two ways. Either it finds all transactions which definitely are IN an envelope
* and exclude them or we search for transactions outside of the range of any of the envelopes we have. * and exclude them or it searches for transactions outside of the range of any of the envelopes there are.
* *
* Since either is shitty we go with the first one because it's easier to build. * Since either is kinda shitty Firefly uses the first one because it's easier to build.
*/ */
$inRepetitions = $this->_chart->allJournalsInBudgetEnvelope($budget); $inRepetitions = $this->_chart->allJournalsInBudgetEnvelope($budget);
/* /*
* With this set of id's, we can search for all journals NOT in that set. * With this set of id's, Firefly can search for all journals NOT in that set.
* BUT they have to be in the budget (duh). * BUT they have to be in the budget (duh).
*/ */
$set = $this->_chart->journalsNotInSet($budget, $inRepetitions); $set = $this->_chart->journalsNotInSet($budget, $inRepetitions);
@@ -226,14 +229,15 @@ class ChartController extends BaseController
$reps = $this->_chart->limitsInRange($budget, $start, $end); $reps = $this->_chart->limitsInRange($budget, $start, $end);
/* /*
* For each limitrepetition we create a serie that contains the amount left in * For each limitrepetition Firefly creates a serie that contains the amount left in
* the limitrepetition for its entire date-range. Entries are only actually included when they * the limitrepetition for its entire date-range. Entries are only actually included when they
* fall into the charts date range. * fall into the charts date range.
* *
* So example: we have a session date from Jan 15 to Jan 30. The limitrepetition starts at 1 Jan until 1 Feb. * So example: the user has a session date from Jan 15 to Jan 30. The limitrepetition
* starts at 1 Jan until 1 Feb.
* *
* We loop from 1 Jan to 1 Feb but only include Jan 15 / Jan 30. But we do keep count of the amount outside * Firefly loops from 1 Jan to 1 Feb but only includes Jan 15 / Jan 30.
* of these dates because otherwise the line might be wrong. * But it does keep count of the amount outside of these dates because otherwise the line might be wrong.
*/ */
/** @var \LimitRepetition $repetition */ /** @var \LimitRepetition $repetition */
foreach ($reps as $repetition) { foreach ($reps as $repetition) {

View File

@@ -1,5 +1,4 @@
<?php <?php
use Carbon\Carbon;
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI; use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
use Firefly\Storage\Account\AccountRepositoryInterface as ARI; use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI; use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI;
@@ -7,6 +6,8 @@ use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as
/** /**
* Class HomeController * Class HomeController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class HomeController extends BaseController class HomeController extends BaseController
{ {
@@ -15,12 +16,18 @@ class HomeController extends BaseController
protected $_journal; protected $_journal;
protected $_reminders; protected $_reminders;
/**
* @param ARI $accounts
* @param PHI $preferences
* @param TJRI $journal
* @param RRI $reminders
*/
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, RRI $reminders) public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, RRI $reminders)
{ {
$this->_accounts = $accounts; $this->_accounts = $accounts;
$this->_preferences = $preferences; $this->_preferences = $preferences;
$this->_journal = $journal; $this->_journal = $journal;
$this->_reminders = $reminders; $this->_reminders = $reminders;
} }
/** /**
@@ -38,11 +45,14 @@ class HomeController extends BaseController
*/ */
public function index() public function index()
{ {
Event::fire('limits.check');
Event::fire('piggybanks.check');
Event::fire('recurring.check');
// count, maybe we need some introducing text to show: // count, maybe Firefly needs some introducing text to show:
$count = $this->_accounts->count(); $count = $this->_accounts->count();
$start = Session::get('start'); $start = Session::get('start');
$end = Session::get('end'); $end = Session::get('end');
// get the preference for the home accounts to show: // get the preference for the home accounts to show:

View File

@@ -7,6 +7,8 @@ use Firefly\Storage\Component\ComponentRepositoryInterface as CRI;
/** /**
* Class JsonController * Class JsonController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class JsonController extends BaseController class JsonController extends BaseController
{ {
@@ -24,9 +26,9 @@ class JsonController extends BaseController
public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets) public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets)
{ {
$this->_components = $components; $this->_components = $components;
$this->_accounts = $accounts; $this->_accounts = $accounts;
$this->_categories = $categories; $this->_categories = $categories;
$this->_budgets = $budgets; $this->_budgets = $budgets;
} }
/** /**
@@ -34,7 +36,7 @@ class JsonController extends BaseController
*/ */
public function beneficiaries() public function beneficiaries()
{ {
$list = $this->_accounts->getBeneficiaries(); $list = $this->_accounts->getBeneficiaries();
$return = []; $return = [];
foreach ($list as $entry) { foreach ($list as $entry) {
$return[] = $entry->name; $return[] = $entry->name;
@@ -49,7 +51,7 @@ class JsonController extends BaseController
*/ */
public function categories() public function categories()
{ {
$list = $this->_categories->get(); $list = $this->_categories->get();
$return = []; $return = [];
foreach ($list as $entry) { foreach ($list as $entry) {
$return[] = $entry->name; $return[] = $entry->name;

View File

@@ -5,6 +5,8 @@ use Firefly\Storage\Limit\LimitRepositoryInterface as LRI;
/** /**
* Class LimitController * Class LimitController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class LimitController extends BaseController class LimitController extends BaseController
{ {
@@ -19,7 +21,7 @@ class LimitController extends BaseController
public function __construct(BRI $budgets, LRI $limits) public function __construct(BRI $budgets, LRI $limits)
{ {
$this->_budgets = $budgets; $this->_budgets = $budgets;
$this->_limits = $limits; $this->_limits = $limits;
} }
/** /**
@@ -29,7 +31,7 @@ class LimitController extends BaseController
*/ */
public function create(\Budget $budget = null) public function create(\Budget $budget = null)
{ {
$periods = \Config::get('firefly.periods_to_text'); $periods = \Config::get('firefly.periods_to_text');
$prefilled = [ $prefilled = [
'startdate' => \Input::get('startdate') ? : date('Y-m-d'), 'startdate' => \Input::get('startdate') ? : date('Y-m-d'),
'repeat_freq' => \Input::get('repeat_freq') ? : 'monthly', 'repeat_freq' => \Input::get('repeat_freq') ? : 'monthly',
@@ -98,7 +100,7 @@ class LimitController extends BaseController
public function store(Budget $budget = null) public function store(Budget $budget = null)
{ {
// find a limit with these properties, as we might already have one: // find a limit with these properties, as Firefly might already have one:
$limit = $this->_limits->store(Input::all()); $limit = $this->_limits->store(Input::all());
if ($limit->validate()) { if ($limit->validate()) {
Session::flash('success', 'Envelope created!'); Session::flash('success', 'Envelope created!');
@@ -110,7 +112,7 @@ class LimitController extends BaseController
} }
} else { } else {
Session::flash('error', 'Could not save new envelope.'); Session::flash('error', 'Could not save new envelope.');
$budgetId = $budget ? $budget->id : null; $budgetId = $budget ? $budget->id : null;
$parameters = [$budgetId, 'from' => Input::get('from')]; $parameters = [$budgetId, 'from' => Input::get('from')];
return Redirect::route('budgets.limits.create', $parameters)->withInput() return Redirect::route('budgets.limits.create', $parameters)->withInput()

View File

@@ -27,7 +27,7 @@ class MigrateController extends BaseController
$fullName = $path . DIRECTORY_SEPARATOR . $fileName; $fullName = $path . DIRECTORY_SEPARATOR . $fileName;
if (is_writable($path)) { if (is_writable($path)) {
Input::file('file')->move($path, $fileName); Input::file('file')->move($path, $fileName);
// so now we push something in a queue and do something with it! Yay! // so now Firefly pushes something in a queue and does something with it! Yay!
\Log::debug('Pushed a job to start the import.'); \Log::debug('Pushed a job to start the import.');
Queue::push('Firefly\Queue\Import@start', ['file' => $fullName, 'user' => \Auth::user()->id]); Queue::push('Firefly\Queue\Import@start', ['file' => $fullName, 'user' => \Auth::user()->id]);
Session::flash('success', 'The import job has been queued. Please be patient. Data will appear'); Session::flash('success', 'The import job has been queued. Please be patient. Data will appear');

View File

@@ -7,6 +7,10 @@ use Firefly\Storage\Piggybank\PiggybankRepositoryInterface as PRI;
/** /**
* Class PiggybankController * Class PiggybankController
* *
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyMethods)
*
*/ */
class PiggybankController extends BaseController class PiggybankController extends BaseController
{ {
@@ -21,16 +25,18 @@ class PiggybankController extends BaseController
public function __construct(PRI $repository, ARI $accounts) public function __construct(PRI $repository, ARI $accounts)
{ {
$this->_repository = $repository; $this->_repository = $repository;
$this->_accounts = $accounts; $this->_accounts = $accounts;
} }
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggyBank
*
* @return $this
*/ */
public function addMoney(Piggybank $piggyBank) public function addMoney(Piggybank $piggyBank)
{ {
$what = 'add'; $what = 'add';
$maxAdd = $this->_repository->leftOnAccount($piggyBank->account); $maxAdd = $this->_repository->leftOnAccount($piggyBank->account);
$maxRemove = null; $maxRemove = null;
return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with( return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with(
@@ -43,7 +49,7 @@ class PiggybankController extends BaseController
*/ */
public function createPiggybank() public function createPiggybank()
{ {
$periods = Config::get('firefly.piggybank_periods'); $periods = Config::get('firefly.piggybank_periods');
$accounts = $this->_accounts->getActiveDefaultAsSelectList(); $accounts = $this->_accounts->getActiveDefaultAsSelectList();
return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)->with('periods', $periods); return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)->with('periods', $periods);
@@ -54,7 +60,7 @@ class PiggybankController extends BaseController
*/ */
public function createRepeated() public function createRepeated()
{ {
$periods = Config::get('firefly.piggybank_periods'); $periods = Config::get('firefly.piggybank_periods');
$accounts = $this->_accounts->getActiveDefaultAsSelectList(); $accounts = $this->_accounts->getActiveDefaultAsSelectList();
return View::make('piggybanks.create-repeated')->with('accounts', $accounts)->with('periods', $periods); return View::make('piggybanks.create-repeated')->with('accounts', $accounts)->with('periods', $periods);
@@ -93,7 +99,7 @@ class PiggybankController extends BaseController
public function edit(Piggybank $piggyBank) public function edit(Piggybank $piggyBank)
{ {
$accounts = $this->_accounts->getActiveDefaultAsSelectList(); $accounts = $this->_accounts->getActiveDefaultAsSelectList();
$periods = Config::get('firefly.piggybank_periods'); $periods = Config::get('firefly.piggybank_periods');
if ($piggyBank->repeats == 1) { if ($piggyBank->repeats == 1) {
return View::make('piggybanks.edit-repeated')->with('piggybank', $piggyBank)->with('accounts', $accounts) return View::make('piggybanks.edit-repeated')->with('piggybank', $piggyBank)->with('accounts', $accounts)
->with('periods', $periods); ->with('periods', $periods);
@@ -110,19 +116,19 @@ class PiggybankController extends BaseController
*/ */
public function index() public function index()
{ {
$countRepeating = $this->_repository->countRepeating(); $countRepeating = $this->_repository->countRepeating();
$countNonRepeating = $this->_repository->countNonrepeating(); $countNonRepeating = $this->_repository->countNonrepeating();
$piggybanks = $this->_repository->get(); $piggybanks = $this->_repository->get();
// get the accounts with each piggy bank and check their balance; we might need to // get the accounts with each piggy bank and check their balance; Fireflyy might needs to
// show the user a correction. // show the user a correction.
$accounts = []; $accounts = [];
/** @var \Piggybank $piggybank */ /** @var \Piggybank $piggybank */
foreach ($piggybanks as $piggybank) { foreach ($piggybanks as $piggybank) {
$account = $piggybank->account; $account = $piggybank->account;
$id = $account->id; $id = $account->id;
if (!isset($accounts[$id])) { if (!isset($accounts[$id])) {
$accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)]; $accounts[$id] = ['account' => $account, 'left' => $this->_repository->leftOnAccount($account)];
} }
@@ -158,7 +164,7 @@ class PiggybankController extends BaseController
} }
break; break;
case 'remove': case 'remove':
$rep = $piggyBank->currentRelevantRep(); $rep = $piggyBank->currentRelevantRep();
$maxRemove = $rep->currentamount; $maxRemove = $rep->currentamount;
if (round($amount, 2) <= round($maxRemove, 2)) { if (round($amount, 2) <= round($maxRemove, 2)) {
Session::flash('success', 'Amount updated!'); Session::flash('success', 'Amount updated!');
@@ -175,11 +181,13 @@ class PiggybankController extends BaseController
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggyBank
*
* @return $this
*/ */
public function removeMoney(Piggybank $piggyBank) public function removeMoney(Piggybank $piggyBank)
{ {
$what = 'remove'; $what = 'remove';
$maxAdd = $this->_repository->leftOnAccount($piggyBank->account); $maxAdd = $this->_repository->leftOnAccount($piggyBank->account);
$maxRemove = $piggyBank->currentRelevantRep()->currentamount; $maxRemove = $piggyBank->currentRelevantRep()->currentamount;
return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with( return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with(
@@ -193,7 +201,7 @@ class PiggybankController extends BaseController
public function show(Piggybank $piggyBank) public function show(Piggybank $piggyBank)
{ {
$leftOnAccount = $this->_repository->leftOnAccount($piggyBank->account); $leftOnAccount = $this->_repository->leftOnAccount($piggyBank->account);
$balance = $piggyBank->account->balance(); $balance = $piggyBank->account->balance();
return View::make('piggybanks.show')->with('piggyBank', $piggyBank)->with('leftOnAccount', $leftOnAccount) return View::make('piggybanks.show')->with('piggyBank', $piggyBank)->with('leftOnAccount', $leftOnAccount)
->with('balance', $balance); ->with('balance', $balance);
@@ -208,10 +216,10 @@ class PiggybankController extends BaseController
unset($data['_token']); unset($data['_token']);
// extend the data array with the settings needed to create a piggy bank: // extend the data array with the settings needed to create a piggy bank:
$data['repeats'] = 0; $data['repeats'] = 0;
$data['rep_times'] = 1; $data['rep_times'] = 1;
$data['rep_every'] = 1; $data['rep_every'] = 1;
$data['order'] = 0; $data['order'] = 0;
$piggyBank = $this->_repository->store($data); $piggyBank = $this->_repository->store($data);
if (!is_null($piggyBank->id)) { if (!is_null($piggyBank->id)) {
@@ -240,7 +248,7 @@ class PiggybankController extends BaseController
// extend the data array with the settings needed to create a repeated: // extend the data array with the settings needed to create a repeated:
$data['repeats'] = 1; $data['repeats'] = 1;
$data['order'] = 0; $data['order'] = 0;
$piggyBank = $this->_repository->store($data); $piggyBank = $this->_repository->store($data);
if ($piggyBank->id) { if ($piggyBank->id) {
@@ -258,6 +266,8 @@ class PiggybankController extends BaseController
} }
/** /**
* @param Piggybank $piggyBank
*
* @return $this|\Illuminate\Http\RedirectResponse * @return $this|\Illuminate\Http\RedirectResponse
*/ */
public function update(Piggybank $piggyBank) public function update(Piggybank $piggyBank)

View File

@@ -5,6 +5,8 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
/** /**
* Class PreferencesController * Class PreferencesController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class PreferencesController extends BaseController class PreferencesController extends BaseController
{ {
@@ -18,7 +20,7 @@ class PreferencesController extends BaseController
public function __construct(ARI $accounts, PHI $preferences) public function __construct(ARI $accounts, PHI $preferences)
{ {
$this->_accounts = $accounts; $this->_accounts = $accounts;
$this->_preferences = $preferences; $this->_preferences = $preferences;
} }
@@ -29,7 +31,7 @@ class PreferencesController extends BaseController
{ {
$accounts = $this->_accounts->getDefault(); $accounts = $this->_accounts->getDefault();
$viewRange = $this->_preferences->get('viewRange', '1M'); $viewRange = $this->_preferences->get('viewRange', '1M');
$viewRangeValue = $viewRange->data; $viewRangeValue = $viewRange->data;
// pref: // pref:

View File

@@ -4,6 +4,8 @@ use Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface
/** /**
* Class RecurringController * Class RecurringController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class RecurringController extends BaseController class RecurringController extends BaseController
{ {
@@ -114,6 +116,8 @@ class RecurringController extends BaseController
/** /**
* @param RecurringTransaction $recurringTransaction * @param RecurringTransaction $recurringTransaction
*
* @return $this|\Illuminate\Http\RedirectResponse
*/ */
public function update(RecurringTransaction $recurringTransaction) public function update(RecurringTransaction $recurringTransaction)
{ {

View File

@@ -5,12 +5,17 @@ use Firefly\Storage\Reminder\ReminderRepositoryInterface as RRI;
/** /**
* Class ReminderController * Class ReminderController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class ReminderController extends BaseController class ReminderController extends BaseController
{ {
protected $_repository; protected $_repository;
/**
* @param RRI $repository
*/
public function __construct(RRI $repository) public function __construct(RRI $repository)
{ {
$this->_repository = $repository; $this->_repository = $repository;
@@ -33,8 +38,8 @@ class ReminderController extends BaseController
*/ */
public function modalDialog() public function modalDialog()
{ {
$today = new Carbon; $today = new Carbon;
$reminders = $this->_repository->get(); $reminders = $this->_repository->getPiggybankReminders();
/** @var \Reminder $reminder */ /** @var \Reminder $reminder */
foreach ($reminders as $index => $reminder) { foreach ($reminders as $index => $reminder) {
@@ -66,6 +71,8 @@ class ReminderController extends BaseController
/** /**
* @param Reminder $reminder * @param Reminder $reminder
*
* @return $this|\Illuminate\Http\RedirectResponse
*/ */
public function redirect(\Reminder $reminder) public function redirect(\Reminder $reminder)
{ {
@@ -83,6 +90,7 @@ class ReminderController extends BaseController
route('transactions.create', ['what' => 'transfer']) . '?' . http_build_query($parameters) route('transactions.create', ['what' => 'transfer']) . '?' . http_build_query($parameters)
); );
} }
return View::make('error')->with('message', 'No such reminder.');
} }

View File

@@ -6,6 +6,8 @@ use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as
/** /**
* Class TransactionController * Class TransactionController
*
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class TransactionController extends BaseController class TransactionController extends BaseController
{ {
@@ -30,18 +32,18 @@ class TransactionController extends BaseController
// get accounts with names and id's. // get accounts with names and id's.
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */ /** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
$accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface'); $accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts = $accountRepository->getActiveDefaultAsSelectList(); $accounts = $accountRepository->getActiveDefaultAsSelectList();
// get budgets as a select list. // get budgets as a select list.
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */ /** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
$budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface'); $budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets = $budgetRepository->getAsSelectList(); $budgets = $budgetRepository->getAsSelectList();
$budgets[0] = '(no budget)'; $budgets[0] = '(no budget)';
// get the piggy banks. // get the piggy banks.
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */ /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface'); $piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
$piggies = $piggyRepository->get(); $piggies = $piggyRepository->get();
return View::make('transactions.create')->with('accounts', $accounts)->with('budgets', $budgets)->with( return View::make('transactions.create')->with('accounts', $accounts)->with('budgets', $budgets)->with(
'what', $what 'what', $what
@@ -88,18 +90,18 @@ class TransactionController extends BaseController
// get accounts with names and id's. // get accounts with names and id's.
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */ /** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
$accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface'); $accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts = $accountRepository->getActiveDefaultAsSelectList(); $accounts = $accountRepository->getActiveDefaultAsSelectList();
// get budgets as a select list. // get budgets as a select list.
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */ /** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
$budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface'); $budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets = $budgetRepository->getAsSelectList(); $budgets = $budgetRepository->getAsSelectList();
$budgets[0] = '(no budget)'; $budgets[0] = '(no budget)';
// get the piggy banks. // get the piggy banks.
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */ /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface'); $piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
$piggies = $piggyRepository->get(); $piggies = $piggyRepository->get();
// piggy bank id? // piggy bank id?
$piggyBankId = null; $piggyBankId = null;
foreach ($journal->transactions as $t) { foreach ($journal->transactions as $t) {
@@ -107,7 +109,7 @@ class TransactionController extends BaseController
} }
// data to properly display form: // data to properly display form:
$data = [ $data = [
'date' => $journal->date->format('Y-m-d'), 'date' => $journal->date->format('Y-m-d'),
'category' => '', 'category' => '',
'budget_id' => 0, 'budget_id' => 0,
@@ -119,23 +121,23 @@ class TransactionController extends BaseController
} }
switch ($journal->transactiontype->type) { switch ($journal->transactiontype->type) {
case 'Withdrawal': case 'Withdrawal':
$data['account_id'] = $journal->transactions[0]->account->id; $data['account_id'] = $journal->transactions[0]->account->id;
$data['beneficiary'] = $journal->transactions[1]->account->name; $data['beneficiary'] = $journal->transactions[1]->account->name;
$data['amount'] = floatval($journal->transactions[1]->amount); $data['amount'] = floatval($journal->transactions[1]->amount);
$budget = $journal->budgets()->first(); $budget = $journal->budgets()->first();
if (!is_null($budget)) { if (!is_null($budget)) {
$data['budget_id'] = $budget->id; $data['budget_id'] = $budget->id;
} }
break; break;
case 'Deposit': case 'Deposit':
$data['account_id'] = $journal->transactions[1]->account->id; $data['account_id'] = $journal->transactions[1]->account->id;
$data['beneficiary'] = $journal->transactions[0]->account->name; $data['beneficiary'] = $journal->transactions[0]->account->name;
$data['amount'] = floatval($journal->transactions[1]->amount); $data['amount'] = floatval($journal->transactions[1]->amount);
break; break;
case 'Transfer': case 'Transfer':
$data['account_from_id'] = $journal->transactions[1]->account->id; $data['account_from_id'] = $journal->transactions[1]->account->id;
$data['account_to_id'] = $journal->transactions[0]->account->id; $data['account_to_id'] = $journal->transactions[0]->account->id;
$data['amount'] = floatval($journal->transactions[1]->amount); $data['amount'] = floatval($journal->transactions[1]->amount);
break; break;
} }
@@ -150,15 +152,15 @@ class TransactionController extends BaseController
public function index() public function index()
{ {
$start = is_null(Input::get('startdate')) ? null : new Carbon(Input::get('startdate')); $start = is_null(Input::get('startdate')) ? null : new Carbon(Input::get('startdate'));
$end = is_null(Input::get('enddate')) ? null : new Carbon(Input::get('enddate')); $end = is_null(Input::get('enddate')) ? null : new Carbon(Input::get('enddate'));
if ($start <= $end && !is_null($start) && !is_null($end)) { if ($start <= $end && !is_null($start) && !is_null($end)) {
$journals = $this->_repository->paginate(25, $start, $end); $journals = $this->_repository->paginate(25, $start, $end);
$filtered = true; $filtered = true;
$filters = ['start' => $start, 'end' => $end]; $filters = ['start' => $start, 'end' => $end];
} else { } else {
$journals = $this->_repository->paginate(25); $journals = $this->_repository->paginate(25);
$filtered = false; $filtered = false;
$filters = null; $filters = null;
} }
@@ -192,12 +194,12 @@ class TransactionController extends BaseController
if (Input::get('reminder')) { if (Input::get('reminder')) {
/** @var \Firefly\Storage\Reminder\ReminderRepositoryInterface $reminders */ /** @var \Firefly\Storage\Reminder\ReminderRepositoryInterface $reminders */
$reminders = App::make('Firefly\Storage\Reminder\ReminderRepositoryInterface'); $reminders = App::make('Firefly\Storage\Reminder\ReminderRepositoryInterface');
$reminder = $reminders->find(Input::get('reminder')); $reminder = $reminders->find(Input::get('reminder'));
$reminders->deactivate($reminder); $reminders->deactivate($reminder);
} }
// trigger the creation for recurring transactions. // trigger the creation for recurring transactions.
Event::fire('journals.store',[$journal]); Event::fire('journals.store', [$journal]);
if (Input::get('create') == '1') { if (Input::get('create') == '1') {
return Redirect::route('transactions.create', [$what])->withInput(); return Redirect::route('transactions.create', [$what])->withInput();
@@ -226,7 +228,7 @@ class TransactionController extends BaseController
if ($journal->validate()) { if ($journal->validate()) {
// has been saved, return to index: // has been saved, return to index:
Session::flash('success', 'Transaction updated!'); Session::flash('success', 'Transaction updated!');
Event::fire('journals.update',[$journal]); Event::fire('journals.update', [$journal]);
return Redirect::route('transactions.index'); return Redirect::route('transactions.index');
} else { } else {

View File

@@ -17,7 +17,7 @@ class UserController extends BaseController
*/ */
public function __construct(URI $user, EHI $email) public function __construct(URI $user, EHI $email)
{ {
$this->user = $user; $this->user = $user;
$this->email = $email; $this->email = $email;
} }
@@ -41,11 +41,11 @@ class UserController extends BaseController
public function postLogin() public function postLogin()
{ {
$rememberMe = Input::get('remember_me') == '1'; $rememberMe = Input::get('remember_me') == '1';
$data = [ $data = [
'email' => Input::get('email'), 'email' => Input::get('email'),
'password' => Input::get('password') 'password' => Input::get('password')
]; ];
$result = Auth::attempt($data, $rememberMe); $result = Auth::attempt($data, $rememberMe);
if ($result) { if ($result) {
Session::flash('success', 'Logged in!'); Session::flash('success', 'Logged in!');