mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Code cleanup for scrutinizer.
This commit is contained in:
@@ -74,9 +74,9 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Handle a login request to the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response|void
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
@@ -109,9 +109,10 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
* @param CookieJar $cookieJar
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return $this
|
||||
*/
|
||||
public function logout(Request $request, CookieJar $cookieJar)
|
||||
{
|
||||
@@ -127,11 +128,10 @@ class LoginController extends Controller
|
||||
* Show the application's login form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param CookieJar $cookieJar
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showLoginForm(Request $request, CookieJar $cookieJar)
|
||||
public function showLoginForm(Request $request)
|
||||
{
|
||||
// check for presence of tables:
|
||||
$hasTable = Schema::hasTable('users');
|
||||
@@ -166,6 +166,6 @@ class LoginController extends Controller
|
||||
$email = $request->old('email');
|
||||
$remember = $request->old('remember');
|
||||
|
||||
return view('auth.login', compact('allowRegistration', 'email', 'remember')); //->withCookie($cookie);
|
||||
return view('auth.login', compact('allowRegistration', 'email', 'remember'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class BudgetController extends Controller
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
|
||||
if (0 === $amount) {
|
||||
if (bccomp($amount,'0') === 0) {
|
||||
$budgetLimit = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ class BankController extends Controller
|
||||
$remoteAccounts = array_keys($remoteAccounts);
|
||||
$class = config(sprintf('firefly.import_pre.%s', $bank));
|
||||
// get import file
|
||||
unset($remoteAccounts, $class);
|
||||
|
||||
// get import config
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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;
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\SingleCacheProperties;
|
||||
use Illuminate\Http\Request;
|
||||
use Response;
|
||||
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
public function amounts(Request $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
$ids = $request->get('transactions');
|
||||
|
||||
$cache = new SingleCacheProperties;
|
||||
$cache->addProperty('json-reconcile-amounts');
|
||||
$cache->addProperty($ids);
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get());
|
||||
}
|
||||
|
||||
$totals = [];
|
||||
// for each transaction, get amount(s)
|
||||
foreach ($ids as $transactionId) {
|
||||
$transaction = $repository->findTransaction(intval($transactionId));
|
||||
$transactionType = $transaction->transactionJournal->transactionType->type;
|
||||
|
||||
// default amount:
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
if (!isset($totals[$currencyId])) {
|
||||
$totals[$currencyId] = [
|
||||
'amount' => '0',
|
||||
'currency' => $transaction->transactionCurrency,
|
||||
'type' => $transactionType,
|
||||
];
|
||||
}
|
||||
// add default amount:
|
||||
$totals[$currencyId]['amount'] = bcadd($totals[$currencyId]['amount'], app('steam')->positive($transaction->amount));
|
||||
|
||||
// foreign amount:
|
||||
if (null !== $transaction->foreign_amount) {
|
||||
$currencyId = $transaction->foreign_currency_id;
|
||||
if (!isset($totals[$currencyId])) {
|
||||
$totals[$currencyId] = [
|
||||
'amount' => '0',
|
||||
'currency' => $transaction->foreignCurrency,
|
||||
'type' => $transactionType,
|
||||
];
|
||||
}
|
||||
// add foreign amount:
|
||||
$totals[$currencyId]['amount'] = bcadd($totals[$currencyId]['amount'], app('steam')->positive($transaction->foreign_amount));
|
||||
}
|
||||
}
|
||||
$entries = [];
|
||||
foreach ($totals as $entry) {
|
||||
$amount = $entry['amount'];
|
||||
if (TransactionType::WITHDRAWAL === $entry['type']) {
|
||||
$amount = bcmul($entry['amount'], '-1');
|
||||
}
|
||||
$entries[] = app('amount')->formatAnything($entry['currency'], $amount, false);
|
||||
}
|
||||
$result = ['amounts' => join(' / ', $entries)];
|
||||
$cache->store($result);
|
||||
|
||||
return Response::json($result);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Hash;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Session;
|
||||
@@ -41,6 +42,8 @@ use View;
|
||||
|
||||
/**
|
||||
* Class ProfileController.
|
||||
*
|
||||
* @method Guard guard()
|
||||
*/
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace FireflyIII\Http\Controllers;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Search\SearchInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Response;
|
||||
use View;
|
||||
|
||||
@@ -70,8 +71,8 @@ class SearchController extends Controller
|
||||
|
||||
public function search(Request $request, SearchInterface $searcher)
|
||||
{
|
||||
$fullQuery = strval($request->get('query'));
|
||||
|
||||
$fullQuery = strval($request->get('query'));
|
||||
$transactions = new Collection;
|
||||
// cache
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('search');
|
||||
|
||||
@@ -143,7 +143,7 @@ class LinkController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function switch(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link)
|
||||
public function switchLink(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link)
|
||||
{
|
||||
$repository->switchLink($link);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user