mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -37,7 +37,6 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Trait AugumentData
|
||||
@@ -48,7 +47,7 @@ trait AugumentData
|
||||
/**
|
||||
* Searches for the opposing account.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -75,7 +74,7 @@ trait AugumentData
|
||||
/**
|
||||
* Small helper function for the revenue and expense account charts.
|
||||
*
|
||||
* @param array $names
|
||||
* @param array $names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -92,7 +91,7 @@ trait AugumentData
|
||||
/**
|
||||
* Small helper function for the revenue and expense account charts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -110,7 +109,7 @@ trait AugumentData
|
||||
/**
|
||||
* Get the account names belonging to a bunch of account ID's.
|
||||
*
|
||||
* @param array $accountIds
|
||||
* @param array $accountIds
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -123,7 +122,7 @@ trait AugumentData
|
||||
$return = [];
|
||||
foreach ($accountIds as $combinedId) {
|
||||
$parts = explode('-', $combinedId);
|
||||
$accountId = (int) $parts[0];
|
||||
$accountId = (int)$parts[0];
|
||||
if (array_key_exists($accountId, $grouped)) {
|
||||
$return[$accountId] = $grouped[$accountId][0]['name'];
|
||||
}
|
||||
@@ -136,7 +135,7 @@ trait AugumentData
|
||||
/**
|
||||
* Get the budget names from a set of budget ID's.
|
||||
*
|
||||
* @param array $budgetIds
|
||||
* @param array $budgetIds
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -152,7 +151,7 @@ trait AugumentData
|
||||
$return[$budgetId] = $grouped[$budgetId][0]['name'];
|
||||
}
|
||||
}
|
||||
$return[0] = (string) trans('firefly.no_budget');
|
||||
$return[0] = (string)trans('firefly.no_budget');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -160,7 +159,7 @@ trait AugumentData
|
||||
/**
|
||||
* Get the category names from a set of category ID's. Small helper function for some of the charts.
|
||||
*
|
||||
* @param array $categoryIds
|
||||
* @param array $categoryIds
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -173,12 +172,12 @@ trait AugumentData
|
||||
$return = [];
|
||||
foreach ($categoryIds as $combinedId) {
|
||||
$parts = explode('-', $combinedId);
|
||||
$categoryId = (int) $parts[0];
|
||||
$categoryId = (int)$parts[0];
|
||||
if (array_key_exists($categoryId, $grouped)) {
|
||||
$return[$categoryId] = $grouped[$categoryId][0]['name'];
|
||||
}
|
||||
}
|
||||
$return[0] = (string) trans('firefly.no_category');
|
||||
$return[0] = (string)trans('firefly.no_category');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -186,9 +185,9 @@ trait AugumentData
|
||||
/**
|
||||
* Gets all budget limits for a budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
@@ -221,7 +220,7 @@ trait AugumentData
|
||||
$currentStart = clone $entry->start_date;
|
||||
$currentEnd = clone $entry->end_date;
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
|
||||
$spent = $expenses[(int) $currency->id]['sum'] ?? '0';
|
||||
$spent = $expenses[(int)$currency->id]['sum'] ?? '0';
|
||||
$entry->spent = $spent;
|
||||
|
||||
$limits->push($entry);
|
||||
@@ -234,7 +233,7 @@ trait AugumentData
|
||||
/**
|
||||
* Group set of transactions by name of opposing account.
|
||||
*
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -262,10 +261,10 @@ trait AugumentData
|
||||
/**
|
||||
* Spent in a period.
|
||||
*
|
||||
* @param Collection $assets
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $assets
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -283,7 +282,7 @@ trait AugumentData
|
||||
];
|
||||
// loop to support multi currency
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
|
||||
// if not set, set to zero:
|
||||
if (!array_key_exists($currencyId, $sum['per_currency'])) {
|
||||
|
||||
@@ -34,8 +34,8 @@ trait BasicDataSupport
|
||||
/**
|
||||
* Find the ID in a given array. Return '0' if not there (amount).
|
||||
*
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
*
|
||||
* @return null|mixed
|
||||
*/
|
||||
@@ -47,8 +47,8 @@ trait BasicDataSupport
|
||||
/**
|
||||
* Find the ID in a given array. Return null if not there (amount).
|
||||
*
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
* @param array $array
|
||||
* @param int $entryId
|
||||
*
|
||||
* @return null|Carbon
|
||||
*/
|
||||
|
||||
@@ -42,9 +42,9 @@ trait ChartGeneration
|
||||
/**
|
||||
* Shows an overview of the account balances for a set of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
@@ -76,7 +76,7 @@ trait ChartGeneration
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
// TODO we can use getAccountCurrency instead.
|
||||
$currency = $repository->find((int) $accountRepos->getMetaValue($account, 'currency_id'));
|
||||
$currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));
|
||||
if (null === $currency) {
|
||||
$currency = $default;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ trait ChartGeneration
|
||||
$previous = array_values($range)[0];
|
||||
while ($currentStart <= $end) {
|
||||
$format = $currentStart->format('Y-m-d');
|
||||
$label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));
|
||||
$label = trim($currentStart->isoFormat((string)trans('config.month_and_day_js', [], $locale)));
|
||||
$balance = $range[$format] ?? $previous;
|
||||
$previous = $balance;
|
||||
$currentStart->addDay();
|
||||
|
||||
@@ -42,8 +42,8 @@ trait CreateStuff
|
||||
/**
|
||||
* Creates an asset account.
|
||||
*
|
||||
* @param NewUserFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param NewUserFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -72,8 +72,8 @@ trait CreateStuff
|
||||
/**
|
||||
* Creates a cash wallet.
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
* @param string $language
|
||||
* @param TransactionCurrency $currency
|
||||
* @param string $language
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ trait CreateStuff
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$assetAccount = [
|
||||
'name' => (string) trans('firefly.cash_wallet', [], $language),
|
||||
'name' => (string)trans('firefly.cash_wallet', [], $language),
|
||||
'iban' => null,
|
||||
'account_type_name' => 'asset',
|
||||
'virtual_balance' => 0,
|
||||
@@ -138,9 +138,9 @@ trait CreateStuff
|
||||
/**
|
||||
* Create a savings account.
|
||||
*
|
||||
* @param NewUserFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param string $language
|
||||
* @param NewUserFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param string $language
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -149,7 +149,7 @@ trait CreateStuff
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$savingsAccount = [
|
||||
'name' => (string) trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
|
||||
'name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
|
||||
'iban' => null,
|
||||
'account_type_name' => 'asset',
|
||||
'account_type_id' => null,
|
||||
@@ -168,7 +168,7 @@ trait CreateStuff
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
|
||||
@@ -34,8 +34,8 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||
trait CronRunner
|
||||
{
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -65,8 +65,8 @@ trait CronRunner
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
* @param bool $force
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -37,8 +37,8 @@ trait DateCalculation
|
||||
*
|
||||
* If both are in the past OR both are in the future, simply return the number of days in the period with a minimum of 1
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -59,8 +59,8 @@ trait DateCalculation
|
||||
*
|
||||
* If both are in the past OR both are in the future, simply return the period between them with a minimum of 1
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -77,8 +77,8 @@ trait DateCalculation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -103,8 +103,8 @@ trait DateCalculation
|
||||
* Get a list of the periods that will occur after this date. For example,
|
||||
* March 2018, April 2018, etc.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param string $range
|
||||
* @param Carbon $date
|
||||
* @param string $range
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -139,8 +139,8 @@ trait DateCalculation
|
||||
* Get a list of the periods that occurred before the start date. For example,
|
||||
* March 2018, February 2018, etc.
|
||||
*
|
||||
* @param Carbon $date
|
||||
* @param string $range
|
||||
* @param Carbon $date
|
||||
* @param string $range
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace FireflyIII\Support\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Trait GetConfigurationData
|
||||
@@ -36,7 +38,7 @@ trait GetConfigurationData
|
||||
/**
|
||||
* Some common combinations.
|
||||
*
|
||||
* @param int $value
|
||||
* @param int $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -52,13 +54,13 @@ trait GetConfigurationData
|
||||
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
|
||||
];
|
||||
|
||||
return $array[$value] ?? (string) $value;
|
||||
return $array[$value] ?? (string)$value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the basic steps from config.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string $route
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -72,7 +74,7 @@ trait GetConfigurationData
|
||||
$currentStep = $options;
|
||||
|
||||
// get the text:
|
||||
$currentStep['intro'] = (string) trans('intro.' . $route . '_' . $key);
|
||||
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$key);
|
||||
|
||||
// save in array:
|
||||
$steps[] = $currentStep;
|
||||
@@ -88,12 +90,12 @@ trait GetConfigurationData
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getDateRangeConfig(): array // get configuration + get preferences.
|
||||
{
|
||||
$viewRange = (string) app('preferences')->get('viewRange', '1M')->data;
|
||||
$viewRange = (string)app('preferences')->get('viewRange', '1M')->data;
|
||||
/** @var Carbon $start */
|
||||
$start = session('start');
|
||||
/** @var Carbon $end */
|
||||
@@ -134,41 +136,41 @@ trait GetConfigurationData
|
||||
/** @var Carbon $todayEnd */
|
||||
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
|
||||
if ($todayStart->ne($start) || $todayEnd->ne($end)) {
|
||||
$ranges[ucfirst((string) trans('firefly.today'))] = [$todayStart, $todayEnd];
|
||||
$ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];
|
||||
}
|
||||
|
||||
// last seven days:
|
||||
$seven = Carbon::now()->subDays(7);
|
||||
$index = (string) trans('firefly.last_seven_days');
|
||||
$index = (string)trans('firefly.last_seven_days');
|
||||
$ranges[$index] = [$seven, new Carbon()];
|
||||
|
||||
// last 30 days:
|
||||
$thirty = Carbon::now()->subDays(30);
|
||||
$index = (string) trans('firefly.last_thirty_days');
|
||||
$index = (string)trans('firefly.last_thirty_days');
|
||||
$ranges[$index] = [$thirty, new Carbon()];
|
||||
|
||||
// month to date:
|
||||
$monthBegin = Carbon::now()->startOfMonth();
|
||||
$index = (string) trans('firefly.month_to_date');
|
||||
$index = (string)trans('firefly.month_to_date');
|
||||
$ranges[$index] = [$monthBegin, new Carbon()];
|
||||
|
||||
// year to date:
|
||||
$yearBegin = Carbon::now()->startOfYear();
|
||||
$index = (string) trans('firefly.year_to_date');
|
||||
$index = (string)trans('firefly.year_to_date');
|
||||
$ranges[$index] = [$yearBegin, new Carbon()];
|
||||
|
||||
// everything
|
||||
$index = (string) trans('firefly.everything');
|
||||
$index = (string)trans('firefly.everything');
|
||||
$ranges[$index] = [$first, new Carbon()];
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'configuration' => [
|
||||
'apply' => (string) trans('firefly.apply'),
|
||||
'cancel' => (string) trans('firefly.cancel'),
|
||||
'from' => (string) trans('firefly.from'),
|
||||
'to' => (string) trans('firefly.to'),
|
||||
'customRange' => (string) trans('firefly.customRange'),
|
||||
'apply' => (string)trans('firefly.apply'),
|
||||
'cancel' => (string)trans('firefly.cancel'),
|
||||
'from' => (string)trans('firefly.from'),
|
||||
'to' => (string)trans('firefly.to'),
|
||||
'customRange' => (string)trans('firefly.customRange'),
|
||||
'start' => $start->format('Y-m-d'),
|
||||
'end' => $end->format('Y-m-d'),
|
||||
'ranges' => $ranges,
|
||||
@@ -179,8 +181,8 @@ trait GetConfigurationData
|
||||
/**
|
||||
* Get specific info for special routes.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string $specificPage
|
||||
* @param string $route
|
||||
* @param string $specificPage
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
@@ -193,13 +195,13 @@ trait GetConfigurationData
|
||||
// user is on page with specific instructions:
|
||||
if ('' !== $specificPage) {
|
||||
$routeKey = str_replace('.', '_', $route);
|
||||
$elements = config(sprintf('intro.%s', $routeKey . '_' . $specificPage));
|
||||
$elements = config(sprintf('intro.%s', $routeKey.'_'.$specificPage));
|
||||
if (is_array($elements) && count($elements) > 0) {
|
||||
foreach ($elements as $key => $options) {
|
||||
$currentStep = $options;
|
||||
|
||||
// get the text:
|
||||
$currentStep['intro'] = (string) trans('intro.' . $route . '_' . $specificPage . '_' . $key);
|
||||
$currentStep['intro'] = (string)trans('intro.'.$route.'_'.$specificPage.'_'.$key);
|
||||
|
||||
// save in array:
|
||||
$steps[] = $currentStep;
|
||||
@@ -217,7 +219,7 @@ trait GetConfigurationData
|
||||
protected function verifyRecurringCronJob(): void
|
||||
{
|
||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||
$lastTime = (int) $config->data;
|
||||
$lastTime = (int)$config->data;
|
||||
$now = time();
|
||||
Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config->data, $now));
|
||||
if (0 === $lastTime) {
|
||||
|
||||
@@ -42,7 +42,7 @@ trait ModelInformation
|
||||
/**
|
||||
* Get actions based on a bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -80,13 +80,13 @@ trait ModelInformation
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
// types of liability:
|
||||
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
|
||||
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
|
||||
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
|
||||
$debt = $repository->getAccountTypeByType(AccountType::DEBT);
|
||||
$loan = $repository->getAccountTypeByType(AccountType::LOAN);
|
||||
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
|
||||
$liabilityTypes = [
|
||||
$debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
|
||||
$loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
|
||||
$mortgage->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
|
||||
$debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
|
||||
$loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
|
||||
$mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
|
||||
];
|
||||
asort($liabilityTypes);
|
||||
|
||||
@@ -101,7 +101,7 @@ trait ModelInformation
|
||||
{
|
||||
$roles = [];
|
||||
foreach (config('firefly.accountRoles') as $role) {
|
||||
$roles[$role] = (string) trans(sprintf('firefly.account_role_%s', $role));
|
||||
$roles[$role] = (string)trans(sprintf('firefly.account_role_%s', $role));
|
||||
}
|
||||
|
||||
return $roles;
|
||||
@@ -110,7 +110,7 @@ trait ModelInformation
|
||||
/**
|
||||
* Create fake triggers to match the bill's properties
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ trait ModelInformation
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -161,7 +161,7 @@ trait ModelInformation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -172,7 +172,7 @@ trait ModelInformation
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
|
||||
@@ -33,8 +33,9 @@ use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Trait PeriodOverview.
|
||||
@@ -73,14 +74,14 @@ trait PeriodOverview
|
||||
* and for each period, the amount of money spent and earned. This is a complex operation which is cached for
|
||||
* performance reasons.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getAccountPeriodOverview(Account $account, Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -152,9 +153,9 @@ trait PeriodOverview
|
||||
/**
|
||||
* Filter a list of journals by a set of dates, and then group them by currency.
|
||||
*
|
||||
* @param array $array
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param array $array
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -174,8 +175,8 @@ trait PeriodOverview
|
||||
/**
|
||||
* Return only transactions where $account is the source.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $journals
|
||||
* @param Account $account
|
||||
* @param array $journals
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -184,7 +185,7 @@ trait PeriodOverview
|
||||
$return = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if ($account->id === (int) $journal['source_account_id']) {
|
||||
if ($account->id === (int)$journal['source_account_id']) {
|
||||
$return[] = $journal;
|
||||
}
|
||||
}
|
||||
@@ -195,8 +196,8 @@ trait PeriodOverview
|
||||
/**
|
||||
* Return only transactions where $account is the source.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $journals
|
||||
* @param Account $account
|
||||
* @param array $journals
|
||||
*
|
||||
* @return array
|
||||
* @codeCoverageIgnore
|
||||
@@ -206,7 +207,7 @@ trait PeriodOverview
|
||||
$return = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
if ($account->id === (int) $journal['destination_account_id']) {
|
||||
if ($account->id === (int)$journal['destination_account_id']) {
|
||||
$return[] = $journal;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +216,7 @@ trait PeriodOverview
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $journals
|
||||
* @param array $journals
|
||||
*
|
||||
* @return array
|
||||
* @codeCoverageIgnore
|
||||
@@ -225,7 +226,7 @@ trait PeriodOverview
|
||||
$return = [];
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||
if (!array_key_exists($currencyId, $return)) {
|
||||
$return[$currencyId] = [
|
||||
@@ -246,7 +247,7 @@ trait PeriodOverview
|
||||
$return[$foreignCurrencyId] = [
|
||||
'amount' => '0',
|
||||
'count' => 0,
|
||||
'currency_id' => (int) $foreignCurrencyId,
|
||||
'currency_id' => (int)$foreignCurrencyId,
|
||||
'currency_name' => $journal['foreign_currency_name'],
|
||||
'currency_code' => $journal['foreign_currency_code'],
|
||||
'currency_symbol' => $journal['foreign_currency_symbol'],
|
||||
@@ -264,14 +265,14 @@ trait PeriodOverview
|
||||
/**
|
||||
* Overview for single category. Has been refactored recently.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getCategoryPeriodOverview(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -345,13 +346,13 @@ trait PeriodOverview
|
||||
*
|
||||
* This method has been refactored recently.
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getNoBudgetPeriodOverview(Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -401,12 +402,12 @@ trait PeriodOverview
|
||||
*
|
||||
* Show period overview for no category view.
|
||||
*
|
||||
* @param Carbon $theDate
|
||||
* @param Carbon $theDate
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getNoCategoryPeriodOverview(Carbon $theDate): array
|
||||
{
|
||||
@@ -471,14 +472,14 @@ trait PeriodOverview
|
||||
/**
|
||||
* This shows a period overview for a tag. It goes back in time and lists all relevant transactions and sums.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Tag $tag
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getTagPeriodOverview(Tag $tag, Carbon $start, Carbon $end): array // period overview for tags.
|
||||
{
|
||||
@@ -546,14 +547,14 @@ trait PeriodOverview
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $transactionType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $transactionType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getTransactionPeriodOverview(string $transactionType, Carbon $start, Carbon $end): array
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* View for transactions in a budget for an account.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -59,10 +59,10 @@ trait RenderPartialViews
|
||||
|
||||
/** @var BudgetRepositoryInterface $budgetRepository */
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
$budget = $budgetRepository->find((int) $attributes['budgetId']);
|
||||
$budget = $budgetRepository->find((int)$attributes['budgetId']);
|
||||
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$account = $accountRepos->find((int) $attributes['accountId']);
|
||||
$account = $accountRepos->find((int)$attributes['accountId']);
|
||||
|
||||
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
|
||||
|
||||
@@ -102,7 +102,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* View for spent in a single budget.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ trait RenderPartialViews
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
|
||||
$budget = $budgetRepository->find((int) $attributes['budgetId']);
|
||||
$budget = $budgetRepository->find((int)$attributes['budgetId']);
|
||||
if (null === $budget) {
|
||||
$budget = new Budget();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* View for transactions in a category.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -145,7 +145,7 @@ trait RenderPartialViews
|
||||
|
||||
/** @var CategoryRepositoryInterface $categoryRepository */
|
||||
$categoryRepository = app(CategoryRepositoryInterface::class);
|
||||
$category = $categoryRepository->find((int) $attributes['categoryId']);
|
||||
$category = $categoryRepository->find((int)$attributes['categoryId']);
|
||||
$journals = $popupHelper->byCategory($category, $attributes);
|
||||
|
||||
try {
|
||||
@@ -226,7 +226,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* Returns all the expenses that went to the given expense account.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -238,7 +238,7 @@ trait RenderPartialViews
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
|
||||
$account = $accountRepository->find((int) $attributes['accountId']);
|
||||
$account = $accountRepository->find((int)$attributes['accountId']);
|
||||
|
||||
if (null === $account) {
|
||||
return 'This is an unknown account. Apologies.';
|
||||
@@ -260,7 +260,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* Get current (from system) rule actions.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -298,7 +298,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* Get current (from DB) rule triggers.
|
||||
*
|
||||
* @param Rule $rule
|
||||
* @param Rule $rule
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
@@ -310,7 +310,7 @@ trait RenderPartialViews
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -354,7 +354,7 @@ trait RenderPartialViews
|
||||
/**
|
||||
* Returns all the incomes that went to the given asset account.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -365,7 +365,7 @@ trait RenderPartialViews
|
||||
|
||||
/** @var PopupReportInterface $popupHelper */
|
||||
$popupHelper = app(PopupReportInterface::class);
|
||||
$account = $accountRepository->find((int) $attributes['accountId']);
|
||||
$account = $accountRepository->find((int)$attributes['accountId']);
|
||||
|
||||
if (null === $account) {
|
||||
return 'This is an unknown category. Apologies.';
|
||||
|
||||
@@ -37,6 +37,8 @@ use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use InvalidArgumentException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Route as RouteFacade;
|
||||
|
||||
/**
|
||||
@@ -88,8 +90,8 @@ trait RequestInformation
|
||||
*
|
||||
* @return bool
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
final protected function hasSeenDemo(): bool // get request info + get preference
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ use Throwable;
|
||||
trait RuleManagement
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return array
|
||||
* @codeCoverageIgnore
|
||||
@@ -55,7 +55,7 @@ trait RuleManagement
|
||||
[
|
||||
'oldAction' => $oldAction['type'],
|
||||
'oldValue' => $oldAction['value'],
|
||||
'oldChecked' => 1 === (int) ($oldAction['stop_processing'] ?? '0'),
|
||||
'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'),
|
||||
'count' => $index + 1,
|
||||
]
|
||||
)->render();
|
||||
@@ -72,7 +72,7 @@ trait RuleManagement
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return array
|
||||
* @codeCoverageIgnore
|
||||
@@ -84,7 +84,7 @@ trait RuleManagement
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -100,8 +100,8 @@ trait RuleManagement
|
||||
[
|
||||
'oldTrigger' => OperatorQuerySearch::getRootOperator($oldTrigger['type']),
|
||||
'oldValue' => $oldTrigger['value'],
|
||||
'oldChecked' => 1 === (int) ($oldTrigger['stop_processing'] ?? '0'),
|
||||
'oldProhibited' => 1 === (int) ($oldTrigger['prohibited'] ?? '0'),
|
||||
'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'),
|
||||
'oldProhibited' => 1 === (int)($oldTrigger['prohibited'] ?? '0'),
|
||||
'count' => $index + 1,
|
||||
'triggers' => $triggers,
|
||||
]
|
||||
@@ -119,7 +119,7 @@ trait RuleManagement
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $submittedOperators
|
||||
* @param array $submittedOperators
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -131,7 +131,7 @@ trait RuleManagement
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -169,8 +169,8 @@ trait RuleManagement
|
||||
$repository = app(RuleGroupRepositoryInterface::class);
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'title' => (string) trans('firefly.default_rule_group_name'),
|
||||
'description' => (string) trans('firefly.default_rule_group_description'),
|
||||
'title' => (string)trans('firefly.default_rule_group_name'),
|
||||
'description' => (string)trans('firefly.default_rule_group_description'),
|
||||
'active' => true,
|
||||
];
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get all expenses for a set of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -61,10 +61,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get all expenses by tags.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
@@ -83,10 +83,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Helper function that collects expenses for the given budgets.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -103,10 +103,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get all expenses in a period for categories.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -127,10 +127,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get all income for a period and a bunch of categories.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -147,10 +147,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get the income for a set of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -167,10 +167,10 @@ trait TransactionCalculation
|
||||
/**
|
||||
* Get all income by tag.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -46,14 +46,14 @@ trait UserNavigation
|
||||
* will be returned.
|
||||
* - If the remembered url contains "jscript/" the remembered url will not be returned but instead the index (/) will be returned.
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
final protected function getPreviousUrl(string $identifier): string
|
||||
{
|
||||
Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
|
||||
$url = (string) session($identifier);
|
||||
$url = (string)session($identifier);
|
||||
Log::debug(sprintf('The URL is %s', $url));
|
||||
|
||||
return app('steam')->getSafeUrl($url, route('index'));
|
||||
@@ -62,7 +62,7 @@ trait UserNavigation
|
||||
/**
|
||||
* Will return false if you cant edit this account type.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -75,7 +75,7 @@ trait UserNavigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $group
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ trait UserNavigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -128,7 +128,7 @@ trait UserNavigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $group
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ trait UserNavigation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $identifier
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user