mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-08 10:48:13 +00:00
Code cleanup.
This commit is contained in:
@@ -7,7 +7,7 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Pref;
|
||||
/**
|
||||
* Class BudgetController
|
||||
*
|
||||
* TODO move AJAX methods to their own BudgetAjaxControlle
|
||||
* TODO move AJAX methods to their own BudgetAjaxController
|
||||
* TODO Find out what constitutes proper camelCase
|
||||
* TODO How is object coupling counted?
|
||||
*
|
||||
@@ -44,7 +44,7 @@ class BudgetController extends BaseController
|
||||
public function amount(Budget $budget)
|
||||
{
|
||||
$amount = intval(Input::get('amount'));
|
||||
$date = Session::get('start',Carbon::now()->startOfMonth());
|
||||
$date = Session::get('start', Carbon::now()->startOfMonth());
|
||||
$limitRepetition = $this->_repository->updateLimitAmount($budget, $date, $amount);
|
||||
|
||||
return Response::json(['name' => $budget->name, 'repetition' => $limitRepetition->id]);
|
||||
@@ -112,16 +112,18 @@ class BudgetController extends BaseController
|
||||
$budgets->each(
|
||||
function (Budget $budget) {
|
||||
/** @noinspection PhpUndefinedFieldInspection */
|
||||
$budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start',Carbon::now()->startOfMonth()));
|
||||
$budget->spent = $this->_repository->spentInMonth($budget, \Session::get('start', Carbon::now()->startOfMonth()));
|
||||
/** @noinspection PhpUndefinedFieldInspection */
|
||||
$budget->currentRep = $budget->limitrepetitions()->where('limit_repetitions.startdate', \Session::get('start',Carbon::now()->startOfMonth())->format('Y-m-d'))->first(
|
||||
$budget->currentRep = $budget->limitrepetitions()->where(
|
||||
'limit_repetitions.startdate', \Session::get('start', Carbon::now()->startOfMonth())->format('Y-m-d')
|
||||
)->first(
|
||||
['limit_repetitions.*']
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$spent = $budgets->sum('spent');
|
||||
$amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
|
||||
$amount = $this->_preferences->get('budgetIncomeTotal' . \Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000)->data;
|
||||
$overspent = $spent > $amount;
|
||||
$spentPCT = $overspent ? ceil($amount / $spent * 100) : ceil($spent / $amount * 100);
|
||||
|
||||
@@ -133,7 +135,7 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
$this->_preferences->set('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
|
||||
$this->_preferences->set('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), intval(Input::get('amount')));
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
@@ -146,13 +148,13 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function show(Budget $budget, LimitRepetition $repetition = null)
|
||||
{
|
||||
if (!is_null($repetition) && $repetition->limit->budget->id != $budget->id) {
|
||||
if (!is_null($repetition) && $repetition->budgetlimit->budget->id != $budget->id) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
$hideBudget = true; // used in transaction list.
|
||||
$journals = $this->_repository->getJournals($budget, $repetition);
|
||||
$limits = $repetition ? [$repetition->limit] : $budget->limits()->orderBy('startdate', 'DESC')->get();
|
||||
$limits = $repetition ? [$repetition->limit] : $budget->budgetlimits()->orderBy('startdate', 'DESC')->get();
|
||||
$subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
|
||||
|
||||
return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget'));
|
||||
@@ -244,7 +246,7 @@ class BudgetController extends BaseController
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
$budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start',Carbon::now()->startOfMonth())->format('FY'), 1000);
|
||||
$budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start', Carbon::now()->startOfMonth())->format('FY'), 1000);
|
||||
|
||||
return View::make('budgets.income')->with('amount', $budgetAmount);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Grumpydictator\Gchart\GChart as GChart;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*
|
||||
* Class GoogleChartController
|
||||
*/
|
||||
class GoogleChartController extends BaseController
|
||||
@@ -119,11 +120,9 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
public function allBudgetsHomeChart()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
$this->_chart->addColumn('Budget', 'string');
|
||||
$this->_chart->addColumn('Budgeted', 'number');
|
||||
$this->_chart->addColumn('Spent', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\Budget $bdt */
|
||||
$bdt = App::make('FireflyIII\Database\Budget');
|
||||
@@ -165,7 +164,7 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
$expenses = floatval($budget->transactionjournals()->before($searchEnd)->after($searchStart)->lessThan(0)->sum('amount')) * -1;
|
||||
if ($expenses > 0) {
|
||||
$chart->addRow($budget->name, $limit, $expenses);
|
||||
$this->_chart->addRow($budget->name, $limit, $expenses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,12 +174,12 @@ class GoogleChartController extends BaseController
|
||||
*/
|
||||
$noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange(Session::get('start', Carbon::now()->startOfMonth()), Session::get('end'));
|
||||
$sum = $noBudgetSet->sum('amount') * -1;
|
||||
$chart->addRow('No budget', 0, $sum);
|
||||
$this->_chart->addRow('No budget', 0, $sum);
|
||||
|
||||
|
||||
$chart->generate();
|
||||
$this->_chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
return Response::json($this->_chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,9 +29,9 @@ class HelpController extends BaseController
|
||||
}
|
||||
|
||||
// get the help-content from Github:
|
||||
$URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
|
||||
$uri = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
|
||||
try {
|
||||
$content = file_get_contents($URL);
|
||||
$content = file_get_contents($uri);
|
||||
} catch (ErrorException $e) {
|
||||
$content = '<p>There is no help for this route.</p>';
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ use FireflyIII\Database\TransactionJournal as TransactionJournalRepository;
|
||||
use FireflyIII\Report\ReportInterface as ReportHelper;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("CamelCase")
|
||||
*
|
||||
* Class ReportController
|
||||
*/
|
||||
class ReportController extends BaseController
|
||||
@@ -163,7 +165,7 @@ class ReportController extends BaseController
|
||||
public function unbalanced($year, $month)
|
||||
{
|
||||
try {
|
||||
$date = new Carbon($year . '-' . $month . '-01');
|
||||
new Carbon($year . '-' . $month . '-01');
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
@@ -45,11 +45,11 @@ class TransactionController extends BaseController
|
||||
}
|
||||
}
|
||||
$unique = array_unique($ids);
|
||||
if (count($ids) > 0) {
|
||||
if (count($unique) > 0) {
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $repository */
|
||||
$repository = App::make('FireflyIII\Database\TransactionJournal');
|
||||
$set = $repository->getByIds($ids);
|
||||
$set = $repository->getByIds($unique);
|
||||
$set->each(
|
||||
function (TransactionJournal $journal) {
|
||||
$journal->amount = mf($journal->getAmount());
|
||||
@@ -544,6 +544,7 @@ class TransactionController extends BaseController
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return $this
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(TransactionJournal $journal)
|
||||
|
||||
Reference in New Issue
Block a user