Various code cleanup.

This commit is contained in:
James Cole
2017-12-22 18:32:43 +01:00
parent f13a93348f
commit 8bd76d1ff0
188 changed files with 383 additions and 396 deletions

View File

@@ -43,6 +43,7 @@ use Session;
/**
* Class ReconcileController.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ReconcileController extends Controller
@@ -72,7 +73,7 @@ class ReconcileController extends Controller
*/
public function edit(TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.edit', [$journal->id]));
}
// view related code
@@ -99,7 +100,6 @@ class ReconcileController extends Controller
'accounts.reconcile.edit',
compact('journal', 'subTitle')
)->with('data', $preFilled);
}
/**
@@ -166,6 +166,7 @@ class ReconcileController extends Controller
* @param Carbon|null $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
* @throws FireflyException
*/
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
@@ -226,7 +227,7 @@ class ReconcileController extends Controller
*/
public function show(JournalRepositoryInterface $repository, TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.show', [$journal->id]));
}
$subTitle = trans('firefly.reconciliation') . ' "' . $journal->description . '"';
@@ -235,7 +236,6 @@ class ReconcileController extends Controller
$transaction = $repository->getAssetTransaction($journal);
$account = $transaction->account;
return view('accounts.reconcile.show', compact('journal', 'subTitle', 'transaction', 'account'));
}
@@ -297,6 +297,7 @@ class ReconcileController extends Controller
* @param Carbon $end
*
* @return mixed
*
* @throws \Throwable
* @throws FireflyException
*/
@@ -346,10 +347,10 @@ class ReconcileController extends Controller
*/
public function update(ReconciliationFormRequest $request, AccountRepositoryInterface $repository, TransactionJournal $journal)
{
if ($journal->transactionType->type !== TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION !== $journal->transactionType->type) {
return redirect(route('transactions.show', [$journal->id]));
}
if (bccomp('0', $request->get('amount')) === 0) {
if (0 === bccomp('0', $request->get('amount'))) {
Session::flash('error', trans('firefly.amount_cannot_be_zero'));
return redirect(route('accounts.reconcile.edit', [$journal->id]))->withInput();
@@ -368,10 +369,8 @@ class ReconcileController extends Controller
// redirect to previous URL.
return redirect($this->getPreviousUri('reconcile.edit.uri'));
}
/**
* @param Account $account
*

View File

@@ -152,6 +152,7 @@ class AccountController extends Controller
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @return View
*
* @throws FireflyException
* @throws FireflyException
* @throws FireflyException
@@ -229,9 +230,9 @@ class AccountController extends Controller
$types = config('firefly.accountTypesByIdentifier.' . $what);
$collection = $repository->getAccountsByType($types);
$total = $collection->count();
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
$page = 0 === intval($request->get('page')) ? 1 : intval($request->get('page'));
$pageSize = intval(Preferences::get('listPageSize', 50)->data);
$accounts = $collection->slice(($page-1) * $pageSize, $pageSize);
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
unset($collection);
/** @var Carbon $start */
$start = clone session('start', Carbon::now()->startOfMonth());
@@ -272,6 +273,7 @@ class AccountController extends Controller
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // long and complex but not that excessively so.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*
* @throws FireflyException
*/
public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')

View File

@@ -45,7 +45,6 @@ class HomeController extends Controller
$this->middleware(IsSandStormUser::class)->except(['index']);
}
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/

View File

@@ -24,7 +24,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\LinkTypeFormRequest;
use FireflyIII\Models\LinkType;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;

View File

@@ -149,6 +149,7 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @return \Illuminate\Http\Response
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function preview(Attachment $attachment)

View File

@@ -65,6 +65,7 @@ class LoginController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response|void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)

View File

@@ -41,7 +41,6 @@ use Session;
*/
class RegisterController extends Controller
{
use RegistersUsers;
/**

View File

@@ -69,7 +69,6 @@ class TwoFactorController extends Controller
/**
* @return mixed
*
*/
public function lostTwoFactor()
{

View File

@@ -246,7 +246,6 @@ class BillController extends Controller
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('bills.show', [$bill->id]));
$bill->paidDates = $repository->getPaidDatesInRange($bill, $date, $end);
$bill->payDates = $repository->getPayDatesInRange($bill, $date, $end);
$lastPaidDate = $this->lastPaidDate($repository->getPaidDatesInRange($bill, $date, $end), $date);
@@ -274,7 +273,6 @@ class BillController extends Controller
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name])));
Preferences::mark();
/** @var array $files */
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
$this->attachments->saveAttachmentsForModel($bill, $files);
@@ -341,7 +339,7 @@ class BillController extends Controller
*/
private function lastPaidDate(Collection $dates, Carbon $default): Carbon
{
if ($dates->count() === 0) {
if (0 === $dates->count()) {
return $default; // @codeCoverageIgnore
}
$latest = $dates->first();
@@ -353,6 +351,5 @@ class BillController extends Controller
}
return $latest;
}
}

View File

@@ -85,7 +85,7 @@ class BudgetController extends Controller
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
if (bccomp($amount, '0') === 0) {
if (0 === bccomp($amount, '0')) {
$budgetLimit = null;
}
@@ -302,7 +302,7 @@ class BudgetController extends Controller
$currentStart = app('navigation')->addPeriod($currentStart, $range, 0);
++$count;
}
if ($count === 0) {
if (0 === $count) {
$count = 1; // @codeCoverageIgnore
}
$result['available'] = bcdiv($total, strval($count));

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
@@ -341,7 +340,6 @@ class AccountController extends Controller
* @param Carbon $start
*
* @return \Illuminate\Http\JsonResponse
*
*/
public function period(Account $account, Carbon $start)
{

View File

@@ -63,7 +63,6 @@ class ExpenseReportController extends Controller
);
}
/**
* @param Collection $accounts
* @param Collection $expense
@@ -74,7 +73,6 @@ class ExpenseReportController extends Controller
*/
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
$cache = new CacheProperties;
$cache->addProperty('chart.expense.report.main');
$cache->addProperty($accounts);
@@ -82,7 +80,7 @@ class ExpenseReportController extends Controller
$cache->addProperty($start);
$cache->addProperty($end);
if ($cache->has()) {
return Response::json($cache->get()); // @codeCoverageIgnore
return Response::json($cache->get()); // @codeCoverageIgnore
}
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);

View File

@@ -104,7 +104,7 @@ class HomeController extends Controller
*/
public function displayDebug(Request $request)
{
$phpVersion = str_replace('~','\~',PHP_VERSION);
$phpVersion = str_replace('~', '\~', PHP_VERSION);
$phpOs = php_uname();
$interface = PHP_SAPI;
$now = Carbon::create()->format('Y-m-d H:i:s e');

View File

@@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
@@ -66,6 +64,7 @@ class ConfigurationController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*
* @throws FireflyException
*/
public function index(ImportJob $job)
@@ -95,6 +94,7 @@ class ConfigurationController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function post(Request $request, ImportJob $job)
@@ -141,4 +141,4 @@ class ConfigurationController extends Controller
return $configurator;
}
}
}

View File

@@ -18,16 +18,13 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Import\Routine\ImportRoutine;
use FireflyIII\Import\Routine\RoutineInterface;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
@@ -61,7 +58,7 @@ class IndexController extends Controller
}
);
$this->middleware(IsDemoUser::class)->except(['create','index']);
$this->middleware(IsDemoUser::class)->except(['create', 'index']);
}
/**
@@ -70,11 +67,12 @@ class IndexController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function create(string $bank)
{
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
}
@@ -82,7 +80,6 @@ class IndexController extends Controller
// from here, always go to configure step.
return redirect(route('import.configure', [$importJob->key]));
}
/**
@@ -139,11 +136,11 @@ class IndexController extends Controller
* @param ImportJob $job
*
* @return \Illuminate\Http\JsonResponse
*
* @throws FireflyException
*/
public function start(ImportJob $job)
{
$type = $job->file_type;
$key = sprintf('import.routine.%s', $type);
$className = config($key);
@@ -162,5 +159,4 @@ class IndexController extends Controller
throw new FireflyException('Job did not complete successfully. Please review the log files.');
}
}
}

View File

@@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
@@ -43,11 +41,12 @@ class PrerequisitesController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|null
*
* @throws FireflyException
*/
public function index(string $bank)
{
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
}
$class = strval(config(sprintf('import.prerequisites.%s', $bank)));
@@ -83,6 +82,7 @@ class PrerequisitesController extends Controller
* @param string $bank
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function post(Request $request, string $bank)
@@ -112,6 +112,4 @@ class PrerequisitesController extends Controller
return redirect(route('import.create-job', [$bank]));
}
}
}

View File

@@ -18,12 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Import;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
@@ -34,7 +32,6 @@ use Response;
*/
class StatusController extends Controller
{
/**
*
*/
@@ -115,5 +112,4 @@ class StatusController extends Controller
return Response::json($result);
}
}
}

View File

@@ -88,7 +88,6 @@ class JavascriptController extends Controller
/**
* @param Request $request
*
* @param AccountRepositoryInterface $repository
* @param CurrencyRepositoryInterface $currencyRepository
*
@@ -141,7 +140,7 @@ class JavascriptController extends Controller
$end = session('end');
$first = session('first');
$title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
$isCustom = session('is_custom_range', false) === true;
$isCustom = true === session('is_custom_range', false);
$today = new Carbon;
$ranges = [
// first range is the current range:
@@ -182,7 +181,6 @@ class JavascriptController extends Controller
$index = strval(trans('firefly.everything'));
$ranges[$index] = [$first, new Carbon];
$return = [
'title' => $title,
'configuration' => [

View File

@@ -36,6 +36,7 @@ class FrontpageController extends Controller
* @param PiggyBankRepositoryInterface $repository
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function piggyBanks(PiggyBankRepositoryInterface $repository)

View File

@@ -46,6 +46,7 @@ class JsonController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function action(Request $request)
@@ -121,6 +122,7 @@ class JsonController extends Controller
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function trigger(Request $request)

View File

@@ -395,7 +395,6 @@ class PiggyBankController extends Controller
}
$piggyBank = $repository->store($data);
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();

View File

@@ -71,6 +71,7 @@ class PreferencesController extends Controller
/**
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \Exception
* @throws \Exception
*/
@@ -91,19 +92,19 @@ class PreferencesController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = Preferences::get('listPageSize', 50)->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); // hasTwoFactorAuthSecret
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
$viewRangePref = Preferences::get('viewRange', '1M');
$viewRange = $viewRangePref->data;
$frontPageAccounts = Preferences::get('frontPageAccounts', []);
$language = Preferences::get('language', config('firefly.default_language', 'en_US'))->data;
$listPageSize = Preferences::get('listPageSize', 50)->data;
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
$showDeps = Preferences::get('showDepositsFrontpage', false)->data;
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
$has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); // hasTwoFactorAuthSecret
return view(
'preferences.index',

View File

@@ -97,6 +97,7 @@ class ProfileController extends Controller
* @param string $token
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
*/
public function confirmEmailChange(UserRepositoryInterface $repository, string $token)
@@ -286,7 +287,7 @@ class ProfileController extends Controller
// found user.
// which email address to return to?
$set = Preferences::beginsWith($user, 'previous_email_');
$set = Preferences::beginsWith($user, 'previous_email_');
/** @var string $match */
$match = null;
foreach ($set as $entry) {

View File

@@ -39,6 +39,7 @@ class AccountController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function general(Collection $accounts, Carbon $start, Carbon $end)

View File

@@ -40,6 +40,7 @@ class BalanceController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)

View File

@@ -41,6 +41,7 @@ class BudgetController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
@@ -69,6 +70,7 @@ class BudgetController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function period(Collection $accounts, Carbon $start, Carbon $end)

View File

@@ -40,6 +40,7 @@ class CategoryController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function expenses(Collection $accounts, Carbon $start, Carbon $end)
@@ -72,6 +73,7 @@ class CategoryController extends Controller
* @param Collection $accounts
*
* @return string
*
* @throws \Throwable
*/
public function income(Collection $accounts, Carbon $start, Carbon $end)
@@ -106,6 +108,7 @@ class CategoryController extends Controller
* @return mixed|string
*
* @internal param ReportHelperInterface $helper
*
* @throws \Throwable
*/
public function operations(Collection $accounts, Carbon $start, Carbon $end)

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Report;
@@ -34,7 +33,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
/**
* Class ExpenseController
*/
@@ -69,6 +67,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function budget(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@@ -116,6 +115,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function category(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@@ -173,6 +173,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return array|mixed|string
*
* @throws \Throwable
*/
public function spent(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@@ -193,7 +194,7 @@ class ExpenseController extends Controller
foreach ($combined as $name => $combi) {
/**
* @var string $name
* @var string
* @var Collection $combi
*/
$spent = $this->spentInPeriod($accounts, $combi, $start, $end);
@@ -208,7 +209,6 @@ class ExpenseController extends Controller
return $result;
// for period, get spent and earned for each account (by name)
}
/**
@@ -218,6 +218,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@@ -254,7 +255,6 @@ class ExpenseController extends Controller
return $result;
}
/**
* @param Collection $accounts
* @param Collection $expense
@@ -262,6 +262,7 @@ class ExpenseController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
@@ -343,17 +344,16 @@ class ExpenseController extends Controller
$categoryName = $transaction->transaction_category_name;
$categoryId = intval($transaction->transaction_category_id);
// if null, grab from journal:
if ($categoryId === 0) {
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
$categoryId = intval($transaction->transaction_journal_category_id);
}
if ($categoryId !== 0) {
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
}
// if not set, set to zero:
if (!isset($sum[$categoryId][$currencyId])) {
$sum[$categoryId] = [
'grand_total' => '0',
'name' => $categoryName,
@@ -371,7 +371,6 @@ class ExpenseController extends Controller
],
],
];
}
// add amount
@@ -448,17 +447,16 @@ class ExpenseController extends Controller
$budgetName = $transaction->transaction_budget_name;
$budgetId = intval($transaction->transaction_budget_id);
// if null, grab from journal:
if ($budgetId === 0) {
if (0 === $budgetId) {
$budgetName = $transaction->transaction_journal_budget_name;
$budgetId = intval($transaction->transaction_journal_budget_id);
}
if ($budgetId !== 0) {
if (0 !== $budgetId) {
$budgetName = app('steam')->tryDecrypt($budgetName);
}
// if not set, set to zero:
if (!isset($sum[$budgetId][$currencyId])) {
$sum[$budgetId] = [
'grand_total' => '0',
'name' => $budgetName,
@@ -510,17 +508,16 @@ class ExpenseController extends Controller
$categoryName = $transaction->transaction_category_name;
$categoryId = intval($transaction->transaction_category_id);
// if null, grab from journal:
if ($categoryId === 0) {
if (0 === $categoryId) {
$categoryName = $transaction->transaction_journal_category_name;
$categoryId = intval($transaction->transaction_journal_category_id);
}
if ($categoryId !== 0) {
if (0 !== $categoryId) {
$categoryName = app('steam')->tryDecrypt($categoryName);
}
// if not set, set to zero:
if (!isset($sum[$categoryId][$currencyId])) {
$sum[$categoryId] = [
'grand_total' => '0',
'name' => $categoryName,
@@ -591,5 +588,4 @@ class ExpenseController extends Controller
return $sum;
}
}
}

View File

@@ -40,6 +40,7 @@ class OperationsController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function expenses(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
@@ -68,6 +69,7 @@ class OperationsController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \Throwable
*/
public function income(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)
@@ -97,6 +99,7 @@ class OperationsController extends Controller
* @param Carbon $end
*
* @return mixed|string
*
* @throws \Throwable
*/
public function operations(AccountTaskerInterface $tasker, Collection $accounts, Carbon $start, Carbon $end)

View File

@@ -75,12 +75,13 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
if ($end < $start) {
return view('error')->with('message', trans('firefly.end_after_start_date'));// @codeCoverageIgnore
return view('error')->with('message', trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
if ($start < session('first')) {
@@ -90,7 +91,7 @@ class ReportController extends Controller
View::share(
'subTitle', trans(
'firefly.report_default',
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat),]
['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]
)
);
@@ -108,6 +109,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
@@ -144,6 +146,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
@@ -181,6 +184,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
@@ -217,6 +221,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
@@ -268,6 +273,7 @@ class ReportController extends Controller
* @param string $reportType
*
* @return mixed
*
* @throws \Throwable
*/
public function options(string $reportType)
@@ -297,6 +303,7 @@ class ReportController extends Controller
* @param ReportFormRequest $request
*
* @return RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \FireflyIII\Exceptions\FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
@@ -373,6 +380,7 @@ class ReportController extends Controller
* @param Carbon $end
*
* @return string
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
@@ -405,6 +413,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function accountReportOptions(): string
@@ -428,6 +437,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function budgetReportOptions(): string
@@ -442,6 +452,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function categoryReportOptions(): string
@@ -456,6 +467,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function noReportOptions(): string
@@ -465,6 +477,7 @@ class ReportController extends Controller
/**
* @return string
*
* @throws \Throwable
*/
private function tagReportOptions(): string

View File

@@ -72,6 +72,7 @@ class RuleController extends Controller
* @param RuleGroup $ruleGroup
*
* @return View
*
* @throws \Throwable
* @throws \Throwable
*/
@@ -166,6 +167,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return View
*
* @throws \Throwable
* @throws \Throwable
* @throws \Throwable
@@ -362,6 +364,7 @@ class RuleController extends Controller
* @param TestRuleFormRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function testTriggers(TestRuleFormRequest $request)
@@ -410,6 +413,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function testTriggersByRule(Rule $rule)
@@ -535,6 +539,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return array
*
* @throws \Throwable
*/
private function getCurrentActions(Rule $rule)
@@ -564,6 +569,7 @@ class RuleController extends Controller
* @param Rule $rule
*
* @return array
*
* @throws \Throwable
*/
private function getCurrentTriggers(Rule $rule)
@@ -595,6 +601,7 @@ class RuleController extends Controller
* @param Request $request
*
* @return array
*
* @throws \Throwable
*/
private function getPreviousActions(Request $request)
@@ -625,6 +632,7 @@ class RuleController extends Controller
* @param Request $request
*
* @return array
*
* @throws \Throwable
*/
private function getPreviousTriggers(Request $request)

View File

@@ -74,6 +74,7 @@ class SearchController extends Controller
* @param SearchInterface $searcher
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function search(Request $request, SearchInterface $searcher)

View File

@@ -128,6 +128,7 @@ class ConvertController extends Controller
* @param TransactionJournal $journal
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws FireflyException
* @throws FireflyException
*/

View File

@@ -257,7 +257,7 @@ class SingleController extends Controller
$assetAccounts = $this->groupedAccountList();
$budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets());
if ($journal->transactionType->type === TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION === $journal->transactionType->type) {
return redirect(route('accounts.reconcile.edit', [$journal->id]));
}

View File

@@ -116,7 +116,6 @@ class SplitController extends Controller
$accountArray[$account->id]['currency_id'] = intval($account->getMeta('currency_id'));
}
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('transactions.edit-split.fromUpdate')) {
$this->rememberPreviousUri('transactions.edit-split.uri');

View File

@@ -69,6 +69,7 @@ class TransactionController extends Controller
* @param string $moment
*
* @return View
*
* @throws FireflyException
*/
public function index(Request $request, JournalRepositoryInterface $repository, string $what, string $moment = '')
@@ -142,7 +143,8 @@ class TransactionController extends Controller
$repository->reconcile($transaction);
}
return Response::json(['ok'=>'reconciled']);
return Response::json(['ok' => 'reconciled']);
}
/**
@@ -183,7 +185,7 @@ class TransactionController extends Controller
if ($this->isOpeningBalance($journal)) {
return $this->redirectToAccount($journal);
}
if ($journal->transactionType->type === TransactionType::RECONCILIATION) {
if (TransactionType::RECONCILIATION === $journal->transactionType->type) {
return redirect(route('accounts.reconcile.show', [$journal->id])); // @codeCoverageIgnore
}
$linkTypes = $linkTypeRepository->get();
@@ -200,7 +202,6 @@ class TransactionController extends Controller
* @param string $what
*
* @return Collection
*
*/
private function getPeriodOverview(string $what): Collection
{