Skip to content

Firefly III: a personal finances manager

Various code cleanup.

James Colee68594a93b4d
diff --git a/app/Console/Commands/CreateImport.php b/app/Console/Commands/CreateImport.php
index d0be59aa1e..be7e62987e 100644
--- a/app/Console/Commands/CreateImport.php
+++ b/app/Console/Commands/CreateImport.php
@@ -43,7 +43,8 @@ class CreateImport extends Command
*
* @var string
*/
- protected $signature = 'firefly:create-import
+ protected $signature
+ = 'firefly:create-import
{file : The file to import.}
{configuration : The configuration file to use for the import/}
{--type=csv : The file type of the import.}
diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.php
index 889f64ad0e..ebf3311b0c 100644
--- a/app/Console/Commands/VerifiesAccessToken.php
+++ b/app/Console/Commands/VerifiesAccessToken.php
@@ -27,6 +27,7 @@ trait VerifiesAccessToken
{
/**
* Abstract method to make sure trait knows about method "option".
+ *
* @param null $key
*
* @return mixed
diff --git a/app/Export/Entry/Entry.php b/app/Export/Entry/Entry.php
index 1422750e6b..d99f79587b 100644
--- a/app/Export/Entry/Entry.php
+++ b/app/Export/Entry/Entry.php
@@ -14,7 +14,6 @@ declare(strict_types=1);
namespace FireflyIII\Export\Entry;
use FireflyIII\Models\Transaction;
-use Steam;
/**
* To extend the exported object, in case of new features in Firefly III for example,
diff --git a/app/Export/ExpandedProcessor.php b/app/Export/ExpandedProcessor.php
index b4a0ddc3e5..c476b937dc 100644
--- a/app/Export/ExpandedProcessor.php
+++ b/app/Export/ExpandedProcessor.php
@@ -108,8 +108,8 @@ class ExpandedProcessor implements ProcessorInterface
$notes = $this->getNotes($ids);
$tags = $this->getTags($ids);
/** @var array $ibans */
- $ibans = $this->getIbans($assetIds) + $this->getIbans($opposingIds);
- $currencies = $this->getAccountCurrencies($ibans);
+ $ibans = $this->getIbans($assetIds) + $this->getIbans($opposingIds);
+ $currencies = $this->getAccountCurrencies($ibans);
$transactions->each(
function (Transaction $transaction) use ($notes, $tags, $ibans, $currencies) {
$journalId = intval($transaction->journal_id);
diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.php
index 55b83abadf..4f5431745e 100644
--- a/app/Handlers/Events/AdminEventHandler.php
+++ b/app/Handlers/Events/AdminEventHandler.php
@@ -49,6 +49,7 @@ class AdminEventHandler
Session::flash('error', 'Possible email error: ' . $e->getMessage());
}
Log::debug('If no error above this line, message was sent.');
+
// @codeCoverageIgnoreEnd
return true;
}
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index f64f72b098..942988086b 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
use Carbon\Carbon;
use ExpandedForm;
use FireflyIII\Exceptions\FireflyException;
@@ -73,7 +72,7 @@ class AccountController extends Controller
$repository = app(CurrencyRepositoryInterface::class);
$allCurrencies = $repository->get();
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
$subTitle = trans('firefly.make_new_' . $what . '_account');
$roles = [];
@@ -244,6 +243,7 @@ class AccountController extends Controller
/**
* Show an account.
+ *
* @param Request $request
* @param JournalRepositoryInterface $repository
* @param Account $account
diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.php
index 66da4a214c..f4270c3f38 100644
--- a/app/Http/Controllers/Admin/HomeController.php
+++ b/app/Http/Controllers/Admin/HomeController.php
@@ -17,8 +17,8 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Http\Controllers\Controller;
use Illuminate\Http\Request;
-use Session;
use Log;
+use Session;
/**
* Class HomeController
@@ -49,6 +49,7 @@ class HomeController extends Controller
Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress));
event(new AdminRequestedTestMessage(auth()->user(), $ipAddress));
Session::flash('info', strval(trans('firefly.send_test_triggered')));
+
return redirect(route('admin.index'));
}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index 8c5a860e13..d975ec5adc 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -14,7 +14,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
use FireflyConfig;
-use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\User;
use Illuminate\Cookie\CookieJar;
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index c5ac25fcd3..a517272c6b 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest;
@@ -131,7 +130,7 @@ class BillController extends Controller
$this->rememberPreviousUri('bills.edit.uri');
}
- $currency = Amount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
$bill->amount_min = round($bill->amount_min, $currency->decimal_places);
$bill->amount_max = round($bill->amount_max, $currency->decimal_places);
diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php
index e371aeeeab..79a5e03409 100644
--- a/app/Http/Controllers/BudgetController.php
+++ b/app/Http/Controllers/BudgetController.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
@@ -199,7 +198,7 @@ class BudgetController extends Controller
$periodStart = $start->formatLocalized($this->monthAndDayFormat);
$periodEnd = $end->formatLocalized($this->monthAndDayFormat);
$budgetInformation = $this->repository->collectBudgetInformation($budgets, $start, $end);
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
$spent = array_sum(array_column($budgetInformation, 'spent'));
$budgeted = array_sum(array_column($budgetInformation, 'budgeted'));
@@ -268,7 +267,7 @@ class BudgetController extends Controller
'earned' => '0',
'suggested' => '0',
];
- $currency = Amount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
$range = Preferences::get('viewRange', '1M')->data;
$begin = Navigation::subtractPeriod($start, $range, 3);
@@ -380,7 +379,7 @@ class BudgetController extends Controller
{
$start = Carbon::createFromFormat('Y-m-d', $request->string('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->string('end'));
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
$amount = $request->get('amount');
$this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount);
@@ -515,7 +514,7 @@ class BudgetController extends Controller
*/
public function updateIncome(Carbon $start, Carbon $end)
{
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
$available = round($available, $defaultCurrency->decimal_places);
diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php
index 056260f5b5..c35295733f 100644
--- a/app/Http/Controllers/CategoryController.php
+++ b/app/Http/Controllers/CategoryController.php
@@ -238,8 +238,8 @@ class CategoryController extends Controller
$subTitle = trans('firefly.all_journals_for_category', ['name' => $category->name]);
$first = $repository->firstUseDate($category);
/** @var Carbon $start */
- $start = is_null($first) ? new Carbon : $first;
- $end = new Carbon;
+ $start = is_null($first) ? new Carbon : $first;
+ $end = new Carbon;
}
// prep for "specific date" view.
@@ -257,7 +257,7 @@ class CategoryController extends Controller
// prep for current period
if (strlen($moment) === 0) {
/** @var Carbon $start */
- $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
+ $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
/** @var Carbon $end */
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
$periods = $this->getPeriodOverview($category);
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 87f254a110..664fe01622 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -44,7 +44,7 @@ class Controller extends BaseController
protected $monthAndDayFormat;
/** @var string */
protected $monthFormat;
- /** @var string */
+ /** @var string */
protected $redirectUri = '/';
/**
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 75b6721562..66fe45ce1e 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -153,12 +153,12 @@ class HomeController extends Controller
public function routes()
{
$set = RouteFacade::getRoutes();
- $ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.','attachments.download', 'attachments.preview',
- 'bills.rescan','budgets.income','currencies.def','error','flush','help.show','import.file',
- 'login','logout','password.reset','profile.confirm-email-change','profile.undo-email-change',
- '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'
+ $ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.', 'attachments.download', 'attachments.preview',
+ 'bills.rescan', 'budgets.income', 'currencies.def', 'error', 'flush', 'help.show', 'import.file',
+ 'login', 'logout', 'password.reset', 'profile.confirm-email-change', 'profile.undo-email-change',
+ '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',
];
diff --git a/app/Http/Controllers/Import/BankController.php b/app/Http/Controllers/Import/BankController.php
index 3e2d59b9c3..c3f8dde8ee 100644
--- a/app/Http/Controllers/Import/BankController.php
+++ b/app/Http/Controllers/Import/BankController.php
@@ -79,7 +79,7 @@ class BankController extends Controller
return redirect(route('import.bank.form', [$bank]));
}
$remoteAccounts = array_keys($remoteAccounts);
- $class = config(sprintf('firefly.import_pre.%s', $bank));
+ $class = config(sprintf('firefly.import_pre.%s', $bank));
// get import file
// get import config
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index 23d4111303..67a2c2dd08 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
@@ -90,17 +89,17 @@ class JavascriptController extends Controller
public function variables(Request $request)
{
$localeconv = localeconv();
- $accounting = Amount::getJsConfig($localeconv);
+ $accounting = app('amount')->getJsConfig($localeconv);
$localeconv = localeconv();
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
$localeconv['frac_digits'] = $defaultCurrency->decimal_places;
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
$lang = $pref->data;
$dateRange = $this->getDateRangeConfig();
$data = [
- 'currencyCode' => Amount::getCurrencyCode(),
- 'currencySymbol' => Amount::getCurrencySymbol(),
+ 'currencyCode' => app('amount')->getCurrencyCode(),
+ 'currencySymbol' => app('amount')->getCurrencySymbol(),
'accounting' => $accounting,
'localeconv' => $localeconv,
'language' => $lang,
diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php
index 4058e30cce..84141443c4 100644
--- a/app/Http/Controllers/JsonController.php
+++ b/app/Http/Controllers/JsonController.php
@@ -13,16 +13,10 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
-use Carbon\Carbon;
-use FireflyIII\Helpers\Collector\JournalCollectorInterface;
-use FireflyIII\Models\TransactionType;
-use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
-use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
use Response;
diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php
index c9fbe8dba4..bed151d63b 100644
--- a/app/Http/Controllers/PiggyBankController.php
+++ b/app/Http/Controllers/PiggyBankController.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
-use Amount;
use Carbon\Carbon;
use ExpandedForm;
use FireflyIII\Http\Requests\PiggyBankFormRequest;
@@ -277,14 +276,14 @@ class PiggyBankController extends Controller
public function postAdd(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
$amount = $request->get('amount');
- $currency = Amount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
if ($repository->canAddAmount($piggyBank, $amount)) {
$repository->addAmount($piggyBank, $amount);
Session::flash(
'success', strval(
trans(
'firefly.added_amount_to_piggy',
- ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
)
);
@@ -296,7 +295,10 @@ class PiggyBankController extends Controller
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
Session::flash(
'error', strval(
- trans('firefly.cannot_add_amount_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])
+ trans(
+ 'firefly.cannot_add_amount_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
+ )
)
);
@@ -313,12 +315,16 @@ class PiggyBankController extends Controller
public function postRemove(Request $request, PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
{
$amount = $request->get('amount');
- $currency = Amount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
if ($repository->canRemoveAmount($piggyBank, $amount)) {
$repository->removeAmount($piggyBank, $amount);
Session::flash(
'success',
- strval(trans('firefly.removed_amount_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => $piggyBank->name]))
+ strval(
+ trans(
+ 'firefly.removed_amount_from_piggy', ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
+ )
+ )
);
Preferences::mark();
@@ -329,7 +335,10 @@ class PiggyBankController extends Controller
Session::flash(
'error', strval(
- trans('firefly.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)])
+ trans(
+ 'firefly.cannot_remove_from_piggy',
+ ['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
+ )
)
);
diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php
index 854cfe5c59..dbd3807428 100644
--- a/app/Http/Middleware/Range.php
+++ b/app/Http/Middleware/Range.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
-use Amount;
use App;
use Carbon\Carbon;
use Closure;
@@ -109,7 +108,7 @@ class Range
// save some formats:
$monthAndDayFormat = (string)trans('config.month_and_day');
$dateTimeFormat = (string)trans('config.date_time');
- $defaultCurrency = Amount::getDefaultCurrency();
+ $defaultCurrency = app('amount')->getDefaultCurrency();
View::share('monthAndDayFormat', $monthAndDayFormat);
View::share('dateTimeFormat', $dateTimeFormat);
diff --git a/app/Import/Storage/ImportSupport.php b/app/Import/Storage/ImportSupport.php
index 80bb804ec1..d90383664b 100644
--- a/app/Import/Storage/ImportSupport.php
+++ b/app/Import/Storage/ImportSupport.php
@@ -44,12 +44,10 @@ trait ImportSupport
{
/** @var int */
protected $defaultCurrencyId = 1;
-
- /** @var Collection */
- protected $rules;
-
/** @var ImportJob */
protected $job;
+ /** @var Collection */
+ protected $rules;
/**
* @param TransactionJournal $journal
diff --git a/app/Jobs/ExecuteRuleOnExistingTransactions.php b/app/Jobs/ExecuteRuleOnExistingTransactions.php
index e1dff7ef7d..657d66d4fa 100644
--- a/app/Jobs/ExecuteRuleOnExistingTransactions.php
+++ b/app/Jobs/ExecuteRuleOnExistingTransactions.php
@@ -130,17 +130,17 @@ class ExecuteRuleOnExistingTransactions extends Job implements ShouldQueue
// Lookup all journals that match the parameters specified
$transactions = $this->collectJournals();
$processor = Processor::make($this->rule, true);
- $hits = 0;
- $misses = 0;
- $total = 0;
+ $hits = 0;
+ $misses = 0;
+ $total = 0;
// Execute the rules for each transaction
foreach ($transactions as $transaction) {
$total++;
$result = $processor->handleTransaction($transaction);
- if($result) {
+ if ($result) {
$hits++;
}
- if(!$result) {
+ if (!$result) {
$misses++;
}
Log::info(sprintf('Current progress: %d Transactions. Hits: %d, misses: %d', $total, $hits, $misses));
diff --git a/app/Mail/UndoEmailChangeMail.php b/app/Mail/UndoEmailChangeMail.php
index 5686795fb2..d3d526f18f 100644
--- a/app/Mail/UndoEmailChangeMail.php
+++ b/app/Mail/UndoEmailChangeMail.php
@@ -5,7 +5,6 @@ namespace FireflyIII\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-use Illuminate\Contracts\Queue\ShouldQueue;
class UndoEmailChangeMail extends Mailable
{
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 2b11be8d60..82de186656 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -29,16 +29,16 @@ use Watson\Validating\ValidatingTrait;
* @property string $transaction_foreign_amount
* @property string $transaction_type_type
* @property string $foreign_currency_symbol
- * @property int $foreign_currency_dp
+ * @property int $foreign_currency_dp
*
* @property int $account_id
- * @property string $account_name
+ * @property string $account_name
* @property string $account_iban
* @property string $account_number
* @property string $account_bic
* @property string $account_currency_code
*
- * @property int $opposing_account_id
+ * @property int $opposing_account_id
* @property string $opposing_account_name
* @property string $opposing_account_iban
* @property string $opposing_account_number
@@ -46,10 +46,10 @@ use Watson\Validating\ValidatingTrait;
* @property string $opposing_currency_code
*
*
- * @property int $transaction_budget_id
- * @property string $transaction_budget_name
- * @property int $transaction_journal_budget_id
- * @property string $transaction_journal_budget_name
+ * @property int $transaction_budget_id
+ * @property string $transaction_budget_name
+ * @property int $transaction_journal_budget_id
+ * @property string $transaction_journal_budget_name
*
* @property-read int $transaction_category_id
* @property-read string $transaction_category_name
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 6d4db0c635..a3a4d33aac 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -52,6 +52,52 @@ class BudgetRepository implements BudgetRepositoryInterface
}
+ /**
+ * This method collects various info on budgets, used on the budget page and on the index.
+ *
+ * @param Collection $budgets
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ */
+ public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array
+ {
+ // get account information
+ /** @var AccountRepositoryInterface $accountRepository */
+ $accountRepository = app(AccountRepositoryInterface::class);
+ $accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
+ $return = [];
+ /** @var Budget $budget */
+ foreach ($budgets as $budget) {
+ $budgetId = $budget->id;
+ $return[$budgetId] = [
+ 'spent' => $this->spentInPeriod(new Collection([$budget]), $accounts, $start, $end),
+ 'budgeted' => '0',
+ 'currentRep' => false,
+ ];
+ $budgetLimits = $this->getBudgetLimits($budget, $start, $end);
+ $otherLimits = new Collection;
+
+ // get all the budget limits relevant between start and end and examine them:
+ /** @var BudgetLimit $limit */
+ foreach ($budgetLimits as $limit) {
+ if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)
+ ) {
+ $return[$budgetId]['currentLimit'] = $limit;
+ $return[$budgetId]['budgeted'] = $limit->amount;
+ continue;
+ }
+ // otherwise it's just one of the many relevant repetitions:
+ $otherLimits->push($limit);
+ }
+ $return[$budgetId]['otherLimits'] = $otherLimits;
+ }
+
+ return $return;
+ }
+
/**
* @param Budget $budget
*
@@ -222,53 +268,6 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set;
}
- /**
- * This method collects various info on budgets, used on the budget page and on the index.
- *
- * @param Collection $budgets
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- */
- public function collectBudgetInformation(Collection $budgets, Carbon $start, Carbon $end): array
- {
- // get account information
- /** @var AccountRepositoryInterface $accountRepository */
- $accountRepository = app(AccountRepositoryInterface::class);
- $accounts = $accountRepository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::CASH]);
- $return = [];
- /** @var Budget $budget */
- foreach ($budgets as $budget) {
- $budgetId = $budget->id;
- $return[$budgetId] = [
- 'spent' => $this->spentInPeriod(new Collection([$budget]), $accounts, $start, $end),
- 'budgeted' => '0',
- 'currentRep' => false,
- ];
- $budgetLimits = $this->getBudgetLimits($budget, $start, $end);
- $otherLimits = new Collection;
-
- // get all the budget limits relevant between start and end and examine them:
- /** @var BudgetLimit $limit */
- foreach ($budgetLimits as $limit) {
- if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)
- ) {
- $return[$budgetId]['currentLimit'] = $limit;
- $return[$budgetId]['budgeted'] = $limit->amount;
- continue;
- }
- // otherwise it's just one of the many relevant repetitions:
- $otherLimits->push($limit);
- }
- $return[$budgetId]['otherLimits'] = $otherLimits;
- }
-
- return $return;
- }
-
-
/**
* @param TransactionCurrency $currency
* @param Carbon $start
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index aa6973b6b2..1412314d45 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -17,8 +17,8 @@ use Carbon\Carbon;
use FireflyIII\Models\ExportJob;
use FireflyIII\User;
use Illuminate\Support\Str;
-use Storage;
use Log;
+use Storage;
/**
* Class ExportJobRepository
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index 6c05daa897..d6c0f2554f 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\PiggyBank;
-use Amount;
use Carbon\Carbon;
use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBank;
@@ -240,12 +239,12 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function getPiggyBanksWithAmount(): Collection
{
- $currency = Amount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
$set = $this->getPiggyBanks();
foreach ($set as $piggy) {
$currentAmount = $piggy->currentRelevantRep()->currentamount ?? '0';
- $piggy->name = $piggy->name . ' (' . Amount::formatAnything($currency, $currentAmount, false) . ')';
+ $piggy->name = $piggy->name . ' (' . app('amount')->formatAnything($currency, $currentAmount, false) . ')';
}
return $set;
diff --git a/app/Services/Bunq/Request/BunqRequest.php b/app/Services/Bunq/Request/BunqRequest.php
index fc67efaf0f..bc692c5d17 100644
--- a/app/Services/Bunq/Request/BunqRequest.php
+++ b/app/Services/Bunq/Request/BunqRequest.php
@@ -40,15 +40,6 @@ abstract class BunqRequest
'x-bunq-client-request-id' => 'X-Bunq-Client-Request-Id',
];
- /**
- * @return ServerPublicKey
- */
- public function getServerPublicKey(): ServerPublicKey
- {
- return $this->serverPublicKey;
- }
-
-
/**
* BunqRequest constructor.
*/
@@ -70,6 +61,22 @@ abstract class BunqRequest
return $this->server;
}
+ /**
+ * @return ServerPublicKey
+ */
+ public function getServerPublicKey(): ServerPublicKey
+ {
+ return $this->serverPublicKey;
+ }
+
+ /**
+ * @param ServerPublicKey $serverPublicKey
+ */
+ public function setServerPublicKey(ServerPublicKey $serverPublicKey)
+ {
+ $this->serverPublicKey = $serverPublicKey;
+ }
+
/**
* @param string $privateKey
*/
@@ -86,14 +93,6 @@ abstract class BunqRequest
$this->secret = $secret;
}
- /**
- * @param ServerPublicKey $serverPublicKey
- */
- public function setServerPublicKey(ServerPublicKey $serverPublicKey)
- {
- $this->serverPublicKey = $serverPublicKey;
- }
-
/**
* @param string $method
* @param string $uri
diff --git a/app/Support/Import/Information/BunqInformation.php b/app/Support/Import/Information/BunqInformation.php
index 466d90c6c8..b931be584e 100644
--- a/app/Support/Import/Information/BunqInformation.php
+++ b/app/Support/Import/Information/BunqInformation.php
@@ -66,7 +66,7 @@ class BunqInformation implements InformationInterface
}
Log::debug('Now in getAccounts()');
$sessionToken = $this->startSession();
- $userId = $this->getUserInformation($sessionToken);
+ $userId = $this->getUserInformation($sessionToken);
// get list of Bunq accounts:
$accounts = $this->getMonetaryAccounts($sessionToken, $userId);
$return = [];
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 19252c1cff..09a570cbf1 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -13,7 +13,6 @@ declare(strict_types=1);
namespace FireflyIII\Support;
-use Amount as GlobalAmount;
use Carbon\Carbon;
use Crypt;
use DB;
@@ -51,7 +50,7 @@ class Steam
$currencyId = intval($account->getMeta('currency_id'));
// use system default currency:
if ($currencyId === 0) {
- $currency = GlobalAmount::getDefaultCurrency();
+ $currency = app('amount')->getDefaultCurrency();
$currencyId = $currency->id;
}
// first part: get all balances in own currency:
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php
index c438b7261a..e3f5801b49 100644
--- a/app/Support/Twig/AmountFormat.php
+++ b/app/Support/Twig/AmountFormat.php
@@ -265,12 +265,12 @@ class AmountFormat extends Twig_Extension
/**
* @return Twig_SimpleFunction
*/
- protected function journalTotalAmount(): Twig_SimpleFunction
+ protected function journalAmount(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
- 'journalTotalAmount', function (TransactionJournal $journal): string {
+ 'journalAmount', function (TransactionJournal $journal): string {
- return app('amount')->journalTotalAmount($journal, true);
+ return app('amount')->journalAmount($journal, true);
}, ['is_safe' => ['html']]
);
}
@@ -278,12 +278,12 @@ class AmountFormat extends Twig_Extension
/**
* @return Twig_SimpleFunction
*/
- protected function journalAmount(): Twig_SimpleFunction
+ protected function journalTotalAmount(): Twig_SimpleFunction
{
return new Twig_SimpleFunction(
- 'journalAmount', function (TransactionJournal $journal): string {
+ 'journalTotalAmount', function (TransactionJournal $journal): string {
- return app('amount')->journalAmount($journal, true);
+ return app('amount')->journalTotalAmount($journal, true);
}, ['is_safe' => ['html']]
);
}
diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.php
index 509b229d26..570cfbb53f 100644
--- a/app/TransactionRules/Processor.php
+++ b/app/TransactionRules/Processor.php
@@ -40,7 +40,7 @@ final class Processor
public $rule;
/** @var Collection */
public $triggers;
- /** @var int */
+ /** @var int */
protected $foundTriggers = 0;
/**
diff --git a/app/TransactionRules/Triggers/NotesAny.php b/app/TransactionRules/Triggers/NotesAny.php
index 4e94bb90d1..41586d79fd 100644
--- a/app/TransactionRules/Triggers/NotesAny.php
+++ b/app/TransactionRules/Triggers/NotesAny.php
@@ -51,7 +51,7 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
*/
public function triggered(TransactionJournal $journal): bool
{
- $notes = $journal->getMeta('notes') ?? '';
+ $notes = $journal->getMeta('notes') ?? '';
if (strlen($notes) > 0) {
diff --git a/tests/Feature/Controllers/BudgetControllerTest.php b/tests/Feature/Controllers/BudgetControllerTest.php
index acb687037c..5db4645cd2 100644
--- a/tests/Feature/Controllers/BudgetControllerTest.php
+++ b/tests/Feature/Controllers/BudgetControllerTest.php
@@ -136,7 +136,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
@@ -184,7 +183,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
@@ -232,7 +230,6 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\BudgetController::index
- * @covers \FireflyIII\Http\Controllers\BudgetController::collectBudgetInformation
* @covers \FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
*
diff --git a/tests/Feature/Controllers/JavascriptControllerTest.php b/tests/Feature/Controllers/JavascriptControllerTest.php
index 73e37f9282..dd7b52b121 100644
--- a/tests/Feature/Controllers/JavascriptControllerTest.php
+++ b/tests/Feature/Controllers/JavascriptControllerTest.php
@@ -63,7 +63,7 @@ class JavascriptControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
- * @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangePicker
+ * @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
*
* @param string $range
*
diff --git a/tests/Feature/Controllers/NewUserControllerTest.php b/tests/Feature/Controllers/NewUserControllerTest.php
index 7a18d8824f..d76919f9d3 100644
--- a/tests/Feature/Controllers/NewUserControllerTest.php
+++ b/tests/Feature/Controllers/NewUserControllerTest.php
@@ -68,7 +68,6 @@ class NewUserControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\NewUserController::submit
* @covers \FireflyIII\Http\Controllers\NewUserController::createAssetAccount
* @covers \FireflyIII\Http\Controllers\NewUserController::createSavingsAccount
- * @covers \FireflyIII\Http\Controllers\NewUserController::storeCreditCard
*/
public function testSubmit()
{