mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 12:04:00 +00:00
Code clean up.
This commit is contained in:
@@ -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\Account;
|
||||
@@ -37,9 +36,7 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ReconcileController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Account
|
||||
* Class ReconcileController.
|
||||
*/
|
||||
class ReconcileController extends Controller
|
||||
{
|
||||
@@ -94,14 +91,14 @@ class ReconcileController extends Controller
|
||||
*/
|
||||
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->find($currencyId);
|
||||
if ($currencyId === 0) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
@@ -109,11 +106,11 @@ class ReconcileController extends Controller
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
|
||||
// get start and end
|
||||
if (is_null($start) && is_null($end)) {
|
||||
if (null === $start && null === $end) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
}
|
||||
if (is_null($end)) {
|
||||
if (null === $end) {
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
}
|
||||
|
||||
@@ -158,7 +155,7 @@ class ReconcileController extends Controller
|
||||
*/
|
||||
public function transactions(Account $account, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
|
||||
@@ -168,7 +165,6 @@ class ReconcileController extends Controller
|
||||
$selectionEnd = clone $end;
|
||||
$selectionEnd->addDays(3);
|
||||
|
||||
|
||||
// grab transactions:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
|
@@ -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;
|
||||
@@ -45,9 +44,8 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
* Class AccountController.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
@@ -90,12 +88,11 @@ class AccountController extends Controller
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// pre fill some data
|
||||
$request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id,]);
|
||||
$request->session()->flash('preFilled', ['currency_id' => $defaultCurrency->id]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('accounts.create.fromStore') !== true) {
|
||||
if (true !== session('accounts.create.fromStore')) {
|
||||
$this->rememberPreviousUri('accounts.create.uri');
|
||||
}
|
||||
$request->session()->forget('accounts.create.fromStore');
|
||||
@@ -174,9 +171,8 @@ class AccountController extends Controller
|
||||
$roles[$role] = strval(trans('firefly.account_role_' . $role));
|
||||
}
|
||||
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('accounts.edit.fromUpdate') !== true) {
|
||||
if (true !== session('accounts.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('accounts.edit.uri');
|
||||
}
|
||||
$request->session()->forget('accounts.edit.fromUpdate');
|
||||
@@ -185,9 +181,9 @@ class AccountController extends Controller
|
||||
|
||||
// the opening balance is tricky:
|
||||
$openingBalanceAmount = $account->getOpeningBalanceAmount();
|
||||
$openingBalanceAmount = $account->getOpeningBalanceAmount() === '0' ? '' : $openingBalanceAmount;
|
||||
$openingBalanceAmount = '0' === $account->getOpeningBalanceAmount() ? '' : $openingBalanceAmount;
|
||||
$openingBalanceDate = $account->getOpeningBalanceDate();
|
||||
$openingBalanceDate = $openingBalanceDate->year === 1900 ? null : $openingBalanceDate->format('Y-m-d');
|
||||
$openingBalanceDate = 1900 === $openingBalanceDate->year ? null : $openingBalanceDate->format('Y-m-d');
|
||||
$currency = $repository->find(intval($account->getMeta('currency_id')));
|
||||
|
||||
$preFilled = [
|
||||
@@ -200,7 +196,6 @@ class AccountController extends Controller
|
||||
'openingBalance' => $openingBalanceAmount,
|
||||
'virtualBalance' => $account->virtual_balance,
|
||||
'currency_id' => $currency->id,
|
||||
|
||||
];
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
$request->session()->flash('gaEventCategory', 'accounts');
|
||||
@@ -273,7 +268,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')
|
||||
{
|
||||
if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
|
||||
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
|
||||
return $this->redirectToOriginalAccount($account);
|
||||
}
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
@@ -288,13 +283,12 @@ class AccountController extends Controller
|
||||
$periods = new Collection;
|
||||
$currencyId = intval($account->getMeta('currency_id'));
|
||||
$currency = $currencyRepos->find($currencyId);
|
||||
if ($currencyId === 0) {
|
||||
if (0 === $currencyId) {
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
}
|
||||
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$chartUri = route('chart.account.all', [$account->id]);
|
||||
$first = $repository->first();
|
||||
@@ -303,7 +297,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
@@ -314,7 +308,7 @@ class AccountController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period view
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$fStart = $start->formatLocalized($this->monthAndDayFormat);
|
||||
@@ -326,7 +320,7 @@ class AccountController extends Controller
|
||||
// grab journals:
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page);
|
||||
if (!is_null($start)) {
|
||||
if (null !== $start) {
|
||||
$collector->setRange($start, $end);
|
||||
}
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
@@ -343,7 +337,6 @@ class AccountController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
*/
|
||||
public function store(AccountFormRequest $request, AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -354,12 +347,12 @@ class AccountController extends Controller
|
||||
|
||||
// update preferences if necessary:
|
||||
$frontPage = Preferences::get('frontPageAccounts', [])->data;
|
||||
if (count($frontPage) > 0 && $account->accountType->type === AccountType::ASSET) {
|
||||
if (count($frontPage) > 0 && AccountType::ASSET === $account->accountType->type) {
|
||||
$frontPage[] = $account->id;
|
||||
Preferences::set('frontPageAccounts', $frontPage);
|
||||
}
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('accounts.create.fromStore', true);
|
||||
|
||||
@@ -385,7 +378,7 @@ class AccountController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_account', ['name' => $account->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('accounts.edit.fromUpdate', true);
|
||||
|
||||
@@ -396,7 +389,6 @@ class AccountController extends Controller
|
||||
return redirect($this->getPreviousUri('accounts.edit.uri'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
@@ -468,10 +460,10 @@ class AccountController extends Controller
|
||||
'name' => $dateName,
|
||||
'spent' => $spent,
|
||||
'earned' => $earned,
|
||||
'date' => clone $end]
|
||||
'date' => clone $end,]
|
||||
);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
||||
@@ -482,13 +474,14 @@ class AccountController extends Controller
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function redirectToOriginalAccount(Account $account)
|
||||
{
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $account->transactions()->first();
|
||||
if (is_null($transaction)) {
|
||||
if (null === $transaction) {
|
||||
throw new FireflyException('Expected a transaction. This account has none. BEEP, error.');
|
||||
}
|
||||
|
||||
@@ -496,7 +489,7 @@ class AccountController extends Controller
|
||||
/** @var Transaction $opposingTransaction */
|
||||
$opposingTransaction = $journal->transactions()->where('transactions.id', '!=', $transaction->id)->first();
|
||||
|
||||
if (is_null($opposingTransaction)) {
|
||||
if (null === $opposingTransaction) {
|
||||
throw new FireflyException('Expected an opposing transaction. This account has none. BEEP, error.'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -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\Admin;
|
||||
@@ -32,9 +31,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ConfigurationController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class ConfigurationController.
|
||||
*/
|
||||
class ConfigurationController extends Controller
|
||||
{
|
||||
@@ -45,7 +42,6 @@ class ConfigurationController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', strval(trans('firefly.administration')));
|
||||
|
@@ -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\Admin;
|
||||
@@ -30,9 +29,7 @@ use Log;
|
||||
use Session;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class HomeController.
|
||||
*/
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
@@ -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\Admin;
|
||||
@@ -32,9 +31,7 @@ use Preferences;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class LinkController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class LinkController.
|
||||
*/
|
||||
class LinkController extends Controller
|
||||
{
|
||||
@@ -64,7 +61,7 @@ class LinkController extends Controller
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('link_types.create.fromStore') !== true) {
|
||||
if (true !== session('link_types.create.fromStore')) {
|
||||
$this->rememberPreviousUri('link_types.create.uri');
|
||||
}
|
||||
|
||||
@@ -139,7 +136,7 @@ class LinkController extends Controller
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('link_types.edit.fromUpdate') !== true) {
|
||||
if (true !== session('link_types.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('link_types.edit.uri');
|
||||
}
|
||||
$request->session()->forget('link_types.edit.fromUpdate');
|
||||
@@ -196,7 +193,7 @@ class LinkController extends Controller
|
||||
$linkType = $repository->store($data);
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_new_link_type', ['name' => $linkType->name])));
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('link_types.create.fromStore', true);
|
||||
|
||||
@@ -225,7 +222,7 @@ class LinkController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_link_type', ['name' => $linkType->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('link_types.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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\Admin;
|
||||
@@ -33,9 +32,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class UserController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Admin
|
||||
* Class UserController.
|
||||
*/
|
||||
class UserController extends Controller
|
||||
{
|
||||
@@ -46,7 +43,6 @@ class UserController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', strval(trans('firefly.administration')));
|
||||
@@ -91,7 +87,7 @@ class UserController extends Controller
|
||||
public function edit(User $user)
|
||||
{
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('users.edit.fromUpdate') !== true) {
|
||||
if (true !== session('users.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('users.edit.uri');
|
||||
}
|
||||
Session::forget('users.edit.fromUpdate');
|
||||
@@ -125,14 +121,13 @@ class UserController extends Controller
|
||||
$list = ['twoFactorAuthEnabled', 'twoFactorAuthSecret'];
|
||||
$preferences = Preferences::getArrayForUser($user, $list);
|
||||
$user->isAdmin = $user->hasRole('owner');
|
||||
$is2faEnabled = $preferences['twoFactorAuthEnabled'] === true;
|
||||
$has2faSecret = !is_null($preferences['twoFactorAuthSecret']);
|
||||
$is2faEnabled = true === $preferences['twoFactorAuthEnabled'];
|
||||
$has2faSecret = null !== $preferences['twoFactorAuthSecret'];
|
||||
$user->has2FA = ($is2faEnabled && $has2faSecret) ? true : false;
|
||||
$user->prefs = $preferences;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users'));
|
||||
}
|
||||
|
||||
@@ -166,7 +161,6 @@ class UserController extends Controller
|
||||
/**
|
||||
* @param UserFormRequest $request
|
||||
* @param User $user
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
@@ -187,7 +181,7 @@ class UserController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.updated_user', ['email' => $user->email])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('users.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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;
|
||||
@@ -35,15 +34,12 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AttachmentController
|
||||
* Class AttachmentController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // it's 13.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
*/
|
||||
class AttachmentController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -104,6 +100,7 @@ class AttachmentController extends Controller
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function download(AttachmentRepositoryInterface $repository, Attachment $attachment)
|
||||
@@ -112,7 +109,6 @@ class AttachmentController extends Controller
|
||||
$content = $repository->getContent($attachment);
|
||||
$quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
|
||||
|
||||
|
||||
/** @var LaravelResponse $response */
|
||||
$response = response($content, 200);
|
||||
$response
|
||||
@@ -143,7 +139,7 @@ class AttachmentController extends Controller
|
||||
$subTitle = trans('firefly.edit_attachment', ['name' => $attachment->filename]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('attachments.edit.fromUpdate') !== true) {
|
||||
if (true !== session('attachments.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('attachments.edit.uri');
|
||||
}
|
||||
$request->session()->forget('attachments.edit.fromUpdate');
|
||||
@@ -160,8 +156,7 @@ class AttachmentController extends Controller
|
||||
{
|
||||
$image = 'images/page_green.png';
|
||||
|
||||
|
||||
if ($attachment->mime === 'application/pdf') {
|
||||
if ('application/pdf' === $attachment->mime) {
|
||||
$image = 'images/page_white_acrobat.png';
|
||||
}
|
||||
$file = public_path($image);
|
||||
@@ -171,7 +166,6 @@ class AttachmentController extends Controller
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AttachmentFormRequest $request
|
||||
* @param AttachmentRepositoryInterface $repository
|
||||
@@ -187,7 +181,7 @@ class AttachmentController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.attachment_updated', ['name' => $attachment->filename])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('attachments.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* ForgotPasswordController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -53,7 +51,6 @@ class ForgotPasswordController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* LoginController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -66,7 +64,6 @@ class LoginController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -93,7 +90,7 @@ class LoginController extends Controller
|
||||
|
||||
// check for presence of currency:
|
||||
$currency = TransactionCurrency::where('code', 'EUR')->first();
|
||||
if (is_null($currency)) {
|
||||
if (null === $currency) {
|
||||
$message
|
||||
= 'Firefly III could not find the EURO currency. This is a strong indication the database has not been initialized correctly. Did you follow the installation instructions?';
|
||||
|
||||
@@ -107,7 +104,7 @@ class LoginController extends Controller
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
$allowRegistration = true;
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* RegisterController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -66,7 +64,6 @@ class RegisterController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -77,7 +74,7 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* Handle a registration request for the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
@@ -86,7 +83,7 @@ class RegisterController extends Controller
|
||||
// is allowed to?
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$message = 'Registration is currently not available.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
@@ -119,7 +116,7 @@ class RegisterController extends Controller
|
||||
// is allowed to?
|
||||
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
if ($singleUserMode === true && $userCount > 0) {
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$message = 'Registration is currently not available.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
@@ -127,14 +124,13 @@ class RegisterController extends Controller
|
||||
|
||||
$email = $request->old('email');
|
||||
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return \FireflyIII\User
|
||||
*/
|
||||
@@ -151,7 +147,7 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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);
|
||||
|
||||
|
||||
/**
|
||||
* ResetPasswordController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
@@ -60,7 +58,6 @@ class ResetPasswordController extends Controller
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -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\Auth;
|
||||
@@ -32,17 +31,15 @@ use Log;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class TwoFactorController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Auth
|
||||
* Class TwoFactorController.
|
||||
*/
|
||||
class TwoFactorController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
@@ -53,16 +50,16 @@ class TwoFactorController extends Controller
|
||||
|
||||
// to make sure the validator in the next step gets the secret, we push it in session
|
||||
$secretPreference = Preferences::get('twoFactorAuthSecret', null);
|
||||
$secret = is_null($secretPreference) ? null : $secretPreference->data;
|
||||
$secret = null === $secretPreference ? null : $secretPreference->data;
|
||||
$title = strval(trans('firefly.two_factor_title'));
|
||||
|
||||
// make sure the user has two factor configured:
|
||||
$has2FA = Preferences::get('twoFactorAuthEnabled', false)->data;
|
||||
if (is_null($has2FA) || $has2FA === false) {
|
||||
if (null === $has2FA || false === $has2FA) {
|
||||
return redirect(route('index'));
|
||||
}
|
||||
|
||||
if (strlen(strval($secret)) === 0) {
|
||||
if (0 === strlen(strval($secret))) {
|
||||
throw new FireflyException('Your two factor authentication secret is empty, which it cannot be at this point. Please check the log files.');
|
||||
}
|
||||
$request->session()->flash('two-factor-secret', $secret);
|
||||
@@ -72,6 +69,7 @@ class TwoFactorController extends Controller
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function lostTwoFactor()
|
||||
@@ -95,7 +93,6 @@ class TwoFactorController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
|
||||
*
|
||||
*/
|
||||
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
|
||||
{
|
||||
|
@@ -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;
|
||||
@@ -36,13 +35,10 @@ use URL;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class BillController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class BillController.
|
||||
*/
|
||||
class BillController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -50,7 +46,6 @@ class BillController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.bills'));
|
||||
@@ -74,9 +69,8 @@ class BillController extends Controller
|
||||
}
|
||||
$subTitle = trans('firefly.create_new_bill');
|
||||
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('bills.create.fromStore') !== true) {
|
||||
if (true !== session('bills.create.fromStore')) {
|
||||
$this->rememberPreviousUri('bills.create.uri');
|
||||
}
|
||||
$request->session()->forget('bills.create.fromStore');
|
||||
@@ -136,7 +130,7 @@ class BillController extends Controller
|
||||
$subTitle = trans('firefly.edit_bill', ['name' => $bill->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('bills.edit.fromUpdate') !== true) {
|
||||
if (true !== session('bills.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('bills.edit.uri');
|
||||
}
|
||||
|
||||
@@ -166,7 +160,6 @@ class BillController extends Controller
|
||||
$bills = $repository->getBills();
|
||||
$bills->each(
|
||||
function (Bill $bill) use ($repository, $start, $end) {
|
||||
|
||||
// paid in this period?
|
||||
$bill->paidDates = $repository->getPaidDatesInRange($bill, $start, $end);
|
||||
$bill->payDates = $repository->getPayDatesInRange($bill, $start, $end);
|
||||
@@ -190,7 +183,7 @@ class BillController extends Controller
|
||||
*/
|
||||
public function rescan(Request $request, BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
if (intval($bill->active) === 0) {
|
||||
if (0 === intval($bill->active)) {
|
||||
$request->session()->flash('warning', strval(trans('firefly.cannot_scan_inactive_bill')));
|
||||
|
||||
return redirect(URL::previous());
|
||||
@@ -202,7 +195,6 @@ class BillController extends Controller
|
||||
$repository->scan($bill, $journal);
|
||||
}
|
||||
|
||||
|
||||
$request->session()->flash('success', strval(trans('firefly.rescanned_bill')));
|
||||
Preferences::mark();
|
||||
|
||||
@@ -254,7 +246,7 @@ class BillController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_new_bill', ['name' => $bill->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('bills.create.fromStore', true);
|
||||
|
||||
@@ -281,7 +273,7 @@ class BillController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_bill', ['name' => $bill->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('bills.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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;
|
||||
@@ -44,16 +43,14 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class BudgetController
|
||||
* Class BudgetController.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
@@ -88,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 ($amount === 0) {
|
||||
if (0 === $amount) {
|
||||
$budgetLimit = null;
|
||||
}
|
||||
Preferences::mark();
|
||||
@@ -104,7 +101,7 @@ class BudgetController extends Controller
|
||||
public function create(Request $request)
|
||||
{
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('budgets.create.fromStore') !== true) {
|
||||
if (true !== session('budgets.create.fromStore')) {
|
||||
$this->rememberPreviousUri('budgets.create.uri');
|
||||
}
|
||||
$request->session()->forget('budgets.create.fromStore');
|
||||
@@ -160,7 +157,7 @@ class BudgetController extends Controller
|
||||
$subTitle = trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('budgets.edit.fromUpdate') !== true) {
|
||||
if (true !== session('budgets.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('budgets.edit.uri');
|
||||
}
|
||||
$request->session()->forget('budgets.edit.fromUpdate');
|
||||
@@ -185,7 +182,7 @@ class BudgetController extends Controller
|
||||
$end = session('end', new Carbon);
|
||||
|
||||
// make date if present:
|
||||
if (!is_null($moment) || strlen(strval($moment)) !== 0) {
|
||||
if (null !== $moment || 0 !== strlen(strval($moment))) {
|
||||
try {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
@@ -218,7 +215,7 @@ class BudgetController extends Controller
|
||||
$previousDate = Navigation::startOfPeriod($previousDate, $range);
|
||||
$format = $previousDate->format('Y-m-d');
|
||||
$previousLoop[$format] = Navigation::periodShow($previousDate, $range);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
|
||||
// select thing for next 12 periods:
|
||||
@@ -231,7 +228,7 @@ class BudgetController extends Controller
|
||||
$format = $nextDate->format('Y-m-d');
|
||||
$nextLoop[$format] = Navigation::periodShow($nextDate, $range);
|
||||
$nextDate = Navigation::endOfPeriod($nextDate, $range);
|
||||
$count++;
|
||||
++$count;
|
||||
$nextDate->addDay();
|
||||
}
|
||||
|
||||
@@ -301,7 +298,7 @@ class BudgetController extends Controller
|
||||
$currentEnd = Navigation::endOfPeriod($currentStart, $range);
|
||||
$total = bcadd($total, $this->repository->getAvailableBudget($currency, $currentStart, $currentEnd));
|
||||
$currentStart = Navigation::addPeriod($currentStart, $range, 0);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
$result['available'] = bcdiv($total, strval($count));
|
||||
|
||||
@@ -320,12 +317,11 @@ class BudgetController extends Controller
|
||||
$result['spent'] = bcdiv(strval($collector->getJournals()->sum('transaction_amount')), strval($count));
|
||||
// suggestion starts with the amount spent
|
||||
$result['suggested'] = bcmul($result['spent'], '-1');
|
||||
$result['suggested'] = bccomp($result['suggested'], $result['earned']) === 1 ? $result['earned'] : $result['suggested'];
|
||||
$result['suggested'] = 1 === bccomp($result['suggested'], $result['earned']) ? $result['earned'] : $result['suggested'];
|
||||
// unless it's more than you earned. So min() of suggested/earned
|
||||
|
||||
$cache->store($result);
|
||||
|
||||
|
||||
return view('budgets.info', compact('result', 'begin', 'currentEnd'));
|
||||
}
|
||||
|
||||
@@ -348,7 +344,7 @@ class BudgetController extends Controller
|
||||
$periods = new Collection;
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_without_budget');
|
||||
$first = $repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
@@ -356,7 +352,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
@@ -367,7 +363,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$periods = $this->getPeriodOverview();
|
||||
@@ -430,7 +426,6 @@ class BudgetController extends Controller
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath(route('budgets.show', [$budget->id]));
|
||||
|
||||
|
||||
$subTitle = trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'transactions', 'subTitle'));
|
||||
@@ -442,6 +437,7 @@ class BudgetController extends Controller
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
|
||||
@@ -488,7 +484,7 @@ class BudgetController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_new_budget', ['name' => $budget->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('budgets.create.fromStore', true);
|
||||
|
||||
@@ -513,7 +509,7 @@ class BudgetController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_budget', ['name' => $budget->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('budgets.edit.fromUpdate', true);
|
||||
|
||||
@@ -605,7 +601,7 @@ class BudgetController extends Controller
|
||||
$journals = $set->count();
|
||||
$dateStr = $end->format('Y-m-d');
|
||||
$dateName = Navigation::periodShow($end, $range);
|
||||
$entries->push(['string' => $dateStr, 'name' => $dateName, 'count' => $journals, 'sum' => $sum, 'date' => clone $end,]);
|
||||
$entries->push(['string' => $dateStr, 'name' => $dateName, 'count' => $journals, 'sum' => $sum, 'date' => clone $end]);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
@@ -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;
|
||||
@@ -43,13 +42,10 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class CategoryController.
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -57,7 +53,6 @@ class CategoryController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.categories'));
|
||||
@@ -75,7 +70,7 @@ class CategoryController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
if (session('categories.create.fromStore') !== true) {
|
||||
if (true !== session('categories.create.fromStore')) {
|
||||
$this->rememberPreviousUri('categories.create.uri');
|
||||
}
|
||||
$request->session()->forget('categories.create.fromStore');
|
||||
@@ -104,7 +99,6 @@ class CategoryController extends Controller
|
||||
return view('categories.delete', compact('category', 'subTitle'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -134,7 +128,7 @@ class CategoryController extends Controller
|
||||
$subTitle = trans('firefly.edit_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('categories.edit.fromUpdate') !== true) {
|
||||
if (true !== session('categories.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('categories.edit.uri');
|
||||
}
|
||||
$request->session()->forget('categories.edit.fromUpdate');
|
||||
@@ -180,7 +174,7 @@ class CategoryController extends Controller
|
||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_without_category');
|
||||
$first = $repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
@@ -188,7 +182,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
@@ -199,7 +193,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$periods = $this->getNoCategoryPeriodOverview();
|
||||
@@ -209,7 +203,6 @@ class CategoryController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withoutCategory()->withOpposingAccount()
|
||||
@@ -242,28 +235,28 @@ class CategoryController extends Controller
|
||||
$periods = new Collection;
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$first = $repository->firstUseDate($category);
|
||||
/** @var Carbon $start */
|
||||
$start = is_null($first) ? new Carbon : $first;
|
||||
$start = null === $first ? new Carbon : $first;
|
||||
$end = new Carbon;
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_category',
|
||||
['name' => $category->name,
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
$periods = $this->getPeriodOverview($category);
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
/** @var Carbon $end */
|
||||
@@ -272,7 +265,7 @@ class CategoryController extends Controller
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_category',
|
||||
['name' => $category->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -284,11 +277,9 @@ class CategoryController extends Controller
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath(route('categories.show', [$category->id]));
|
||||
|
||||
|
||||
return view('categories.show', compact('category', 'moment', 'transactions', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -303,7 +294,7 @@ class CategoryController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.stored_category', ['name' => $category->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('categories.create.fromStore', true);
|
||||
|
||||
@@ -314,7 +305,6 @@ class CategoryController extends Controller
|
||||
return redirect(route('categories.index'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
@@ -330,7 +320,7 @@ class CategoryController extends Controller
|
||||
$request->session()->flash('success', strval(trans('firefly.updated_category', ['name' => $category->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('categories.edit.fromUpdate', true);
|
||||
|
||||
@@ -432,7 +422,7 @@ class CategoryController extends Controller
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$first = $repository->firstUseDate($category);
|
||||
if (is_null($first)) {
|
||||
if (null === $first) {
|
||||
$first = new Carbon;
|
||||
}
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
@@ -479,7 +469,7 @@ class CategoryController extends Controller
|
||||
]
|
||||
);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
$cache->store($entries);
|
||||
|
||||
|
@@ -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\Chart;
|
||||
@@ -45,14 +44,11 @@ use Response;
|
||||
use Steam;
|
||||
|
||||
/** checked
|
||||
* Class AccountController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
* Class AccountController.
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
@@ -133,7 +129,7 @@ class AccountController extends Controller
|
||||
$startBalance = $startBalances[$id] ?? '0';
|
||||
$endBalance = $endBalances[$id] ?? '0';
|
||||
$diff = bcsub($endBalance, $startBalance);
|
||||
if (bccomp($diff, '0') !== 0) {
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
$chartData[$account->name] = $diff;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +270,7 @@ class AccountController extends Controller
|
||||
Log::debug('Default set is ', $defaultSet);
|
||||
$frontPage = Preferences::get('frontPageAccounts', $defaultSet);
|
||||
Log::debug('Frontpage preference set is ', $frontPage->data);
|
||||
if (count($frontPage->data) === 0) {
|
||||
if (0 === count($frontPage->data)) {
|
||||
$frontPage->data = $defaultSet;
|
||||
Log::debug('frontpage set is empty!');
|
||||
$frontPage->save();
|
||||
@@ -346,6 +342,7 @@ class AccountController extends Controller
|
||||
* @param Carbon $start
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function period(Account $account, Carbon $start)
|
||||
@@ -427,7 +424,7 @@ class AccountController extends Controller
|
||||
$endBalance = $endBalances[$id] ?? '0';
|
||||
$diff = bcsub($endBalance, $startBalance);
|
||||
$diff = bcmul($diff, '-1');
|
||||
if (bccomp($diff, '0') !== 0) {
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
$chartData[$account->name] = $diff;
|
||||
}
|
||||
}
|
||||
@@ -539,7 +536,6 @@ class AccountController extends Controller
|
||||
*/
|
||||
private function getBudgetNames(array $budgetIds): array
|
||||
{
|
||||
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
$repository = app(BudgetRepositoryInterface::class);
|
||||
$budgets = $repository->getBudgets();
|
||||
|
@@ -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\Chart;
|
||||
@@ -35,18 +34,15 @@ use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class BillController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
* Class BillController.
|
||||
*/
|
||||
class BillController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* checked
|
||||
* checked.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -108,9 +104,9 @@ class BillController extends Controller
|
||||
}
|
||||
);
|
||||
$chartData = [
|
||||
['type' => 'bar', 'label' => trans('firefly.min-amount'), 'entries' => [],],
|
||||
['type' => 'bar', 'label' => trans('firefly.max-amount'), 'entries' => [],],
|
||||
['type' => 'line', 'label' => trans('firefly.journal-amount'), 'entries' => [],],
|
||||
['type' => 'bar', 'label' => trans('firefly.min-amount'), 'entries' => []],
|
||||
['type' => 'bar', 'label' => trans('firefly.max-amount'), 'entries' => []],
|
||||
['type' => 'line', 'label' => trans('firefly.journal-amount'), 'entries' => []],
|
||||
];
|
||||
|
||||
/** @var Transaction $entry */
|
||||
|
@@ -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\Chart;
|
||||
@@ -44,19 +43,16 @@ use Response;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class BudgetController
|
||||
* Class BudgetController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) // can't realy be helped.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
*/
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
@@ -77,7 +73,6 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
@@ -125,10 +120,12 @@ class BudgetController extends Controller
|
||||
* Shows the amount left in a specific budget limit.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function budgetLimit(Budget $budget, BudgetLimit $budgetLimit)
|
||||
@@ -185,7 +182,7 @@ class BudgetController extends Controller
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setBudget($budget);
|
||||
if (!is_null($budgetLimit->id)) {
|
||||
if (null !== $budgetLimit->id) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
@@ -229,7 +226,7 @@ class BudgetController extends Controller
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setBudget($budget)->withCategoryInformation();
|
||||
if (!is_null($budgetLimit->id)) {
|
||||
if (null !== $budgetLimit->id) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
@@ -275,7 +272,7 @@ class BudgetController extends Controller
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAllAssetAccounts()->setTypes([TransactionType::WITHDRAWAL])->setBudget($budget)->withOpposingAccount();
|
||||
if (!is_null($budgetLimit->id)) {
|
||||
if (null !== $budgetLimit->id) {
|
||||
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
|
||||
}
|
||||
|
||||
@@ -303,6 +300,7 @@ class BudgetController extends Controller
|
||||
|
||||
/**
|
||||
* Shows a budget list with spent/left/overspent.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // 46 lines, I'm fine with this.
|
||||
*
|
||||
@@ -322,9 +320,9 @@ class BudgetController extends Controller
|
||||
}
|
||||
$budgets = $this->repository->getActiveBudgets();
|
||||
$chartData = [
|
||||
['label' => strval(trans('firefly.spent_in_budget')), 'entries' => [], 'type' => 'bar',],
|
||||
['label' => strval(trans('firefly.left_to_spend')), 'entries' => [], 'type' => 'bar',],
|
||||
['label' => strval(trans('firefly.overspent')), 'entries' => [], 'type' => 'bar',],
|
||||
['label' => strval(trans('firefly.spent_in_budget')), 'entries' => [], 'type' => 'bar'],
|
||||
['label' => strval(trans('firefly.left_to_spend')), 'entries' => [], 'type' => 'bar'],
|
||||
['label' => strval(trans('firefly.overspent')), 'entries' => [], 'type' => 'bar'],
|
||||
];
|
||||
|
||||
/** @var Budget $budget */
|
||||
@@ -342,7 +340,7 @@ class BudgetController extends Controller
|
||||
// for no budget:
|
||||
$spent = $this->spentInPeriodWithout($start, $end);
|
||||
$name = strval(trans('firefly.no_budget'));
|
||||
if (bccomp($spent, '0') !== 0) {
|
||||
if (0 !== bccomp($spent, '0')) {
|
||||
$chartData[0]['entries'][$name] = bcmul($spent, '-1');
|
||||
$chartData[1]['entries'][$name] = '0';
|
||||
$chartData[2]['entries'][$name] = '0';
|
||||
@@ -354,7 +352,6 @@ class BudgetController extends Controller
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's exactly five.
|
||||
*
|
||||
@@ -383,8 +380,8 @@ class BudgetController extends Controller
|
||||
|
||||
// join them into one set of data:
|
||||
$chartData = [
|
||||
['label' => strval(trans('firefly.spent')), 'type' => 'bar', 'entries' => [],],
|
||||
['label' => strval(trans('firefly.budgeted')), 'type' => 'bar', 'entries' => [],],
|
||||
['label' => strval(trans('firefly.spent')), 'type' => 'bar', 'entries' => []],
|
||||
['label' => strval(trans('firefly.budgeted')), 'type' => 'bar', 'entries' => []],
|
||||
];
|
||||
|
||||
foreach (array_keys($periods) as $period) {
|
||||
@@ -509,7 +506,6 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // it's 6 but ok.
|
||||
*
|
||||
* @param Collection $limits
|
||||
@@ -522,9 +518,9 @@ class BudgetController extends Controller
|
||||
private function getExpensesForBudget(Collection $limits, Budget $budget, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$return = [];
|
||||
if ($limits->count() === 0) {
|
||||
if (0 === $limits->count()) {
|
||||
$spent = $this->repository->spentInPeriod(new Collection([$budget]), new Collection, $start, $end);
|
||||
if (bccomp($spent, '0') !== 0) {
|
||||
if (0 !== bccomp($spent, '0')) {
|
||||
$return[$budget->name]['spent'] = bcmul($spent, '-1');
|
||||
$return[$budget->name]['left'] = 0;
|
||||
$return[$budget->name]['overspent'] = 0;
|
||||
@@ -535,7 +531,7 @@ class BudgetController extends Controller
|
||||
|
||||
$rows = $this->spentInPeriodMulti($budget, $limits);
|
||||
foreach ($rows as $name => $row) {
|
||||
if (bccomp($row['spent'], '0') !== 0 || bccomp($row['left'], '0') !== 0) {
|
||||
if (0 !== bccomp($row['spent'], '0') || 0 !== bccomp($row['left'], '0')) {
|
||||
$return[$name] = $row;
|
||||
}
|
||||
}
|
||||
@@ -607,7 +603,7 @@ class BudgetController extends Controller
|
||||
* 'name' => "no budget" in local language
|
||||
* 'repetition_left' => left in budget repetition (always zero)
|
||||
* 'repetition_overspent' => spent more than budget repetition? (always zero)
|
||||
* 'spent' => actually spent in period for budget
|
||||
* 'spent' => actually spent in period for budget.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@@ -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\Chart;
|
||||
@@ -45,15 +44,12 @@ use Response;
|
||||
* Separate controller because many helper functions are shared.
|
||||
*
|
||||
* Class BudgetReportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
*/
|
||||
class BudgetReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $budgetRepository;
|
||||
/** @var GeneratorInterface */
|
||||
/** @var GeneratorInterface */
|
||||
private $generator;
|
||||
|
||||
/**
|
||||
@@ -89,7 +85,7 @@ class BudgetReportController extends Controller
|
||||
$helper->setBudgets($budgets);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('expense', 'account');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -113,7 +109,7 @@ class BudgetReportController extends Controller
|
||||
$helper->setBudgets($budgets);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('expense', 'budget');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
|
@@ -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\Chart;
|
||||
@@ -37,13 +36,11 @@ use Preferences;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
* Class CategoryController.
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
/** @var GeneratorInterface */
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
@@ -76,7 +73,7 @@ class CategoryController extends Controller
|
||||
|
||||
$start = $repository->firstUseDate($category);
|
||||
|
||||
if (is_null($start)) {
|
||||
if (null === $start) {
|
||||
$start = new Carbon;
|
||||
}
|
||||
|
||||
@@ -277,7 +274,6 @@ class CategoryController extends Controller
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
*
|
||||
* @param $date
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
@@ -292,7 +288,6 @@ class CategoryController extends Controller
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CategoryRepositoryInterface $repository
|
||||
* @param Category $category
|
||||
@@ -347,7 +342,6 @@ class CategoryController extends Controller
|
||||
$chartData[1]['entries'][$label] = round($earned, 12);
|
||||
$chartData[2]['entries'][$label] = round($sum, 12);
|
||||
|
||||
|
||||
$start->addDay();
|
||||
}
|
||||
|
||||
|
@@ -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\Chart;
|
||||
@@ -44,13 +43,10 @@ use Response;
|
||||
* Separate controller because many helper functions are shared.
|
||||
*
|
||||
* Class CategoryReportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
*/
|
||||
class CategoryReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
/** @var GeneratorInterface */
|
||||
private $generator;
|
||||
|
||||
/**
|
||||
@@ -81,7 +77,7 @@ class CategoryReportController extends Controller
|
||||
{
|
||||
/** @var MetaPieChartInterface $helper */
|
||||
$helper = app(MetaPieChartInterface::class);
|
||||
$helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === intval($others));
|
||||
|
||||
$chartData = $helper->generate('expense', 'account');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
@@ -106,7 +102,7 @@ class CategoryReportController extends Controller
|
||||
$helper->setCategories($categories);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('income', 'account');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -130,7 +126,7 @@ class CategoryReportController extends Controller
|
||||
$helper->setCategories($categories);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('expense', 'category');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -148,14 +144,13 @@ class CategoryReportController extends Controller
|
||||
*/
|
||||
public function categoryIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others)
|
||||
{
|
||||
|
||||
/** @var MetaPieChartInterface $helper */
|
||||
$helper = app(MetaPieChartInterface::class);
|
||||
$helper->setAccounts($accounts);
|
||||
$helper->setCategories($categories);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('income', 'category');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -236,7 +231,6 @@ class CategoryReportController extends Controller
|
||||
$currentIncome = $income[$category->id] ?? '0';
|
||||
$currentExpense = $expenses[$category->id] ?? '0';
|
||||
|
||||
|
||||
// add to sum:
|
||||
$sumOfIncome[$category->id] = $sumOfIncome[$category->id] ?? '0';
|
||||
$sumOfExpense[$category->id] = $sumOfExpense[$category->id] ?? '0';
|
||||
@@ -255,11 +249,11 @@ class CategoryReportController extends Controller
|
||||
// remove all empty entries to prevent cluttering:
|
||||
$newSet = [];
|
||||
foreach ($chartData as $key => $entry) {
|
||||
if (!array_sum($entry['entries']) === 0) {
|
||||
if (0 === !array_sum($entry['entries'])) {
|
||||
$newSet[$key] = $chartData[$key];
|
||||
}
|
||||
}
|
||||
if (count($newSet) === 0) {
|
||||
if (0 === count($newSet)) {
|
||||
$newSet = $chartData;
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
@@ -268,7 +262,6 @@ class CategoryReportController extends Controller
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
|
@@ -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\Chart;
|
||||
@@ -32,13 +31,10 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class PiggyBankController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
* Class PiggyBankController.
|
||||
*/
|
||||
class PiggyBankController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
|
@@ -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\Chart;
|
||||
@@ -35,13 +34,10 @@ use Response;
|
||||
use Steam;
|
||||
|
||||
/**
|
||||
* Class ReportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Chart
|
||||
* Class ReportController.
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
@@ -92,15 +88,13 @@ class ReportController extends Controller
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows income and expense, debet/credit: operations
|
||||
* Shows income and expense, debet/credit: operations.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function operations(Collection $accounts, Carbon $start, Carbon $end)
|
||||
@@ -143,7 +137,6 @@ class ReportController extends Controller
|
||||
$chartData[1]['entries'][$label] = bcadd($spent, $amount);
|
||||
}
|
||||
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
@@ -151,7 +144,7 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows sum income and expense, debet/credit: operations
|
||||
* Shows sum income and expense, debet/credit: operations.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
@@ -161,8 +154,6 @@ class ReportController extends Controller
|
||||
*/
|
||||
public function sum(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('chart.report.sum');
|
||||
@@ -173,7 +164,6 @@ class ReportController extends Controller
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
$source = $this->getChartData($accounts, $start, $end);
|
||||
$numbers = [
|
||||
'sum_earned' => '0',
|
||||
@@ -185,14 +175,14 @@ class ReportController extends Controller
|
||||
];
|
||||
foreach ($source['earned'] as $amount) {
|
||||
$numbers['sum_earned'] = bcadd($amount, $numbers['sum_earned']);
|
||||
$numbers['count_earned']++;
|
||||
++$numbers['count_earned'];
|
||||
}
|
||||
if ($numbers['count_earned'] > 0) {
|
||||
$numbers['avg_earned'] = $numbers['sum_earned'] / $numbers['count_earned'];
|
||||
}
|
||||
foreach ($source['spent'] as $amount) {
|
||||
$numbers['sum_spent'] = bcadd($amount, $numbers['sum_spent']);
|
||||
$numbers['count_spent']++;
|
||||
++$numbers['count_spent'];
|
||||
}
|
||||
if ($numbers['count_spent'] > 0) {
|
||||
$numbers['avg_spent'] = $numbers['sum_spent'] / $numbers['count_spent'];
|
||||
@@ -217,7 +207,6 @@ class ReportController extends Controller
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
$cache->store($data);
|
||||
|
||||
@@ -240,7 +229,7 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the incomes and expenses for the given periods, grouped per month. Will cache its results
|
||||
* Collects the incomes and expenses for the given periods, grouped per month. Will cache its results.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
@@ -290,7 +279,6 @@ class ReportController extends Controller
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$label = $currentStart->format('Y-m') . '-01';
|
||||
$spentArray[$label] = bcmul($spent, '-1');
|
||||
$earnedArray[$label] = $earned;
|
||||
|
@@ -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\Chart;
|
||||
@@ -72,7 +71,7 @@ class TagReportController extends Controller
|
||||
$helper->setTags($tags);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('expense', 'account');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -96,7 +95,7 @@ class TagReportController extends Controller
|
||||
$helper->setTags($tags);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('income', 'account');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -223,7 +222,6 @@ class TagReportController extends Controller
|
||||
$currentIncome = $income[$tag->id] ?? '0';
|
||||
$currentExpense = $expenses[$tag->id] ?? '0';
|
||||
|
||||
|
||||
// add to sum:
|
||||
$sumOfIncome[$tag->id] = $sumOfIncome[$tag->id] ?? '0';
|
||||
$sumOfExpense[$tag->id] = $sumOfExpense[$tag->id] ?? '0';
|
||||
@@ -242,11 +240,11 @@ class TagReportController extends Controller
|
||||
// remove all empty entries to prevent cluttering:
|
||||
$newSet = [];
|
||||
foreach ($chartData as $key => $entry) {
|
||||
if (!array_sum($entry['entries']) === 0) {
|
||||
if (0 === !array_sum($entry['entries'])) {
|
||||
$newSet[$key] = $chartData[$key];
|
||||
}
|
||||
}
|
||||
if (count($newSet) === 0) {
|
||||
if (0 === count($newSet)) {
|
||||
$newSet = $chartData; // @codeCoverageIgnore
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
@@ -272,7 +270,7 @@ class TagReportController extends Controller
|
||||
$helper->setTags($tags);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('expense', 'tag');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
@@ -290,14 +288,13 @@ class TagReportController extends Controller
|
||||
*/
|
||||
public function tagIncome(Collection $accounts, Collection $tags, Carbon $start, Carbon $end, string $others)
|
||||
{
|
||||
|
||||
/** @var MetaPieChartInterface $helper */
|
||||
$helper = app(MetaPieChartInterface::class);
|
||||
$helper->setAccounts($accounts);
|
||||
$helper->setTags($tags);
|
||||
$helper->setStart($start);
|
||||
$helper->setEnd($end);
|
||||
$helper->setCollectOtherObjects(intval($others) === 1);
|
||||
$helper->setCollectOtherObjects(1 === intval($others));
|
||||
$chartData = $helper->generate('income', 'tag');
|
||||
$data = $this->generator->pieChart($chartData);
|
||||
|
||||
|
@@ -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;
|
||||
@@ -40,15 +39,13 @@ use URL;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class Controller
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class Controller.
|
||||
*/
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
/** @var string */
|
||||
/** @var string */
|
||||
protected $dateTimeFormat;
|
||||
/** @var string */
|
||||
protected $monthAndDayFormat;
|
||||
@@ -75,7 +72,6 @@ class Controller extends BaseController
|
||||
View::share('DEMO_PASSWORD', env('DEMO_PASSWORD', ''));
|
||||
View::share('FF_VERSION', config('firefly.version'));
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
// translations for specific strings:
|
||||
@@ -86,7 +82,7 @@ class Controller extends BaseController
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
// some routes have a "what" parameter, which indicates a special page:
|
||||
$specificPage = is_null(Route::current()->parameter('what')) ? '' : '_' . Route::current()->parameter('what');
|
||||
$specificPage = null === Route::current()->parameter('what') ? '' : '_' . Route::current()->parameter('what');
|
||||
$page = str_replace('.', '_', Route::currentRouteName());
|
||||
|
||||
// indicator if user has seen the help for this page ( + special page):
|
||||
@@ -113,7 +109,7 @@ class Controller extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Functionality:
|
||||
* Functionality:.
|
||||
*
|
||||
* - If the $identifier contains the word "delete" then a remembered uri with the text "/show/" in it will not be returned but instead the index (/)
|
||||
* will be returned.
|
||||
@@ -126,10 +122,10 @@ class Controller extends BaseController
|
||||
protected function getPreviousUri(string $identifier): string
|
||||
{
|
||||
$uri = strval(session($identifier));
|
||||
if (!(strpos($identifier, 'delete') === false) && !(strpos($uri, '/show/') === false)) {
|
||||
if (!(false === strpos($identifier, 'delete')) && !(false === strpos($uri, '/show/'))) {
|
||||
$uri = $this->redirectUri;
|
||||
}
|
||||
if (!(strpos($uri, 'jscript') === false)) {
|
||||
if (!(false === strpos($uri, 'jscript'))) {
|
||||
$uri = $this->redirectUri;
|
||||
}
|
||||
|
||||
@@ -143,7 +139,7 @@ class Controller extends BaseController
|
||||
*/
|
||||
protected function isOpeningBalance(TransactionJournal $journal): bool
|
||||
{
|
||||
return $journal->transactionTypeStr() === TransactionType::OPENING_BALANCE;
|
||||
return TransactionType::OPENING_BALANCE === $journal->transactionTypeStr();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
@@ -34,17 +33,14 @@ use Preferences;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class CurrencyController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class CurrencyController.
|
||||
*/
|
||||
class CurrencyController extends Controller
|
||||
{
|
||||
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
protected $repository;
|
||||
|
||||
/** @var UserRepositoryInterface */
|
||||
/** @var UserRepositoryInterface */
|
||||
protected $userRepository;
|
||||
|
||||
/**
|
||||
@@ -54,7 +50,6 @@ class CurrencyController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.currencies'));
|
||||
@@ -84,7 +79,7 @@ class CurrencyController extends Controller
|
||||
$subTitle = trans('firefly.create_currency');
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('currencies.create.fromStore') !== true) {
|
||||
if (true !== session('currencies.create.fromStore')) {
|
||||
$this->rememberPreviousUri('currencies.create.uri');
|
||||
}
|
||||
$request->session()->forget('currencies.create.fromStore');
|
||||
@@ -112,7 +107,6 @@ class CurrencyController extends Controller
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
@@ -135,14 +129,12 @@ class CurrencyController extends Controller
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUri('currencies.delete.uri');
|
||||
$request->session()->flash('gaEventCategory', 'currency');
|
||||
$request->session()->flash('gaEventAction', 'delete');
|
||||
$subTitle = trans('form.delete_currency', ['name' => $currency->name]);
|
||||
|
||||
|
||||
return view('currencies.delete', compact('currency', 'subTitle'));
|
||||
}
|
||||
|
||||
@@ -195,7 +187,7 @@ class CurrencyController extends Controller
|
||||
$currency->symbol = htmlentities($currency->symbol);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('currencies.edit.fromUpdate') !== true) {
|
||||
if (true !== session('currencies.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('currencies.edit.uri');
|
||||
}
|
||||
$request->session()->forget('currencies.edit.fromUpdate');
|
||||
@@ -242,7 +234,7 @@ class CurrencyController extends Controller
|
||||
$currency = $this->repository->store($data);
|
||||
$request->session()->flash('success', trans('firefly.created_currency', ['name' => $currency->name]));
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('currencies.create.fromStore', true);
|
||||
|
||||
@@ -274,8 +266,7 @@ class CurrencyController extends Controller
|
||||
$request->session()->flash('success', trans('firefly.updated_currency', ['name' => $currency->name]));
|
||||
Preferences::mark();
|
||||
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
$request->session()->put('currencies.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -39,9 +37,7 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ExportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class ExportController.
|
||||
*/
|
||||
class ExportController extends Controller
|
||||
{
|
||||
@@ -52,7 +48,6 @@ class ExportController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('mainTitleIcon', 'fa-file-archive-o');
|
||||
@@ -68,6 +63,7 @@ class ExportController extends Controller
|
||||
* @param ExportJob $job
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function download(ExportJobRepositoryInterface $repository, ExportJob $job)
|
||||
@@ -82,7 +78,6 @@ class ExportController extends Controller
|
||||
}
|
||||
$content = $repository->getContent($job);
|
||||
|
||||
|
||||
$job->change('export_downloaded');
|
||||
/** @var LaravelResponse $response */
|
||||
$response = response($content, 200);
|
||||
@@ -162,48 +157,35 @@ class ExportController extends Controller
|
||||
$processor = app(ProcessorInterface::class);
|
||||
$processor->setSettings($settings);
|
||||
|
||||
/*
|
||||
* Collect journals:
|
||||
*/
|
||||
// Collect journals:
|
||||
$jobs->changeStatus($job, 'export_status_collecting_journals');
|
||||
$processor->collectJournals();
|
||||
$jobs->changeStatus($job, 'export_status_collected_journals');
|
||||
|
||||
/*
|
||||
* Transform to exportable entries:
|
||||
*/
|
||||
// Transform to exportable entries:
|
||||
$jobs->changeStatus($job, 'export_status_converting_to_export_format');
|
||||
$processor->convertJournals();
|
||||
$jobs->changeStatus($job, 'export_status_converted_to_export_format');
|
||||
|
||||
/*
|
||||
* Transform to (temporary) file:
|
||||
*/
|
||||
// Transform to (temporary) file:
|
||||
$jobs->changeStatus($job, 'export_status_creating_journal_file');
|
||||
$processor->exportJournals();
|
||||
$jobs->changeStatus($job, 'export_status_created_journal_file');
|
||||
/*
|
||||
* Collect attachments, if applicable.
|
||||
*/
|
||||
// Collect attachments, if applicable.
|
||||
if ($settings['includeAttachments']) {
|
||||
$jobs->changeStatus($job, 'export_status_collecting_attachments');
|
||||
$processor->collectAttachments();
|
||||
$jobs->changeStatus($job, 'export_status_collected_attachments');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Collect old uploads
|
||||
*/
|
||||
// Collect old uploads
|
||||
if ($settings['includeOldUploads']) {
|
||||
$jobs->changeStatus($job, 'export_status_collecting_old_uploads');
|
||||
$processor->collectOldUploads();
|
||||
$jobs->changeStatus($job, 'export_status_collected_old_uploads');
|
||||
}
|
||||
|
||||
/*
|
||||
* Create ZIP file:
|
||||
*/
|
||||
// Create ZIP file:
|
||||
$jobs->changeStatus($job, 'export_status_creating_zip_file');
|
||||
$processor->createZipFile();
|
||||
$jobs->changeStatus($job, 'export_status_created_zip_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;
|
||||
@@ -29,13 +28,10 @@ use Preferences;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class HelpController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class HelpController.
|
||||
*/
|
||||
class HelpController extends Controller
|
||||
{
|
||||
|
||||
/** @var HelpInterface */
|
||||
private $help;
|
||||
|
||||
@@ -56,7 +52,7 @@ class HelpController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $route
|
||||
* @param $route
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@@ -99,7 +95,7 @@ class HelpController extends Controller
|
||||
$content = $this->help->getFromGithub($route, $language);
|
||||
|
||||
// content will have 0 length when Github failed. Try en_US when it does:
|
||||
if (strlen($content) === 0) {
|
||||
if (0 === strlen($content)) {
|
||||
$language = 'en_US';
|
||||
|
||||
// also check cache first:
|
||||
@@ -114,7 +110,7 @@ class HelpController extends Controller
|
||||
}
|
||||
|
||||
// help still empty?
|
||||
if (strlen($content) !== 0) {
|
||||
if (0 !== strlen($content)) {
|
||||
$this->help->putInCache($route, $language, $content);
|
||||
|
||||
return $content;
|
||||
|
@@ -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;
|
||||
@@ -42,9 +41,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class HomeController.
|
||||
*/
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -112,7 +109,7 @@ class HomeController extends Controller
|
||||
foreach ($handlers as $handler) {
|
||||
if ($handler instanceof RotatingFileHandler) {
|
||||
$logFile = $handler->getUrl();
|
||||
if (!is_null($logFile)) {
|
||||
if (null !== $logFile) {
|
||||
$logContent = file_get_contents($logFile);
|
||||
}
|
||||
}
|
||||
@@ -180,7 +177,7 @@ class HomeController extends Controller
|
||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||
$count = $repository->count($types);
|
||||
|
||||
if ($count === 0) {
|
||||
if (0 === $count) {
|
||||
return redirect(route('new-user.index'));
|
||||
}
|
||||
|
||||
@@ -202,7 +199,6 @@ class HomeController extends Controller
|
||||
$billRepository = app(BillRepositoryInterface::class);
|
||||
$billCount = $billRepository->getBills()->count();
|
||||
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||
@@ -225,16 +221,15 @@ class HomeController extends Controller
|
||||
'register', 'report.options', 'routes', 'rule-groups.down', 'rule-groups.up', 'rules.up', 'rules.down',
|
||||
'rules.select', 'search.search', 'test-flash', 'transactions.link.delete', 'transactions.link.switch',
|
||||
'two-factor.lost', 'report.options',
|
||||
|
||||
];
|
||||
|
||||
/** @var Route $route */
|
||||
foreach ($set as $route) {
|
||||
$name = $route->getName();
|
||||
if (!is_null($name) && in_array('GET', $route->methods()) && strlen($name) > 0) {
|
||||
if (null !== $name && in_array('GET', $route->methods()) && strlen($name) > 0) {
|
||||
$found = false;
|
||||
foreach ($ignore as $string) {
|
||||
if (strpos($name, $string) !== false) {
|
||||
if (false !== strpos($name, $string)) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
@@ -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\Import;
|
||||
@@ -32,7 +31,6 @@ use Session;
|
||||
|
||||
class BankController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* This method must ask the user all parameters necessary to start importing data. This may not be enough
|
||||
* to finish the import itself (ie. mapping) but it should be enough to begin: accounts to import from,
|
||||
@@ -82,7 +80,7 @@ class BankController extends Controller
|
||||
return redirect(route('import.bank.prerequisites', [$bank]));
|
||||
}
|
||||
$remoteAccounts = $request->get('do_import');
|
||||
if (!is_array($remoteAccounts) || count($remoteAccounts) === 0) {
|
||||
if (!is_array($remoteAccounts) || 0 === count($remoteAccounts)) {
|
||||
Session::flash('error', 'Must select accounts');
|
||||
|
||||
return redirect(route('import.bank.form', [$bank]));
|
||||
|
@@ -18,10 +18,8 @@
|
||||
* 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;
|
||||
@@ -41,12 +39,10 @@ use View;
|
||||
|
||||
/**
|
||||
* Class FileController.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Import
|
||||
*/
|
||||
class FileController extends Controller
|
||||
{
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
public $repository;
|
||||
|
||||
/**
|
||||
@@ -73,6 +69,7 @@ class FileController extends Controller
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function configure(ImportJob $job)
|
||||
@@ -110,7 +107,7 @@ class FileController extends Controller
|
||||
$config['column-roles-complete'] = false;
|
||||
$config['column-mapping-complete'] = false;
|
||||
$config['initial-config-complete'] = false;
|
||||
$config['delimiter'] = $config['delimiter'] === "\t" ? 'tab' : $config['delimiter'];
|
||||
$config['delimiter'] = "\t" === $config['delimiter'] ? 'tab' : $config['delimiter'];
|
||||
|
||||
$result = json_encode($config, JSON_PRETTY_PRINT);
|
||||
$name = sprintf('"%s"', addcslashes('import-configuration-' . date('Y-m-d') . '.json', '"\\'));
|
||||
@@ -177,9 +174,7 @@ class FileController extends Controller
|
||||
return redirect(route('import.file.configure', [$job->key]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Show status of import job in JSON.
|
||||
*
|
||||
* @param ImportJob $job
|
||||
@@ -202,12 +197,12 @@ class FileController extends Controller
|
||||
'finishedText' => '',
|
||||
];
|
||||
|
||||
if ($job->extended_status['steps'] !== 0) {
|
||||
if (0 !== $job->extended_status['steps']) {
|
||||
$result['percentage'] = round(($job->extended_status['done'] / $job->extended_status['steps']) * 100, 0);
|
||||
$result['show_percentage'] = true;
|
||||
}
|
||||
|
||||
if ($job->status === 'finished') {
|
||||
if ('finished' === $job->status) {
|
||||
$tagId = $job->extended_status['tag'];
|
||||
/** @var TagRepositoryInterface $repository */
|
||||
$repository = app(TagRepositoryInterface::class);
|
||||
@@ -216,7 +211,7 @@ class FileController extends Controller
|
||||
$result['finishedText'] = trans('firefly.import_status_finished_job', ['link' => route('tags.show', [$tag->id, 'all']), 'tag' => $tag->tag]);
|
||||
}
|
||||
|
||||
if ($job->status === 'running') {
|
||||
if ('running' === $job->status) {
|
||||
$result['started'] = true;
|
||||
$result['running'] = true;
|
||||
}
|
||||
@@ -259,6 +254,7 @@ class FileController extends Controller
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function start(ImportJob $job)
|
||||
@@ -295,6 +291,7 @@ class FileController extends Controller
|
||||
* @param ImportJob $job
|
||||
*
|
||||
* @return ConfiguratorInterface
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function makeConfigurator(ImportJob $job): ConfiguratorInterface
|
||||
@@ -302,14 +299,13 @@ class FileController extends Controller
|
||||
$type = $job->file_type;
|
||||
$key = sprintf('firefly.import_configurators.%s', $type);
|
||||
$className = config($key);
|
||||
if (is_null($className)) {
|
||||
if (null === $className) {
|
||||
throw new FireflyException('Cannot find configurator class for this job.'); // @codeCoverageIgnore
|
||||
}
|
||||
/** @var ConfiguratorInterface $configurator */
|
||||
$configurator = app($className);
|
||||
$configurator->setJob($job);
|
||||
|
||||
|
||||
return $configurator;
|
||||
}
|
||||
}
|
||||
|
@@ -27,12 +27,10 @@ use View;
|
||||
|
||||
/**
|
||||
* Class ImportController.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
*/
|
||||
class ImportController extends Controller
|
||||
{
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
/** @var ImportJobRepositoryInterface */
|
||||
public $repository;
|
||||
|
||||
/**
|
||||
@@ -53,9 +51,8 @@ class ImportController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* General import index
|
||||
* General import index.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
@@ -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;
|
||||
@@ -35,9 +34,7 @@ use Navigation;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class JavascriptController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class JavascriptController.
|
||||
*/
|
||||
class JavascriptController extends Controller
|
||||
{
|
||||
@@ -53,19 +50,17 @@ class JavascriptController extends Controller
|
||||
$preference = Preferences::get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$default = $currencyRepository->findByCode($preference->data);
|
||||
|
||||
$data = ['accounts' => [],];
|
||||
|
||||
$data = ['accounts' => []];
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountId = $account->id;
|
||||
$currency = intval($account->getMeta('currency_id'));
|
||||
$currency = $currency === 0 ? $default->id : $currency;
|
||||
$currency = 0 === $currency ? $default->id : $currency;
|
||||
$entry = ['preferredCurrency' => $currency, 'name' => $account->name];
|
||||
$data['accounts'][$accountId] = $entry;
|
||||
}
|
||||
|
||||
|
||||
return response()
|
||||
->view('javascript.accounts', $data, 200)
|
||||
->header('Content-Type', 'text/javascript');
|
||||
@@ -79,7 +74,7 @@ class JavascriptController extends Controller
|
||||
public function currencies(CurrencyRepositoryInterface $repository)
|
||||
{
|
||||
$currencies = $repository->get();
|
||||
$data = ['currencies' => [],];
|
||||
$data = ['currencies' => []];
|
||||
/** @var TransactionCurrency $currency */
|
||||
foreach ($currencies as $currency) {
|
||||
$currencyId = $currency->id;
|
||||
@@ -180,7 +175,6 @@ class JavascriptController extends Controller
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
@@ -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\Json;
|
||||
@@ -33,20 +32,16 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class AutoCompleteController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
* Class AutoCompleteController.
|
||||
*/
|
||||
class AutoCompleteController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a JSON list of all accounts.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
*/
|
||||
public function allAccounts(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -80,7 +75,6 @@ class AutoCompleteController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
*/
|
||||
public function expenseAccounts(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -103,7 +97,6 @@ class AutoCompleteController extends Controller
|
||||
|
||||
/**
|
||||
* @param JournalCollectorInterface $collector
|
||||
*
|
||||
* @param TransactionJournal $except
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|mixed
|
||||
@@ -139,7 +132,6 @@ class AutoCompleteController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
*/
|
||||
public function revenueAccounts(AccountRepositoryInterface $repository)
|
||||
{
|
||||
|
@@ -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\Json;
|
||||
@@ -35,9 +34,7 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class BoxController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
* Class BoxController.
|
||||
*/
|
||||
class BoxController extends Controller
|
||||
{
|
||||
@@ -63,7 +60,6 @@ class BoxController extends Controller
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$available = $repository->getAvailableBudget($currency, $start, $end);
|
||||
|
||||
|
||||
// get spent amount:
|
||||
$budgets = $repository->getActiveBudgets();
|
||||
$budgetInformation = $repository->collectBudgetInformation($budgets, $start, $end);
|
||||
@@ -75,7 +71,7 @@ class BoxController extends Controller
|
||||
}
|
||||
$days = $today->diffInDays($end) + 1;
|
||||
$perDay = '0';
|
||||
if ($days !== 0) {
|
||||
if (0 !== $days) {
|
||||
$perDay = bcdiv($left, strval($days));
|
||||
}
|
||||
|
||||
|
@@ -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\Json;
|
||||
@@ -33,9 +32,7 @@ use Log;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class ExchangeController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
* Class ExchangeController.
|
||||
*/
|
||||
class ExchangeController extends Controller
|
||||
{
|
||||
@@ -52,7 +49,7 @@ class ExchangeController extends Controller
|
||||
/** @var CurrencyRepositoryInterface $repository */
|
||||
$repository = app(CurrencyRepositoryInterface::class);
|
||||
$rate = $repository->getExchangeRate($fromCurrency, $toCurrency, $date);
|
||||
if (is_null($rate->id)) {
|
||||
if (null === $rate->id) {
|
||||
Log::debug(sprintf('No cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
|
||||
$preferred = env('EXCHANGE_RATE_SERVICE', config('firefly.preferred_exchange_service'));
|
||||
$class = config('firefly.currency_exchange_services.' . $preferred);
|
||||
@@ -63,7 +60,7 @@ class ExchangeController extends Controller
|
||||
}
|
||||
$return = $rate->toArray();
|
||||
$return['amount'] = null;
|
||||
if (!is_null($request->get('amount'))) {
|
||||
if (null !== $request->get('amount')) {
|
||||
// assume amount is in "from" currency:
|
||||
$return['amount'] = bcmul($request->get('amount'), strval($rate->rate), 12);
|
||||
// round to toCurrency decimal places:
|
||||
|
@@ -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\Json;
|
||||
@@ -29,9 +28,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class FrontpageController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
* Class FrontpageController.
|
||||
*/
|
||||
class FrontpageController extends Controller
|
||||
{
|
||||
@@ -46,8 +43,7 @@ class FrontpageController extends Controller
|
||||
foreach ($set as $piggyBank) {
|
||||
$rep = $piggyBank->currentRelevantRep();
|
||||
$amount = strval($rep->currentamount);
|
||||
if (!is_null($rep->id) && bccomp($amount, '0') === 1) {
|
||||
|
||||
if (null !== $rep->id && 1 === bccomp($amount, '0')) {
|
||||
// percentage!
|
||||
$pct = round(($amount / $piggyBank->targetamount) * 100);
|
||||
|
||||
|
@@ -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\Json;
|
||||
@@ -28,13 +27,10 @@ use Log;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class IntroController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
* Class IntroController.
|
||||
*/
|
||||
class IntroController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $specificPage
|
||||
@@ -45,7 +41,7 @@ class IntroController
|
||||
{
|
||||
$steps = $this->getBasicSteps($route);
|
||||
$specificSteps = $this->getSpecificSteps($route, $specificPage);
|
||||
if (count($specificSteps) === 0) {
|
||||
if (0 === count($specificSteps)) {
|
||||
return Response::json($steps);
|
||||
}
|
||||
if ($this->hasOutroStep($route)) {
|
||||
@@ -91,7 +87,7 @@ class IntroController
|
||||
{
|
||||
$route = str_replace('.', '_', $route);
|
||||
$key = 'shown_demo_' . $route;
|
||||
if ($specialPage !== '') {
|
||||
if ('' !== $specialPage) {
|
||||
$key .= '_' . $specialPage;
|
||||
}
|
||||
Log::debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key));
|
||||
@@ -109,7 +105,7 @@ class IntroController
|
||||
public function postFinished(string $route, string $specialPage = '')
|
||||
{
|
||||
$key = 'shown_demo_' . $route;
|
||||
if ($specialPage !== '') {
|
||||
if ('' !== $specialPage) {
|
||||
$key .= '_' . $specialPage;
|
||||
}
|
||||
Log::debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key));
|
||||
@@ -135,7 +131,6 @@ class IntroController
|
||||
// get the text:
|
||||
$currentStep['intro'] = trans('intro.' . $route . '_' . $key);
|
||||
|
||||
|
||||
// save in array:
|
||||
$steps[] = $currentStep;
|
||||
}
|
||||
|
@@ -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\Json;
|
||||
@@ -62,7 +61,7 @@ class TransactionController extends Controller
|
||||
$totals[$currencyId]['amount'] = bcadd($totals[$currencyId]['amount'], app('steam')->positive($transaction->amount));
|
||||
|
||||
// foreign amount:
|
||||
if (!is_null($transaction->foreign_amount)) {
|
||||
if (null !== $transaction->foreign_amount) {
|
||||
$currencyId = $transaction->foreign_currency_id;
|
||||
if (!isset($totals[$currencyId])) {
|
||||
$totals[$currencyId] = [
|
||||
@@ -78,7 +77,7 @@ class TransactionController extends Controller
|
||||
$entries = [];
|
||||
foreach ($totals as $entry) {
|
||||
$amount = $entry['amount'];
|
||||
if ($entry['type'] === TransactionType::WITHDRAWAL) {
|
||||
if (TransactionType::WITHDRAWAL === $entry['type']) {
|
||||
$amount = bcmul($entry['amount'], '-1');
|
||||
}
|
||||
$entries[] = app('amount')->formatAnything($entry['currency'], $amount, false);
|
||||
|
@@ -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;
|
||||
@@ -31,9 +30,7 @@ use Illuminate\Http\Request;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class JsonController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class JsonController.
|
||||
*/
|
||||
class JsonController extends Controller
|
||||
{
|
||||
@@ -60,7 +57,6 @@ class JsonController extends Controller
|
||||
}
|
||||
$view = view('rules.partials.action', compact('actions', 'count'))->render();
|
||||
|
||||
|
||||
return Response::json(['html' => $view]);
|
||||
}
|
||||
|
||||
@@ -131,7 +127,7 @@ class JsonController extends Controller
|
||||
$keys = array_keys(config('firefly.rule-triggers'));
|
||||
$triggers = [];
|
||||
foreach ($keys as $key) {
|
||||
if ($key !== 'user_action') {
|
||||
if ('user_action' !== $key) {
|
||||
$triggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
||||
}
|
||||
}
|
||||
@@ -139,7 +135,6 @@ class JsonController extends Controller
|
||||
|
||||
$view = view('rules.partials.trigger', compact('triggers', 'count'))->render();
|
||||
|
||||
|
||||
return Response::json(['html' => $view]);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -32,9 +31,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class NewUserController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class NewUserController.
|
||||
*/
|
||||
class NewUserController extends Controller
|
||||
{
|
||||
@@ -52,7 +49,6 @@ class NewUserController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
@@ -90,13 +86,12 @@ class NewUserController extends Controller
|
||||
// also store currency preference from input:
|
||||
$currency = $currencyRepository->find(intval($request->input('amount_currency_id_bank_balance')));
|
||||
|
||||
if (!is_null($currency->id)) {
|
||||
if (null !== $currency->id) {
|
||||
// store currency preference:
|
||||
Preferences::set('currencyPreference', $currency->code);
|
||||
Preferences::mark();
|
||||
}
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.stored_new_accounts_new_user')));
|
||||
Preferences::mark();
|
||||
|
||||
|
@@ -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;
|
||||
@@ -40,15 +39,10 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Class PiggyBankController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class PiggyBankController.
|
||||
*/
|
||||
class PiggyBankController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -56,7 +50,6 @@ class PiggyBankController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.piggyBanks'));
|
||||
@@ -68,7 +61,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Add money to piggy bank
|
||||
* Add money to piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
@@ -87,7 +80,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Add money to piggy bank (for mobile devices)
|
||||
* Add money to piggy bank (for mobile devices).
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
@@ -109,7 +102,6 @@ class PiggyBankController extends Controller
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return View
|
||||
*
|
||||
*/
|
||||
public function create(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -117,14 +109,14 @@ class PiggyBankController extends Controller
|
||||
$subTitle = trans('firefly.new_piggy_bank');
|
||||
$subTitleIcon = 'fa-plus';
|
||||
|
||||
if (count($accounts) === 0) {
|
||||
if (0 === count($accounts)) {
|
||||
Session::flash('error', strval(trans('firefly.need_at_least_one_account')));
|
||||
|
||||
return redirect(route('new-user.index'));
|
||||
}
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('piggy-banks.create.fromStore') !== true) {
|
||||
if (true !== session('piggy-banks.create.fromStore')) {
|
||||
$this->rememberPreviousUri('piggy-banks.create.uri');
|
||||
}
|
||||
Session::forget('piggy-banks.create.fromStore');
|
||||
@@ -179,10 +171,8 @@ class PiggyBankController extends Controller
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$targetDate = null;
|
||||
$note = $piggyBank->notes()->first();
|
||||
/*
|
||||
* Flash some data to fill the form.
|
||||
*/
|
||||
if (!is_null($piggyBank->targetdate)) {
|
||||
// Flash some data to fill the form.
|
||||
if (null !== $piggyBank->targetdate) {
|
||||
$targetDate = $piggyBank->targetdate->format('Y-m-d');
|
||||
}
|
||||
|
||||
@@ -190,14 +180,14 @@ class PiggyBankController extends Controller
|
||||
'account_id' => $piggyBank->account_id,
|
||||
'targetamount' => $piggyBank->targetamount,
|
||||
'targetdate' => $targetDate,
|
||||
'note' => is_null($note) ? '' : $note->text,
|
||||
'note' => null === $note ? '' : $note->text,
|
||||
];
|
||||
Session::flash('preFilled', $preFilled);
|
||||
Session::flash('gaEventCategory', 'piggy-banks');
|
||||
Session::flash('gaEventAction', 'edit');
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('piggy-banks.edit.fromUpdate') !== true) {
|
||||
if (true !== session('piggy-banks.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('piggy-banks.edit.uri');
|
||||
}
|
||||
Session::forget('piggy-banks.edit.fromUpdate');
|
||||
@@ -222,13 +212,11 @@ class PiggyBankController extends Controller
|
||||
/** @var PiggyBank $piggyBank */
|
||||
foreach ($piggyBanks as $piggyBank) {
|
||||
$piggyBank->savedSoFar = $piggyBank->currentRelevantRep()->currentamount ?? '0';
|
||||
$piggyBank->percentage = bccomp('0', $piggyBank->savedSoFar) !== 0 ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
||||
$piggyBank->percentage = 0 !== bccomp('0', $piggyBank->savedSoFar) ? intval($piggyBank->savedSoFar / $piggyBank->targetamount * 100) : 0;
|
||||
$piggyBank->leftToSave = bcsub($piggyBank->targetamount, strval($piggyBank->savedSoFar));
|
||||
$piggyBank->percentage = $piggyBank->percentage > 100 ? 100 : $piggyBank->percentage;
|
||||
|
||||
/*
|
||||
* Fill account information:
|
||||
*/
|
||||
// Fill account information:
|
||||
$account = $piggyBank->account;
|
||||
$new = false;
|
||||
if (!isset($accounts[$account->id])) {
|
||||
@@ -242,7 +230,7 @@ class PiggyBankController extends Controller
|
||||
'leftToSave' => $piggyBank->leftToSave,
|
||||
];
|
||||
}
|
||||
if (isset($accounts[$account->id]) && $new === false) {
|
||||
if (isset($accounts[$account->id]) && false === $new) {
|
||||
$accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], strval($piggyBank->savedSoFar));
|
||||
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
|
||||
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
|
||||
@@ -265,7 +253,6 @@ class PiggyBankController extends Controller
|
||||
// set all users piggy banks to zero:
|
||||
$repository->reset();
|
||||
|
||||
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $order => $id) {
|
||||
$repository->setOrder(intval($id), ($order + 1));
|
||||
@@ -361,7 +348,6 @@ class PiggyBankController extends Controller
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function remove(PiggyBank $piggyBank)
|
||||
@@ -370,7 +356,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove money from piggy bank (for mobile devices)
|
||||
* Remove money from piggy bank (for mobile devices).
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
@@ -410,7 +396,7 @@ class PiggyBankController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('piggy-banks.create.fromStore', true);
|
||||
|
||||
@@ -436,7 +422,7 @@ class PiggyBankController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('piggy-banks.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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\Popup;
|
||||
@@ -38,13 +37,10 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ReportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Popup
|
||||
* Class ReportController.
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $accountRepository;
|
||||
/** @var BudgetRepositoryInterface */
|
||||
@@ -54,7 +50,6 @@ class ReportController extends Controller
|
||||
/** @var PopupReportInterface */
|
||||
private $popupHelper;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -63,17 +58,16 @@ class ReportController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
// @var AccountRepositoryInterface $repository
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
/** @var BudgetRepositoryInterface $repository */
|
||||
// @var BudgetRepositoryInterface $repository
|
||||
$this->budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
/** @var CategoryRepositoryInterface categoryRepository */
|
||||
// @var CategoryRepositoryInterface categoryRepository
|
||||
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
/** @var PopupReportInterface popupHelper */
|
||||
// @var PopupReportInterface popupHelper
|
||||
$this->popupHelper = app(PopupReportInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -81,11 +75,11 @@ class ReportController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function general(Request $request)
|
||||
@@ -123,6 +117,7 @@ class ReportController extends Controller
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function balanceAmount(array $attributes): string
|
||||
@@ -132,20 +127,20 @@ class ReportController extends Controller
|
||||
$account = $this->accountRepository->find(intval($attributes['accountId']));
|
||||
|
||||
switch (true) {
|
||||
case ($role === BalanceLine::ROLE_DEFAULTROLE && !is_null($budget->id)):
|
||||
case BalanceLine::ROLE_DEFAULTROLE === $role && null !== $budget->id:
|
||||
// normal row with a budget:
|
||||
$journals = $this->popupHelper->balanceForBudget($budget, $account, $attributes);
|
||||
break;
|
||||
case ($role === BalanceLine::ROLE_DEFAULTROLE && is_null($budget->id)):
|
||||
case BalanceLine::ROLE_DEFAULTROLE === $role && null === $budget->id:
|
||||
// normal row without a budget:
|
||||
$journals = $this->popupHelper->balanceForNoBudget($account, $attributes);
|
||||
$budget->name = strval(trans('firefly.no_budget'));
|
||||
break;
|
||||
case ($role === BalanceLine::ROLE_DIFFROLE):
|
||||
case BalanceLine::ROLE_DIFFROLE === $role:
|
||||
$journals = $this->popupHelper->balanceDifference($account, $attributes);
|
||||
$budget->name = strval(trans('firefly.leftUnbalanced'));
|
||||
break;
|
||||
case ($role === BalanceLine::ROLE_TAGROLE):
|
||||
case BalanceLine::ROLE_TAGROLE === $role:
|
||||
// row with tag info.
|
||||
throw new FireflyException('Firefly cannot handle this type of info-button (BalanceLine::TagRole)');
|
||||
}
|
||||
@@ -160,6 +155,7 @@ class ReportController extends Controller
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function budgetSpentAmount(array $attributes): string
|
||||
@@ -177,6 +173,7 @@ class ReportController extends Controller
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function categoryEntry(array $attributes): string
|
||||
@@ -194,6 +191,7 @@ class ReportController extends Controller
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function expenseEntry(array $attributes): string
|
||||
@@ -211,6 +209,7 @@ class ReportController extends Controller
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function incomeEntry(array $attributes): string
|
||||
@@ -226,6 +225,7 @@ class ReportController extends Controller
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function parseAttributes(array $attributes): array
|
||||
@@ -244,7 +244,6 @@ class ReportController extends Controller
|
||||
throw new FireflyException('Could not parse start date "' . e($attributes['endDate']) . '".');
|
||||
}
|
||||
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -34,13 +33,10 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class PreferencesController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class PreferencesController.
|
||||
*/
|
||||
class PreferencesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -48,7 +44,6 @@ class PreferencesController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.preferences'));
|
||||
@@ -71,7 +66,6 @@ class PreferencesController extends Controller
|
||||
Session::flash('two-factor-secret', $secret);
|
||||
$image = $google2fa->getQRCodeInline($domain, auth()->user()->email, $secret, 200);
|
||||
|
||||
|
||||
return view('preferences.code', compact('image'));
|
||||
}
|
||||
|
||||
@@ -107,8 +101,8 @@ class PreferencesController extends Controller
|
||||
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
||||
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||
$is2faEnabled = Preferences::get('twoFactorAuthEnabled', 0)->data; // twoFactorAuthEnabled
|
||||
$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); // hasTwoFactorAuthSecret
|
||||
$showIncomplete = env('SHOW_INCOMPLETE_TRANSLATIONS', false) === true;
|
||||
$has2faSecret = null !== Preferences::get('twoFactorAuthSecret'); // hasTwoFactorAuthSecret
|
||||
$showIncomplete = true === env('SHOW_INCOMPLETE_TRANSLATIONS', false);
|
||||
|
||||
return view(
|
||||
'preferences.index',
|
||||
@@ -148,7 +142,6 @@ class PreferencesController extends Controller
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
@@ -172,13 +165,13 @@ class PreferencesController extends Controller
|
||||
Session::forget('range');
|
||||
|
||||
// custom fiscal year
|
||||
$customFiscalYear = intval($request->get('customFiscalYear')) === 1;
|
||||
$customFiscalYear = 1 === intval($request->get('customFiscalYear'));
|
||||
$fiscalYearStart = date('m-d', strtotime(strval($request->get('fiscalYearStart'))));
|
||||
Preferences::set('customFiscalYear', $customFiscalYear);
|
||||
Preferences::set('fiscalYearStart', $fiscalYearStart);
|
||||
|
||||
// show deposits frontpage:
|
||||
$showDepositsFrontpage = intval($request->get('showDepositsFrontpage')) === 1;
|
||||
$showDepositsFrontpage = 1 === intval($request->get('showDepositsFrontpage'));
|
||||
Preferences::set('showDepositsFrontpage', $showDepositsFrontpage);
|
||||
|
||||
// save page size:
|
||||
@@ -193,7 +186,7 @@ class PreferencesController extends Controller
|
||||
if (!$repository->hasRole(auth()->user(), 'demo')) {
|
||||
// two factor auth
|
||||
$twoFactorAuthEnabled = intval($request->get('twoFactorAuthEnabled'));
|
||||
$hasTwoFactorAuthSecret = !is_null(Preferences::get('twoFactorAuthSecret'));
|
||||
$hasTwoFactorAuthSecret = null !== Preferences::get('twoFactorAuthSecret');
|
||||
|
||||
// If we already have a secret, just set the two factor auth enabled to 1, and let the user continue with the existing secret.
|
||||
if ($hasTwoFactorAuthSecret) {
|
||||
@@ -222,13 +215,12 @@ class PreferencesController extends Controller
|
||||
];
|
||||
Preferences::set('transaction_journal_optional_fields', $optionalTj);
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.saved_preferences')));
|
||||
Preferences::mark();
|
||||
|
||||
// if we don't have a valid secret yet, redirect to the code page.
|
||||
// AND USER HAS ACTUALLY ENABLED 2FA
|
||||
if (!$hasTwoFactorAuthSecret && $twoFactorAuthEnabled === 1) {
|
||||
if (!$hasTwoFactorAuthSecret && 1 === $twoFactorAuthEnabled) {
|
||||
return redirect(route('preferences.code'));
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
@@ -41,9 +40,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ProfileController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class ProfileController.
|
||||
*/
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
@@ -54,7 +51,6 @@ class ProfileController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.profile'));
|
||||
@@ -95,6 +91,7 @@ class ProfileController extends Controller
|
||||
* @param string $token
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function confirmEmailChange(string $token)
|
||||
@@ -109,7 +106,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
}
|
||||
// update user to clear blocked and blocked_code.
|
||||
if (is_null($user)) {
|
||||
if (null === $user) {
|
||||
throw new FireflyException('Invalid token.');
|
||||
}
|
||||
$user->blocked = 0;
|
||||
@@ -136,7 +133,6 @@ class ProfileController extends Controller
|
||||
|
||||
/**
|
||||
* @return View
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -145,7 +141,7 @@ class ProfileController extends Controller
|
||||
|
||||
// get access token or create one.
|
||||
$accessToken = Preferences::get('access_token', null);
|
||||
if (is_null($accessToken)) {
|
||||
if (null === $accessToken) {
|
||||
$token = auth()->user()->generateAccessToken();
|
||||
$accessToken = Preferences::set('access_token', $token);
|
||||
}
|
||||
@@ -171,7 +167,7 @@ class ProfileController extends Controller
|
||||
return redirect(route('profile.change-email'))->withInput();
|
||||
}
|
||||
$existing = $repository->findByEmail($newEmail);
|
||||
if (!is_null($existing)) {
|
||||
if (null !== $existing) {
|
||||
// force user logout.
|
||||
$this->guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
@@ -245,7 +241,6 @@ class ProfileController extends Controller
|
||||
Session::flash('gaEventCategory', 'user');
|
||||
Session::flash('gaEventAction', 'delete-account');
|
||||
|
||||
|
||||
return redirect(route('index'));
|
||||
}
|
||||
|
||||
@@ -278,7 +273,7 @@ class ProfileController extends Controller
|
||||
$user = $preference->user;
|
||||
}
|
||||
}
|
||||
if (is_null($user)) {
|
||||
if (null === $user) {
|
||||
throw new FireflyException('Invalid token.');
|
||||
}
|
||||
|
||||
@@ -293,7 +288,7 @@ class ProfileController extends Controller
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_null($match)) {
|
||||
if (null === $match) {
|
||||
throw new FireflyException('Invalid token.');
|
||||
}
|
||||
// change user back
|
||||
@@ -314,6 +309,7 @@ class ProfileController extends Controller
|
||||
* @param string $new
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validatePassword(User $user, string $current, string $new): bool
|
||||
|
@@ -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;
|
||||
@@ -30,13 +29,10 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
* Class AccountController.
|
||||
*/
|
||||
class AccountController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
|
@@ -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;
|
||||
@@ -30,13 +29,10 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class BalanceController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
* Class BalanceController.
|
||||
*/
|
||||
class BalanceController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param BalanceReportHelperInterface $helper
|
||||
* @param Collection $accounts
|
||||
@@ -47,8 +43,6 @@ class BalanceController extends Controller
|
||||
*/
|
||||
public function general(BalanceReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
|
@@ -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;
|
||||
@@ -32,14 +31,10 @@ use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
|
||||
/**
|
||||
* Class BudgetController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
* Class BudgetController.
|
||||
*/
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param BudgetReportHelperInterface $helper
|
||||
* @param Collection $accounts
|
||||
@@ -50,7 +45,6 @@ class BudgetController extends Controller
|
||||
*/
|
||||
public function general(BudgetReportHelperInterface $helper, Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
|
||||
// chart properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
@@ -103,7 +97,7 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters empty results from getBudgetPeriodReport
|
||||
* Filters empty results from getBudgetPeriodReport.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
@@ -112,7 +106,7 @@ class BudgetController extends Controller
|
||||
private function filterBudgetPeriodReport(array $data): array
|
||||
{
|
||||
/**
|
||||
* @var int $budgetId
|
||||
* @var int
|
||||
* @var array $set
|
||||
*/
|
||||
foreach ($data as $budgetId => $set) {
|
||||
@@ -121,7 +115,7 @@ class BudgetController extends Controller
|
||||
$sum = bcadd($amount, $sum);
|
||||
}
|
||||
$data[$budgetId]['sum'] = $sum;
|
||||
if (bccomp('0', $sum) === 0) {
|
||||
if (0 === bccomp('0', $sum)) {
|
||||
unset($data[$budgetId]);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -32,9 +31,7 @@ use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
|
||||
/**
|
||||
* Class CategoryController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
* Class CategoryController.
|
||||
*/
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
@@ -70,7 +67,6 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
@@ -107,6 +103,7 @@ class CategoryController extends Controller
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return mixed|string
|
||||
*
|
||||
* @internal param ReportHelperInterface $helper
|
||||
*/
|
||||
public function operations(Collection $accounts, Carbon $start, Carbon $end)
|
||||
@@ -128,7 +125,7 @@ class CategoryController extends Controller
|
||||
/** @var Category $category */
|
||||
foreach ($categories as $category) {
|
||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $start, $end);
|
||||
if (bccomp($spent, '0') !== 0) {
|
||||
if (0 !== bccomp($spent, '0')) {
|
||||
$report[$category->id] = ['name' => $category->name, 'spent' => $spent, 'id' => $category->id];
|
||||
}
|
||||
}
|
||||
@@ -149,7 +146,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters empty results from category period report
|
||||
* Filters empty results from category period report.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
@@ -163,12 +160,11 @@ class CategoryController extends Controller
|
||||
$sum = bcadd($amount, $sum);
|
||||
}
|
||||
$data[$categoryId]['sum'] = $sum;
|
||||
if (bccomp('0', $sum) === 0) {
|
||||
if (0 === bccomp('0', $sum)) {
|
||||
unset($data[$categoryId]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -30,13 +29,10 @@ use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class OperationsController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Report
|
||||
* Class OperationsController.
|
||||
*/
|
||||
class OperationsController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @param AccountTaskerInterface $tasker
|
||||
* @param Collection $accounts
|
||||
|
@@ -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;
|
||||
@@ -42,9 +41,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ReportController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class ReportController.
|
||||
*/
|
||||
class ReportController extends Controller
|
||||
{
|
||||
@@ -98,7 +95,6 @@ class ReportController extends Controller
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$generator = ReportGeneratorFactory::reportGenerator('Audit', $start, $end);
|
||||
$generator->setAccounts($accounts);
|
||||
$result = $generator->generate();
|
||||
@@ -227,7 +223,6 @@ class ReportController extends Controller
|
||||
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||
$accountList = join(',', $accounts->pluck('id')->toArray());
|
||||
|
||||
|
||||
return view('reports.index', compact('months', 'accounts', 'start', 'accountList', 'customFiscalYear'));
|
||||
}
|
||||
|
||||
@@ -274,26 +269,26 @@ class ReportController extends Controller
|
||||
$tags = join(',', $request->getTagList()->pluck('tag')->toArray());
|
||||
$uri = route('reports.index');
|
||||
|
||||
if ($request->getAccountList()->count() === 0) {
|
||||
if (0 === $request->getAccountList()->count()) {
|
||||
Log::debug('Account count is zero');
|
||||
Session::flash('error', trans('firefly.select_more_than_one_account'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ($request->getCategoryList()->count() === 0 && $reportType === 'category') {
|
||||
if (0 === $request->getCategoryList()->count() && 'category' === $reportType) {
|
||||
Session::flash('error', trans('firefly.select_more_than_one_category'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ($request->getBudgetList()->count() === 0 && $reportType === 'budget') {
|
||||
if (0 === $request->getBudgetList()->count() && 'budget' === $reportType) {
|
||||
Session::flash('error', trans('firefly.select_more_than_one_budget'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ($request->getTagList()->count() === 0 && $reportType === 'tag') {
|
||||
if (0 === $request->getTagList()->count() && 'tag' === $reportType) {
|
||||
Session::flash('error', trans('firefly.select_more_than_one_tag'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
|
@@ -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;
|
||||
@@ -45,9 +44,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class RuleController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class RuleController.
|
||||
*/
|
||||
class RuleController extends Controller
|
||||
{
|
||||
@@ -58,7 +55,6 @@ class RuleController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.rules'));
|
||||
@@ -102,7 +98,7 @@ class RuleController extends Controller
|
||||
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('rules.create.fromStore') !== true) {
|
||||
if (true !== session('rules.create.fromStore')) {
|
||||
$this->rememberPreviousUri('rules.create.uri');
|
||||
}
|
||||
Session::forget('rules.create.fromStore');
|
||||
@@ -191,7 +187,7 @@ class RuleController extends Controller
|
||||
}
|
||||
|
||||
// overrule old input when it as no rule data:
|
||||
if ($triggerCount === 0 && $actionCount === 0) {
|
||||
if (0 === $triggerCount && 0 === $actionCount) {
|
||||
$oldTriggers = $this->getCurrentTriggers($rule);
|
||||
$triggerCount = count($oldTriggers);
|
||||
$oldActions = $this->getCurrentActions($rule);
|
||||
@@ -203,7 +199,7 @@ class RuleController extends Controller
|
||||
$subTitle = trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('rules.edit.fromUpdate') !== true) {
|
||||
if (true !== session('rules.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('rules.edit.uri');
|
||||
}
|
||||
Session::forget('rules.edit.fromUpdate');
|
||||
@@ -226,13 +222,14 @@ class RuleController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given rule on a set of existing transactions
|
||||
* Execute the given rule on a set of existing transactions.
|
||||
*
|
||||
* @param SelectTransactionsRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @internal param RuleGroup $ruleGroup
|
||||
*/
|
||||
public function execute(SelectTransactionsRequest $request, AccountRepositoryInterface $repository, Rule $rule)
|
||||
@@ -343,7 +340,7 @@ class RuleController extends Controller
|
||||
Session::flash('success', trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rules.create.fromStore', true);
|
||||
|
||||
@@ -371,7 +368,7 @@ class RuleController extends Controller
|
||||
// build trigger array from response
|
||||
$triggers = $this->getValidTriggerList($request);
|
||||
|
||||
if (count($triggers) === 0) {
|
||||
if (0 === count($triggers)) {
|
||||
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
@@ -390,7 +387,7 @@ class RuleController extends Controller
|
||||
if (count($matchingTransactions) === $limit) {
|
||||
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
|
||||
}
|
||||
if (count($matchingTransactions) === 0) {
|
||||
if (0 === count($matchingTransactions)) {
|
||||
$warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
|
||||
}
|
||||
|
||||
@@ -417,7 +414,7 @@ class RuleController extends Controller
|
||||
{
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (count($triggers) === 0) {
|
||||
if (0 === count($triggers)) {
|
||||
return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
@@ -436,7 +433,7 @@ class RuleController extends Controller
|
||||
if (count($matchingTransactions) === $limit) {
|
||||
$warning = trans('firefly.warning_transaction_subset', ['max_num_transactions' => $limit]);
|
||||
}
|
||||
if (count($matchingTransactions) === 0) {
|
||||
if (0 === count($matchingTransactions)) {
|
||||
$warning = trans('firefly.warning_no_matching_transactions', ['num_transactions' => $range]);
|
||||
}
|
||||
|
||||
@@ -474,7 +471,7 @@ class RuleController extends Controller
|
||||
Session::flash('success', trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rules.edit.fromUpdate', true);
|
||||
|
||||
@@ -490,7 +487,7 @@ class RuleController extends Controller
|
||||
/** @var RuleRepositoryInterface $repository */
|
||||
$repository = app(RuleRepositoryInterface::class);
|
||||
|
||||
if ($repository->count() === 0) {
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'rule_group_id' => $repository->getFirstRuleGroup()->id,
|
||||
'stop_processing' => 0,
|
||||
@@ -519,11 +516,10 @@ class RuleController extends Controller
|
||||
*/
|
||||
private function createDefaultRuleGroup()
|
||||
{
|
||||
|
||||
/** @var RuleGroupRepositoryInterface $repository */
|
||||
$repository = app(RuleGroupRepositoryInterface::class);
|
||||
|
||||
if ($repository->count() === 0) {
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'title' => trans('firefly.default_rule_group_name'),
|
||||
'description' => trans('firefly.default_rule_group_description'),
|
||||
@@ -555,7 +551,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
++$index;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
@@ -573,7 +569,7 @@ class RuleController extends Controller
|
||||
|
||||
/** @var RuleTrigger $entry */
|
||||
foreach ($rule->ruleTriggers as $entry) {
|
||||
if ($entry->trigger_type !== 'user_action') {
|
||||
if ('user_action' !== $entry->trigger_type) {
|
||||
$count = ($index + 1);
|
||||
$triggers[] = view(
|
||||
'rules.partials.trigger',
|
||||
@@ -584,7 +580,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$index++;
|
||||
++$index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,7 +610,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
++$newIndex;
|
||||
}
|
||||
|
||||
return $actions;
|
||||
@@ -643,7 +639,7 @@ class RuleController extends Controller
|
||||
'count' => $count,
|
||||
]
|
||||
)->render();
|
||||
$newIndex++;
|
||||
++$newIndex;
|
||||
}
|
||||
|
||||
return $triggers;
|
||||
@@ -668,7 +664,7 @@ class RuleController extends Controller
|
||||
$triggers[] = [
|
||||
'type' => $triggerType,
|
||||
'value' => $data['rule-trigger-values'][$index],
|
||||
'stopProcessing' => intval($data['rule-trigger-stop'][$index]) === 1 ? true : false,
|
||||
'stopProcessing' => 1 === intval($data['rule-trigger-stop'][$index]) ? true : false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -38,9 +37,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class RuleGroupController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class RuleGroupController.
|
||||
*/
|
||||
class RuleGroupController extends Controller
|
||||
{
|
||||
@@ -51,7 +48,6 @@ class RuleGroupController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.rules'));
|
||||
@@ -71,7 +67,7 @@ class RuleGroupController extends Controller
|
||||
$subTitle = trans('firefly.make_new_rule_group');
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('rule-groups.create.fromStore') !== true) {
|
||||
if (true !== session('rule-groups.create.fromStore')) {
|
||||
$this->rememberPreviousUri('rule-groups.create.uri');
|
||||
}
|
||||
Session::forget('rule-groups.create.fromStore');
|
||||
@@ -116,7 +112,6 @@ class RuleGroupController extends Controller
|
||||
|
||||
$repository->destroy($ruleGroup, $moveTo);
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.deleted_rule_group', ['title' => $title])));
|
||||
Preferences::mark();
|
||||
|
||||
@@ -146,7 +141,7 @@ class RuleGroupController extends Controller
|
||||
$subTitle = trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('rule-groups.edit.fromUpdate') !== true) {
|
||||
if (true !== session('rule-groups.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('rule-groups.edit.uri');
|
||||
}
|
||||
Session::forget('rule-groups.edit.fromUpdate');
|
||||
@@ -157,7 +152,7 @@ class RuleGroupController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given rulegroup on a set of existing transactions
|
||||
* Execute the given rulegroup on a set of existing transactions.
|
||||
*
|
||||
* @param SelectTransactionsRequest $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
@@ -223,7 +218,7 @@ class RuleGroupController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rule-groups.create.fromStore', true);
|
||||
|
||||
@@ -259,7 +254,7 @@ class RuleGroupController extends Controller
|
||||
$data = [
|
||||
'title' => $request->input('title'),
|
||||
'description' => $request->input('description'),
|
||||
'active' => intval($request->input('active')) === 1,
|
||||
'active' => 1 === intval($request->input('active')),
|
||||
];
|
||||
|
||||
$repository->update($ruleGroup, $data);
|
||||
@@ -267,7 +262,7 @@ class RuleGroupController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.updated_rule_group', ['title' => $ruleGroup->title])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('rule-groups.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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;
|
||||
@@ -30,9 +29,7 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class SearchController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class SearchController.
|
||||
*/
|
||||
class SearchController extends Controller
|
||||
{
|
||||
|
@@ -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;
|
||||
@@ -38,7 +37,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class TagController
|
||||
* Class TagController.
|
||||
*
|
||||
* Remember: a balancingAct takes at most one expense and one transfer.
|
||||
* an advancePayment takes at most one expense, infinite deposits and NO transfers.
|
||||
@@ -47,13 +46,10 @@ use View;
|
||||
* Other attempts to put in such a tag are blocked.
|
||||
* also show an error when editing a tag and it becomes either
|
||||
* of these two types. Or rather, block editing of the tag.
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
*/
|
||||
class TagController extends Controller
|
||||
{
|
||||
|
||||
/** @var TagRepositoryInterface */
|
||||
/** @var TagRepositoryInterface */
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
@@ -88,7 +84,7 @@ class TagController extends Controller
|
||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('tags.create.fromStore') !== true) {
|
||||
if (true !== session('tags.create.fromStore')) {
|
||||
$this->rememberPreviousUri('tags.create.uri');
|
||||
}
|
||||
Session::forget('tags.create.fromStore');
|
||||
@@ -99,7 +95,7 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a tag
|
||||
* Delete a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
@@ -134,7 +130,7 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a tag
|
||||
* Edit a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
@@ -147,7 +143,7 @@ class TagController extends Controller
|
||||
$apiKey = env('GOOGLE_MAPS_API_KEY', '');
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('tags.edit.fromUpdate') !== true) {
|
||||
if (true !== session('tags.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('tags.edit.uri');
|
||||
}
|
||||
Session::forget('tags.edit.fromUpdate');
|
||||
@@ -158,7 +154,7 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* View all tags
|
||||
* View all tags.
|
||||
*
|
||||
* @param TagRepositoryInterface $repository
|
||||
*
|
||||
@@ -170,13 +166,13 @@ class TagController extends Controller
|
||||
$oldestTag = $repository->oldestTag();
|
||||
/** @var Carbon $start */
|
||||
$start = new Carbon;
|
||||
if (!is_null($oldestTag)) {
|
||||
if (null !== $oldestTag) {
|
||||
/** @var Carbon $start */
|
||||
$start = $oldestTag->date;
|
||||
}
|
||||
if (is_null($oldestTag)) {
|
||||
if (null === $oldestTag) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone(session('first'));
|
||||
$start = clone session('first');
|
||||
}
|
||||
|
||||
$now = new Carbon;
|
||||
@@ -216,7 +212,7 @@ class TagController extends Controller
|
||||
$path = route('tags.show', [$tag->id]);
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$start = $repository->firstUseDate($tag);
|
||||
$end = new Carbon;
|
||||
@@ -224,20 +220,20 @@ class TagController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_tag',
|
||||
['tag' => $tag->tag,
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
|
||||
'start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
);
|
||||
$periods = $this->getPeriodOverview($tag);
|
||||
$path = route('tags.show', [$tag->id, $moment]);
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
/** @var Carbon $start */
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
/** @var Carbon $end */
|
||||
@@ -274,7 +270,7 @@ class TagController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.created_tag', ['tag' => $data['tag']])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('create_another')) === 1) {
|
||||
if (1 === intval($request->get('create_another'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('tags.create.fromStore', true);
|
||||
|
||||
@@ -299,7 +295,7 @@ class TagController extends Controller
|
||||
Session::flash('success', strval(trans('firefly.updated_tag', ['tag' => $data['tag']])));
|
||||
Preferences::mark();
|
||||
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
Session::put('tags.edit.fromUpdate', true);
|
||||
|
||||
|
@@ -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\Transaction;
|
||||
@@ -37,13 +36,11 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class ConvertController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Transaction
|
||||
* Class ConvertController.
|
||||
*/
|
||||
class ConvertController extends Controller
|
||||
{
|
||||
/** @var AccountRepositoryInterface */
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $accounts;
|
||||
|
||||
/**
|
||||
@@ -117,11 +114,9 @@ class ConvertController extends Controller
|
||||
'sourceType',
|
||||
'subTitle',
|
||||
'subTitleIcon'
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// convert withdrawal to deposit requires a new source account ()
|
||||
// or to transfer requires
|
||||
}
|
||||
@@ -178,6 +173,7 @@ class ConvertController extends Controller
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getDestinationAccount(TransactionJournal $journal, TransactionType $destinationType, array $data): Account
|
||||
@@ -202,7 +198,7 @@ class ConvertController extends Controller
|
||||
case TransactionType::DEPOSIT . '-' . TransactionType::WITHDRAWAL:
|
||||
case TransactionType::TRANSFER . '-' . TransactionType::WITHDRAWAL:
|
||||
// three and five
|
||||
if ($data['destination_account_expense'] === '' || is_null($data['destination_account_expense'])) {
|
||||
if ('' === $data['destination_account_expense'] || null === $data['destination_account_expense']) {
|
||||
// destination is a cash account.
|
||||
$destination = $accountRepository->getCashAccount();
|
||||
|
||||
@@ -233,6 +229,7 @@ class ConvertController extends Controller
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getSourceAccount(TransactionJournal $journal, TransactionType $destinationType, array $data): Account
|
||||
@@ -249,7 +246,7 @@ class ConvertController extends Controller
|
||||
case TransactionType::WITHDRAWAL . '-' . TransactionType::DEPOSIT:
|
||||
case TransactionType::TRANSFER . '-' . TransactionType::DEPOSIT:
|
||||
|
||||
if ($data['source_account_revenue'] === '' || is_null($data['source_account_revenue'])) {
|
||||
if ('' === $data['source_account_revenue'] || null === $data['source_account_revenue']) {
|
||||
// destination is a cash account.
|
||||
$destination = $accountRepository->getCashAccount();
|
||||
|
||||
|
@@ -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\Transaction;
|
||||
@@ -36,14 +35,10 @@ use URL;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class LinkController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Transaction
|
||||
* Class LinkController.
|
||||
*/
|
||||
class LinkController extends Controller
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -61,7 +56,6 @@ class LinkController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
@@ -107,7 +101,7 @@ class LinkController extends Controller
|
||||
TransactionJournal $journal
|
||||
) {
|
||||
$linkInfo = $request->getLinkInfo();
|
||||
if ($linkInfo['transaction_journal_id'] === 0) {
|
||||
if (0 === $linkInfo['transaction_journal_id']) {
|
||||
Session::flash('error', trans('firefly.invalid_link_selection'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->id]));
|
||||
@@ -124,13 +118,13 @@ class LinkController extends Controller
|
||||
|
||||
$journalLink = new TransactionJournalLink;
|
||||
$journalLink->linkType()->associate($linkType);
|
||||
if ($linkInfo['direction'] === 'inward') {
|
||||
if ('inward' === $linkInfo['direction']) {
|
||||
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $other->id, $journal->id));
|
||||
$journalLink->source()->associate($other);
|
||||
$journalLink->destination()->associate($journal);
|
||||
}
|
||||
|
||||
if ($linkInfo['direction'] === 'outward') {
|
||||
if ('outward' === $linkInfo['direction']) {
|
||||
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $journal->id, $other->id));
|
||||
$journalLink->source()->associate($journal);
|
||||
$journalLink->destination()->associate($other);
|
||||
|
@@ -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\Transaction;
|
||||
@@ -39,9 +38,7 @@ use Session;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class MassController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Transaction
|
||||
* Class MassController.
|
||||
*/
|
||||
class MassController extends Controller
|
||||
{
|
||||
@@ -52,7 +49,6 @@ class MassController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.transactions'));
|
||||
@@ -95,7 +91,7 @@ class MassController extends Controller
|
||||
foreach ($ids as $journalId) {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $repository->find(intval($journalId));
|
||||
if (!is_null($journal->id) && intval($journalId) === $journal->id) {
|
||||
if (null !== $journal->id && intval($journalId) === $journal->id) {
|
||||
$set->push($journal);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +102,7 @@ class MassController extends Controller
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($set as $journal) {
|
||||
$repository->delete($journal);
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
|
||||
Preferences::mark();
|
||||
@@ -116,7 +112,6 @@ class MassController extends Controller
|
||||
return redirect($this->getPreviousUri('transactions.mass-delete.uri'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $journals
|
||||
*
|
||||
@@ -139,7 +134,7 @@ class MassController extends Controller
|
||||
$filtered = new Collection;
|
||||
$messages = [];
|
||||
/**
|
||||
* @var TransactionJournal $journal
|
||||
* @var TransactionJournal
|
||||
*/
|
||||
foreach ($journals as $journal) {
|
||||
$sources = $journal->sourceAccountList();
|
||||
@@ -153,7 +148,7 @@ class MassController extends Controller
|
||||
$messages[] = trans('firefly.cannot_edit_multiple_dest', ['description' => $journal->description, 'id' => $journal->id]);
|
||||
continue;
|
||||
}
|
||||
if ($journal->transactionType->type === TransactionType::OPENING_BALANCE) {
|
||||
if (TransactionType::OPENING_BALANCE === $journal->transactionType->type) {
|
||||
$messages[] = trans('firefly.cannot_edit_opening_balance');
|
||||
continue;
|
||||
}
|
||||
@@ -191,18 +186,18 @@ class MassController extends Controller
|
||||
$journal->foreign_amount = floatval($transaction->foreign_amount);
|
||||
$journal->foreign_currency = $transaction->foreignCurrency;
|
||||
|
||||
if (!is_null($sources->first())) {
|
||||
if (null !== $sources->first()) {
|
||||
$journal->source_account_id = $sources->first()->id;
|
||||
$journal->source_account_name = $sources->first()->editname;
|
||||
}
|
||||
if (!is_null($destinations->first())) {
|
||||
if (null !== $destinations->first()) {
|
||||
$journal->destination_account_id = $destinations->first()->id;
|
||||
$journal->destination_account_name = $destinations->first()->editname;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ($filtered->count() === 0) {
|
||||
if (0 === $filtered->count()) {
|
||||
Session::flash('error', trans('firefly.no_edit_multiple_left'));
|
||||
}
|
||||
|
||||
@@ -265,7 +260,7 @@ class MassController extends Controller
|
||||
// call repository update function.
|
||||
$repository->update($journal, $data);
|
||||
|
||||
$count++;
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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\Transaction;
|
||||
@@ -48,26 +47,24 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class SingleController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Transaction
|
||||
* Class SingleController.
|
||||
*/
|
||||
class SingleController extends Controller
|
||||
{
|
||||
/** @var AccountRepositoryInterface */
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $accounts;
|
||||
|
||||
/** @var AttachmentHelperInterface */
|
||||
private $attachments;
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $budgets;
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
private $currency;
|
||||
/** @var PiggyBankRepositoryInterface */
|
||||
/** @var PiggyBankRepositoryInterface */
|
||||
private $piggyBanks;
|
||||
|
||||
/** @var JournalRepositoryInterface */
|
||||
/** @var JournalRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
@@ -105,14 +102,14 @@ class SingleController extends Controller
|
||||
$source = $journal->sourceAccountList()->first();
|
||||
$destination = $journal->destinationAccountList()->first();
|
||||
$budget = $journal->budgets()->first();
|
||||
$budgetId = is_null($budget) ? 0 : $budget->id;
|
||||
$budgetId = null === $budget ? 0 : $budget->id;
|
||||
$category = $journal->categories()->first();
|
||||
$categoryName = is_null($category) ? '' : $category->name;
|
||||
$categoryName = null === $category ? '' : $category->name;
|
||||
$tags = join(',', $journal->tags()->get()->pluck('tag')->toArray());
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $journal->transactions()->first();
|
||||
$amount = Steam::positive($transaction->amount);
|
||||
$foreignAmount = is_null($transaction->foreign_amount) ? null : Steam::positive($transaction->foreign_amount);
|
||||
$foreignAmount = null === $transaction->foreign_amount ? null : Steam::positive($transaction->foreign_amount);
|
||||
|
||||
$preFilled = [
|
||||
'description' => $journal->description,
|
||||
@@ -142,7 +139,7 @@ class SingleController extends Controller
|
||||
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$preFilled['notes'] = $note->text;
|
||||
}
|
||||
|
||||
@@ -172,7 +169,7 @@ class SingleController extends Controller
|
||||
Session::put('preFilled', $preFilled);
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (session('transactions.create.fromStore') !== true) {
|
||||
if (true !== session('transactions.create.fromStore')) {
|
||||
$this->rememberPreviousUri('transactions.create.uri');
|
||||
}
|
||||
Session::forget('transactions.create.fromStore');
|
||||
@@ -218,6 +215,7 @@ class SingleController extends Controller
|
||||
* @param TransactionJournal $transactionJournal
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @internal param JournalRepositoryInterface $repository
|
||||
*/
|
||||
public function destroy(TransactionJournal $transactionJournal)
|
||||
@@ -265,7 +263,7 @@ class SingleController extends Controller
|
||||
$destinationAccounts = $journal->destinationAccountList();
|
||||
$optionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
|
||||
$pTransaction = $journal->positiveTransaction();
|
||||
$foreignCurrency = !is_null($pTransaction->foreignCurrency) ? $pTransaction->foreignCurrency : $pTransaction->transactionCurrency;
|
||||
$foreignCurrency = null !== $pTransaction->foreignCurrency ? $pTransaction->foreignCurrency : $pTransaction->transactionCurrency;
|
||||
$preFilled = [
|
||||
'date' => $journal->dateAsString(),
|
||||
'interest_date' => $journal->dateAsString('interest_date'),
|
||||
@@ -299,13 +297,13 @@ class SingleController extends Controller
|
||||
];
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$preFilled['notes'] = $note->text;
|
||||
}
|
||||
|
||||
// amounts for withdrawals and deposits:
|
||||
// amount, native_amount, source_amount, destination_amount
|
||||
if (($journal->isWithdrawal() || $journal->isDeposit()) && !is_null($pTransaction->foreign_amount)) {
|
||||
if (($journal->isWithdrawal() || $journal->isDeposit()) && null !== $pTransaction->foreign_amount) {
|
||||
$preFilled['amount'] = $pTransaction->foreign_amount;
|
||||
$preFilled['currency'] = $pTransaction->foreignCurrency;
|
||||
}
|
||||
@@ -315,7 +313,7 @@ class SingleController extends Controller
|
||||
Session::flash('gaEventAction', 'edit-' . $what);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('transactions.edit.fromUpdate') !== true) {
|
||||
if (true !== session('transactions.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('transactions.edit.uri');
|
||||
}
|
||||
Session::forget('transactions.edit.fromUpdate');
|
||||
@@ -334,11 +332,11 @@ class SingleController extends Controller
|
||||
*/
|
||||
public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
$doSplit = intval($request->get('split_journal')) === 1;
|
||||
$createAnother = intval($request->get('create_another')) === 1;
|
||||
$doSplit = 1 === intval($request->get('split_journal'));
|
||||
$createAnother = 1 === intval($request->get('create_another'));
|
||||
$data = $request->getJournalData();
|
||||
$journal = $repository->store($data);
|
||||
if (is_null($journal->id)) {
|
||||
if (null === $journal->id) {
|
||||
// error!
|
||||
Log::error('Could not store transaction journal: ', $journal->getErrors()->toArray());
|
||||
Session::flash('error', $journal->getErrors()->first());
|
||||
@@ -366,13 +364,13 @@ class SingleController extends Controller
|
||||
Preferences::mark();
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($createAnother === true) {
|
||||
if (true === $createAnother) {
|
||||
Session::put('transactions.create.fromStore', true);
|
||||
|
||||
return redirect(route('transactions.create', [$request->input('what')]))->withInput();
|
||||
}
|
||||
|
||||
if ($doSplit === true) {
|
||||
if (true === $doSplit) {
|
||||
return redirect(route('transactions.split.edit', [$journal->id]));
|
||||
}
|
||||
|
||||
@@ -419,7 +417,7 @@ class SingleController extends Controller
|
||||
Preferences::mark();
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
Session::put('transactions.edit.fromUpdate', true);
|
||||
|
||||
return redirect(route('transactions.edit', [$journal->id]))->withInput(['return_to_edit' => 1]);
|
||||
@@ -440,7 +438,7 @@ class SingleController extends Controller
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$type = $account->getMeta('accountRole');
|
||||
if (strlen($type) === 0) {
|
||||
if (0 === strlen($type)) {
|
||||
$type = 'no_account_type';
|
||||
}
|
||||
$key = strval(trans('firefly.opt_group_' . $type));
|
||||
@@ -460,7 +458,7 @@ class SingleController extends Controller
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$type = $account->getMeta('accountRole');
|
||||
if (strlen($type) === 0) {
|
||||
if (0 === strlen($type)) {
|
||||
$type = 'no_account_type';
|
||||
}
|
||||
$key = strval(trans('firefly.opt_group_' . $type));
|
||||
|
@@ -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\Transaction;
|
||||
@@ -45,21 +44,17 @@ use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class SplitController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Transaction
|
||||
*
|
||||
* Class SplitController.
|
||||
*/
|
||||
class SplitController extends Controller
|
||||
{
|
||||
|
||||
/** @var AccountRepositoryInterface */
|
||||
/** @var AccountRepositoryInterface */
|
||||
private $accounts;
|
||||
|
||||
/** @var AttachmentHelperInterface */
|
||||
private $attachments;
|
||||
|
||||
/** @var BudgetRepositoryInterface */
|
||||
/** @var BudgetRepositoryInterface */
|
||||
private $budgets;
|
||||
|
||||
/** @var CurrencyRepositoryInterface */
|
||||
@@ -75,7 +70,6 @@ class SplitController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
// some useful repositories:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
@@ -122,12 +116,11 @@ class SplitController extends Controller
|
||||
$accountArray[$account->id]['currency_id'] = intval($account->getMeta('currency_id'));
|
||||
}
|
||||
|
||||
|
||||
Session::flash('gaEventCategory', 'transactions');
|
||||
Session::flash('gaEventAction', 'edit-split-' . $preFilled['what']);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (session('transactions.edit-split.fromUpdate') !== true) {
|
||||
if (true !== session('transactions.edit-split.fromUpdate')) {
|
||||
$this->rememberPreviousUri('transactions.edit-split.uri');
|
||||
}
|
||||
Session::forget('transactions.edit-split.fromUpdate');
|
||||
@@ -150,7 +143,6 @@ class SplitController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SplitJournalFormRequest $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
@@ -183,7 +175,7 @@ class SplitController extends Controller
|
||||
Preferences::mark();
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (intval($request->get('return_to_edit')) === 1) {
|
||||
if (1 === intval($request->get('return_to_edit'))) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
Session::put('transactions.edit-split.fromUpdate', true);
|
||||
|
||||
@@ -202,7 +194,7 @@ class SplitController extends Controller
|
||||
*/
|
||||
private function arrayFromInput(SplitJournalFormRequest $request): array
|
||||
{
|
||||
$tags = is_null($request->get('tags')) ? '' : $request->get('tags');
|
||||
$tags = null === $request->get('tags') ? '' : $request->get('tags');
|
||||
$array = [
|
||||
'journal_description' => $request->get('journal_description'),
|
||||
'journal_source_account_id' => $request->get('journal_source_account_id'),
|
||||
@@ -225,7 +217,6 @@ class SplitController extends Controller
|
||||
'transactions' => $this->getTransactionDataFromRequest($request),
|
||||
];
|
||||
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -242,7 +233,7 @@ class SplitController extends Controller
|
||||
$notes = '';
|
||||
/** @var Note $note */
|
||||
$note = $journal->notes()->first();
|
||||
if (!is_null($note)) {
|
||||
if (null !== $note) {
|
||||
$notes = $note->text;
|
||||
}
|
||||
$array = [
|
||||
@@ -303,11 +294,10 @@ class SplitController extends Controller
|
||||
'foreign_currency_id' => $transaction['foreign_currency_id'],
|
||||
'foreign_currency_code' => $transaction['foreign_currency_code'],
|
||||
'foreign_currency_symbol' => $transaction['foreign_currency_symbol'],
|
||||
|
||||
];
|
||||
|
||||
// set initial category and/or budget:
|
||||
if (count($transactions) === 1 && $index === 0) {
|
||||
if (1 === count($transactions) && 0 === $index) {
|
||||
$set['budget_id'] = $journal->budgetId();
|
||||
$set['category'] = $journal->categoryAsString();
|
||||
}
|
||||
@@ -340,7 +330,6 @@ class SplitController extends Controller
|
||||
'category' => $transaction['category'] ?? '',
|
||||
'transaction_currency_id' => intval($transaction['transaction_currency_id']),
|
||||
'foreign_currency_id' => $transaction['foreign_currency_id'] ?? null,
|
||||
|
||||
];
|
||||
}
|
||||
Log::debug(sprintf('Found %d splits in request data.', count($return)));
|
||||
@@ -356,7 +345,7 @@ class SplitController extends Controller
|
||||
*/
|
||||
private function updateWithPrevious($array, $old): array
|
||||
{
|
||||
if (count($old) === 0 || !isset($old['transactions'])) {
|
||||
if (0 === count($old) || !isset($old['transactions'])) {
|
||||
return $array;
|
||||
}
|
||||
$old = $old['transactions'];
|
||||
|
@@ -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;
|
||||
@@ -42,9 +41,7 @@ use Response;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class TransactionController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers
|
||||
* Class TransactionController.
|
||||
*/
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
@@ -55,7 +52,6 @@ class TransactionController extends Controller
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
View::share('title', trans('firefly.transactions'));
|
||||
@@ -70,7 +66,6 @@ class TransactionController extends Controller
|
||||
* @param Request $request
|
||||
* @param JournalRepositoryInterface $repository
|
||||
* @param string $what
|
||||
*
|
||||
* @param string $moment
|
||||
*
|
||||
* @return View
|
||||
@@ -89,7 +84,7 @@ class TransactionController extends Controller
|
||||
$path = route('transactions.index', [$what]);
|
||||
|
||||
// prep for "all" view.
|
||||
if ($moment === 'all') {
|
||||
if ('all' === $moment) {
|
||||
$subTitle = trans('firefly.all_' . $what);
|
||||
$first = $repository->first();
|
||||
$start = $first->date ?? new Carbon;
|
||||
@@ -98,7 +93,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
// prep for "specific date" view.
|
||||
if (strlen($moment) > 0 && $moment !== 'all') {
|
||||
if (strlen($moment) > 0 && 'all' !== $moment) {
|
||||
$start = new Carbon($moment);
|
||||
$end = Navigation::endOfPeriod($start, $range);
|
||||
$path = route('transactions.index', [$what, $moment]);
|
||||
@@ -110,7 +105,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
// prep for current period
|
||||
if (strlen($moment) === 0) {
|
||||
if (0 === strlen($moment)) {
|
||||
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$periods = $this->getPeriodOverview($what);
|
||||
@@ -127,7 +122,6 @@ class TransactionController extends Controller
|
||||
$transactions = $collector->getPaginatedJournals();
|
||||
$transactions->setPath($path);
|
||||
|
||||
|
||||
return view('transactions.index', compact('subTitle', 'what', 'subTitleIcon', 'transactions', 'periods', 'start', 'end', 'moment'));
|
||||
}
|
||||
|
||||
@@ -163,7 +157,7 @@ class TransactionController extends Controller
|
||||
$journal = $repository->find(intval($id));
|
||||
if ($journal && $journal->date->isSameDay($date)) {
|
||||
$repository->setOrder($journal, $order);
|
||||
$order++;
|
||||
++$order;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +169,6 @@ class TransactionController extends Controller
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param JournalTaskerInterface $tasker
|
||||
*
|
||||
* @param LinkTypeRepositoryInterface $linkTypeRepository
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||
@@ -199,6 +192,7 @@ class TransactionController extends Controller
|
||||
* @param string $what
|
||||
*
|
||||
* @return Collection
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function getPeriodOverview(string $what): Collection
|
||||
@@ -290,7 +284,7 @@ class TransactionController extends Controller
|
||||
}
|
||||
// save amount:
|
||||
$return[$currencyId]['sum'] = bcadd($return[$currencyId]['sum'], $transaction->transaction_amount);
|
||||
$return[$currencyId]['count']++;
|
||||
++$return[$currencyId]['count'];
|
||||
}
|
||||
asort($return);
|
||||
|
||||
|
Reference in New Issue
Block a user