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
{ {
@@ -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
@@ -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);

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
{ {
@@ -89,7 +91,7 @@ class CategoryController extends BaseController
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,6 +16,12 @@ 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;
@@ -38,8 +45,11 @@ 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');

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
{ {

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
{ {
@@ -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!');

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
{ {
@@ -26,6 +30,8 @@ class PiggybankController extends BaseController
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggyBank
*
* @return $this
*/ */
public function addMoney(Piggybank $piggyBank) public function addMoney(Piggybank $piggyBank)
{ {
@@ -115,7 +121,7 @@ class PiggybankController extends BaseController
$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 = [];
@@ -175,6 +181,8 @@ class PiggybankController extends BaseController
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggyBank
*
* @return $this
*/ */
public function removeMoney(Piggybank $piggyBank) public function removeMoney(Piggybank $piggyBank)
{ {
@@ -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
{ {

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;
@@ -34,7 +39,7 @@ 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
{ {
@@ -197,7 +199,7 @@ class TransactionController extends BaseController
} }
// 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 {