mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +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\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);
|
||||
|
Reference in New Issue
Block a user