Some code cleanup and reordering

This commit is contained in:
James Cole
2016-01-24 15:58:16 +01:00
parent 2832d308f1
commit 97db618cd8
10 changed files with 453 additions and 458 deletions

View File

@@ -35,74 +35,6 @@ class ReportController extends Controller
}
/**
* @param ARI $repository
*
* @return View
* @internal param ReportHelperInterface $helper
*/
public function index(ARI $repository)
{
$start = Session::get('first');
$months = $this->helper->listOfMonths($start);
// does the user have shared accounts?
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
// get id's for quick links:
$accountIds = [];
/** @var Account $account */
foreach ($accounts as $account) {
$accountIds [] = $account->id;
}
$accountList = join(',', $accountIds);
return view(
'reports.index', compact(
'months', 'accounts', 'start', 'accountList'
)
);
}
/**
* @param $reportType
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return View
*/
public function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$incomeTopLength = 8;
$expenseTopLength = 8;
$accountReport = $this->helper->getAccountReport($start, $end, $accounts);
$incomes = $this->helper->getIncomeReport($start, $end, $accounts);
$expenses = $this->helper->getExpenseReport($start, $end, $accounts);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'year');
Session::flash('gaEventLabel', $start->format('Y'));
// and some id's, joined:
$accountIds = [];
/** @var Account $account */
foreach ($accounts as $account) {
$accountIds[] = $account->id;
}
$accountIds = join(',', $accountIds);
return view(
'reports.default.year',
compact(
'start', 'accountReport', 'incomes', 'reportType', 'accountIds', 'end',
'expenses', 'incomeTopLength', 'expenseTopLength'
)
);
}
/**
* @param $reportType
* @param Carbon $start
@@ -181,6 +113,73 @@ class ReportController extends Controller
);
}
/**
* @param $reportType
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
*
* @return View
*/
public function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
{
$incomeTopLength = 8;
$expenseTopLength = 8;
$accountReport = $this->helper->getAccountReport($start, $end, $accounts);
$incomes = $this->helper->getIncomeReport($start, $end, $accounts);
$expenses = $this->helper->getExpenseReport($start, $end, $accounts);
Session::flash('gaEventCategory', 'report');
Session::flash('gaEventAction', 'year');
Session::flash('gaEventLabel', $start->format('Y'));
// and some id's, joined:
$accountIds = [];
/** @var Account $account */
foreach ($accounts as $account) {
$accountIds[] = $account->id;
}
$accountIds = join(',', $accountIds);
return view(
'reports.default.year',
compact(
'start', 'accountReport', 'incomes', 'reportType', 'accountIds', 'end',
'expenses', 'incomeTopLength', 'expenseTopLength'
)
);
}
/**
* @param ARI $repository
*
* @return View
* @internal param ReportHelperInterface $helper
*/
public function index(ARI $repository)
{
$start = Session::get('first');
$months = $this->helper->listOfMonths($start);
// does the user have shared accounts?
$accounts = $repository->getAccounts(['Default account', 'Asset account']);
// get id's for quick links:
$accountIds = [];
/** @var Account $account */
foreach ($accounts as $account) {
$accountIds [] = $account->id;
}
$accountList = join(',', $accountIds);
return view(
'reports.index', compact(
'months', 'accounts', 'start', 'accountList'
)
);
}
/**
* @param $reportType
* @param Carbon $start