This commit is contained in:
James Cole
2014-12-06 17:53:25 +01:00
parent 792e8a9947
commit dbc95dd878
13 changed files with 157 additions and 64 deletions

View File

@@ -19,6 +19,8 @@ class AccountController extends BaseController
} }
/** /**
* @param $what
*
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function create($what) public function create($what)

View File

@@ -11,6 +11,9 @@ class BudgetController extends BaseController
{ {
/**
*
*/
public function __construct() public function __construct()
{ {
View::share('title', 'Budgets'); View::share('title', 'Budgets');
@@ -18,9 +21,10 @@ class BudgetController extends BaseController
} }
/** /**
* Update the amount for a budget's limitrepetition and/or create it.
*
* @param Budget $budget * @param Budget $budget
*
* @return \Illuminate\Http\JsonResponse
* @throws Exception
*/ */
public function amount(Budget $budget) public function amount(Budget $budget)
{ {
@@ -82,6 +86,11 @@ class BudgetController extends BaseController
return View::make('budgets.delete')->with('budget', $budget)->with('subTitle', 'Delete budget "' . $budget->name . '"'); return View::make('budgets.delete')->with('budget', $budget)->with('subTitle', 'Delete budget "' . $budget->name . '"');
} }
/**
* @param Budget $budget
*
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Budget $budget) public function destroy(Budget $budget)
{ {
/** @var \FireflyIII\Database\Budget $repos */ /** @var \FireflyIII\Database\Budget $repos */
@@ -115,7 +124,6 @@ class BudgetController extends BaseController
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */ /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface'); $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
$date = Session::get('start');
/** @var \FireflyIII\Database\Budget $repos */ /** @var \FireflyIII\Database\Budget $repos */
$repos = App::make('FireflyIII\Database\Budget'); $repos = App::make('FireflyIII\Database\Budget');
@@ -205,7 +213,6 @@ class BudgetController extends BaseController
// get nothing? i dunno // get nothing? i dunno
$limits = [$repetition->limit]; $limits = [$repetition->limit];
// get all transaction journals for this budget and limit repetition. // get all transaction journals for this budget and limit repetition.
$journals = [];
$subTitle = $budget->name . ' in ' . $repetition->startdate->format('F Y'); $subTitle = $budget->name . ' in ' . $repetition->startdate->format('F Y');
$journals = $repos->getTransactionJournalsInRepetition($budget, $repetition, 50); $journals = $repos->getTransactionJournalsInRepetition($budget, $repetition, 50);
} }
@@ -216,7 +223,8 @@ class BudgetController extends BaseController
} }
/** /**
* @return \Illuminate\Http\RedirectResponse * @return $this
* @throws FireflyException
*/ */
public function store() public function store()
{ {
@@ -263,6 +271,7 @@ class BudgetController extends BaseController
/** /**
* @param Budget $budget * @param Budget $budget
* *
* @return $this
* @throws FireflyException * @throws FireflyException
*/ */
public function update(Budget $budget) public function update(Budget $budget)

View File

@@ -90,7 +90,8 @@ class CategoryController extends BaseController
} }
/** /**
* @return $this|\Illuminate\Http\RedirectResponse * @return $this
* @throws FireflyException
*/ */
public function store() public function store()
{ {
@@ -137,7 +138,8 @@ class CategoryController extends BaseController
/** /**
* @param Category $category * @param Category $category
* *
* @return $this|\Illuminate\Http\RedirectResponse * @return $this
* @throws FireflyException
*/ */
public function update(Category $category) public function update(Category $category)
{ {

View File

@@ -68,6 +68,7 @@ class GoogleChartController extends BaseController
/** /**
* @param Account $account * @param Account $account
* @param string $view
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
@@ -148,6 +149,7 @@ class GoogleChartController extends BaseController
/** /**
* @param Account $account * @param Account $account
* @param string $view
* *
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
@@ -376,6 +378,12 @@ class GoogleChartController extends BaseController
} }
/**
* @param Budget $budget
* @param LimitRepetition $repetition
*
* @return \Illuminate\Http\JsonResponse
*/
public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition) public function budgetLimitSpending(\Budget $budget, \LimitRepetition $repetition)
{ {
$start = clone $repetition->startdate; $start = clone $repetition->startdate;
@@ -405,6 +413,8 @@ class GoogleChartController extends BaseController
} }
/** /**
* @param $year
*
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function budgetsReportChart($year) public function budgetsReportChart($year)
@@ -513,13 +523,17 @@ class GoogleChartController extends BaseController
} }
/**
* @param Piggybank $piggybank
*
* @return \Illuminate\Http\JsonResponse
*/
public function piggyBankHistory(\Piggybank $piggybank) public function piggyBankHistory(\Piggybank $piggybank)
{ {
/** @var \Grumpydictator\Gchart\GChart $chart */ /** @var \Grumpydictator\Gchart\GChart $chart */
$chart = App::make('gchart'); $chart = App::make('gchart');
$chart->addColumn('Date', 'date'); $chart->addColumn('Date', 'date');
$chart->addColumn('Balance', 'number'); $chart->addColumn('Balance', 'number');
$sum = 0;
$set = \DB::table('piggybank_events')->where('piggybank_id', $piggybank->id)->groupBy('date')->get(['date', DB::Raw('SUM(`amount`) AS `sum`')]); $set = \DB::table('piggybank_events')->where('piggybank_id', $piggybank->id)->groupBy('date')->get(['date', DB::Raw('SUM(`amount`) AS `sum`')]);
@@ -535,6 +549,8 @@ class GoogleChartController extends BaseController
/** /**
* @param RecurringTransaction $recurring * @param RecurringTransaction $recurring
*
* @return \Illuminate\Http\JsonResponse
*/ */
public function recurringOverview(RecurringTransaction $recurring) public function recurringOverview(RecurringTransaction $recurring)
{ {

View File

@@ -1,7 +1,15 @@
<?php <?php
/**
* Class HelpController
*/
class HelpController extends BaseController class HelpController extends BaseController
{ {
/**
* @param $route
*
* @return \Illuminate\Http\JsonResponse
*/
public function show($route) public function show($route)
{ {
// no valid route // no valid route

View File

@@ -6,48 +6,6 @@
*/ */
class HomeController extends BaseController class HomeController extends BaseController
{ {
public function cleanup()
{
Auth::loginUsingId(1);
/** @var \FireflyIII\Database\TransactionJournal $repository */
$repository = App::make('FireflyIII\Database\TransactionJournal');
/** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account');
$journals = $repository->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if ($journal->transactionType->type == 'Withdrawal') {
echo '#' . $journal->id . ': ' . e($journal->description);
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
if (floatval($transaction->amount) > 0) {
// this is the one with the beneficiary account!
if ($transaction->account->accountType->type == 'Beneficiary account') {
echo ', <span style="color:red;">should be an expense account</span>';
if (Input::get('update') == 'true') {
$newAccount = $acct->firstExpenseAccountOrCreate($transaction->account->name);
$transaction->account_id = $newAccount->id;
$transaction->save();
echo '<span style="color:darkgreen">, updated!</span>';
}
}
}
}
echo '<br />';
}
}
return '&nbsp;';
}
/** /**
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */

View File

@@ -59,7 +59,7 @@ class PiggybankController extends BaseController
} }
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggybank
* *
* @return $this * @return $this
*/ */
@@ -86,7 +86,7 @@ class PiggybankController extends BaseController
} }
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggybank
* *
* @return $this * @return $this
*/ */
@@ -117,6 +117,9 @@ class PiggybankController extends BaseController
)->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil'); )->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil');
} }
/**
* @return $this
*/
public function index() public function index()
{ {
/** @var \FireflyIII\Database\Piggybank $repos */ /** @var \FireflyIII\Database\Piggybank $repos */
@@ -226,6 +229,11 @@ class PiggybankController extends BaseController
return View::make('piggybanks.remove', compact('piggybank')); return View::make('piggybanks.remove', compact('piggybank'));
} }
/**
* @param Piggybank $piggybank
*
* @return $this
*/
public function show(Piggybank $piggybank) public function show(Piggybank $piggybank)
{ {
@@ -301,7 +309,8 @@ class PiggybankController extends BaseController
/** /**
* @param Piggybank $piggyBank * @param Piggybank $piggyBank
* *
* @return $this|\Illuminate\Http\RedirectResponse * @return $this
* @throws FireflyException
*/ */
public function update(Piggybank $piggyBank) public function update(Piggybank $piggyBank)
{ {

View File

@@ -3,7 +3,6 @@
/** /**
* Class PreferencesController * Class PreferencesController
* *
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class PreferencesController extends BaseController class PreferencesController extends BaseController
{ {

View File

@@ -5,10 +5,12 @@ use Illuminate\Support\MessageBag;
/** /**
* Class RecurringController * Class RecurringController
* *
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
*/ */
class RecurringController extends BaseController class RecurringController extends BaseController
{ {
/**
*
*/
public function __construct() public function __construct()
{ {
@@ -126,6 +128,10 @@ class RecurringController extends BaseController
); );
} }
/**
* @return $this
* @throws FireflyException
*/
public function store() public function store()
{ {
$data = Input::except('_token'); $data = Input::except('_token');
@@ -169,6 +175,12 @@ class RecurringController extends BaseController
} }
/**
* @param RecurringTransaction $recurringTransaction
*
* @return $this
* @throws FireflyException
*/
public function update(RecurringTransaction $recurringTransaction) public function update(RecurringTransaction $recurringTransaction)
{ {
/** @var \FireflyIII\Database\Recurring $repos */ /** @var \FireflyIII\Database\Recurring $repos */

View File

@@ -8,12 +8,21 @@ use FireflyIII\Exception\FireflyException;
class ReminderController extends BaseController class ReminderController extends BaseController
{ {
/**
*
*/
public function __construct() public function __construct()
{ {
View::share('title', 'Reminders'); View::share('title', 'Reminders');
View::share('mainTitleIcon', 'fa-lightbulb-o'); View::share('mainTitleIcon', 'fa-lightbulb-o');
} }
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
* @throws FireflyException
*/
public function act(Reminder $reminder) public function act(Reminder $reminder)
{ {
@@ -38,6 +47,11 @@ class ReminderController extends BaseController
} }
} }
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
public function dismiss(Reminder $reminder) public function dismiss(Reminder $reminder)
{ {
$reminder->active = 0; $reminder->active = 0;
@@ -47,6 +61,11 @@ class ReminderController extends BaseController
return Redirect::route('index'); return Redirect::route('index');
} }
/**
* @param Reminder $reminder
*
* @return \Illuminate\Http\RedirectResponse
*/
public function notnow(Reminder $reminder) public function notnow(Reminder $reminder)
{ {
$reminder->active = 0; $reminder->active = 0;
@@ -59,6 +78,8 @@ class ReminderController extends BaseController
/** /**
* @param Reminder $reminder * @param Reminder $reminder
*
* @return \Illuminate\View\View
*/ */
public function show(Reminder $reminder) public function show(Reminder $reminder)
{ {

View File

@@ -4,14 +4,23 @@ use Carbon\Carbon;
use FireflyIII\Exception\FireflyException; use FireflyIII\Exception\FireflyException;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
/**
* Class RepeatedExpenseController
*/
class RepeatedExpenseController extends BaseController class RepeatedExpenseController extends BaseController
{ {
/**
*
*/
public function __construct() public function __construct()
{ {
View::share('title', 'Repeated expenses'); View::share('title', 'Repeated expenses');
View::share('mainTitleIcon', 'fa-rotate-left'); View::share('mainTitleIcon', 'fa-rotate-left');
} }
/**
* @return $this
*/
public function create() public function create()
{ {
/** @var \FireflyIII\Database\Account $acct */ /** @var \FireflyIII\Database\Account $acct */
@@ -27,6 +36,9 @@ class RepeatedExpenseController extends BaseController
); );
} }
/**
* @return \Illuminate\View\View
*/
public function index() public function index()
{ {
@@ -45,6 +57,11 @@ class RepeatedExpenseController extends BaseController
return View::make('repeatedexpense.index', compact('expenses', 'subTitle')); return View::make('repeatedexpense.index', compact('expenses', 'subTitle'));
} }
/**
* @param Piggybank $piggyBank
*
* @return \Illuminate\View\View
*/
public function show(Piggybank $piggyBank) public function show(Piggybank $piggyBank)
{ {
$subTitle = $piggyBank->name; $subTitle = $piggyBank->name;
@@ -56,7 +73,7 @@ class RepeatedExpenseController extends BaseController
$repetitions = $piggyBank->piggybankrepetitions()->get(); $repetitions = $piggyBank->piggybankrepetitions()->get();
$repetitions->each( $repetitions->each(
function (PiggybankRepetition $repetition) use ($repository) { function (PiggybankRepetition $repetition) use ($repository) {
$repetition = $repository->calculateParts($repetition); $repository->calculateParts($repetition);
} }
); );
@@ -64,7 +81,8 @@ class RepeatedExpenseController extends BaseController
} }
/** /**
* * @return $this
* @throws FireflyException
*/ */
public function store() public function store()
{ {

View File

@@ -7,15 +7,19 @@ use Carbon\Carbon;
class ReportController extends BaseController class ReportController extends BaseController
{ {
/**
* @param $year
* @param $month
*
* @return \Illuminate\View\View
*/
public function budgets($year, $month) public function budgets($year, $month)
{ {
try { try {
$date = new Carbon($year . '-' . $month . '-01'); $start = new Carbon($year . '-' . $month . '-01');
} catch (Exception $e) { } catch (Exception $e) {
App::abort(500); App::abort(500);
} }
$start = new Carbon($year . '-' . $month . '-01');
$end = clone $start; $end = clone $start;
$title = 'Reports'; $title = 'Reports';
$subTitle = 'Budgets in ' . $start->format('F Y'); $subTitle = 'Budgets in ' . $start->format('F Y');
@@ -145,6 +149,12 @@ class ReportController extends BaseController
return View::make('reports.index', compact('years', 'months'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart'); return View::make('reports.index', compact('years', 'months'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart');
} }
/**
* @param $year
* @param $month
*
* @return \Illuminate\View\View
*/
public function unbalanced($year, $month) public function unbalanced($year, $month)
{ {
try { try {

View File

@@ -23,7 +23,14 @@ class TransactionController extends BaseController
View::share('mainTitleIcon', 'fa-repeat'); View::share('mainTitleIcon', 'fa-repeat');
} }
// TODO this needs cleaning up and thinking over. /**
*
* TODO this needs cleaning up and thinking over.
*
* @param TransactionJournal $journal
*
* @return array|\Illuminate\Http\JsonResponse
*/
public function alreadyRelated(TransactionJournal $journal) public function alreadyRelated(TransactionJournal $journal)
{ {
@@ -155,7 +162,11 @@ class TransactionController extends BaseController
return Redirect::route('transactions.index', $return); return Redirect::route('transactions.index', $return);
} }
// TODO this needs cleaning up and thinking over. /**
* TODO this needs cleaning up and thinking over.
*
* @return \Illuminate\Http\JsonResponse
*/
public function doRelate() public function doRelate()
{ {
$id = intval(Input::get('id')); $id = intval(Input::get('id'));
@@ -352,6 +363,11 @@ class TransactionController extends BaseController
} }
/**
* @param TransactionJournal $journal
*
* @return \Illuminate\View\View
*/
public function relate(TransactionJournal $journal) public function relate(TransactionJournal $journal)
{ {
$groups = $journal->transactiongroups()->get(); $groups = $journal->transactiongroups()->get();
@@ -369,7 +385,13 @@ class TransactionController extends BaseController
return View::make('transactions.relate', compact('journal', 'members')); return View::make('transactions.relate', compact('journal', 'members'));
} }
// TODO this needs cleaning up and thinking over. /**
* TODO this needs cleaning up and thinking over.
*
* @param TransactionJournal $journal
*
* @return \Illuminate\Http\JsonResponse
*/
public function relatedSearch(TransactionJournal $journal) public function relatedSearch(TransactionJournal $journal)
{ {
$search = e(trim(Input::get('searchValue'))); $search = e(trim(Input::get('searchValue')));
@@ -490,7 +512,14 @@ class TransactionController extends BaseController
} }
} }
// TODO this needs cleaning up and thinking over. /**
* TODO this needs cleaning up and thinking over.
*
* @param TransactionJournal $journal
*
* @return \Illuminate\Http\JsonResponse
* @throws Exception
*/
public function unrelate(TransactionJournal $journal) public function unrelate(TransactionJournal $journal)
{ {
$groups = $journal->transactiongroups()->get(); $groups = $journal->transactiongroups()->get();