mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Changed a lot of parameters.
This commit is contained in:
@@ -36,7 +36,7 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create($what = 'asset')
|
||||
public function create(string $what = 'asset')
|
||||
{
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(ARI $repository, $what)
|
||||
public function index(ARI $repository, string $what)
|
||||
{
|
||||
$subTitle = trans('firefly.' . $what . '_accounts');
|
||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||
@@ -275,11 +275,11 @@ class AccountController extends Controller
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param $entryId
|
||||
* @param int $entryId
|
||||
*
|
||||
* @return null|mixed
|
||||
*/
|
||||
protected function isInArray(array $array, $entryId)
|
||||
protected function isInArray(array $array, int $entryId)
|
||||
{
|
||||
if (isset($array[$entryId])) {
|
||||
return $array[$entryId];
|
||||
|
@@ -205,11 +205,11 @@ class AuthController extends Controller
|
||||
/**
|
||||
* Get the failed login message.
|
||||
*
|
||||
* @param $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFailedLoginMessage($message)
|
||||
protected function getFailedLoginMessage(string $message)
|
||||
{
|
||||
if (strlen($message) > 0) {
|
||||
return $message;
|
||||
@@ -221,11 +221,11 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
* @param string $email
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isBlockedDomain($email)
|
||||
protected function isBlockedDomain(string $email)
|
||||
{
|
||||
$parts = explode('@', $email);
|
||||
$blocked = $this->getBlockedDomains();
|
||||
@@ -241,12 +241,11 @@ class AuthController extends Controller
|
||||
* Get the failed login response instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @param $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function sendFailedLoginResponse(Request $request, $message)
|
||||
protected function sendFailedLoginResponse(Request $request, string $message)
|
||||
{
|
||||
return redirect()->back()
|
||||
->withInput($request->only($this->loginUsername(), 'remember'))
|
||||
|
@@ -229,7 +229,7 @@ class BudgetController extends Controller
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
||||
$journals = $repository->getJournals($budget, $repetition);
|
||||
$journals = $repository->getJournals($budget, $repetition, 50);
|
||||
|
||||
if (is_null($repetition->id)) {
|
||||
$start = $repository->firstActivity($budget);
|
||||
|
@@ -213,7 +213,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showWithDate(SCRI $repository, Category $category, $date)
|
||||
public function showWithDate(SCRI $repository, Category $category, string $date)
|
||||
{
|
||||
$carbon = new Carbon($date);
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
|
@@ -43,7 +43,7 @@ class AccountController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
|
@@ -35,87 +35,6 @@ class BudgetController extends Controller
|
||||
$this->generator = app('FireflyIII\Generator\Chart\Budget\BudgetChartGeneratorInterface');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function multiYear(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($reportType);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($accounts);
|
||||
$cache->addProperty($budgets);
|
||||
$cache->addProperty('multiYearBudget');
|
||||
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the budgeted amounts for each budgets in each year.
|
||||
*/
|
||||
$budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end);
|
||||
$budgetedArray = [];
|
||||
/** @var Budget $entry */
|
||||
foreach ($budgetedSet as $entry) {
|
||||
$budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted;
|
||||
}
|
||||
|
||||
$set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end);
|
||||
$entries = new Collection;
|
||||
// go by budget, not by year.
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$entry = ['name' => '', 'spent' => [], 'budgeted' => []];
|
||||
$id = $budget->id;
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart < $end) {
|
||||
// fix the date:
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd->endOfYear();
|
||||
|
||||
// save to array:
|
||||
$year = $currentStart->year;
|
||||
$entry['name'] = $budget->name;
|
||||
$spent = 0;
|
||||
$budgeted = 0;
|
||||
if (isset($set[$id]['entries'][$year])) {
|
||||
$spent = $set[$id]['entries'][$year] * -1;
|
||||
}
|
||||
|
||||
if (isset($budgetedArray[$id][$year])) {
|
||||
$budgeted = round($budgetedArray[$id][$year], 2);
|
||||
}
|
||||
|
||||
$entry['spent'][$year] = $spent;
|
||||
$entry['budgeted'][$year] = $budgeted;
|
||||
|
||||
// jump to next year.
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();
|
||||
}
|
||||
$entries->push($entry);
|
||||
}
|
||||
// generate chart with data:
|
||||
$data = $this->generator->multiYear($entries);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Budget $budget
|
||||
@@ -298,10 +217,91 @@ class BudgetController extends Controller
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) // need all parameters
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function year(BudgetRepositoryInterface $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function multiYear(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $budgets)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($reportType);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($accounts);
|
||||
$cache->addProperty($budgets);
|
||||
$cache->addProperty('multiYearBudget');
|
||||
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the budgeted amounts for each budgets in each year.
|
||||
*/
|
||||
$budgetedSet = $repository->getBudgetedPerYear($budgets, $start, $end);
|
||||
$budgetedArray = [];
|
||||
/** @var Budget $entry */
|
||||
foreach ($budgetedSet as $entry) {
|
||||
$budgetedArray[$entry->id][$entry->dateFormatted] = $entry->budgeted;
|
||||
}
|
||||
|
||||
$set = $repository->getBudgetsAndExpensesPerYear($budgets, $accounts, $start, $end);
|
||||
$entries = new Collection;
|
||||
// go by budget, not by year.
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$entry = ['name' => '', 'spent' => [], 'budgeted' => []];
|
||||
$id = $budget->id;
|
||||
$currentStart = clone $start;
|
||||
while ($currentStart < $end) {
|
||||
// fix the date:
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd->endOfYear();
|
||||
|
||||
// save to array:
|
||||
$year = $currentStart->year;
|
||||
$entry['name'] = $budget->name;
|
||||
$spent = 0;
|
||||
$budgeted = 0;
|
||||
if (isset($set[$id]['entries'][$year])) {
|
||||
$spent = $set[$id]['entries'][$year] * -1;
|
||||
}
|
||||
|
||||
if (isset($budgetedArray[$id][$year])) {
|
||||
$budgeted = round($budgetedArray[$id][$year], 2);
|
||||
}
|
||||
|
||||
$entry['spent'][$year] = $spent;
|
||||
$entry['budgeted'][$year] = $budgeted;
|
||||
|
||||
// jump to next year.
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();
|
||||
}
|
||||
$entries->push($entry);
|
||||
}
|
||||
// generate chart with data:
|
||||
$data = $this->generator->multiYear($entries);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param $reportType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function year(BudgetRepositoryInterface $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties();
|
||||
|
@@ -114,7 +114,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function earnedInPeriod(CRI $repository, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function earnedInPeriod(CRI $repository, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$cache = new CacheProperties; // chart properties for cache:
|
||||
$cache->addProperty($start);
|
||||
@@ -215,7 +215,7 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function multiYear($reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories)
|
||||
public function multiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts, Collection $categories)
|
||||
{
|
||||
/** @var CRI $repository */
|
||||
$repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
|
@@ -45,7 +45,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInOut(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function yearInOut(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
@@ -88,7 +88,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInOutSummarized(ReportQueryInterface $query, $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function yearInOutSummarized(ReportQueryInterface $query, string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
|
||||
// chart properties for cache:
|
||||
|
@@ -25,7 +25,7 @@ class HelpController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(HelpInterface $help, $route)
|
||||
public function show(HelpInterface $help, string $route)
|
||||
{
|
||||
$content = [
|
||||
'text' => '<p>There is no help for this route!</p>',
|
||||
|
@@ -122,7 +122,7 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function validatePassword($old, $new1)
|
||||
protected function validatePassword(string $old, string $new1)
|
||||
{
|
||||
if ($new1 == $old) {
|
||||
return trans('firefly.should_change');
|
||||
|
@@ -78,7 +78,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
// throw an error if necessary.
|
||||
if ($end < $start) {
|
||||
@@ -130,7 +130,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
private function defaultMonth($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
private function defaultMonth(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$incomeTopLength = 8;
|
||||
$expenseTopLength = 8;
|
||||
@@ -171,7 +171,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
private function defaultMultiYear($reportType, $start, $end, $accounts)
|
||||
private function defaultMultiYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
|
||||
$incomeTopLength = 8;
|
||||
@@ -208,7 +208,7 @@ class ReportController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
private function defaultYear($reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
private function defaultYear(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$incomeTopLength = 8;
|
||||
$expenseTopLength = 8;
|
||||
|
@@ -159,11 +159,11 @@ class TagController extends Controller
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function hideTagHelp($state)
|
||||
public function hideTagHelp(string $state)
|
||||
{
|
||||
|
||||
$state = $state == 'true' ? true : false;
|
||||
Preferences::set('hideTagHelp', $state);
|
||||
$newState = $state == 'true' ? true : false;
|
||||
Preferences::set('hideTagHelp', $newState);
|
||||
|
||||
return Response::json([true]);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ class TransactionController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(ARI $repository, $what = TransactionType::DEPOSIT)
|
||||
public function create(ARI $repository, string $what = TransactionType::DEPOSIT)
|
||||
{
|
||||
$what = strtolower($what);
|
||||
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
||||
@@ -211,7 +211,7 @@ class TransactionController extends Controller
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(JournalRepositoryInterface $repository, $what)
|
||||
public function index(JournalRepositoryInterface $repository, string $what)
|
||||
{
|
||||
$subTitleIcon = Config::get('firefly.transactionIconsByWhat.' . $what);
|
||||
$types = Config::get('firefly.transactionTypesByWhat.' . $what);
|
||||
|
@@ -33,14 +33,14 @@ Breadcrumbs::register(
|
||||
|
||||
// accounts
|
||||
Breadcrumbs::register(
|
||||
'accounts.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
|
||||
'accounts.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
|
||||
$breadcrumbs->parent('home');
|
||||
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what]));
|
||||
}
|
||||
);
|
||||
|
||||
Breadcrumbs::register(
|
||||
'accounts.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
|
||||
'accounts.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
|
||||
$breadcrumbs->parent('accounts.index', $what);
|
||||
$breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what]));
|
||||
}
|
||||
@@ -384,13 +384,13 @@ Breadcrumbs::register(
|
||||
|
||||
// transactions
|
||||
Breadcrumbs::register(
|
||||
'transactions.index', function (BreadCrumbGenerator $breadcrumbs, $what) {
|
||||
'transactions.index', function (BreadCrumbGenerator $breadcrumbs, string $what) {
|
||||
$breadcrumbs->parent('home');
|
||||
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what]));
|
||||
}
|
||||
);
|
||||
Breadcrumbs::register(
|
||||
'transactions.create', function (BreadCrumbGenerator $breadcrumbs, $what) {
|
||||
'transactions.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {
|
||||
$breadcrumbs->parent('transactions.index', $what);
|
||||
$breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('transactions.create', [$what]));
|
||||
}
|
||||
|
Reference in New Issue
Block a user