Skip to content

Firefly III: a personal finances manager

Code cleanup.

James Coleb5eeacc12834
diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.php
index 10a7b7729d..c87c4a5327 100644
--- a/app/Exceptions/GracefulNotFoundHandler.php
+++ b/app/Exceptions/GracefulNotFoundHandler.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Exceptions;
+
use Exception;
use FireflyIII\Models\Account;
use FireflyIII\Models\Attachment;
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php
index 869ebbe9de..e755820b98 100644
--- a/app/Factory/AccountFactory.php
+++ b/app/Factory/AccountFactory.php
@@ -207,6 +207,7 @@ class AccountFactory
if (null !== $result) {
Log::debug(sprintf('Found account type based on %d and "%s": "%s"', $accountTypeId, $accountType, $result->type));
}
+
return $result;
}
diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php
index b7f15d2618..2a5dcbe67f 100644
--- a/app/Factory/CategoryFactory.php
+++ b/app/Factory/CategoryFactory.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Factory;
+
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Category;
use FireflyIII\User;
diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php
index 0300464683..29a4fb70d9 100644
--- a/app/Factory/PiggyBankFactory.php
+++ b/app/Factory/PiggyBankFactory.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Factory;
+
use FireflyIII\Models\PiggyBank;
use FireflyIII\User;
diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.php
index 237365a404..8b0c70e2f1 100644
--- a/app/Factory/RecurrenceFactory.php
+++ b/app/Factory/RecurrenceFactory.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Factory;
+
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Recurrence;
@@ -42,6 +43,7 @@ class RecurrenceFactory
private MessageBag $errors;
private User $user;
+
/**
* Constructor.
*
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php
index bfae66d6a5..759251a790 100644
--- a/app/Factory/TransactionFactory.php
+++ b/app/Factory/TransactionFactory.php
@@ -44,6 +44,7 @@ class TransactionFactory
private TransactionJournal $journal;
private bool $reconciled;
private User $user;
+
/**
* Constructor.
*
diff --git a/app/Factory/TransactionGroupFactory.php b/app/Factory/TransactionGroupFactory.php
index a6dd321faa..902004855f 100644
--- a/app/Factory/TransactionGroupFactory.php
+++ b/app/Factory/TransactionGroupFactory.php
@@ -40,6 +40,7 @@ class TransactionGroupFactory
private $journalFactory;
/** @var User The user */
private $user;
+
/**
* TransactionGroupFactory constructor.
*/
@@ -73,7 +74,7 @@ class TransactionGroupFactory
if (null !== $title) {
$title = substr($title, 0, 1000);
}
- if(0 === $collection->count()) {
+ if (0 === $collection->count()) {
throw new FireflyException('Created zero transaction journals.');
}
diff --git a/app/Generator/Report/Standard/YearReportGenerator.php b/app/Generator/Report/Standard/YearReportGenerator.php
index 14864429b3..7b0f7ec6c2 100644
--- a/app/Generator/Report/Standard/YearReportGenerator.php
+++ b/app/Generator/Report/Standard/YearReportGenerator.php
@@ -65,6 +65,7 @@ class YearReportGenerator implements ReportGeneratorInterface
return $result;
}
+
/**
* Set the accounts.
*
diff --git a/app/Handlers/Events/APIEventHandler.php b/app/Handlers/Events/APIEventHandler.php
index 67f8f929f8..1e9542f6d2 100644
--- a/app/Handlers/Events/APIEventHandler.php
+++ b/app/Handlers/Events/APIEventHandler.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
+
use Exception;
use FireflyIII\Mail\AccessTokenCreatedMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
diff --git a/app/Handlers/Events/DestroyedGroupEventHandler.php b/app/Handlers/Events/DestroyedGroupEventHandler.php
index b0c3c20864..7d6837cd14 100644
--- a/app/Handlers/Events/DestroyedGroupEventHandler.php
+++ b/app/Handlers/Events/DestroyedGroupEventHandler.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
+
use FireflyIII\Events\DestroyedTransactionGroup;
use FireflyIII\Events\RequestedSendWebhookMessages;
use FireflyIII\Generator\Webhook\MessageGeneratorInterface;
diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.php
index c40be1054c..7e8d200bdb 100644
--- a/app/Handlers/Events/VersionCheckEventHandler.php
+++ b/app/Handlers/Events/VersionCheckEventHandler.php
@@ -23,12 +23,14 @@
declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
+
use FireflyIII\Events\RequestedVersionCheckStatus;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Models\Configuration;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Log;
+
/**
* Class VersionCheckEventHandler
*/
diff --git a/app/Handlers/Events/WebhookEventHandler.php b/app/Handlers/Events/WebhookEventHandler.php
index 434d4653b1..2a75380c21 100644
--- a/app/Handlers/Events/WebhookEventHandler.php
+++ b/app/Handlers/Events/WebhookEventHandler.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Handlers\Events;
+
use FireflyIII\Jobs\SendWebhookMessage;
use FireflyIII\Models\WebhookMessage;
use Log;
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index f24a957001..f5ac7b738d 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -55,6 +55,7 @@ class AttachmentHelper implements AttachmentHelperInterface
/** @var Filesystem The disk where attachments are stored. */
protected $uploadDisk;
+
/**
* AttachmentHelper constructor.
*
@@ -69,6 +70,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->attachments = new Collection;
$this->uploadDisk = Storage::disk('upload');
}
+
/**
* Returns the content of an attachment.
*
diff --git a/app/Helpers/Collector/Extensions/AccountCollection.php b/app/Helpers/Collector/Extensions/AccountCollection.php
index c0409333e4..41f3aa35b7 100644
--- a/app/Helpers/Collector/Extensions/AccountCollection.php
+++ b/app/Helpers/Collector/Extensions/AccountCollection.php
@@ -52,6 +52,7 @@ trait AccountCollection
return $this;
}
+
/**
* These accounts must not be source accounts.
*
@@ -70,6 +71,7 @@ trait AccountCollection
return $this;
}
+
/**
* Define which accounts can be part of the source and destination transactions.
*
@@ -115,6 +117,7 @@ trait AccountCollection
return $this;
}
+
/**
* Define which accounts can be part of the source and destination transactions.
*
@@ -133,6 +136,7 @@ trait AccountCollection
return $this;
}
+
/**
* Define which accounts can be part of the source and destination transactions.
*
@@ -151,6 +155,7 @@ trait AccountCollection
return $this;
}
+
/**
* Either account can be set, but NOT both. This effectively excludes internal transfers.
*
@@ -187,6 +192,7 @@ trait AccountCollection
return $this;
}
+
/**
* Will include the source and destination account names and types.
*
@@ -210,9 +216,9 @@ trait AccountCollection
$this->query->leftJoin('account_types as dest_account_type', 'dest_account_type.id', '=', 'dest_account.account_type_id');
// and add fields:
- $this->fields[] = 'dest_account.name as destination_account_name';
- $this->fields[] = 'dest_account.iban as destination_account_iban';
- $this->fields[] = 'dest_account_type.type as destination_account_type';
+ $this->fields[] = 'dest_account.name as destination_account_name';
+ $this->fields[] = 'dest_account.iban as destination_account_iban';
+ $this->fields[] = 'dest_account_type.type as destination_account_type';
$this->hasAccountInfo = true;
}
diff --git a/app/Helpers/Collector/Extensions/CollectorProperties.php b/app/Helpers/Collector/Extensions/CollectorProperties.php
index ea497d7391..c3bf6a3396 100644
--- a/app/Helpers/Collector/Extensions/CollectorProperties.php
+++ b/app/Helpers/Collector/Extensions/CollectorProperties.php
@@ -43,7 +43,7 @@ trait CollectorProperties
/** @var bool Will be true if query result contains category info. */
private $hasCatInformation;
/** @var bool Will be true for attachments */
- private $hasJoinedAttTables;
+ private $hasJoinedAttTables;
private bool $hasJoinedMetaTables;
/** @var bool Will be true of the query has the tag info tables joined. */
private $hasJoinedTagTables;
diff --git a/app/Helpers/Collector/Extensions/TimeCollection.php b/app/Helpers/Collector/Extensions/TimeCollection.php
index 7d344d1725..86c45a6f92 100644
--- a/app/Helpers/Collector/Extensions/TimeCollection.php
+++ b/app/Helpers/Collector/Extensions/TimeCollection.php
@@ -102,6 +102,7 @@ trait TimeCollection
return $this;
}
+
/**
* Collect transactions updated on a specific date.
*
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 11d5cb155c..6db7a7bfd8 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -485,6 +485,25 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
+ /**
+ * Join table to get attachment information.
+ */
+ private function joinAttachmentTables(): void
+ {
+ if (false === $this->hasJoinedAttTables) {
+ // join some extra tables:
+ $this->hasJoinedAttTables = true;
+ $this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
+ ->where(
+ static function (EloquentBuilder $q1) {
+ $q1->where('attachments.attachable_type', TransactionJournal::class);
+ $q1->where('attachments.uploaded', 1);
+ $q1->orWhereNull('attachments.attachable_type');
+ }
+ );
+ }
+ }
+
/**
* Build the query.
*/
@@ -528,25 +547,6 @@ class GroupCollector implements GroupCollectorInterface
->orderBy('source.amount', 'DESC');
}
- /**
- * Join table to get attachment information.
- */
- private function joinAttachmentTables(): void
- {
- if (false === $this->hasJoinedAttTables) {
- // join some extra tables:
- $this->hasJoinedAttTables = true;
- $this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
- ->where(
- static function (EloquentBuilder $q1) {
- $q1->where('attachments.attachable_type', TransactionJournal::class);
- $q1->where('attachments.uploaded', 1);
- $q1->orWhereNull('attachments.attachable_type');
- }
- );
- }
- }
-
/**
*
*/
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index 202afd6cfe..d426f13fe7 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -44,7 +44,7 @@ class CreateController extends Controller
{
use ModelInformation;
- private AttachmentHelperInterface $attachments;
+ private AttachmentHelperInterface $attachments;
private AccountRepositoryInterface $repository;
/**
@@ -60,7 +60,7 @@ class CreateController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
- app('view')->share('title', (string) trans('firefly.accounts'));
+ app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(AccountRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
@@ -83,7 +83,7 @@ class CreateController extends Controller
$objectType = $objectType ?? 'asset';
$defaultCurrency = app('amount')->getDefaultCurrency();
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
- $subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));
+ $subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
$roles = $this->getRoles();
$liabilityTypes = $this->getLiabilityTypes();
$hasOldInput = null !== $request->old('_token');
@@ -98,9 +98,9 @@ class CreateController extends Controller
// interest calculation periods:
$interestPeriods = [
- 'daily' => (string) trans('firefly.interest_calc_daily'),
- 'monthly' => (string) trans('firefly.interest_calc_monthly'),
- 'yearly' => (string) trans('firefly.interest_calc_yearly'),
+ 'daily' => (string)trans('firefly.interest_calc_daily'),
+ 'monthly' => (string)trans('firefly.interest_calc_monthly'),
+ 'yearly' => (string)trans('firefly.interest_calc_yearly'),
];
// pre fill some data
@@ -108,7 +108,7 @@ class CreateController extends Controller
'preFilled',
[
'currency_id' => $defaultCurrency->id,
- 'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,
+ 'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : true,
]
);
@@ -133,7 +133,7 @@ class CreateController extends Controller
{
$data = $request->getAccountData();
$account = $this->repository->store($data);
- $request->session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
app('preferences')->mark();
Log::channel('audit')->info('Stored new account.', $data);
@@ -152,7 +152,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($account, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -161,7 +161,7 @@ class CreateController extends Controller
// redirect to previous URL.
$redirect = redirect($this->getPreviousUri('accounts.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL:
$request->session()->put('accounts.create.fromStore', true);
diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.php
index d2a8f28e54..41a5cc1f59 100644
--- a/app/Http/Controllers/Account/DeleteController.php
+++ b/app/Http/Controllers/Account/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -55,7 +56,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
- app('view')->share('title', (string) trans('firefly.accounts'));
+ app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(AccountRepositoryInterface::class);
@@ -78,7 +79,7 @@ class DeleteController extends Controller
}
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
- $subTitle = (string) trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);
+ $subTitle = (string)trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);
$accountList = app('expandedform')->makeSelectListWithEmpty($this->repository->getAccountsByType([$account->accountType->type]));
$objectType = $typeName;
unset($accountList[$account->id]);
@@ -106,11 +107,11 @@ class DeleteController extends Controller
$type = $account->accountType->type;
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type));
$name = $account->name;
- $moveTo = $this->repository->findNull((int) $request->get('move_account_before_delete'));
+ $moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete'));
$this->repository->destroy($account, $moveTo);
- $request->session()->flash('success', (string) trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));
+ $request->session()->flash('success', (string)trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));
app('preferences')->mark();
return redirect($this->getPreviousUri('accounts.delete.uri'));
diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.php
index 35049ecc49..afa92d88eb 100644
--- a/app/Http/Controllers/Account/EditController.php
+++ b/app/Http/Controllers/Account/EditController.php
@@ -44,13 +44,13 @@ use Illuminate\View\View;
class EditController extends Controller
{
use ModelInformation, UserNavigation;
+
+ private AttachmentHelperInterface $attachments;
/** @var CurrencyRepositoryInterface The currency repository */
private $currencyRepos;
/** @var AccountRepositoryInterface The account repository */
private $repository;
- private AttachmentHelperInterface $attachments;
-
/**
* EditController constructor.
*/
@@ -62,7 +62,7 @@ class EditController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
- app('view')->share('title', (string) trans('firefly.accounts'));
+ app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -89,7 +89,7 @@ class EditController extends Controller
}
$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];
- $subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
+ $subTitle = (string)trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
$roles = $this->getRoles();
$liabilityTypes = $this->getLiabilityTypes();
@@ -109,9 +109,9 @@ class EditController extends Controller
// interest calculation periods:
$interestPeriods = [
- 'daily' => (string) trans('firefly.interest_calc_daily'),
- 'monthly' => (string) trans('firefly.interest_calc_monthly'),
- 'yearly' => (string) trans('firefly.interest_calc_yearly'),
+ 'daily' => (string)trans('firefly.interest_calc_daily'),
+ 'monthly' => (string)trans('firefly.interest_calc_monthly'),
+ 'yearly' => (string)trans('firefly.interest_calc_yearly'),
];
// put previous url in session if not redirect from store (not "return_to_edit").
@@ -120,7 +120,7 @@ class EditController extends Controller
}
$request->session()->forget('accounts.edit.fromUpdate');
- $openingBalanceAmount = (string) $repository->getOpeningBalanceAmount($account);
+ $openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
@@ -145,7 +145,7 @@ class EditController extends Controller
'interest' => $repository->getMetaValue($account, 'interest'),
'interest_period' => $repository->getMetaValue($account, 'interest_period'),
'notes' => $this->repository->getNoteText($account),
- 'active' => $hasOldInput ? (bool) $request->old('active') : $account->active,
+ 'active' => $hasOldInput ? (bool)$request->old('active') : $account->active,
];
$request->session()->flash('preFilled', $preFilled);
@@ -166,6 +166,7 @@ class EditController extends Controller
)
);
}
+
/**
* Update the account.
*
@@ -183,7 +184,7 @@ class EditController extends Controller
$data = $request->getAccountData();
$this->repository->update($account, $data);
- $request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
+ $request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
// store new attachment(s):
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
@@ -191,7 +192,7 @@ class EditController extends Controller
$this->attachments->saveAttachmentsForModel($account, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -200,7 +201,7 @@ class EditController extends Controller
// redirect
$redirect = redirect($this->getPreviousUri('accounts.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL:
$request->session()->put('accounts.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php
index d3dab251f0..112273fef4 100644
--- a/app/Http/Controllers/Account/ReconcileController.php
+++ b/app/Http/Controllers/Account/ReconcileController.php
@@ -50,6 +50,7 @@ use Log;
class ReconcileController extends Controller
{
use UserNavigation;
+
/** @var AccountRepositoryInterface The account repository */
private $accountRepos;
/** @var CurrencyRepositoryInterface The currency repository */
@@ -70,7 +71,7 @@ class ReconcileController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
- app('view')->share('title', (string) trans('firefly.accounts'));
+ app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(JournalRepositoryInterface::class);
$this->accountRepos = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -87,8 +88,8 @@ class ReconcileController extends Controller
* @param Carbon|null $start
* @param Carbon|null $end
*
- * @throws Exception
* @return Factory|RedirectResponse|Redirector|View
+ * @throws Exception
*/
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null)
{
@@ -97,7 +98,7 @@ class ReconcileController extends Controller
}
if (AccountType::ASSET !== $account->accountType->type) {
// @codeCoverageIgnoreStart
- session()->flash('error', (string) trans('firefly.must_be_asset_account'));
+ session()->flash('error', (string)trans('firefly.must_be_asset_account'));
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
// @codeCoverageIgnoreEnd
@@ -127,10 +128,10 @@ class ReconcileController extends Controller
$startDate = clone $start;
$startDate->subDay();
- $startBalance = number_format((float) app('steam')->balance($account, $startDate), $currency->decimal_places, '.', '');
- $endBalance = number_format((float) app('steam')->balance($account, $end), $currency->decimal_places, '.', '');
+ $startBalance = number_format((float)app('steam')->balance($account, $startDate), $currency->decimal_places, '.', '');
+ $endBalance = number_format((float)app('steam')->balance($account, $end), $currency->decimal_places, '.', '');
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
- $subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);
+ $subTitle = (string)trans('firefly.reconcile_account', ['account' => $account->name]);
// various links
$transactionsUri = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);
@@ -178,7 +179,7 @@ class ReconcileController extends Controller
/** @var string $journalId */
foreach ($data['journals'] as $journalId) {
- $this->repository->reconcileById((int) $journalId);
+ $this->repository->reconcileById((int)$journalId);
}
Log::debug('Reconciled all transactions.');
@@ -195,10 +196,10 @@ class ReconcileController extends Controller
Log::debug('End of routine.');
app('preferences')->mark();
if ('' === $result) {
- session()->flash('success', (string) trans('firefly.reconciliation_stored'));
+ session()->flash('success', (string)trans('firefly.reconciliation_stored'));
}
if ('' !== $result) {
- session()->flash('error', (string) trans('firefly.reconciliation_error', ['error' => $result]));
+ session()->flash('error', (string)trans('firefly.reconciliation_error', ['error' => $result]));
}
return redirect(route('accounts.show', [$account->id]));
@@ -212,9 +213,9 @@ class ReconcileController extends Controller
* @param Carbon $end
* @param string $difference
*
+ * @return RedirectResponse|Redirector|string
* @throws DuplicateTransactionException
*
- * @return RedirectResponse|Redirector|string
*/
private function createReconciliation(Account $account, Carbon $start, Carbon $end, string $difference)
{
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index 852e87ace7..6d25d3bb49 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -32,10 +32,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\Http\Controllers\PeriodOverview;
use FireflyIII\Support\Http\Controllers\UserNavigation;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Support\Collection;
+use Illuminate\View\View;
/**
* Class ShowController
@@ -46,7 +48,7 @@ class ShowController extends Controller
use UserNavigation, PeriodOverview;
private CurrencyRepositoryInterface $currencyRepos;
- private AccountRepositoryInterface $repository;
+ private AccountRepositoryInterface $repository;
/**
* ShowController constructor.
@@ -63,7 +65,7 @@ class ShowController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-credit-card');
- app('view')->share('title', (string) trans('firefly.accounts'));
+ app('view')->share('title', (string)trans('firefly.accounts'));
$this->repository = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
@@ -72,6 +74,7 @@ class ShowController extends Controller
}
);
}
+
/**
* Show an account.
*
@@ -80,13 +83,13 @@ class ShowController extends Controller
* @param Carbon|null $start
* @param Carbon|null $end
*
+ * @return RedirectResponse|Redirector|Factory|View
* @throws Exception
*
- * @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null)
{
- $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
+ $objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
if (!$this->isEditableAccount($account)) {
return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
@@ -104,12 +107,12 @@ class ShowController extends Controller
$attachments = $this->repository->getAttachments($account);
$today = today(config('app.timezone'));
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
$fStart = $start->formatLocalized($this->monthAndDayFormat);
$fEnd = $end->formatLocalized($this->monthAndDayFormat);
- $subTitle = (string) trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
+ $subTitle = (string)trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$firstTransaction = $this->repository->oldestJournalDate($account) ?? $start;
$periods = $this->getAccountPeriodOverview($account, $firstTransaction, $end);
@@ -155,9 +158,9 @@ class ShowController extends Controller
* @param Request $request
* @param Account $account
*
+ * @return RedirectResponse|Redirector|Factory|View
* @throws Exception
*
- * @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showAll(Request $request, Account $account)
{
@@ -166,16 +169,16 @@ class ShowController extends Controller
}
$location = $this->repository->getLocation($account);
$isLiability = $this->repository->isLiability($account);
- $attachments = $this->repository->getAttachments($account);
+ $attachments = $this->repository->getAttachments($account);
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
$end = today(config('app.timezone'));
$today = today(config('app.timezone'));
$start = $this->repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
- $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
+ $subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
$periods = new Collection;
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php
index 8d5517bb05..f3c17ce1b0 100644
--- a/app/Http/Controllers/Admin/ConfigurationController.php
+++ b/app/Http/Controllers/Admin/ConfigurationController.php
@@ -47,7 +47,7 @@ class ConfigurationController extends Controller
$this->middleware(
static function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.administration'));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -63,7 +63,7 @@ class ConfigurationController extends Controller
*/
public function index()
{
- $subTitle = (string) trans('firefly.instance_configuration');
+ $subTitle = (string)trans('firefly.instance_configuration');
$subTitleIcon = 'fa-wrench';
Log::channel('audit')->info('User visits admin config index.');
@@ -99,7 +99,7 @@ class ConfigurationController extends Controller
app('fireflyconfig')->set('is_demo_site', $data['is_demo_site']);
// flash message
- session()->flash('success', (string) trans('firefly.configuration_updated'));
+ session()->flash('success', (string)trans('firefly.configuration_updated'));
app('preferences')->mark();
return redirect()->route('admin.configuration.index');
diff --git a/app/Http/Controllers/Admin/TelemetryController.php b/app/Http/Controllers/Admin/TelemetryController.php
index 8aa94a3721..ee377bfc49 100644
--- a/app/Http/Controllers/Admin/TelemetryController.php
+++ b/app/Http/Controllers/Admin/TelemetryController.php
@@ -28,6 +28,8 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Jobs\SubmitTelemetryData;
use FireflyIII\Repositories\Telemetry\TelemetryRepositoryInterface;
use Illuminate\Contracts\View\Factory;
+use Illuminate\Http\RedirectResponse;
+use Illuminate\Routing\Redirector;
use Illuminate\View\View;
/**
@@ -47,7 +49,7 @@ class TelemetryController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.administration'));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
$this->repository = app(TelemetryRepositoryInterface::class);
@@ -57,7 +59,19 @@ class TelemetryController extends Controller
}
/**
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return RedirectResponse|Redirector
+ */
+ public function deleteAll()
+ {
+ $this->repository->deleteAll();
+
+ session()->flash('success', trans('firefly.telemetry_all_deleted'));
+
+ return redirect(url()->previous(route('admin.telemetry.index')));
+ }
+
+ /**
+ * @return RedirectResponse|Redirector
*/
public function deleteSubmitted()
{
@@ -69,15 +83,18 @@ class TelemetryController extends Controller
}
/**
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * Index
*/
- public function deleteAll()
+ public function index()
{
- $this->repository->deleteAll();
+ app('view')->share('subTitleIcon', 'fa-eye');
+ app('view')->share('subTitle', (string)trans('firefly.telemetry_admin_index'));
+ $version = config('firefly.version');
+ $enabled = config('firefly.send_telemetry', false) && config('firefly.feature_flags.telemetry');
- session()->flash('success', trans('firefly.telemetry_all_deleted'));
+ $count = $this->repository->count();
- return redirect(url()->previous(route('admin.telemetry.index')));
+ return prefixView('admin.telemetry.index', compact('version', 'enabled', 'count'));
}
/**
@@ -94,21 +111,6 @@ class TelemetryController extends Controller
return redirect(url()->previous(route('admin.telemetry.index')));
}
- /**
- * Index
- */
- public function index()
- {
- app('view')->share('subTitleIcon', 'fa-eye');
- app('view')->share('subTitle', (string) trans('firefly.telemetry_admin_index'));
- $version = config('firefly.version');
- $enabled = config('firefly.send_telemetry', false) && config('firefly.feature_flags.telemetry');
-
- $count = $this->repository->count();
-
- return prefixView('admin.telemetry.index', compact('version', 'enabled', 'count'));
- }
-
/**
* View telemetry. Paginated because you never know how much will be collected.
*
diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.php
index 64d0fa3244..65911fe54d 100644
--- a/app/Http/Controllers/Admin/UpdateController.php
+++ b/app/Http/Controllers/Admin/UpdateController.php
@@ -49,7 +49,7 @@ class UpdateController extends Controller
parent::__construct();
$this->middleware(
static function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.administration'));
+ app('view')->share('title', (string)trans('firefly.administration'));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
return $next($request);
@@ -67,22 +67,22 @@ class UpdateController extends Controller
*/
public function index()
{
- $subTitle = (string) trans('firefly.update_check_title');
+ $subTitle = (string)trans('firefly.update_check_title');
$subTitleIcon = 'fa-star';
$permission = app('fireflyconfig')->get('permission_update_check', -1);
$channel = app('fireflyconfig')->get('update_channel', 'stable');
$selected = $permission->data;
$channelSelected = $channel->data;
$options = [
- -1 => (string) trans('firefly.updates_ask_me_later'),
- 0 => (string) trans('firefly.updates_do_not_check'),
- 1 => (string) trans('firefly.updates_enable_check'),
+ -1 => (string)trans('firefly.updates_ask_me_later'),
+ 0 => (string)trans('firefly.updates_do_not_check'),
+ 1 => (string)trans('firefly.updates_enable_check'),
];
$channelOptions = [
- 'stable' => (string) trans('firefly.update_channel_stable'),
- 'beta' => (string) trans('firefly.update_channel_beta'),
- 'alpha' => (string) trans('firefly.update_channel_alpha'),
+ 'stable' => (string)trans('firefly.update_channel_stable'),
+ 'beta' => (string)trans('firefly.update_channel_beta'),
+ 'alpha' => (string)trans('firefly.update_channel_alpha'),
];
return prefixView('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions'));
@@ -97,18 +97,18 @@ class UpdateController extends Controller
*/
public function post(Request $request)
{
- $checkForUpdates = (int) $request->get('check_for_updates');
+ $checkForUpdates = (int)$request->get('check_for_updates');
$channel = $request->get('update_channel');
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
// store as telemetry
app('telemetry')->feature('admin.update.channel', $channel);
- app('telemetry')->feature('admin.update.permission', (string) $checkForUpdates);
+ app('telemetry')->feature('admin.update.permission', (string)$checkForUpdates);
app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
app('fireflyconfig')->set('last_update_check', time());
app('fireflyconfig')->set('update_channel', $channel);
- session()->flash('success', (string) trans('firefly.configuration_updated'));
+ session()->flash('success', (string)trans('firefly.configuration_updated'));
return redirect(route('admin.update-check'));
}
diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php
index bae9542d46..d898fdc448 100644
--- a/app/Http/Controllers/Admin/UserController.php
+++ b/app/Http/Controllers/Admin/UserController.php
@@ -27,8 +27,11 @@ use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Requests\UserFormRequest;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
+use Illuminate\View\View;
use Log;
/**
@@ -36,8 +39,8 @@ use Log;
*/
class UserController extends Controller
{
- private UserRepositoryInterface $repository;
protected bool $externalIdentity;
+ private UserRepositoryInterface $repository;
/**
* UserController constructor.
@@ -64,7 +67,7 @@ class UserController extends Controller
/**
* @param User $user
*
- * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|RedirectResponse|Redirector|\Illuminate\View\View
+ * @return Application|Factory|RedirectResponse|Redirector|View
*/
public function delete(User $user)
{
@@ -104,7 +107,7 @@ class UserController extends Controller
*
* @param User $user
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function edit(User $user)
{
@@ -135,7 +138,7 @@ class UserController extends Controller
/**
* Show index of user manager.
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function index()
{
@@ -159,7 +162,7 @@ class UserController extends Controller
*
* @param User $user
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function show(User $user)
{
diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php
index fd8bbb92dd..e8fb8a4b97 100644
--- a/app/Http/Controllers/AttachmentController.php
+++ b/app/Http/Controllers/AttachmentController.php
@@ -26,9 +26,12 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Requests\AttachmentFormRequest;
use FireflyIII\Models\Attachment;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response as LaravelResponse;
+use Illuminate\Routing\Redirector;
+use Illuminate\View\View;
/**
* Class AttachmentController.
@@ -52,7 +55,7 @@ class AttachmentController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paperclip');
- app('view')->share('title', (string) trans('firefly.attachments'));
+ app('view')->share('title', (string)trans('firefly.attachments'));
$this->repository = app(AttachmentRepositoryInterface::class);
return $next($request);
@@ -65,11 +68,11 @@ class AttachmentController extends Controller
*
* @param Attachment $attachment
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function delete(Attachment $attachment)
{
- $subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]);
+ $subTitle = (string)trans('firefly.delete_attachment', ['name' => $attachment->filename]);
// put previous url in session
$this->rememberPreviousUri('attachments.delete.uri');
@@ -83,7 +86,7 @@ class AttachmentController extends Controller
* @param Request $request
* @param Attachment $attachment
*
- * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return RedirectResponse|Redirector
*/
public function destroy(Request $request, Attachment $attachment)
{
@@ -91,7 +94,7 @@ class AttachmentController extends Controller
$this->repository->destroy($attachment);
- $request->session()->flash('success', (string) trans('firefly.attachment_deleted', ['name' => $name]));
+ $request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));
app('preferences')->mark();
return redirect($this->getPreviousUri('attachments.delete.uri'));
@@ -102,9 +105,9 @@ class AttachmentController extends Controller
*
* @param Attachment $attachment
*
- * @throws FireflyException
* @return mixed
*
+ * @throws FireflyException
*/
public function download(Attachment $attachment)
{
@@ -136,12 +139,12 @@ class AttachmentController extends Controller
* @param Request $request
* @param Attachment $attachment
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function edit(Request $request, Attachment $attachment)
{
$subTitleIcon = 'fa-pencil';
- $subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]);
+ $subTitle = (string)trans('firefly.edit_attachment', ['name' => $attachment->filename]);
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('attachments.edit.fromUpdate')) {
@@ -159,7 +162,7 @@ class AttachmentController extends Controller
/**
* Index of all attachments.
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function index()
{
@@ -171,6 +174,7 @@ class AttachmentController extends Controller
return $attachment;
}
);
+
return prefixView('attachments.index', compact('set'));
}
@@ -187,11 +191,11 @@ class AttachmentController extends Controller
$data = $request->getAttachmentData();
$this->repository->update($attachment, $data);
- $request->session()->flash('success', (string) trans('firefly.attachment_updated', ['name' => $attachment->filename]));
+ $request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('attachments.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('attachments.edit.fromUpdate', true);
@@ -208,8 +212,8 @@ class AttachmentController extends Controller
*
* @param Attachment $attachment
*
- * @throws FireflyException
* @return LaravelResponse
+ * @throws FireflyException
*/
public function view(Request $request, Attachment $attachment): LaravelResponse
{
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index edfdbb3399..e64eb3e487 100644
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -67,6 +67,7 @@ class LoginController extends Controller
parent::__construct();
$this->middleware('guest')->except('logout');
}
+
/**
* Handle a login request to the application.
*
@@ -214,6 +215,7 @@ class LoginController extends Controller
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
request()->cookies->set($cookieName, 'invalid');
}
+
return prefixView('auth.login', compact('allowRegistration', 'email', 'remember', 'allowReset', 'title'));
}
diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.php
index 7e8271b4da..41b69d5c17 100644
--- a/app/Http/Controllers/Bill/CreateController.php
+++ b/app/Http/Controllers/Bill/CreateController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill;
+
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
diff --git a/app/Http/Controllers/Bill/DeleteController.php b/app/Http/Controllers/Bill/DeleteController.php
index 80db43dcdb..14bb9f25ec 100644
--- a/app/Http/Controllers/Bill/DeleteController.php
+++ b/app/Http/Controllers/Bill/DeleteController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.php
index 69cc71b0c1..690d9b4faa 100644
--- a/app/Http/Controllers/Bill/EditController.php
+++ b/app/Http/Controllers/Bill/EditController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BillUpdateRequest;
@@ -62,6 +63,7 @@ class EditController extends Controller
}
);
}
+
/**
* Edit a bill.
*
@@ -108,6 +110,7 @@ class EditController extends Controller
return prefixView('bills.edit', compact('subTitle', 'periods', 'rules', 'bill', 'defaultCurrency', 'preFilled'));
}
+
/**
* Update a bill.
*
diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php
index cf78dd5d17..559b86845b 100644
--- a/app/Http/Controllers/Bill/IndexController.php
+++ b/app/Http/Controllers/Bill/IndexController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Bill;
@@ -139,6 +140,7 @@ class IndexController extends Controller
return prefixView('bills.index', compact('bills', 'sums', 'total', 'totals'));
}
+
/**
* @param array $bills
*
diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.php
index f392a48f26..d597d1dce4 100644
--- a/app/Http/Controllers/Bill/ShowController.php
+++ b/app/Http/Controllers/Bill/ShowController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill;
+
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -116,6 +117,7 @@ class ShowController extends Controller
return redirect(route('bills.show', [$bill->id]));
}
+
/**
* Show a bill.
*
diff --git a/app/Http/Controllers/Budget/AvailableBudgetController.php b/app/Http/Controllers/Budget/AvailableBudgetController.php
index d2de3e194f..31ca116e66 100644
--- a/app/Http/Controllers/Budget/AvailableBudgetController.php
+++ b/app/Http/Controllers/Budget/AvailableBudgetController.php
@@ -127,7 +127,7 @@ class AvailableBudgetController extends Controller
return true;
}
);
- $page = (int)($request->get('page') ?? 1);
+ $page = (int)($request->get('page') ?? 1);
return prefixView('budgets.available-budgets.create-alternative', compact('start', 'end', 'page', 'currencies'));
}
diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.php
index 7c9501b325..d7aca5491b 100644
--- a/app/Http/Controllers/Budget/CreateController.php
+++ b/app/Http/Controllers/Budget/CreateController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BudgetFormStoreRequest;
@@ -37,8 +38,8 @@ use Illuminate\View\View;
*/
class CreateController extends Controller
{
- private BudgetRepositoryInterface $repository;
private AttachmentHelperInterface $attachments;
+ private BudgetRepositoryInterface $repository;
/**
* CreateController constructor.
@@ -50,15 +51,16 @@ class CreateController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.budgets'));
+ app('view')->share('title', (string)trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-pie-chart');
- $this->repository = app(BudgetRepositoryInterface::class);
+ $this->repository = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
return $next($request);
}
);
}
+
/**
* Form to create a budget.
*
@@ -72,23 +74,23 @@ class CreateController extends Controller
// auto budget types
$autoBudgetTypes = [
- 0 => (string) trans('firefly.auto_budget_none'),
- AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
- AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
+ 0 => (string)trans('firefly.auto_budget_none'),
+ AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
+ AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
];
$autoBudgetPeriods = [
- 'daily' => (string) trans('firefly.auto_budget_period_daily'),
- 'weekly' => (string) trans('firefly.auto_budget_period_weekly'),
- 'monthly' => (string) trans('firefly.auto_budget_period_monthly'),
- 'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),
- 'half_year' => (string) trans('firefly.auto_budget_period_half_year'),
- 'yearly' => (string) trans('firefly.auto_budget_period_yearly'),
+ 'daily' => (string)trans('firefly.auto_budget_period_daily'),
+ 'weekly' => (string)trans('firefly.auto_budget_period_weekly'),
+ 'monthly' => (string)trans('firefly.auto_budget_period_monthly'),
+ 'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),
+ 'half_year' => (string)trans('firefly.auto_budget_period_half_year'),
+ 'yearly' => (string)trans('firefly.auto_budget_period_yearly'),
];
$currency = app('amount')->getDefaultCurrency();
$preFilled = [
- 'auto_budget_period' => $hasOldInput ? (bool) $request->old('auto_budget_period') : 'monthly',
- 'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,
+ 'auto_budget_period' => $hasOldInput ? (bool)$request->old('auto_budget_period') : 'monthly',
+ 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
];
$request->session()->flash('preFilled', $preFilled);
@@ -98,10 +100,11 @@ class CreateController extends Controller
$this->rememberPreviousUri('budgets.create.uri');
}
$request->session()->forget('budgets.create.fromStore');
- $subTitle = (string) trans('firefly.create_new_budget');
+ $subTitle = (string)trans('firefly.create_new_budget');
return prefixView('budgets.create', compact('subTitle', 'autoBudgetTypes', 'autoBudgetPeriods'));
}
+
/**
* Stores a budget.
*
@@ -115,7 +118,7 @@ class CreateController extends Controller
$budget = $this->repository->store($data);
$this->repository->cleanupBudgets();
- $request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name]));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name]));
app('preferences')->mark();
// store attachment(s):
@@ -124,7 +127,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($budget, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -133,7 +136,7 @@ class CreateController extends Controller
$redirect = redirect($this->getPreviousUri('budgets.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('budgets.create.fromStore', true);
diff --git a/app/Http/Controllers/Budget/DeleteController.php b/app/Http/Controllers/Budget/DeleteController.php
index 40549eaccc..6d7aa47763 100644
--- a/app/Http/Controllers/Budget/DeleteController.php
+++ b/app/Http/Controllers/Budget/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -51,7 +52,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.budgets'));
+ app('view')->share('title', (string)trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-pie-chart');
$this->repository = app(BudgetRepositoryInterface::class);
@@ -59,6 +60,7 @@ class DeleteController extends Controller
}
);
}
+
/**
* Deletes a budget.
*
@@ -68,7 +70,7 @@ class DeleteController extends Controller
*/
public function delete(Budget $budget)
{
- $subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]);
+ $subTitle = (string)trans('firefly.delete_budget', ['name' => $budget->name]);
// put previous url in session
$this->rememberPreviousUri('budgets.delete.uri');
@@ -88,7 +90,7 @@ class DeleteController extends Controller
{
$name = $budget->name;
$this->repository->destroy($budget);
- $request->session()->flash('success', (string) trans('firefly.deleted_budget', ['name' => $name]));
+ $request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name]));
app('preferences')->mark();
return redirect($this->getPreviousUri('budgets.delete.uri'));
diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.php
index 020193f276..1205a19a67 100644
--- a/app/Http/Controllers/Budget/EditController.php
+++ b/app/Http/Controllers/Budget/EditController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BudgetFormUpdateRequest;
@@ -39,11 +40,10 @@ use Illuminate\View\View;
*/
class EditController extends Controller
{
- /** @var BudgetRepositoryInterface The budget repository */
- private $repository;
-
/** @var AttachmentHelperInterface Helper for attachments. */
private $attachments;
+ /** @var BudgetRepositoryInterface The budget repository */
+ private $repository;
/**
* EditController constructor.
@@ -56,9 +56,9 @@ class EditController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.budgets'));
+ app('view')->share('title', (string)trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-pie-chart');
- $this->repository = app(BudgetRepositoryInterface::class);
+ $this->repository = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
return $next($request);
@@ -76,30 +76,30 @@ class EditController extends Controller
*/
public function edit(Request $request, Budget $budget)
{
- $subTitle = (string) trans('firefly.edit_budget', ['name' => $budget->name]);
+ $subTitle = (string)trans('firefly.edit_budget', ['name' => $budget->name]);
$autoBudget = $this->repository->getAutoBudget($budget);
// auto budget types
$autoBudgetTypes = [
- 0 => (string) trans('firefly.auto_budget_none'),
- AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
- AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
+ 0 => (string)trans('firefly.auto_budget_none'),
+ AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
+ AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
];
$autoBudgetPeriods = [
- 'daily' => (string) trans('firefly.auto_budget_period_daily'),
- 'weekly' => (string) trans('firefly.auto_budget_period_weekly'),
- 'monthly' => (string) trans('firefly.auto_budget_period_monthly'),
- 'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),
- 'half_year' => (string) trans('firefly.auto_budget_period_half_year'),
- 'yearly' => (string) trans('firefly.auto_budget_period_yearly'),
+ 'daily' => (string)trans('firefly.auto_budget_period_daily'),
+ 'weekly' => (string)trans('firefly.auto_budget_period_weekly'),
+ 'monthly' => (string)trans('firefly.auto_budget_period_monthly'),
+ 'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),
+ 'half_year' => (string)trans('firefly.auto_budget_period_half_year'),
+ 'yearly' => (string)trans('firefly.auto_budget_period_yearly'),
];
// code to handle active-checkboxes
$hasOldInput = null !== $request->old('_token');
$currency = app('amount')->getDefaultCurrency();
$preFilled = [
- 'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
- 'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,
+ 'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
+ 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
];
if ($autoBudget) {
$preFilled['auto_budget_amount'] = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
@@ -128,7 +128,7 @@ class EditController extends Controller
$data = $request->getBudgetData();
$this->repository->update($budget, $data);
- $request->session()->flash('success', (string) trans('firefly.updated_budget', ['name' => $budget->name]));
+ $request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));
$this->repository->cleanupBudgets();
app('preferences')->mark();
@@ -140,14 +140,14 @@ class EditController extends Controller
$this->attachments->saveAttachmentsForModel($budget, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments')); // @codeCoverageIgnore
}
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
$request->session()->put('budgets.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index 8a90506f15..d796956cb4 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -49,11 +49,12 @@ use Log;
class IndexController extends Controller
{
use DateCalculation;
+
private AvailableBudgetRepositoryInterface $abRepository;
- private BudgetLimitRepositoryInterface $blRepository;
- private CurrencyRepositoryInterface $currencyRepository;
- private OperationsRepositoryInterface $opsRepository;
- private BudgetRepositoryInterface $repository;
+ private BudgetLimitRepositoryInterface $blRepository;
+ private CurrencyRepositoryInterface $currencyRepository;
+ private OperationsRepositoryInterface $opsRepository;
+ private BudgetRepositoryInterface $repository;
/**
* IndexController constructor.
@@ -66,7 +67,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.budgets'));
+ app('view')->share('title', (string)trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-pie-chart');
$this->repository = app(BudgetRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class);
@@ -95,7 +96,7 @@ class IndexController extends Controller
Log::debug('Start of IndexController::index()');
// collect some basic vars:
- $range = (string) app('preferences')->get('viewRange', '1M')->data;
+ $range = (string)app('preferences')->get('viewRange', '1M')->data;
$start = $start ?? session('start', Carbon::now()->startOfMonth());
$end = $end ?? app('navigation')->endOfPeriod($start, $range);
$defaultCurrency = app('amount')->getDefaultCurrency();
@@ -141,91 +142,6 @@ class IndexController extends Controller
);
}
- /**
- * @param Request $request
- * @param BudgetRepositoryInterface $repository
- *
- * @return JsonResponse
- */
- public function reorder(Request $request, BudgetRepositoryInterface $repository): JsonResponse
- {
- $budgetIds = $request->get('budgetIds');
-
- foreach ($budgetIds as $index => $budgetId) {
- $budgetId = (int) $budgetId;
- $budget = $repository->findNull($budgetId);
- if (null !== $budget) {
- Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
- $repository->setBudgetOrder($budget, $index + 1);
- }
- }
- app('preferences')->mark();
-
- return response()->json(['OK']);
- }
-
- /**
- * @param array $budgets
- *
- * @return array
- */
- private function getSums(array $budgets): array
- {
- $sums = [
- 'budgeted' => [],
- 'spent' => [],
- 'left' => [],
- ];
-
- /** @var array $budget */
- foreach ($budgets as $budget) {
- /** @var array $spent */
- foreach ($budget['spent'] as $spent) {
- $currencyId = $spent['currency_id'];
- $sums['spent'][$currencyId]
- = $sums['spent'][$currencyId]
- ?? [
- 'amount' => '0',
- 'currency_id' => $spent['currency_id'],
- 'currency_symbol' => $spent['currency_symbol'],
- 'currency_decimal_places' => $spent['currency_decimal_places'],
- ];
- $sums['spent'][$currencyId]['amount'] = bcadd($sums['spent'][$currencyId]['amount'], $spent['spent']);
- }
-
- /** @var array $budgeted */
- foreach ($budget['budgeted'] as $budgeted) {
- $currencyId = $budgeted['currency_id'];
- $sums['budgeted'][$currencyId]
- = $sums['budgeted'][$currencyId]
- ?? [
- 'amount' => '0',
- 'currency_id' => $budgeted['currency_id'],
- 'currency_symbol' => $budgeted['currency_symbol'],
- 'currency_decimal_places' => $budgeted['currency_decimal_places'],
- ];
- $sums['budgeted'][$currencyId]['amount'] = bcadd($sums['budgeted'][$currencyId]['amount'], $budgeted['amount']);
-
- // also calculate how much left from budgeted:
- $sums['left'][$currencyId] = $sums['left'][$currencyId]
- ?? [
- 'amount' => '0',
- 'currency_id' => $budgeted['currency_id'],
- 'currency_symbol' => $budgeted['currency_symbol'],
- 'currency_decimal_places' => $budgeted['currency_decimal_places'],
- ];
- }
- }
- // final calculation for 'left':
- foreach ($sums['budgeted'] as $currencyId => $info) {
- $spent = $sums['spent'][$currencyId]['amount'] ?? '0';
- $budgeted = $sums['budgeted'][$currencyId]['amount'] ?? '0';
- $sums['left'][$currencyId]['amount'] = bcadd($spent, $budgeted);
- }
-
- return $sums;
- }
-
/**
* @param Carbon $start
* @param Carbon $end
@@ -289,7 +205,7 @@ class IndexController extends Controller
$currency = $limit->transactionCurrency ?? $defaultCurrency;
$array['budgeted'][] = [
'id' => $limit->id,
- 'amount' => number_format((float) $limit->amount, $currency->decimal_places, '.', ''),
+ 'amount' => number_format((float)$limit->amount, $currency->decimal_places, '.', ''),
'start_date' => $limit->start_date->formatLocalized($this->monthAndDayFormat),
'end_date' => $limit->end_date->formatLocalized($this->monthAndDayFormat),
'in_range' => $limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end),
@@ -312,6 +228,92 @@ class IndexController extends Controller
}
$budgets[] = $array;
}
+
return $budgets;
}
+
+ /**
+ * @param array $budgets
+ *
+ * @return array
+ */
+ private function getSums(array $budgets): array
+ {
+ $sums = [
+ 'budgeted' => [],
+ 'spent' => [],
+ 'left' => [],
+ ];
+
+ /** @var array $budget */
+ foreach ($budgets as $budget) {
+ /** @var array $spent */
+ foreach ($budget['spent'] as $spent) {
+ $currencyId = $spent['currency_id'];
+ $sums['spent'][$currencyId]
+ = $sums['spent'][$currencyId]
+ ?? [
+ 'amount' => '0',
+ 'currency_id' => $spent['currency_id'],
+ 'currency_symbol' => $spent['currency_symbol'],
+ 'currency_decimal_places' => $spent['currency_decimal_places'],
+ ];
+ $sums['spent'][$currencyId]['amount'] = bcadd($sums['spent'][$currencyId]['amount'], $spent['spent']);
+ }
+
+ /** @var array $budgeted */
+ foreach ($budget['budgeted'] as $budgeted) {
+ $currencyId = $budgeted['currency_id'];
+ $sums['budgeted'][$currencyId]
+ = $sums['budgeted'][$currencyId]
+ ?? [
+ 'amount' => '0',
+ 'currency_id' => $budgeted['currency_id'],
+ 'currency_symbol' => $budgeted['currency_symbol'],
+ 'currency_decimal_places' => $budgeted['currency_decimal_places'],
+ ];
+ $sums['budgeted'][$currencyId]['amount'] = bcadd($sums['budgeted'][$currencyId]['amount'], $budgeted['amount']);
+
+ // also calculate how much left from budgeted:
+ $sums['left'][$currencyId] = $sums['left'][$currencyId]
+ ?? [
+ 'amount' => '0',
+ 'currency_id' => $budgeted['currency_id'],
+ 'currency_symbol' => $budgeted['currency_symbol'],
+ 'currency_decimal_places' => $budgeted['currency_decimal_places'],
+ ];
+ }
+ }
+ // final calculation for 'left':
+ foreach ($sums['budgeted'] as $currencyId => $info) {
+ $spent = $sums['spent'][$currencyId]['amount'] ?? '0';
+ $budgeted = $sums['budgeted'][$currencyId]['amount'] ?? '0';
+ $sums['left'][$currencyId]['amount'] = bcadd($spent, $budgeted);
+ }
+
+ return $sums;
+ }
+
+ /**
+ * @param Request $request
+ * @param BudgetRepositoryInterface $repository
+ *
+ * @return JsonResponse
+ */
+ public function reorder(Request $request, BudgetRepositoryInterface $repository): JsonResponse
+ {
+ $budgetIds = $request->get('budgetIds');
+
+ foreach ($budgetIds as $index => $budgetId) {
+ $budgetId = (int)$budgetId;
+ $budget = $repository->findNull($budgetId);
+ if (null !== $budget) {
+ Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
+ $repository->setBudgetOrder($budget, $index + 1);
+ }
+ }
+ app('preferences')->mark();
+
+ return response()->json(['OK']);
+ }
}
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index 2c2b415aa7..a146dc199c 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
+
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -44,8 +45,9 @@ use Illuminate\View\View;
class ShowController extends Controller
{
use PeriodOverview, AugumentData;
+
private JournalRepositoryInterface $journalRepos;
- private BudgetRepositoryInterface $repository;
+ private BudgetRepositoryInterface $repository;
/**
* ShowController constructor.
@@ -58,10 +60,10 @@ class ShowController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.budgets'));
+ app('view')->share('title', (string)trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-pie-chart');
$this->journalRepos = app(JournalRepositoryInterface::class);
- $this->repository = app(BudgetRepositoryInterface::class);
+ $this->repository = app(BudgetRepositoryInterface::class);
return $next($request);
}
@@ -92,8 +94,8 @@ class ShowController extends Controller
$first = $this->journalRepos->firstNull();
$firstDate = null !== $first ? $first->date : $start;
$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -115,12 +117,12 @@ class ShowController extends Controller
public function noBudgetAll(Request $request)
{
- $subTitle = (string) trans('firefly.all_journals_without_budget');
+ $subTitle = (string)trans('firefly.all_journals_without_budget');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$end = today(config('app.timezone'));
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -131,6 +133,7 @@ class ShowController extends Controller
return prefixView('budgets.no-budget', compact('groups', 'subTitle', 'start', 'end'));
}
+
/**
* Show a single budget.
*
@@ -142,12 +145,12 @@ class ShowController extends Controller
public function show(Request $request, Budget $budget)
{
/** @var Carbon $start */
- $allStart = session('first', Carbon::now()->startOfYear());
- $allEnd = today();
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
- $limits = $this->getLimits($budget, $allStart, $allEnd);
- $repetition = null;
+ $allStart = session('first', Carbon::now()->startOfYear());
+ $allEnd = today();
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
+ $limits = $this->getLimits($budget, $allStart, $allEnd);
+ $repetition = null;
$attachments = $this->repository->getAttachments($budget);
// collector:
@@ -159,9 +162,9 @@ class ShowController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath(route('budgets.show', [$budget->id]));
- $subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
+ $subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
- return prefixView('budgets.show', compact('limits','attachments', 'budget', 'repetition', 'groups', 'subTitle'));
+ return prefixView('budgets.show', compact('limits', 'attachments', 'budget', 'repetition', 'groups', 'subTitle'));
}
/**
@@ -171,8 +174,8 @@ class ShowController extends Controller
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
- * @throws FireflyException
* @return Factory|View
+ * @throws FireflyException
*/
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
{
@@ -180,8 +183,8 @@ class ShowController extends Controller
throw new FireflyException('This budget limit is not part of this budget.'); // @codeCoverageIgnore
}
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans(
'firefly.budget_in_period',
[
@@ -201,11 +204,11 @@ class ShowController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));
/** @var Carbon $start */
- $start = session('first', Carbon::now()->startOfYear());
- $end = today(config('app.timezone'));
+ $start = session('first', Carbon::now()->startOfYear());
+ $end = today(config('app.timezone'));
$attachments = $this->repository->getAttachments($budget);
- $limits = $this->getLimits($budget, $start, $end);
+ $limits = $this->getLimits($budget, $start, $end);
- return prefixView('budgets.show', compact('limits','attachments', 'budget', 'budgetLimit', 'groups', 'subTitle'));
+ return prefixView('budgets.show', compact('limits', 'attachments', 'budget', 'budgetLimit', 'groups', 'subTitle'));
}
}
diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.php
index 8b4650e38b..c35c44ce94 100644
--- a/app/Http/Controllers/Category/CreateController.php
+++ b/app/Http/Controllers/Category/CreateController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\CategoryFormRequest;
@@ -37,8 +38,8 @@ use Illuminate\View\View;
*/
class CreateController extends Controller
{
- private CategoryRepositoryInterface $repository;
private AttachmentHelperInterface $attachments;
+ private CategoryRepositoryInterface $repository;
/**
* CategoryController constructor.
@@ -51,7 +52,7 @@ class CreateController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.categories'));
+ app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->repository = app(CategoryRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
@@ -60,6 +61,7 @@ class CreateController extends Controller
}
);
}
+
/**
* Create category.
*
@@ -73,10 +75,11 @@ class CreateController extends Controller
$this->rememberPreviousUri('categories.create.uri');
}
$request->session()->forget('categories.create.fromStore');
- $subTitle = (string) trans('firefly.create_new_category');
+ $subTitle = (string)trans('firefly.create_new_category');
return prefixView('categories.create', compact('subTitle'));
}
+
/**
* Store new category.
*
@@ -89,7 +92,7 @@ class CreateController extends Controller
$data = $request->getCategoryData();
$category = $this->repository->store($data);
- $request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));
+ $request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name]));
app('preferences')->mark();
// store attachment(s):
@@ -98,7 +101,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($category, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info', (string) trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -106,7 +109,7 @@ class CreateController extends Controller
}
$redirect = redirect(route('categories.index'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
$request->session()->put('categories.create.fromStore', true);
diff --git a/app/Http/Controllers/Category/DeleteController.php b/app/Http/Controllers/Category/DeleteController.php
index 65165015fe..191b5acdf2 100644
--- a/app/Http/Controllers/Category/DeleteController.php
+++ b/app/Http/Controllers/Category/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@@ -50,7 +51,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.categories'));
+ app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->repository = app(CategoryRepositoryInterface::class);
@@ -68,7 +69,7 @@ class DeleteController extends Controller
*/
public function delete(Category $category)
{
- $subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]);
+ $subTitle = (string)trans('firefly.delete_category', ['name' => $category->name]);
// put previous url in session
$this->rememberPreviousUri('categories.delete.uri');
@@ -89,7 +90,7 @@ class DeleteController extends Controller
$name = $category->name;
$this->repository->destroy($category);
- $request->session()->flash('success', (string) trans('firefly.deleted_category', ['name' => $name]));
+ $request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name]));
app('preferences')->mark();
return redirect($this->getPreviousUri('categories.delete.uri'));
diff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.php
index 1e3d3f8a60..16940cfb70 100644
--- a/app/Http/Controllers/Category/EditController.php
+++ b/app/Http/Controllers/Category/EditController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\CategoryFormRequest;
@@ -39,8 +40,8 @@ use Illuminate\View\View;
class EditController extends Controller
{
- private CategoryRepositoryInterface $repository;
private AttachmentHelperInterface $attachments;
+ private CategoryRepositoryInterface $repository;
/**
* CategoryController constructor.
@@ -62,6 +63,7 @@ class EditController extends Controller
}
);
}
+
/**
* Edit a category.
*
diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.php
index 8443e5b910..9b75383272 100644
--- a/app/Http/Controllers/Category/IndexController.php
+++ b/app/Http/Controllers/Category/IndexController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
@@ -50,7 +51,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.categories'));
+ app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->repository = app(CategoryRepositoryInterface::class);
@@ -58,6 +59,7 @@ class IndexController extends Controller
}
);
}
+
/**
* Show all categories.
*
@@ -67,8 +69,8 @@ class IndexController extends Controller
*/
public function index(Request $request)
{
- $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$collection = $this->repository->getCategories();
$total = $collection->count();
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php
index 3e0844cfb1..5360245aba 100644
--- a/app/Http/Controllers/Category/NoCategoryController.php
+++ b/app/Http/Controllers/Category/NoCategoryController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
+
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
@@ -41,6 +42,7 @@ use Log;
class NoCategoryController extends Controller
{
use PeriodOverview;
+
/** @var JournalRepositoryInterface Journals and transactions overview */
private $journalRepos;
@@ -56,7 +58,7 @@ class NoCategoryController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.categories'));
+ app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->journalRepos = app(JournalRepositoryInterface::class);
@@ -81,8 +83,8 @@ class NoCategoryController extends Controller
$start = $start ?? session('start');
/** @var Carbon $end */
$end = $end ?? session('end');
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans(
'firefly.without_category_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
@@ -103,6 +105,7 @@ class NoCategoryController extends Controller
return prefixView('categories.no-category', compact('groups', 'subTitle', 'periods', 'start', 'end'));
}
+
/**
* Show all transactions without a category.
*
@@ -116,10 +119,10 @@ class NoCategoryController extends Controller
$start = null;
$end = null;
$periods = new Collection;
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
Log::debug('Start of noCategory()');
- $subTitle = (string) trans('firefly.all_journals_without_category');
+ $subTitle = (string)trans('firefly.all_journals_without_category');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon : $first->date;
$end = today(config('app.timezone'));
diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.php
index ad175fd110..67c21af5b4 100644
--- a/app/Http/Controllers/Category/ShowController.php
+++ b/app/Http/Controllers/Category/ShowController.php
@@ -42,6 +42,7 @@ use Illuminate\View\View;
class ShowController extends Controller
{
use PeriodOverview;
+
/** @var CategoryRepositoryInterface The category repository */
private $repository;
@@ -57,7 +58,7 @@ class ShowController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.categories'));
+ app('view')->share('title', (string)trans('firefly.categories'));
app('view')->share('mainTitleIcon', 'fa-bookmark');
$this->repository = app(CategoryRepositoryInterface::class);
@@ -65,6 +66,7 @@ class ShowController extends Controller
}
);
}
+
/**
* Show a single category.
*
@@ -82,9 +84,9 @@ class ShowController extends Controller
/** @var Carbon $end */
$end = $end ?? session('end', Carbon::now()->endOfMonth());
$subTitleIcon = 'fa-bookmark';
- $page = (int) $request->get('page');
+ $page = (int)$request->get('page');
$attachments = $this->repository->getAttachments($category);
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$oldest = $this->repository->firstUseDate($category) ?? Carbon::now()->startOfYear();
$periods = $this->getCategoryPeriodOverview($category, $oldest, $end);
$path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
@@ -103,7 +105,7 @@ class ShowController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath($path);
- return prefixView('categories.show', compact('category','attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
+ return prefixView('categories.show', compact('category', 'attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
}
/**
@@ -118,19 +120,19 @@ class ShowController extends Controller
{
// default values:
$subTitleIcon = 'fa-bookmark';
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$start = null;
$end = null;
$periods = new Collection;
- $subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);
+ $subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]);
$first = $this->repository->firstUseDate($category);
/** @var Carbon $start */
- $start = $first ?? today(config('app.timezone'));
- $end = today(config('app.timezone'));
- $path = route('categories.show.all', [$category->id]);
- $attachments = $this->repository->getAttachments($category);
+ $start = $first ?? today(config('app.timezone'));
+ $end = today(config('app.timezone'));
+ $path = route('categories.show.all', [$category->id]);
+ $attachments = $this->repository->getAttachments($category);
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
@@ -141,6 +143,6 @@ class ShowController extends Controller
$groups = $collector->getPaginatedGroups();
$groups->setPath($path);
- return prefixView('categories.show', compact('category','attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
+ return prefixView('categories.show', compact('category', 'attachments', 'groups', 'periods', 'subTitle', 'subTitleIcon', 'start', 'end'));
}
}
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index c2ab96d99c..75894437eb 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -76,6 +76,7 @@ class AccountController extends Controller
}
);
}
+
/**
* Shows the balances for all the user's expense accounts (on the front page).
*
@@ -113,10 +114,10 @@ class AccountController extends Controller
// loop the end balances. This is an array for each account ($expenses)
foreach ($endBalances as $accountId => $expenses) {
- $accountId = (int) $accountId;
+ $accountId = (int)$accountId;
// loop each expense entry (each entry can be a different currency).
foreach ($expenses as $currencyId => $endAmount) {
- $currencyId = (int) $currencyId;
+ $currencyId = (int)$currencyId;
// see if there is an accompanying start amount.
// grab the difference and find the currency.
@@ -128,7 +129,7 @@ class AccountController extends Controller
$tempData[] = [
'name' => $accountNames[$accountId],
'difference' => $diff,
- 'diff_float' => (float) $diff,
+ 'diff_float' => (float)$diff,
'currency_id' => $currencyId,
];
}
@@ -147,7 +148,7 @@ class AccountController extends Controller
foreach ($currencies as $currencyId => $currency) {
$dataSet
= [
- 'label' => (string) trans('firefly.spent'),
+ 'label' => (string)trans('firefly.spent'),
'type' => 'bar',
'currency_symbol' => $currency->symbol,
'currency_code' => $currency->code,
@@ -169,6 +170,22 @@ class AccountController extends Controller
return response()->json($data);
}
+ /**
+ * Expenses per budget for all time, as shown on account overview.
+ *
+ * @param AccountRepositoryInterface $repository
+ * @param Account $account
+ *
+ * @return JsonResponse
+ */
+ public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ {
+ $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
+ $end = Carbon::now();
+
+ return $this->expenseBudget($account, $start, $end);
+ }
+
/**
* Expenses per budget, as shown on account overview.
*
@@ -197,7 +214,7 @@ class AccountController extends Controller
$budgetIds = [];
/** @var array $journal */
foreach ($journals as $journal) {
- $budgetId = (int) $journal['budget_id'];
+ $budgetId = (int)$journal['budget_id'];
$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);
$budgetIds[] = $budgetId;
if (!isset($result[$key])) {
@@ -217,7 +234,7 @@ class AccountController extends Controller
foreach ($result as $row) {
$budgetId = $row['budget_id'];
$name = $names[$budgetId];
- $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
+ $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
}
@@ -228,19 +245,19 @@ class AccountController extends Controller
}
/**
- * Expenses per budget for all time, as shown on account overview.
+ * Expenses grouped by category for account.
*
* @param AccountRepositoryInterface $repository
* @param Account $account
*
* @return JsonResponse
*/
- public function expenseBudgetAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
{
$start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
$end = Carbon::now();
- return $this->expenseBudget($account, $start, $end);
+ return $this->expenseCategory($account, $start, $end);
}
/**
@@ -276,7 +293,7 @@ class AccountController extends Controller
if (!isset($result[$key])) {
$result[$key] = [
'total' => '0',
- 'category_id' => (int) $journal['category_id'],
+ 'category_id' => (int)$journal['category_id'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@@ -289,7 +306,7 @@ class AccountController extends Controller
foreach ($result as $row) {
$categoryId = $row['category_id'];
$name = $names[$categoryId] ?? '(unknown)';
- $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
+ $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
}
@@ -299,22 +316,6 @@ class AccountController extends Controller
return response()->json($data);
}
- /**
- * Expenses grouped by category for account.
- *
- * @param AccountRepositoryInterface $repository
- * @param Account $account
- *
- * @return JsonResponse
- */
- public function expenseCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
- {
- $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
- $end = Carbon::now();
-
- return $this->expenseCategory($account, $start, $end);
- }
-
/**
* Shows the balances for all the user's frontpage accounts.
*
@@ -339,6 +340,22 @@ class AccountController extends Controller
return response()->json($this->accountBalanceChart($accounts, $start, $end));
}
+ /**
+ * Shows the income grouped by category for an account, in all time.
+ *
+ * @param AccountRepositoryInterface $repository
+ * @param Account $account
+ *
+ * @return JsonResponse
+ */
+ public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
+ {
+ $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
+ $end = Carbon::now();
+
+ return $this->incomeCategory($account, $start, $end);
+ }
+
/**
* Shows all income per account for each category.
*
@@ -376,7 +393,7 @@ class AccountController extends Controller
'category_id' => $journal['category_id'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
- 'currency_code' => $journal['currency_code'],
+ 'currency_code' => $journal['currency_code'],
];
}
$result[$key]['total'] = bcadd($journal['amount'], $result[$key]['total']);
@@ -386,7 +403,7 @@ class AccountController extends Controller
foreach ($result as $row) {
$categoryId = $row['category_id'];
$name = $names[$categoryId] ?? '(unknown)';
- $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
+ $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
}
$data = $this->generator->multiCurrencyPieChart($chartData);
@@ -395,22 +412,6 @@ class AccountController extends Controller
return response()->json($data);
}
- /**
- * Shows the income grouped by category for an account, in all time.
- *
- * @param AccountRepositoryInterface $repository
- * @param Account $account
- *
- * @return JsonResponse
- */
- public function incomeCategoryAll(AccountRepositoryInterface $repository, Account $account): JsonResponse
- {
- $start = $repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
- $end = Carbon::now();
-
- return $this->incomeCategory($account, $start, $end);
- }
-
/**
* Shows overview of account during a single period.
*
@@ -450,6 +451,61 @@ class AccountController extends Controller
return response()->json($data);
}
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param Account $account
+ * @param TransactionCurrency $currency
+ *
+ * @return array
+ */
+ private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array
+ {
+ $locale = app('steam')->getLocale();
+ $step = $this->calculateStep($start, $end);
+ $result = [
+ 'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
+ 'currency_symbol' => $currency->symbol,
+ 'currency_code' => $currency->code,
+ 'entries' => [],
+ ];
+ $entries = [];
+ $current = clone $start;
+ switch ($step) {
+ default:
+ break;
+ case '1D':
+ // per day the entire period, balance for every day.
+ $format = (string)trans('config.month_and_day', [], $locale);
+ $range = app('steam')->balanceInRange($account, $start, $end, $currency);
+ $previous = array_values($range)[0];
+ while ($end >= $current) {
+ $theDate = $current->format('Y-m-d');
+ $balance = $range[$theDate] ?? $previous;
+ $label = $current->formatLocalized($format);
+ $entries[$label] = (float)$balance;
+ $previous = $balance;
+ $current->addDay();
+ }
+ break;
+ // @codeCoverageIgnoreStart
+ case '1W':
+ case '1M':
+ case '1Y':
+ while ($end >= $current) {
+ $balance = (float)app('steam')->balance($account, $current, $currency);
+ $label = app('navigation')->periodShow($current, $step);
+ $entries[$label] = $balance;
+ $current = app('navigation')->addPeriod($current, $step, 0);
+ }
+ break;
+ // @codeCoverageIgnoreEnd
+ }
+ $result['entries'] = $entries;
+
+ return $result;
+ }
+
/**
* Shows the balances for a given set of dates and accounts.
*
@@ -465,6 +521,7 @@ class AccountController extends Controller
{
return response()->json($this->accountBalanceChart($accounts, $start, $end));
}
+
/**
* Shows the balances for all the user's revenue accounts.
*
@@ -502,10 +559,10 @@ class AccountController extends Controller
// loop the end balances. This is an array for each account ($expenses)
foreach ($endBalances as $accountId => $expenses) {
- $accountId = (int) $accountId;
+ $accountId = (int)$accountId;
// loop each expense entry (each entry can be a different currency).
foreach ($expenses as $currencyId => $endAmount) {
- $currencyId = (int) $currencyId;
+ $currencyId = (int)$currencyId;
// see if there is an accompanying start amount.
// grab the difference and find the currency.
@@ -517,7 +574,7 @@ class AccountController extends Controller
$tempData[] = [
'name' => $accountNames[$accountId],
'difference' => $diff,
- 'diff_float' => (float) $diff,
+ 'diff_float' => (float)$diff,
'currency_id' => $currencyId,
];
}
@@ -536,7 +593,7 @@ class AccountController extends Controller
foreach ($currencies as $currencyId => $currency) {
$dataSet
= [
- 'label' => (string) trans('firefly.earned'),
+ 'label' => (string)trans('firefly.earned'),
'type' => 'bar',
'currency_symbol' => $currency->symbol,
'currency_code' => $currency->code,
@@ -557,59 +614,4 @@ class AccountController extends Controller
return response()->json($data);
}
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- * @param Account $account
- * @param TransactionCurrency $currency
- *
- * @return array
- */
- private function periodByCurrency(Carbon $start, Carbon $end, Account $account, TransactionCurrency $currency): array
- {
- $locale = app('steam')->getLocale();
- $step = $this->calculateStep($start, $end);
- $result = [
- 'label' => sprintf('%s (%s)', $account->name, $currency->symbol),
- 'currency_symbol' => $currency->symbol,
- 'currency_code' => $currency->code,
- 'entries' => [],
- ];
- $entries = [];
- $current = clone $start;
- switch ($step) {
- default:
- break;
- case '1D':
- // per day the entire period, balance for every day.
- $format = (string) trans('config.month_and_day', [], $locale);
- $range = app('steam')->balanceInRange($account, $start, $end, $currency);
- $previous = array_values($range)[0];
- while ($end >= $current) {
- $theDate = $current->format('Y-m-d');
- $balance = $range[$theDate] ?? $previous;
- $label = $current->formatLocalized($format);
- $entries[$label] = (float) $balance;
- $previous = $balance;
- $current->addDay();
- }
- break;
- // @codeCoverageIgnoreStart
- case '1W':
- case '1M':
- case '1Y':
- while ($end >= $current) {
- $balance = (float) app('steam')->balance($account, $current, $currency);
- $label = app('navigation')->periodShow($current, $step);
- $entries[$label] = $balance;
- $current = app('navigation')->addPeriod($current, $step, 0);
- }
- break;
- // @codeCoverageIgnoreEnd
- }
- $result['entries'] = $entries;
-
- return $result;
- }
}
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index b6e385c180..de009a6f45 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -50,6 +50,7 @@ class BillController extends Controller
parent::__construct();
$this->generator = app(GeneratorInterface::class);
}
+
/**
* Shows all bills and whether or not they've been paid this month (pie chart).
*
@@ -78,13 +79,15 @@ class BillController extends Controller
foreach ($paid as $currencyId => $amount) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId);
- $label = (string) trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]);
- $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, 'currency_code' => $currencies[$currencyId]->code];
+ $label = (string)trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]);
+ $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
+ 'currency_code' => $currencies[$currencyId]->code];
}
foreach ($unpaid as $currencyId => $amount) {
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId);
- $label = (string) trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]);
- $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, 'currency_code' => $currencies[$currencyId]->code];
+ $label = (string)trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]);
+ $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
+ 'currency_code' => $currencies[$currencyId]->code];
}
$data = $this->generator->multiCurrencyPieChart($chartData);
@@ -92,6 +95,7 @@ class BillController extends Controller
return response()->json($data);
}
+
/**
* Shows overview for a single bill.
*
@@ -105,7 +109,7 @@ class BillController extends Controller
$cache->addProperty('chart.bill.single');
$cache->addProperty($bill->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get()); // @codeCoverageIgnore
}
$locale = app('steam')->getLocale();
@@ -117,24 +121,28 @@ class BillController extends Controller
usort(
$journals,
static function (array $left, array $right) {
- if($left['date']->gt($right['date'])) {
+ if ($left['date']->gt($right['date'])) {
return 1;
}
- if($left['date']->lt($right['date'])) {
+ if ($left['date']->lt($right['date'])) {
return -1;
}
+
return 0;
}
);
$chartData = [
- ['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
- ['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
- ['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
+ ['type' => 'line', 'label' => (string)trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
+ 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
+ ['type' => 'line', 'label' => (string)trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
+ 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
+ ['type' => 'bar', 'label' => (string)trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
+ 'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
];
foreach ($journals as $journal) {
- $date = $journal['date']->formatLocalized((string) trans('config.month_and_day', [], $locale));
+ $date = $journal['date']->formatLocalized((string)trans('config.month_and_day', [], $locale));
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 6e90b688e7..1cca259abf 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -77,6 +77,7 @@ class BudgetController extends Controller
}
);
}
+
/**
* Shows overview of a single budget.
*
@@ -141,6 +142,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows the amount left in a specific budget limit.
*
@@ -167,7 +169,7 @@ class BudgetController extends Controller
$cache->addProperty($budget->id);
if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
+ return response()->json($cache->get()); // @codeCoverageIgnore
}
$locale = app('steam')->getLocale();
$entries = [];
@@ -192,6 +194,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows how much is spent per asset account.
*
@@ -259,6 +262,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows how much is spent per category.
*
@@ -322,6 +326,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows how much is spent per expense account.
*
@@ -388,6 +393,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows a budget list with spent/left/overspent.
*
@@ -419,6 +425,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows a budget overview chart (spent and budgeted).
*
@@ -477,13 +484,13 @@ class BudgetController extends Controller
// get budget limit in this period for this currency.
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
if (null !== $limit) {
- $chartData[1]['entries'][$title] = round((float) $limit->amount, $currency->decimal_places);
+ $chartData[1]['entries'][$title] = round((float)$limit->amount, $currency->decimal_places);
}
// get spent amount in this period for this currency.
$sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency);
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
- $chartData[0]['entries'][$title] = round((float) $amount, $currency->decimal_places);
+ $chartData[0]['entries'][$title] = round((float)$amount, $currency->decimal_places);
$currentStart = clone $currentEnd;
$currentStart->addDay()->startOfDay();
@@ -494,6 +501,7 @@ class BudgetController extends Controller
return response()->json($data);
}
+
/**
* Shows a chart for transactions without a budget.
*
@@ -527,7 +535,7 @@ class BudgetController extends Controller
$title = $currentStart->formatLocalized($titleFormat);
$sum = $this->nbRepository->sumExpenses($currentStart, $currentEnd, $accounts, $currency);
$amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0');
- $chartData[$title] = round((float) $amount, $currency->decimal_places);
+ $chartData[$title] = round((float)$amount, $currency->decimal_places);
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
}
diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php
index 0ab328e656..69bf517433 100644
--- a/app/Http/Controllers/Chart/BudgetReportController.php
+++ b/app/Http/Controllers/Chart/BudgetReportController.php
@@ -42,6 +42,7 @@ use Illuminate\Support\Collection;
class BudgetReportController extends Controller
{
use AugumentData, TransactionCalculation;
+
/** @var GeneratorInterface Chart generation methods. */
private $generator;
@@ -199,7 +200,7 @@ class BudgetReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
+ (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -224,6 +225,29 @@ class BudgetReportController extends Controller
return response()->json($data);
}
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ private function makeEntries(Carbon $start, Carbon $end): array
+ {
+ $return = [];
+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
+ $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
+ $currentStart = clone $start;
+ while ($currentStart <= $end) {
+ $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
+ $key = $currentStart->formatLocalized($format);
+ $return[$key] = '0';
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay()->startOfDay();
+ }
+
+ return $return;
+ }
+
/**
* Chart that groups expenses by the account.
*
@@ -260,27 +284,4 @@ class BudgetReportController extends Controller
return response()->json($data);
}
-
- /**
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function makeEntries(Carbon $start, Carbon $end): array
- {
- $return = [];
- $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
- $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
- $currentStart = clone $start;
- while ($currentStart <= $end) {
- $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
- $key = $currentStart->formatLocalized($format);
- $return[$key] = '0';
- $currentStart = clone $currentEnd;
- $currentStart->addDay()->startOfDay();
- }
-
- return $return;
- }
}
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index 1a0541f31d..bcf58c25c6 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -60,6 +60,7 @@ class CategoryController extends Controller
// create chart generator:
$this->generator = app(GeneratorInterface::class);
}
+
/**
* Show an overview for a category for all time, per month/week/year.
* TODO test method, for category refactor.
@@ -92,6 +93,22 @@ class CategoryController extends Controller
return response()->json($data);
}
+
+ /**
+ * @return Carbon
+ */
+ private function getDate(): Carbon
+ {
+ $carbon = null;
+ try {
+ $carbon = today(config('app.timezone'));
+ } catch (Exception $e) {
+ $e->getMessage();
+ }
+
+ return $carbon;
+ }
+
/**
* Shows the category chart on the front page.
* TODO test method, for category refactor.
@@ -112,8 +129,8 @@ class CategoryController extends Controller
}
$frontPageGenerator = new FrontpageChartGenerator($start, $end);
- $chartData = $frontPageGenerator->generate();
- $data = $this->generator->multiSet($chartData);
+ $chartData = $frontPageGenerator->generate();
+ $data = $this->generator->multiSet($chartData);
$cache->store($data);
return response()->json($data);
@@ -147,84 +164,6 @@ class CategoryController extends Controller
return response()->json($data);
}
- /**
- * Chart for period for transactions without a category.
- * TODO test me.
- *
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return JsonResponse
- */
- public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
- {
- $cache = new CacheProperties;
- $cache->addProperty($start);
- $cache->addProperty($end);
- $cache->addProperty('chart.category.period.no-cat');
- $cache->addProperty($accounts->pluck('id')->toArray());
- if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
- }
- $data = $this->reportPeriodChart($accounts, $start, $end, null);
-
- $cache->store($data);
-
- return response()->json($data);
- }
-
- /**
- * Chart for a specific period.
- * TODO test method, for category refactor.
- *
- * @param Category $category
- * @param $date
- *
- * @return JsonResponse
- */
- public function specificPeriod(Category $category, Carbon $date): JsonResponse
- {
- $range = app('preferences')->get('viewRange', '1M')->data;
- $start = app('navigation')->startOfPeriod($date, $range);
- $end = session()->get('end');
- if ($end < $start) {
- [$end, $start] = [$start, $end]; // @codeCoverageIgnore
- }
-
- $cache = new CacheProperties;
- $cache->addProperty($start);
- $cache->addProperty($end);
- $cache->addProperty($category->id);
- $cache->addProperty('chart.category.period-chart');
- if ($cache->has()) {
- return response()->json($cache->get()); // @codeCoverageIgnore
- }
-
- /** @var WholePeriodChartGenerator $chartGenerator */
- $chartGenerator = app(WholePeriodChartGenerator::class);
- $chartData = $chartGenerator->generate($category, $start, $end);
- $data = $this->generator->multiSet($chartData);
-
- $cache->store($data);
-
- return response()->json($data);
- }
-
- /**
- * @return Carbon
- */
- private function getDate(): Carbon
- {
- $carbon = null;
- try {
- $carbon = today(config('app.timezone'));
- } catch (Exception $e) {
- $e->getMessage();
- }
-
- return $carbon;
- }
/**
* Generate report chart for either with or without category.
@@ -253,7 +192,7 @@ class CategoryController extends Controller
if (null !== $category) {
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
- $categoryId = (int) $category->id;
+ $categoryId = (int)$category->id;
// this gives us all currencies
$collection = new Collection([$category]);
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
@@ -272,7 +211,7 @@ class CategoryController extends Controller
$inKey = sprintf('%d-in', $currencyId);
$chartData[$outKey]
= [
- 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
+ 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currencyInfo['currency_name']),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
@@ -280,7 +219,7 @@ class CategoryController extends Controller
$chartData[$inKey]
= [
- 'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
+ 'label' => sprintf('%s (%s)', (string)trans('firefly.earned'), $currencyInfo['currency_name']),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
@@ -312,4 +251,68 @@ class CategoryController extends Controller
return $this->generator->multiSet($chartData);
}
+
+ /**
+ * Chart for period for transactions without a category.
+ * TODO test me.
+ *
+ * @param Collection $accounts
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return JsonResponse
+ */
+ public function reportPeriodNoCategory(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
+ {
+ $cache = new CacheProperties;
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty('chart.category.period.no-cat');
+ $cache->addProperty($accounts->pluck('id')->toArray());
+ if ($cache->has()) {
+ return response()->json($cache->get()); // @codeCoverageIgnore
+ }
+ $data = $this->reportPeriodChart($accounts, $start, $end, null);
+
+ $cache->store($data);
+
+ return response()->json($data);
+ }
+
+ /**
+ * Chart for a specific period.
+ * TODO test method, for category refactor.
+ *
+ * @param Category $category
+ * @param $date
+ *
+ * @return JsonResponse
+ */
+ public function specificPeriod(Category $category, Carbon $date): JsonResponse
+ {
+ $range = app('preferences')->get('viewRange', '1M')->data;
+ $start = app('navigation')->startOfPeriod($date, $range);
+ $end = session()->get('end');
+ if ($end < $start) {
+ [$end, $start] = [$start, $end]; // @codeCoverageIgnore
+ }
+
+ $cache = new CacheProperties;
+ $cache->addProperty($start);
+ $cache->addProperty($end);
+ $cache->addProperty($category->id);
+ $cache->addProperty('chart.category.period-chart');
+ if ($cache->has()) {
+ return response()->json($cache->get()); // @codeCoverageIgnore
+ }
+
+ /** @var WholePeriodChartGenerator $chartGenerator */
+ $chartGenerator = app(WholePeriodChartGenerator::class);
+ $chartData = $chartGenerator->generate($category, $start, $end);
+ $data = $this->generator->multiSet($chartData);
+
+ $cache->store($data);
+
+ return response()->json($data);
+ }
}
diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php
index 28d155a5fe..92c61e323c 100644
--- a/app/Http/Controllers/Chart/CategoryReportController.php
+++ b/app/Http/Controllers/Chart/CategoryReportController.php
@@ -267,7 +267,7 @@ class CategoryReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.spent_in_specific_category', ['category' => $category->name]),
+ (string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -294,7 +294,7 @@ class CategoryReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.earned_in_specific_category', ['category' => $category->name]),
+ (string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -319,6 +319,31 @@ class CategoryReportController extends Controller
return response()->json($data);
}
+ /**
+ * TODO duplicate function
+ *
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ private function makeEntries(Carbon $start, Carbon $end): array
+ {
+ $return = [];
+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
+ $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
+ $currentStart = clone $start;
+ while ($currentStart <= $end) {
+ $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
+ $key = $currentStart->formatLocalized($format);
+ $return[$key] = '0';
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay()->startOfDay();
+ }
+
+ return $return;
+ }
+
/**
* @param Collection $accounts
* @param Collection $categories
@@ -390,29 +415,4 @@ class CategoryReportController extends Controller
return response()->json($data);
}
-
- /**
- * TODO duplicate function
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function makeEntries(Carbon $start, Carbon $end): array
- {
- $return = [];
- $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
- $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
- $currentStart = clone $start;
- while ($currentStart <= $end) {
- $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
- $key = $currentStart->formatLocalized($format);
- $return[$key] = '0';
- $currentStart = clone $currentEnd;
- $currentStart->addDay()->startOfDay();
- }
-
- return $return;
- }
}
diff --git a/app/Http/Controllers/Chart/DoubleReportController.php b/app/Http/Controllers/Chart/DoubleReportController.php
index 504e8b712e..0060605cdc 100644
--- a/app/Http/Controllers/Chart/DoubleReportController.php
+++ b/app/Http/Controllers/Chart/DoubleReportController.php
@@ -199,7 +199,7 @@ class DoubleReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.spent_in_specific_double', ['account' => $name]),
+ (string)trans('firefly.spent_in_specific_double', ['account' => $name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -225,7 +225,7 @@ class DoubleReportController extends Controller
$chartData[$earnedKey] = $chartData[$earnedKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.earned_in_specific_double', ['account' => $name]),
+ (string)trans('firefly.earned_in_specific_double', ['account' => $name]),
$currency['currency_name']
),
'type' => 'bar',
@@ -247,6 +247,57 @@ class DoubleReportController extends Controller
return response()->json($data);
}
+
+ /**
+ * TODO this method is double.
+ *
+ * @param Collection $accounts
+ * @param int $id
+ * @param string $name
+ * @param null|string $iban
+ *
+ * @return string
+ */
+ private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
+ {
+ /** @var Account $account */
+ foreach ($accounts as $account) {
+ if ($account->name === $name && $account->id !== $id) {
+ return $account->name;
+ }
+ if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
+ return $account->iban;
+ }
+ }
+
+ return $name;
+ }
+
+ /**
+ * TODO duplicate function
+ *
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ private function makeEntries(Carbon $start, Carbon $end): array
+ {
+ $return = [];
+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
+ $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
+ $currentStart = clone $start;
+ while ($currentStart <= $end) {
+ $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
+ $key = $currentStart->formatLocalized($format);
+ $return[$key] = '0';
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay()->startOfDay();
+ }
+
+ return $return;
+ }
+
/**
* @param Collection $accounts
* @param Collection $others
@@ -366,54 +417,4 @@ class DoubleReportController extends Controller
return response()->json($data);
}
-
- /**
- * TODO this method is double.
- *
- * @param Collection $accounts
- * @param int $id
- * @param string $name
- * @param null|string $iban
- *
- * @return string
- */
- private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
- {
- /** @var Account $account */
- foreach ($accounts as $account) {
- if ($account->name === $name && $account->id !== $id) {
- return $account->name;
- }
- if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
- return $account->iban;
- }
- }
-
- return $name;
- }
-
- /**
- * TODO duplicate function
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function makeEntries(Carbon $start, Carbon $end): array
- {
- $return = [];
- $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
- $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
- $currentStart = clone $start;
- while ($currentStart <= $end) {
- $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
- $key = $currentStart->formatLocalized($format);
- $return[$key] = '0';
- $currentStart = clone $currentEnd;
- $currentStart->addDay()->startOfDay();
- }
-
- return $return;
- }
}
diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.php
index 3ce50ae38c..bfda695e27 100644
--- a/app/Http/Controllers/Chart/ExpenseReportController.php
+++ b/app/Http/Controllers/Chart/ExpenseReportController.php
@@ -42,6 +42,7 @@ use Illuminate\Support\Collection;
class ExpenseReportController extends Controller
{
use AugumentData, TransactionCalculation;
+
/** @var AccountRepositoryInterface The account repository */
protected $accountRepository;
/** @var GeneratorInterface Chart generation methods. */
@@ -64,6 +65,7 @@ class ExpenseReportController extends Controller
}
);
}
+
/**
* Main chart that shows income and expense for a combination of expense/revenue accounts.
*
@@ -110,27 +112,27 @@ class ExpenseReportController extends Controller
/** @var Account $exp */
$exp = $combination->first();
$chartData[$exp->id . '-in'] = [
- 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.income')),
+ 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.income')),
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
$chartData[$exp->id . '-out'] = [
- 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.expenses')),
+ 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.expenses')),
'type' => 'bar',
'yAxisID' => 'y-axis-0',
'entries' => [],
];
// total in, total out:
$chartData[$exp->id . '-total-in'] = [
- 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_income')),
+ 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_income')),
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
'entries' => [],
];
$chartData[$exp->id . '-total-out'] = [
- 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_expenses')),
+ 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_expenses')),
'type' => 'line',
'fill' => false,
'yAxisID' => 'y-axis-1',
diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.php
index 2d08fa7aa6..96d7287638 100644
--- a/app/Http/Controllers/Chart/PiggyBankController.php
+++ b/app/Http/Controllers/Chart/PiggyBankController.php
@@ -39,6 +39,7 @@ use Illuminate\Support\Collection;
class PiggyBankController extends Controller
{
use DateCalculation;
+
/** @var GeneratorInterface Chart generation methods. */
protected $generator;
@@ -74,9 +75,9 @@ class PiggyBankController extends Controller
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
}
- $set = $repository->getEvents($piggyBank);
- $set = $set->reverse();
- $locale =app('steam')->getLocale();
+ $set = $repository->getEvents($piggyBank);
+ $set = $set->reverse();
+ $locale = app('steam')->getLocale();
// get first event or start date of piggy bank or today
$startDate = $piggyBank->start_date ?? today(config('app.timezone'));
@@ -100,7 +101,7 @@ class PiggyBankController extends Controller
}
);
$currentSum = $filtered->sum('amount');
- $label = $oldest->formatLocalized((string) trans('config.month_and_day', [], $locale));
+ $label = $oldest->formatLocalized((string)trans('config.month_and_day', [], $locale));
$chartData[$label] = $currentSum;
$oldest = app('navigation')->addPeriod($oldest, $step, 0);
}
@@ -111,7 +112,7 @@ class PiggyBankController extends Controller
}
);
$finalSum = $finalFiltered->sum('amount');
- $finalLabel = $today->formatLocalized((string) trans('config.month_and_day', [], $locale));
+ $finalLabel = $today->formatLocalized((string)trans('config.month_and_day', [], $locale));
$chartData[$finalLabel] = $finalSum;
$data = $this->generator->singleSet($piggyBank->name, $chartData);
diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.php
index 5c24bd889d..9e736e5ea9 100644
--- a/app/Http/Controllers/Chart/ReportController.php
+++ b/app/Http/Controllers/Chart/ReportController.php
@@ -43,6 +43,7 @@ use Log;
class ReportController extends Controller
{
use BasicDataSupport, ChartGeneration;
+
/** @var GeneratorInterface Chart generation methods. */
protected $generator;
@@ -79,7 +80,7 @@ class ReportController extends Controller
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
}
- $locale = app('steam')->getLocale();
+ $locale = app('steam')->getLocale();
$current = clone $start;
$chartData = [];
/** @var NetWorthInterface $helper */
@@ -111,13 +112,13 @@ class ReportController extends Controller
/** @var array $netWorthItem */
foreach ($result as $netWorthItem) {
$currencyId = $netWorthItem['currency']->id;
- $label = $current->formatLocalized((string) trans('config.month_and_day', [], $locale));
+ $label = $current->formatLocalized((string)trans('config.month_and_day', [], $locale));
if (!isset($chartData[$currencyId])) {
$chartData[$currencyId] = [
'label' => 'Net worth in ' . $netWorthItem['currency']->name,
'type' => 'line',
'currency_symbol' => $netWorthItem['currency']->symbol,
- 'currency_code' => $netWorthItem['currency']->code,
+ 'currency_code' => $netWorthItem['currency']->code,
'entries' => [],
];
}
@@ -175,13 +176,13 @@ class ReportController extends Controller
/** @var array $journal */
foreach ($journals as $journal) {
$period = $journal['date']->format($format);
- $currencyId = (int) $journal['currency_id'];
+ $currencyId = (int)$journal['currency_id'];
$data[$currencyId] = $data[$currencyId] ?? [
'currency_id' => $currencyId,
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
- 'currency_decimal_places' => (int) $journal['currency_decimal_places'],
+ 'currency_decimal_places' => (int)$journal['currency_decimal_places'],
];
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
'period' => $period,
@@ -213,7 +214,7 @@ class ReportController extends Controller
/** @var array $currency */
foreach ($data as $currency) {
$income = [
- 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),
+ 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),
'type' => 'bar',
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
'currency_id' => $currency['currency_id'],
@@ -222,7 +223,7 @@ class ReportController extends Controller
'entries' => [],
];
$expense = [
- 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
+ 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
'type' => 'bar',
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
'currency_id' => $currency['currency_id'],
@@ -236,8 +237,8 @@ class ReportController extends Controller
while ($currentStart <= $end) {
$key = $currentStart->format($format);
$title = $currentStart->formatLocalized($titleFormat);
- $income['entries'][$title] = round((float) ($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']);
- $expense['entries'][$title] = round((float) ($currency[$key]['spent'] ?? '0'), $currency['currency_decimal_places']);
+ $income['entries'][$title] = round((float)($currency[$key]['earned'] ?? '0'), $currency['currency_decimal_places']);
+ $expense['entries'][$title] = round((float)($currency[$key]['spent'] ?? '0'), $currency['currency_decimal_places']);
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
}
diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php
index 950d231287..395202d481 100644
--- a/app/Http/Controllers/Chart/TagReportController.php
+++ b/app/Http/Controllers/Chart/TagReportController.php
@@ -38,6 +38,7 @@ use Illuminate\Support\Collection;
class TagReportController extends Controller
{
use AugumentData, TransactionCalculation;
+
/** @var GeneratorInterface Chart generation methods. */
protected $generator;
@@ -171,6 +172,7 @@ class TagReportController extends Controller
return response()->json($data);
}
+
/**
* @param Collection $accounts
* @param Collection $tags
@@ -268,7 +270,7 @@ class TagReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
+ (string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
$currency['currency_name']
),
'type' => 'bar',
@@ -295,7 +297,7 @@ class TagReportController extends Controller
$chartData[$spentKey] = $chartData[$spentKey] ?? [
'label' => sprintf(
'%s (%s)',
- (string) trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
+ (string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
$currency['currency_name']
),
'type' => 'bar',
@@ -320,6 +322,31 @@ class TagReportController extends Controller
return response()->json($data);
}
+ /**
+ * TODO duplicate function
+ *
+ * @param Carbon $start
+ * @param Carbon $end
+ *
+ * @return array
+ */
+ private function makeEntries(Carbon $start, Carbon $end): array
+ {
+ $return = [];
+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
+ $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
+ $currentStart = clone $start;
+ while ($currentStart <= $end) {
+ $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
+ $key = $currentStart->formatLocalized($format);
+ $return[$key] = '0';
+ $currentStart = clone $currentEnd;
+ $currentStart->addDay()->startOfDay();
+ }
+
+ return $return;
+ }
+
/**
* @param Collection $accounts
* @param Collection $tags
@@ -425,6 +452,7 @@ class TagReportController extends Controller
return response()->json($data);
}
+
/**
* @param Collection $accounts
* @param Collection $tags
@@ -458,28 +486,4 @@ class TagReportController extends Controller
return response()->json($data);
}
- /**
- * TODO duplicate function
- *
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function makeEntries(Carbon $start, Carbon $end): array
- {
- $return = [];
- $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
- $preferredRange = app('navigation')->preferredRangeFormat($start, $end);
- $currentStart = clone $start;
- while ($currentStart <= $end) {
- $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);
- $key = $currentStart->formatLocalized($format);
- $return[$key] = '0';
- $currentStart = clone $currentEnd;
- $currentStart->addDay()->startOfDay();
- }
-
- return $return;
- }
}
diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.php
index 54263eac1f..f6d1aca390 100644
--- a/app/Http/Controllers/Chart/TransactionController.php
+++ b/app/Http/Controllers/Chart/TransactionController.php
@@ -56,8 +56,8 @@ class TransactionController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return JsonResponse
+ * @throws FireflyException
*/
public function budgets(Carbon $start, Carbon $end)
{
@@ -80,8 +80,8 @@ class TransactionController extends Controller
// group by category.
/** @var array $journal */
foreach ($result as $journal) {
- $budget = $journal['budget_name'] ?? (string) trans('firefly.no_budget');
- $title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
+ $budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget');
+ $title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
@@ -100,8 +100,8 @@ class TransactionController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return JsonResponse
+ * @throws FireflyException
*/
public function categories(string $objectType, Carbon $start, Carbon $end)
{
@@ -137,8 +137,8 @@ class TransactionController extends Controller
// group by category.
/** @var array $journal */
foreach ($result as $journal) {
- $category = $journal['category_name'] ?? (string) trans('firefly.no_category');
- $title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
+ $category = $journal['category_name'] ?? (string)trans('firefly.no_category');
+ $title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [
'amount' => '0',
'currency_symbol' => $journal['currency_symbol'],
@@ -158,8 +158,8 @@ class TransactionController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return JsonResponse
+ * @throws FireflyException
*/
public function destinationAccounts(string $objectType, Carbon $start, Carbon $end)
{
@@ -215,8 +215,8 @@ class TransactionController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return JsonResponse
+ * @throws FireflyException
*/
public function sourceAccounts(string $objectType, Carbon $start, Carbon $end)
{
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index 2be7f99e4b..a53aef9f5f 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -27,13 +27,16 @@ use Artisan;
use Carbon\Carbon;
use DB;
use Exception;
+use FireflyConfig;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Routing\Route;
+use Illuminate\View\View;
use Log;
use Monolog\Handler\RotatingFileHandler;
use Route as RouteFacade;
@@ -113,7 +116,7 @@ class DebugController extends Controller
*
* @param Request $request
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*
*/
public function index(Request $request)
@@ -132,7 +135,7 @@ class DebugController extends Controller
$userAgent = $request->header('user-agent');
$trustedProxies = config('firefly.trusted_proxies');
$displayErrors = ini_get('display_errors');
- $errorReporting = $this->errorReporting((int) ini_get('error_reporting'));
+ $errorReporting = $this->errorReporting((int)ini_get('error_reporting'));
$appEnv = config('app.env');
$appDebug = var_export(config('app.debug'), true);
$logChannel = config('logging.default');
@@ -144,12 +147,12 @@ class DebugController extends Controller
// expected + found DB version:
$expectedDBversion = config('firefly.db_version');
- $foundDBversion = \FireflyConfig::get('db_version',1)->data;
+ $foundDBversion = FireflyConfig::get('db_version', 1)->data;
// some new vars.
$telemetry = true === config('firefly.send_telemetry') && true === config('firefly.feature_flags.telemetry');
- $defaultLanguage = (string) config('firefly.default_language');
- $defaultLocale = (string) config('firefly.default_locale');
+ $defaultLanguage = (string)config('firefly.default_language');
+ $defaultLocale = (string)config('firefly.default_locale');
$userLanguage = app('steam')->getLanguage();
$userLocale = app('steam')->getLocale();
$isDocker = env('IS_DOCKER', false);
@@ -248,7 +251,7 @@ class DebugController extends Controller
$return = '&nbsp;';
/** @var Route $route */
foreach ($set as $route) {
- $name = (string) $route->getName();
+ $name = (string)$route->getName();
if (in_array('GET', $route->methods(), true)) {
$found = false;
foreach ($ignore as $string) {
diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.php
index 200c2cc775..af0a66181f 100644
--- a/app/Http/Controllers/Export/IndexController.php
+++ b/app/Http/Controllers/Export/IndexController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Export;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -53,7 +54,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-life-bouy');
- app('view')->share('title', (string) trans('firefly.export_data_title'));
+ app('view')->share('title', (string)trans('firefly.export_data_title'));
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->middleware(IsDemoUser::class)->except(['index']);
@@ -63,8 +64,8 @@ class IndexController extends Controller
}
/**
- * @throws CannotInsertRecord
* @return LaravelResponse
+ * @throws CannotInsertRecord
*/
public function export(): LaravelResponse
{
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index a1c543e1cc..4d981a1ffd 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -96,6 +96,7 @@ class HomeController extends Controller
return response()->json(['ok' => 'ok']);
}
+
/**
* Show index.
*
diff --git a/app/Http/Controllers/Json/AutoCompleteController.php b/app/Http/Controllers/Json/AutoCompleteController.php
index 351db67040..af2b1b5f52 100644
--- a/app/Http/Controllers/Json/AutoCompleteController.php
+++ b/app/Http/Controllers/Json/AutoCompleteController.php
@@ -76,6 +76,7 @@ class AutoCompleteController extends Controller
// give another key for consistency
$array[$index]['name'] = sprintf('#%d: %s', $item['transaction_group_id'], $item['description']);
}
+
return response()->json($array);
}
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index ca69682029..5de2c2d2a2 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -125,6 +125,7 @@ class BoxController extends Controller
return response()->json($return);
}
+
/**
* Current total balance.
*
@@ -250,7 +251,7 @@ class BoxController extends Controller
);
$netWorthSet = $netWorthHelper->getNetWorthByCurrency($filtered, $date);
- $return = [];
+ $return = [];
foreach ($netWorthSet as $data) {
/** @var TransactionCurrency $currency */
$currency = $data['currency'];
diff --git a/app/Http/Controllers/Json/BudgetController.php b/app/Http/Controllers/Json/BudgetController.php
index 297c48f35d..28ed024372 100644
--- a/app/Http/Controllers/Json/BudgetController.php
+++ b/app/Http/Controllers/Json/BudgetController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency;
diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.php
index 4fa046cd72..6fc636fd32 100644
--- a/app/Http/Controllers/Json/RecurrenceController.php
+++ b/app/Http/Controllers/Json/RecurrenceController.php
@@ -177,6 +177,7 @@ class RecurrenceController extends Controller
];
}
Log::debug('Dropdown is', $result);
+
return response()->json($result);
}
}
diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.php
index 34b9dd124f..9fe3d32b02 100644
--- a/app/Http/Controllers/Json/RuleController.php
+++ b/app/Http/Controllers/Json/RuleController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
+
use FireflyIII\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -87,6 +88,7 @@ class RuleController extends Controller
Log::error(sprintf('Cannot render rules.partials.trigger: %s', $e->getMessage()));
$view = 'Could not render view.';
}
+
return response()->json(['html' => $view]);
}
diff --git a/app/Http/Controllers/ObjectGroup/DeleteController.php b/app/Http/Controllers/ObjectGroup/DeleteController.php
index 111b2024fc..c5fa6c7f85 100644
--- a/app/Http/Controllers/ObjectGroup/DeleteController.php
+++ b/app/Http/Controllers/ObjectGroup/DeleteController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\ObjectGroup;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\ObjectGroup;
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
@@ -47,7 +48,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-envelope-o');
- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
$this->repository = app(ObjectGroupRepositoryInterface::class);
@@ -63,7 +64,7 @@ class DeleteController extends Controller
*/
public function delete(ObjectGroup $objectGroup)
{
- $subTitle = (string) trans('firefly.delete_object_group', ['title' => $objectGroup->title]);
+ $subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);
$piggyBanks = $objectGroup->piggyBanks()->count();
// put previous url in session
@@ -79,7 +80,7 @@ class DeleteController extends Controller
*/
public function destroy(ObjectGroup $objectGroup): RedirectResponse
{
- session()->flash('success', (string) trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
+ session()->flash('success', (string)trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
app('preferences')->mark();
$this->repository->destroy($objectGroup);
diff --git a/app/Http/Controllers/ObjectGroup/EditController.php b/app/Http/Controllers/ObjectGroup/EditController.php
index ec4a48c05e..e2d966afb7 100644
--- a/app/Http/Controllers/ObjectGroup/EditController.php
+++ b/app/Http/Controllers/ObjectGroup/EditController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\ObjectGroup;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\ObjectGroupFormRequest;
use FireflyIII\Models\ObjectGroup;
@@ -47,7 +48,7 @@ class EditController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-envelope-o');
- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
$this->repository = app(ObjectGroupRepositoryInterface::class);
@@ -63,7 +64,7 @@ class EditController extends Controller
*/
public function edit(ObjectGroup $objectGroup)
{
- $subTitle = (string) trans('firefly.edit_object_group', ['title' => $objectGroup->title]);
+ $subTitle = (string)trans('firefly.edit_object_group', ['title' => $objectGroup->title]);
$subTitleIcon = 'fa-pencil';
if (true !== session('object-groups.edit.fromUpdate')) {
@@ -73,23 +74,24 @@ class EditController extends Controller
return prefixView('object-groups.edit', compact('subTitle', 'subTitleIcon', 'objectGroup'));
}
+
/**
* Update a piggy bank.
*
* @param ObjectGroupFormRequest $request
- * @param ObjectGroup $objectGroup
+ * @param ObjectGroup $objectGroup
*/
public function update(ObjectGroupFormRequest $request, ObjectGroup $objectGroup)
{
$data = $request->getObjectGroupData();
$piggyBank = $this->repository->update($objectGroup, $data);
- session()->flash('success', (string) trans('firefly.updated_object_group', ['title' => $objectGroup->title]));
+ session()->flash('success', (string)trans('firefly.updated_object_group', ['title' => $objectGroup->title]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('object-groups.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
session()->put('object-groups.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.php
index 4100f2df28..59baa17e7c 100644
--- a/app/Http/Controllers/ObjectGroup/IndexController.php
+++ b/app/Http/Controllers/ObjectGroup/IndexController.php
@@ -23,10 +23,14 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\ObjectGroup;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\ObjectGroup;
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
+use Illuminate\Contracts\Foundation\Application;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request;
+use Illuminate\View\View;
use Log;
/**
@@ -49,7 +53,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-envelope-o');
- app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
+ app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
$this->repository = app(ObjectGroupRepositoryInterface::class);
return $next($request);
@@ -58,13 +62,13 @@ class IndexController extends Controller
}
/**
- * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Application|Factory|View
*/
public function index()
{
$this->repository->deleteEmpty();
$this->repository->resetOrder();
- $subTitle = (string) trans('firefly.object_groups_index');
+ $subTitle = (string)trans('firefly.object_groups_index');
$objectGroups = $this->repository->get();
return prefixView('object-groups.index', compact('subTitle', 'objectGroups'));
@@ -76,7 +80,7 @@ class IndexController extends Controller
public function setOrder(Request $request, ObjectGroup $objectGroup)
{
Log::debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title));
- $newOrder = (int) $request->get('order');
+ $newOrder = (int)$request->get('order');
$this->repository->setOrder($objectGroup, $newOrder);
return response()->json([]);
diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.php
index 03d8a9d359..29286be025 100644
--- a/app/Http/Controllers/PiggyBank/AmountController.php
+++ b/app/Http/Controllers/PiggyBank/AmountController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
@@ -54,7 +55,7 @@ class AmountController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
@@ -124,7 +125,7 @@ class AmountController extends Controller
$this->piggyRepos->createEvent($piggyBank, $amount);
session()->flash(
'success',
- (string) trans(
+ (string)trans(
'firefly.added_amount_to_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
@@ -137,7 +138,7 @@ class AmountController extends Controller
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
session()->flash(
'error',
- (string) trans(
+ (string)trans(
'firefly.cannot_add_amount_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
)
@@ -166,7 +167,7 @@ class AmountController extends Controller
$this->piggyRepos->removeAmount($piggyBank, $amount);
session()->flash(
'success',
- (string) trans(
+ (string)trans(
'firefly.removed_amount_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
@@ -175,11 +176,11 @@ class AmountController extends Controller
return redirect(route('piggy-banks.index'));
}
- $amount = number_format((float) $request->get('amount'), 12, '.', '');
+ $amount = number_format((float)$request->get('amount'), 12, '.', '');
session()->flash(
'error',
- (string) trans(
+ (string)trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
)
diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.php
index 41c6f8743b..6ad6f2b4b7 100644
--- a/app/Http/Controllers/PiggyBank/CreateController.php
+++ b/app/Http/Controllers/PiggyBank/CreateController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\PiggyBankStoreRequest;
@@ -51,7 +52,7 @@ class CreateController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->attachments = app(AttachmentHelperInterface::class);
@@ -69,7 +70,7 @@ class CreateController extends Controller
*/
public function create()
{
- $subTitle = (string) trans('firefly.new_piggy_bank');
+ $subTitle = (string)trans('firefly.new_piggy_bank');
$subTitleIcon = 'fa-plus';
// put previous url in session if not redirect from store (not "create another").
@@ -80,6 +81,7 @@ class CreateController extends Controller
return prefixView('piggy-banks.create', compact('subTitle', 'subTitleIcon'));
}
+
/**
* Store a new piggy bank.
*
@@ -95,7 +97,7 @@ class CreateController extends Controller
}
$piggyBank = $this->piggyRepos->store($data);
- session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
+ session()->flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
app('preferences')->mark();
// store attachment(s):
@@ -105,7 +107,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info', (string) trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -113,7 +115,7 @@ class CreateController extends Controller
}
$redirect = redirect($this->getPreviousUri('piggy-banks.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
session()->put('piggy-banks.create.fromStore', true);
diff --git a/app/Http/Controllers/PiggyBank/DeleteController.php b/app/Http/Controllers/PiggyBank/DeleteController.php
index 538916b550..4f2d8e7456 100644
--- a/app/Http/Controllers/PiggyBank/DeleteController.php
+++ b/app/Http/Controllers/PiggyBank/DeleteController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
@@ -49,7 +50,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
@@ -68,7 +69,7 @@ class DeleteController extends Controller
*/
public function delete(PiggyBank $piggyBank)
{
- $subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
+ $subTitle = (string)trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
// put previous url in session
$this->rememberPreviousUri('piggy-banks.delete.uri');
@@ -85,7 +86,7 @@ class DeleteController extends Controller
*/
public function destroy(PiggyBank $piggyBank): RedirectResponse
{
- session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
+ session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
app('preferences')->mark();
$this->piggyRepos->destroy($piggyBank);
diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.php
index 3eafabb5c2..694f1c787d 100644
--- a/app/Http/Controllers/PiggyBank/EditController.php
+++ b/app/Http/Controllers/PiggyBank/EditController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\PiggyBankUpdateRequest;
@@ -52,7 +53,7 @@ class EditController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->attachments = app(AttachmentHelperInterface::class);
@@ -72,7 +73,7 @@ class EditController extends Controller
*/
public function edit(PiggyBank $piggyBank)
{
- $subTitle = (string) trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
+ $subTitle = (string)trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
$subTitleIcon = 'fa-pencil';
$targetDate = null;
$startDate = null;
@@ -103,11 +104,12 @@ class EditController extends Controller
return prefixView('piggy-banks.edit', compact('subTitle', 'subTitleIcon', 'piggyBank', 'preFilled'));
}
+
/**
* Update a piggy bank.
*
* @param PiggyBankUpdateRequest $request
- * @param PiggyBank $piggyBank
+ * @param PiggyBank $piggyBank
*
* @return RedirectResponse|Redirector
*/
@@ -116,7 +118,7 @@ class EditController extends Controller
$data = $request->getPiggyBankData();
$piggyBank = $this->piggyRepos->update($piggyBank, $data);
- session()->flash('success', (string) trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
+ session()->flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
app('preferences')->mark();
// store new attachment(s):
@@ -126,7 +128,7 @@ class EditController extends Controller
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info', (string) trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -134,7 +136,7 @@ class EditController extends Controller
}
$redirect = redirect($this->getPreviousUri('piggy-banks.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
session()->put('piggy-banks.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.php
index 002995ca56..c14bac0b50 100644
--- a/app/Http/Controllers/PiggyBank/IndexController.php
+++ b/app/Http/Controllers/PiggyBank/IndexController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
@@ -42,6 +43,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
class IndexController extends Controller
{
use OrganisesObjectGroups;
+
private PiggyBankRepositoryInterface $piggyRepos;
/**
@@ -55,7 +57,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
@@ -99,7 +101,7 @@ class IndexController extends Controller
/** @var PiggyBank $piggy */
foreach ($collection as $piggy) {
$array = $transformer->transform($piggy);
- $groupOrder = (int) $array['object_group_order'];
+ $groupOrder = (int)$array['object_group_order'];
// make group array if necessary:
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [
'object_group_id' => $array['object_group_id'] ?? 0,
@@ -108,7 +110,7 @@ class IndexController extends Controller
];
$account = $accountTransformer->transform($piggy->account);
- $accountId = (int) $account['id'];
+ $accountId = (int)$account['id'];
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
if (!isset($accounts[$accountId])) {
// create new:
@@ -163,10 +165,10 @@ class IndexController extends Controller
// current_amount
// left_to_save
// save_per_month
- $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);
- $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);
- $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);
- $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);
+ $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string)$piggy['target_amount']);
+ $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string)$piggy['current_amount']);
+ $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string)$piggy['left_to_save']);
+ $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string)$piggy['save_per_month']);
}
}
foreach ($piggyBanks as $groupOrder => $group) {
@@ -187,8 +189,8 @@ class IndexController extends Controller
*/
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
{
- $objectGroupTitle = (string) $request->get('objectGroupTitle');
- $newOrder = (int) $request->get('order');
+ $objectGroupTitle = (string)$request->get('objectGroupTitle');
+ $newOrder = (int)$request->get('order');
$this->piggyRepos->setOrder($piggyBank, $newOrder);
if ('' !== $objectGroupTitle) {
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
diff --git a/app/Http/Controllers/PiggyBank/ShowController.php b/app/Http/Controllers/PiggyBank/ShowController.php
index 6b508de0b2..cd14e7fdbc 100644
--- a/app/Http/Controllers/PiggyBank/ShowController.php
+++ b/app/Http/Controllers/PiggyBank/ShowController.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
@@ -50,7 +51,7 @@ class ShowController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.piggyBanks'));
+ app('view')->share('title', (string)trans('firefly.piggyBanks'));
app('view')->share('mainTitleIcon', 'fa-bullseye');
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php
index b32a89bd7c..1f19e1bfd7 100644
--- a/app/Http/Controllers/Recurring/CreateController.php
+++ b/app/Http/Controllers/Recurring/CreateController.php
@@ -44,9 +44,9 @@ use Illuminate\View\View;
*/
class CreateController extends Controller
{
+ private AttachmentHelperInterface $attachments;
private BudgetRepositoryInterface $budgetRepos;
private RecurringRepositoryInterface $recurring;
- private AttachmentHelperInterface $attachments;
/**
* CreateController constructor.
@@ -61,8 +61,8 @@ class CreateController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paint-brush');
- app('view')->share('title', (string) trans('firefly.recurrences'));
- app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
+ app('view')->share('title', (string)trans('firefly.recurrences'));
+ app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));
$this->recurring = app(RecurringRepositoryInterface::class);
$this->budgetRepos = app(BudgetRepositoryInterface::class);
@@ -73,6 +73,52 @@ class CreateController extends Controller
);
}
+ /**
+ * Create a new recurring transaction.
+ *
+ * @param Request $request
+ *
+ * @return Factory|View
+ */
+ public function create(Request $request)
+ {
+ $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
+ $defaultCurrency = app('amount')->getDefaultCurrency();
+ $tomorrow = today(config('app.timezone'));
+ $oldRepetitionType = $request->old('repetition_type');
+ $tomorrow->addDay();
+
+ // put previous url in session if not redirect from store (not "create another").
+ if (true !== session('recurring.create.fromStore')) {
+ $this->rememberPreviousUri('recurring.create.uri');
+ }
+ $request->session()->forget('recurring.create.fromStore');
+ $repetitionEnds = [
+ 'forever' => (string)trans('firefly.repeat_forever'),
+ 'until_date' => (string)trans('firefly.repeat_until_date'),
+ 'times' => (string)trans('firefly.repeat_times'),
+ ];
+ $weekendResponses = [
+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
+ ];
+ $hasOldInput = null !== $request->old('_token'); // flash some data
+ $preFilled = [
+ 'first_date' => $tomorrow->format('Y-m-d'),
+ 'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
+ 'active' => $hasOldInput ? (bool)$request->old('active') : true,
+ 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,
+ ];
+ $request->session()->flash('preFilled', $preFilled);
+
+ return prefixView(
+ 'recurring.create',
+ compact('tomorrow', 'oldRepetitionType', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
+ );
+ }
+
/**
* @param Request $request
* @param TransactionJournal $journal
@@ -91,15 +137,15 @@ class CreateController extends Controller
}
$request->session()->forget('recurring.create.fromStore');
$repetitionEnds = [
- 'forever' => (string) trans('firefly.repeat_forever'),
- 'until_date' => (string) trans('firefly.repeat_until_date'),
- 'times' => (string) trans('firefly.repeat_times'),
+ 'forever' => (string)trans('firefly.repeat_forever'),
+ 'until_date' => (string)trans('firefly.repeat_until_date'),
+ 'times' => (string)trans('firefly.repeat_times'),
];
$weekendResponses = [
- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
];
/** @var Transaction $source */
@@ -130,8 +176,8 @@ class CreateController extends Controller
'transaction_type' => $request->old('transaction_type'),
'category' => $request->old('category'),
'budget_id' => $request->old('budget_id'),
- 'active' => (bool) $request->old('active'),
- 'apply_rules' => (bool) $request->old('apply_rules'),
+ 'active' => (bool)$request->old('active'),
+ 'apply_rules' => (bool)$request->old('apply_rules'),
];
}
if (false === $hasOldInput) {
@@ -162,51 +208,6 @@ class CreateController extends Controller
);
}
- /**
- * Create a new recurring transaction.
- *
- * @param Request $request
- *
- * @return Factory|View
- */
- public function create(Request $request)
- {
- $budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
- $defaultCurrency = app('amount')->getDefaultCurrency();
- $tomorrow = today(config('app.timezone'));
- $oldRepetitionType = $request->old('repetition_type');
- $tomorrow->addDay();
-
- // put previous url in session if not redirect from store (not "create another").
- if (true !== session('recurring.create.fromStore')) {
- $this->rememberPreviousUri('recurring.create.uri');
- }
- $request->session()->forget('recurring.create.fromStore');
- $repetitionEnds = [
- 'forever' => (string) trans('firefly.repeat_forever'),
- 'until_date' => (string) trans('firefly.repeat_until_date'),
- 'times' => (string) trans('firefly.repeat_times'),
- ];
- $weekendResponses = [
- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
- ];
- $hasOldInput = null !== $request->old('_token'); // flash some data
- $preFilled = [
- 'first_date' => $tomorrow->format('Y-m-d'),
- 'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
- 'active' => $hasOldInput ? (bool) $request->old('active') : true,
- 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,
- ];
- $request->session()->flash('preFilled', $preFilled);
-
- return prefixView(
- 'recurring.create',
- compact('tomorrow', 'oldRepetitionType', 'weekendResponses', 'preFilled', 'repetitionEnds', 'defaultCurrency', 'budgets')
- );
- }
/**
* Store a recurring transaction.
*
@@ -225,7 +226,7 @@ class CreateController extends Controller
return redirect(route('recurring.create'))->withInput();
}
- $request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
+ $request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
app('preferences')->mark();
// store attachment(s):
@@ -235,7 +236,7 @@ class CreateController extends Controller
$this->attachments->saveAttachmentsForModel($recurrence, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info', (string) trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -243,7 +244,7 @@ class CreateController extends Controller
}
$redirect = redirect($this->getPreviousUri('recurring.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// set value so create routine will not overwrite URL:
$request->session()->put('recurring.create.fromStore', true);
diff --git a/app/Http/Controllers/Recurring/DeleteController.php b/app/Http/Controllers/Recurring/DeleteController.php
index 27677a923f..6b3fb29014 100644
--- a/app/Http/Controllers/Recurring/DeleteController.php
+++ b/app/Http/Controllers/Recurring/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Recurrence;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
@@ -52,7 +53,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paint-brush');
- app('view')->share('title', (string) trans('firefly.recurrences'));
+ app('view')->share('title', (string)trans('firefly.recurrences'));
$this->recurring = app(RecurringRepositoryInterface::class);
@@ -70,7 +71,7 @@ class DeleteController extends Controller
*/
public function delete(Recurrence $recurrence)
{
- $subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]);
+ $subTitle = (string)trans('firefly.delete_recurring', ['title' => $recurrence->title]);
// put previous url in session
$this->rememberPreviousUri('recurrences.delete.uri');
@@ -91,7 +92,7 @@ class DeleteController extends Controller
public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence)
{
$repository->destroy($recurrence);
- $request->session()->flash('success', (string) trans('firefly.' . 'recurrence_deleted', ['title' => $recurrence->title]));
+ $request->session()->flash('success', (string)trans('firefly.' . 'recurrence_deleted', ['title' => $recurrence->title]));
app('preferences')->mark();
return redirect($this->getPreviousUri('recurrences.delete.uri'));
diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php
index 14c5e398d3..7a3326c44a 100644
--- a/app/Http/Controllers/Recurring/EditController.php
+++ b/app/Http/Controllers/Recurring/EditController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring;
+
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
@@ -44,9 +45,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
class EditController extends Controller
{
+ private AttachmentHelperInterface $attachments;
private BudgetRepositoryInterface $budgetRepos;
private RecurringRepositoryInterface $recurring;
- private AttachmentHelperInterface $attachments;
/**
* EditController constructor.
@@ -61,12 +62,13 @@ class EditController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paint-brush');
- app('view')->share('title', (string) trans('firefly.recurrences'));
- app('view')->share('subTitle', (string) trans('firefly.recurrences'));
+ app('view')->share('title', (string)trans('firefly.recurrences'));
+ app('view')->share('subTitle', (string)trans('firefly.recurrences'));
$this->recurring = app(RecurringRepositoryInterface::class);
$this->budgetRepos = app(BudgetRepositoryInterface::class);
$this->attachments = app(AttachmentHelperInterface::class);
+
return $next($request);
}
);
@@ -86,7 +88,7 @@ class EditController extends Controller
{
// TODO should be in repos
$count = $recurrence->recurrenceTransactions()->count();
- if(0 === $count) {
+ if (0 === $count) {
throw new FireflyException('This recurring transaction has no meta-data. You will have to delete it and recreate it. Sorry!');
}
@@ -112,9 +114,9 @@ class EditController extends Controller
$repetitionEnd = 'forever';
$repetitionEnds = [
- 'forever' => (string) trans('firefly.repeat_forever'),
- 'until_date' => (string) trans('firefly.repeat_until_date'),
- 'times' => (string) trans('firefly.repeat_times'),
+ 'forever' => (string)trans('firefly.repeat_forever'),
+ 'until_date' => (string)trans('firefly.repeat_until_date'),
+ 'times' => (string)trans('firefly.repeat_times'),
];
if (null !== $recurrence->repeat_until) {
$repetitionEnd = 'until_date'; // @codeCoverageIgnore
@@ -124,17 +126,17 @@ class EditController extends Controller
}
$weekendResponses = [
- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
];
$hasOldInput = null !== $request->old('_token');
$preFilled = [
'transaction_type' => strtolower($recurrence->transactionType->type),
- 'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
- 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
+ 'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,
+ 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,
'deposit_source_id' => $array['transactions'][0]['source_id'],
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
];
@@ -162,7 +164,7 @@ class EditController extends Controller
$this->recurring->update($recurrence, $data);
- $request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
+ $request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
// store new attachment(s):
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
@@ -170,7 +172,7 @@ class EditController extends Controller
$this->attachments->saveAttachmentsForModel($recurrence, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info', (string) trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
@@ -178,7 +180,7 @@ class EditController extends Controller
}
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('recurrences.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// set value so edit routine will not overwrite URL:
$request->session()->put('recurrences.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php
index 67b9adf289..63a0e49dd2 100644
--- a/app/Http/Controllers/Recurring/IndexController.php
+++ b/app/Http/Controllers/Recurring/IndexController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Recurring;
+
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
@@ -42,6 +43,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
class IndexController extends Controller
{
use GetConfigurationData;
+
private RecurringRepositoryInterface $recurringRepos;
/**
@@ -57,7 +59,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paint-brush');
- app('view')->share('title', (string) trans('firefly.recurrences'));
+ app('view')->share('title', (string)trans('firefly.recurrences'));
$this->recurringRepos = app(RecurringRepositoryInterface::class);
@@ -72,20 +74,20 @@ class IndexController extends Controller
*
* @param Request $request
*
+ * @return Factory|View
* @throws FireflyException
*
- * @return Factory|View
*/
public function index(Request $request)
{
- $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$collection = $this->recurringRepos->get();
$today = today(config('app.timezone'));
$year = today(config('app.timezone'));
// split collection
- $total = $collection->count();
+ $total = $collection->count();
$recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize);
/** @var RecurrenceTransformer $transformer */
diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.php
index 7d3c1d8613..6622b4dc37 100644
--- a/app/Http/Controllers/Recurring/ShowController.php
+++ b/app/Http/Controllers/Recurring/ShowController.php
@@ -41,6 +41,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
class ShowController extends Controller
{
use GetConfigurationData;
+
/** @var RecurringRepositoryInterface Recurring repository */
private $recurring;
@@ -58,7 +59,7 @@ class ShowController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-paint-brush');
- app('view')->share('title', (string) trans('firefly.recurrences'));
+ app('view')->share('title', (string)trans('firefly.recurrences'));
$this->recurring = app(RecurringRepositoryInterface::class);
@@ -66,13 +67,14 @@ class ShowController extends Controller
}
);
}
+
/**
* Show a single recurring transaction.
*
* @param Recurrence $recurrence
*
- * @throws FireflyException
* @return Factory|View
+ * @throws FireflyException
*/
public function show(Recurrence $recurrence)
{
@@ -92,8 +94,8 @@ class ShowController extends Controller
}
}
- $subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
+ $subTitle = (string)trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
- return prefixView('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups','today'));
+ return prefixView('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today'));
}
}
diff --git a/app/Http/Controllers/Report/BalanceController.php b/app/Http/Controllers/Report/BalanceController.php
index 3f4eb79ad9..4613e1c506 100644
--- a/app/Http/Controllers/Report/BalanceController.php
+++ b/app/Http/Controllers/Report/BalanceController.php
@@ -56,6 +56,7 @@ class BalanceController extends Controller
}
);
}
+
/**
* Show overview of budget balances.
*
diff --git a/app/Http/Controllers/Report/BillController.php b/app/Http/Controllers/Report/BillController.php
index 10b62c5c08..4f92954c24 100644
--- a/app/Http/Controllers/Report/BillController.php
+++ b/app/Http/Controllers/Report/BillController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Report;
+
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Http\Controllers\Controller;
diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php
index ebe22808fd..d455ba5e3d 100644
--- a/app/Http/Controllers/Report/BudgetController.php
+++ b/app/Http/Controllers/Report/BudgetController.php
@@ -265,7 +265,7 @@ class BudgetController extends Controller
$total = $sums[$currencyId]['sum'] ?? '0';
$pct = '0';
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
- $pct = round((float) bcmul(bcdiv($sum, $total), '100'));
+ $pct = round((float)bcmul(bcdiv($sum, $total), '100'));
}
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
}
diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php
index db532cf95f..15561046e8 100644
--- a/app/Http/Controllers/Report/CategoryController.php
+++ b/app/Http/Controllers/Report/CategoryController.php
@@ -44,8 +44,8 @@ class CategoryController extends Controller
{
use BasicDataSupport;
- private OperationsRepositoryInterface $opsRepository;
private NoCategoryRepositoryInterface $noCatRepository;
+ private OperationsRepositoryInterface $opsRepository;
/**
* ExpenseReportController constructor.
@@ -131,16 +131,16 @@ class CategoryController extends Controller
/** @var array $category */
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
- $destinationId = $journal['destination_account_id'];
+ $destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId]
- = $report[$destinationId]['currencies'][$currencyId]
- ?? [
- 'currency_id' => $currency['currency_id'],
- 'currency_symbol' => $currency['currency_symbol'],
- 'currency_name' => $currency['currency_name'],
- 'currency_decimal_places' => $currency['currency_decimal_places'],
- 'categories' => [],
- ];
+ = $report[$destinationId]['currencies'][$currencyId]
+ ?? [
+ 'currency_id' => $currency['currency_id'],
+ 'currency_symbol' => $currency['currency_symbol'],
+ 'currency_name' => $currency['currency_name'],
+ 'currency_decimal_places' => $currency['currency_decimal_places'],
+ 'categories' => [],
+ ];
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]
??
diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.php
index 5a4a7de4cd..0cd1bf0bc5 100644
--- a/app/Http/Controllers/Report/DoubleController.php
+++ b/app/Http/Controllers/Report/DoubleController.php
@@ -291,6 +291,31 @@ class DoubleController extends Controller
return prefixView('reports.double.partials.accounts', compact('sums', 'report'));
}
+ /**
+ * TODO this method is double.
+ *
+ * @param Collection $accounts
+ * @param int $id
+ * @param string $name
+ * @param string|null $iban
+ *
+ * @return string
+ */
+ private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
+ {
+ /** @var Account $account */
+ foreach ($accounts as $account) {
+ if ($account->name === $name && $account->id !== $id) {
+ return $account->name;
+ }
+ if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
+ return $account->iban;
+ }
+ }
+
+ return $name;
+ }
+
/**
* @param Collection $accounts
* @param Collection $double
@@ -490,29 +515,4 @@ class DoubleController extends Controller
return $result;
}
-
- /**
- * TODO this method is double.
- *
- * @param Collection $accounts
- * @param int $id
- * @param string $name
- * @param string|null $iban
- *
- * @return string
- */
- private function getCounterpartName(Collection $accounts, int $id, string $name, ?string $iban): string
- {
- /** @var Account $account */
- foreach ($accounts as $account) {
- if ($account->name === $name && $account->id !== $id) {
- return $account->name;
- }
- if (null !== $account->iban && $account->iban === $iban && $account->id !== $id) {
- return $account->iban;
- }
- }
-
- return $name;
- }
}
diff --git a/app/Http/Controllers/Report/OperationsController.php b/app/Http/Controllers/Report/OperationsController.php
index 4c4b4a503d..0dc06329eb 100644
--- a/app/Http/Controllers/Report/OperationsController.php
+++ b/app/Http/Controllers/Report/OperationsController.php
@@ -57,6 +57,7 @@ class OperationsController extends Controller
}
);
}
+
/**
* View of income and expense.
*
diff --git a/app/Http/Controllers/Report/TagController.php b/app/Http/Controllers/Report/TagController.php
index 10a0586aca..48a506d581 100644
--- a/app/Http/Controllers/Report/TagController.php
+++ b/app/Http/Controllers/Report/TagController.php
@@ -125,16 +125,16 @@ class TagController extends Controller
/** @var array $category */
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
- $destinationId = $journal['destination_account_id'];
+ $destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId]
- = $report[$destinationId]['currencies'][$currencyId]
- ?? [
- 'currency_id' => $currency['currency_id'],
- 'currency_symbol' => $currency['currency_symbol'],
- 'currency_name' => $currency['currency_name'],
- 'currency_decimal_places' => $currency['currency_decimal_places'],
- 'tags' => [],
- ];
+ = $report[$destinationId]['currencies'][$currencyId]
+ ?? [
+ 'currency_id' => $currency['currency_id'],
+ 'currency_symbol' => $currency['currency_symbol'],
+ 'currency_name' => $currency['currency_name'],
+ 'currency_decimal_places' => $currency['currency_decimal_places'],
+ 'tags' => [],
+ ];
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]
??
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 9e75606025..d4e5c9f2a7 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -63,7 +63,7 @@ class ReportController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.reports'));
+ app('view')->share('title', (string)trans('firefly.reports'));
app('view')->share('mainTitleIcon', 'fa-bar-chart');
app('view')->share('subTitleIcon', 'fa-calendar');
$this->helper = app(ReportHelperInterface::class);
@@ -81,14 +81,14 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
*
+ * @throws FireflyException
*/
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
$this->repository->cleanupBudgets();
@@ -117,14 +117,14 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
*
+ * @throws FireflyException
*/
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
$this->repository->cleanupBudgets();
@@ -154,14 +154,14 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
*
+ * @throws FireflyException
*/
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
$this->repository->cleanupBudgets();
@@ -190,14 +190,14 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
*
+ * @throws FireflyException
*/
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date'));
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
$this->repository->cleanupBudgets();
@@ -227,8 +227,8 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
+ * @throws FireflyException
*/
public function doubleReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
{
@@ -330,10 +330,10 @@ class ReportController extends Controller
*
* @param ReportFormRequest $request
*
- * @throws FireflyException
- *
* @return RedirectResponse|Redirector
*
+ * @throws FireflyException
+ *
*/
public function postIndex(ReportFormRequest $request)
{
@@ -349,37 +349,37 @@ class ReportController extends Controller
if (0 === $request->getAccountList()->count()) {
Log::debug('Account count is zero');
- session()->flash('error', (string) trans('firefly.select_at_least_one_account'));
+ session()->flash('error', (string)trans('firefly.select_at_least_one_account'));
return redirect(route('reports.index'));
}
if ('category' === $reportType && 0 === $request->getCategoryList()->count()) {
- session()->flash('error', (string) trans('firefly.select_at_least_one_category'));
+ session()->flash('error', (string)trans('firefly.select_at_least_one_category'));
return redirect(route('reports.index'));
}
if ('budget' === $reportType && 0 === $request->getBudgetList()->count()) {
- session()->flash('error', (string) trans('firefly.select_at_least_one_budget'));
+ session()->flash('error', (string)trans('firefly.select_at_least_one_budget'));
return redirect(route('reports.index'));
}
if ('tag' === $reportType && 0 === $request->getTagList()->count()) {
- session()->flash('error', (string) trans('firefly.select_at_least_one_tag'));
+ session()->flash('error', (string)trans('firefly.select_at_least_one_tag'));
return redirect(route('reports.index'));
}
if ('double' === $reportType && 0 === $request->getDoubleList()->count()) {
- session()->flash('error', (string) trans('firefly.select_at_least_one_expense'));
+ session()->flash('error', (string)trans('firefly.select_at_least_one_expense'));
return redirect(route('reports.index'));
}
if ($request->getEndDate() < $request->getStartDate()) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date'));
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date'));
}
switch ($reportType) {
@@ -406,6 +406,7 @@ class ReportController extends Controller
return redirect($uri);
}
+
/**
* Get a tag report.
*
@@ -414,13 +415,13 @@ class ReportController extends Controller
* @param Carbon $start
* @param Carbon $end
*
- * @throws FireflyException
* @return Factory|View|string
+ * @throws FireflyException
*/
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
{
if ($end < $start) {
- return prefixView('error')->with('message', (string) trans('firefly.end_after_start_date')); // @codeCoverageIgnore
+ return prefixView('error')->with('message', (string)trans('firefly.end_after_start_date')); // @codeCoverageIgnore
}
$this->repository->cleanupBudgets();
diff --git a/app/Http/Controllers/Rule/DeleteController.php b/app/Http/Controllers/Rule/DeleteController.php
index f19d1f37a4..aba1d789a3 100644
--- a/app/Http/Controllers/Rule/DeleteController.php
+++ b/app/Http/Controllers/Rule/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Rule;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Rule;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php
index 34b8ede876..8dcec9c785 100644
--- a/app/Http/Controllers/Rule/EditController.php
+++ b/app/Http/Controllers/Rule/EditController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Rule;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Models\Rule;
diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php
index db6877c3b0..4299fce5e3 100644
--- a/app/Http/Controllers/Rule/SelectController.php
+++ b/app/Http/Controllers/Rule/SelectController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Rule;
+
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\SelectTransactionsRequest;
@@ -101,6 +102,7 @@ class SelectController extends Controller
return redirect()->route('rules.index');
}
+
/**
* View to select transactions by a rule.
*
diff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.php
index 5f5debef6a..9c4456544e 100644
--- a/app/Http/Controllers/RuleGroup/CreateController.php
+++ b/app/Http/Controllers/RuleGroup/CreateController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\RuleGroup;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleGroupFormRequest;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
@@ -49,7 +50,7 @@ class CreateController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.rules'));
+ app('view')->share('title', (string)trans('firefly.rules'));
app('view')->share('mainTitleIcon', 'fa-random');
$this->repository = app(RuleGroupRepositoryInterface::class);
@@ -67,7 +68,7 @@ class CreateController extends Controller
public function create()
{
$subTitleIcon = 'fa-clone';
- $subTitle = (string) trans('firefly.make_new_rule_group');
+ $subTitle = (string)trans('firefly.make_new_rule_group');
// put previous url in session if not redirect from store (not "create another").
if (true !== session('rule-groups.create.fromStore')) {
@@ -90,11 +91,11 @@ class CreateController extends Controller
$data = $request->getRuleGroupData();
$ruleGroup = $this->repository->store($data);
- session()->flash('success', (string) trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
+ session()->flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUri('rule-groups.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
session()->put('rule-groups.create.fromStore', true);
diff --git a/app/Http/Controllers/RuleGroup/DeleteController.php b/app/Http/Controllers/RuleGroup/DeleteController.php
index f65deeb4f2..d499868af9 100644
--- a/app/Http/Controllers/RuleGroup/DeleteController.php
+++ b/app/Http/Controllers/RuleGroup/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\RuleGroup;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
@@ -50,7 +51,7 @@ class DeleteController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.rules'));
+ app('view')->share('title', (string)trans('firefly.rules'));
app('view')->share('mainTitleIcon', 'fa-random');
$this->repository = app(RuleGroupRepositoryInterface::class);
@@ -59,6 +60,7 @@ class DeleteController extends Controller
}
);
}
+
/**
* Delete a rule group.
*
@@ -68,7 +70,7 @@ class DeleteController extends Controller
*/
public function delete(RuleGroup $ruleGroup)
{
- $subTitle = (string) trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
+ $subTitle = (string)trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
// put previous url in session
$this->rememberPreviousUri('rule-groups.delete.uri');
@@ -89,10 +91,10 @@ class DeleteController extends Controller
$title = $ruleGroup->title;
/** @var RuleGroup $moveTo */
- $moveTo = $this->repository->find((int) $request->get('move_rules_before_delete'));
+ $moveTo = $this->repository->find((int)$request->get('move_rules_before_delete'));
$this->repository->destroy($ruleGroup, $moveTo);
- session()->flash('success', (string) trans('firefly.deleted_rule_group', ['title' => $title]));
+ session()->flash('success', (string)trans('firefly.deleted_rule_group', ['title' => $title]));
app('preferences')->mark();
return redirect($this->getPreviousUri('rule-groups.delete.uri'));
diff --git a/app/Http/Controllers/RuleGroup/EditController.php b/app/Http/Controllers/RuleGroup/EditController.php
index 2b349cbfca..f7ff347786 100644
--- a/app/Http/Controllers/RuleGroup/EditController.php
+++ b/app/Http/Controllers/RuleGroup/EditController.php
@@ -70,8 +70,8 @@ class EditController extends Controller
*/
public function down(RuleGroup $ruleGroup)
{
- $maxOrder =$this->repository->maxOrder();
- $order = (int)$ruleGroup->order;
+ $maxOrder = $this->repository->maxOrder();
+ $order = (int)$ruleGroup->order;
if ($order < $maxOrder) {
$newOrder = $order + 1;
$this->repository->setOrder($ruleGroup, $newOrder);
@@ -79,6 +79,7 @@ class EditController extends Controller
return redirect(route('rules.index'));
}
+
/**
* Edit a rule group.
*
diff --git a/app/Http/Controllers/RuleGroup/ExecutionController.php b/app/Http/Controllers/RuleGroup/ExecutionController.php
index cd17264bfe..8df7f6f719 100644
--- a/app/Http/Controllers/RuleGroup/ExecutionController.php
+++ b/app/Http/Controllers/RuleGroup/ExecutionController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\RuleGroup;
+
use Carbon\Carbon;
use Exception;
use FireflyIII\Http\Controllers\Controller;
@@ -52,7 +53,7 @@ class ExecutionController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.rules'));
+ app('view')->share('title', (string)trans('firefly.rules'));
app('view')->share('mainTitleIcon', 'fa-random');
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
@@ -61,6 +62,7 @@ class ExecutionController extends Controller
}
);
}
+
/**
* Execute the given rulegroup on a set of existing transactions.
*
@@ -93,7 +95,7 @@ class ExecutionController extends Controller
$newRuleEngine->fire();
// Tell the user that the job is queued
- session()->flash('success', (string) trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));
+ session()->flash('success', (string)trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));
return redirect()->route('rules.index');
}
@@ -109,7 +111,7 @@ class ExecutionController extends Controller
{
$first = session('first')->format('Y-m-d');
$today = Carbon::now()->format('Y-m-d');
- $subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
+ $subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
return prefixView('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
}
diff --git a/app/Http/Controllers/System/CronController.php b/app/Http/Controllers/System/CronController.php
index 38ee1b2be0..442954d010 100644
--- a/app/Http/Controllers/System/CronController.php
+++ b/app/Http/Controllers/System/CronController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\System;
+
use Log;
/**
@@ -35,6 +36,7 @@ class CronController
public function cron()
{
Log::error('The cron endpoint has moved to GET /api/v1/cron/[token]');
+
return response('The cron endpoint has moved to GET /api/v1/cron/[token]', 500);
}
}
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index a5e0742b92..5460890474 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -22,17 +22,22 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\System;
+
use Artisan;
use Cache;
use Exception;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
+use Illuminate\View\View;
use Laravel\Passport\Passport;
use Log;
+use phpseclib3\Crypt\RSA;
+
/**
* Class InstallController
*
@@ -45,10 +50,11 @@ class InstallController extends Controller
public const FORBIDDEN_ERROR = 'Internal PHP function "proc_close" is disabled for your installation. Auto-migration is not possible.';
public const BASEDIR_ERROR = 'Firefly III cannot execute the upgrade commands. It is not allowed to because of an open_basedir restriction.';
public const OTHER_ERROR = 'An unknown error prevented Firefly III from executing the upgrade commands. Sorry.';
- private array $upgradeCommands;
private string $lastError;
+ private array $upgradeCommands;
/** @noinspection MagicMethodsValidityInspection */
/** @noinspection PhpMissingParentConstructorInspection */
+
/**
* InstallController constructor.
*/
@@ -110,7 +116,7 @@ class InstallController extends Controller
/**
* Show index.
*
- * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return Factory|View
*/
public function index()
{
@@ -123,40 +129,6 @@ class InstallController extends Controller
return prefixView('install.index');
}
- /**
- * Create specific RSA keys.
- */
- public function keys(): void
- {
- // switch on PHP version.
- $result = version_compare(phpversion(), '8.0');
- Log::info(sprintf('PHP version is %s', $result));
- if (-1 === $result) {
- Log::info('Will run PHP7 code.');
- // PHP 7
- $rsa = new \phpseclib\Crypt\RSA;
- $keys = $rsa->createKey(4096);
- }
-
- if ($result >= 0) {
- Log::info('Will run PHP8 code.');
- // PHP 8
- $keys = \phpseclib3\Crypt\RSA::createKey(4096);
- }
-
- [$publicKey, $privateKey] = [
- Passport::keyPath('oauth-public.key'),
- Passport::keyPath('oauth-private.key'),
- ];
-
- if (file_exists($publicKey) || file_exists($privateKey)) {
- return;
- }
-
- file_put_contents($publicKey, Arr::get($keys, 'publickey'));
- file_put_contents($privateKey, Arr::get($keys, 'privatekey'));
- }
-
/**
* @param Request $request
*
@@ -238,4 +210,38 @@ class InstallController extends Controller
return true;
}
+
+ /**
+ * Create specific RSA keys.
+ */
+ public function keys(): void
+ {
+ // switch on PHP version.
+ $result = version_compare(phpversion(), '8.0');
+ Log::info(sprintf('PHP version is %s', $result));
+ if (-1 === $result) {
+ Log::info('Will run PHP7 code.');
+ // PHP 7
+ $rsa = new \phpseclib\Crypt\RSA;
+ $keys = $rsa->createKey(4096);
+ }
+
+ if ($result >= 0) {
+ Log::info('Will run PHP8 code.');
+ // PHP 8
+ $keys = RSA::createKey(4096);
+ }
+
+ [$publicKey, $privateKey] = [
+ Passport::keyPath('oauth-public.key'),
+ Passport::keyPath('oauth-private.key'),
+ ];
+
+ if (file_exists($publicKey) || file_exists($privateKey)) {
+ return;
+ }
+
+ file_put_contents($publicKey, Arr::get($keys, 'publickey'));
+ file_put_contents($privateKey, Arr::get($keys, 'privatekey'));
+ }
}
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index ea3656db00..5f32e14a81 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -43,7 +43,7 @@ class TagController extends Controller
{
use PeriodOverview;
- protected TagRepositoryInterface $repository;
+ protected TagRepositoryInterface $repository;
private AttachmentHelperInterface $attachmentsHelper;
/**
@@ -56,11 +56,11 @@ class TagController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.tags'));
+ app('view')->share('title', (string)trans('firefly.tags'));
app('view')->share('mainTitleIcon', 'fa-tag');
$this->attachmentsHelper = app(AttachmentHelperInterface::class);
- $this->repository = app(TagRepositoryInterface::class);
+ $this->repository = app(TagRepositoryInterface::class);
return $next($request);
}
@@ -74,7 +74,7 @@ class TagController extends Controller
*/
public function create(Request $request)
{
- $subTitle = (string) trans('firefly.new_tag');
+ $subTitle = (string)trans('firefly.new_tag');
$subTitleIcon = 'fa-tag';
// location info:
@@ -106,7 +106,7 @@ class TagController extends Controller
*/
public function delete(Tag $tag)
{
- $subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
+ $subTitle = (string)trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
// put previous url in session
$this->rememberPreviousUri('tags.delete.uri');
@@ -126,7 +126,7 @@ class TagController extends Controller
$tagName = $tag->tag;
$this->repository->destroy($tag);
- session()->flash('success', (string) trans('firefly.deleted_tag', ['tag' => $tagName]));
+ session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));
app('preferences')->mark();
return redirect($this->getPreviousUri('tags.delete.uri'));
@@ -141,7 +141,7 @@ class TagController extends Controller
*/
public function edit(Tag $tag)
{
- $subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]);
+ $subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]);
$subTitleIcon = 'fa-tag';
$location = $this->repository->getLocation($tag);
@@ -177,7 +177,7 @@ class TagController extends Controller
public function index(TagRepositoryInterface $repository)
{
// start with oldest tag
- $first = session('first', today()) ?? today();
+ $first = session('first', today()) ?? today();
$oldestTagDate = null === $repository->oldestTag() ? clone $first : $repository->oldestTag()->date;
$newestTagDate = null === $repository->newestTag() ? today() : $repository->newestTag()->date;
$oldestTagDate->startOfYear();
@@ -202,20 +202,20 @@ class TagController extends Controller
{
$tags = $request->get('tags');
if (null === $tags || !is_array($tags)) {
- session()->flash('info', (string) trans('firefly.select_tags_to_delete'));
+ session()->flash('info', (string)trans('firefly.select_tags_to_delete'));
return redirect(route('tags.index'));
}
$count = 0;
foreach ($tags as $tagId) {
- $tagId = (int) $tagId;
+ $tagId = (int)$tagId;
$tag = $this->repository->findNull($tagId);
if (null !== $tag) {
$this->repository->destroy($tag);
$count++;
}
}
- session()->flash('success', (string) trans_choice('firefly.deleted_x_tags', $count));
+ session()->flash('success', (string)trans_choice('firefly.deleted_x_tags', $count));
return redirect(route('tags.index'));
}
@@ -235,8 +235,8 @@ class TagController extends Controller
{
// default values:
$subTitleIcon = 'fa-tag';
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$start = $start ?? session('start');
$end = $end ?? session('end');
$location = $this->repository->getLocation($tag);
@@ -278,10 +278,10 @@ class TagController extends Controller
{
// default values:
$subTitleIcon = 'fa-tag';
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$periods = [];
- $subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
+ $subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
$start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone'));
$end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone'));
$attachments = $this->repository->getAttachments($tag);
@@ -313,7 +313,7 @@ class TagController extends Controller
$result = $this->repository->store($data);
Log::debug('Data after storage', $result->toArray());
- session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']]));
+ session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));
app('preferences')->mark();
// store attachment(s):
@@ -323,14 +323,14 @@ class TagController extends Controller
$this->attachmentsHelper->saveAttachmentsForModel($result, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
}
$redirect = redirect($this->getPreviousUri('tags.create.uri'));
- if (1 === (int) $request->get('create_another')) {
+ if (1 === (int)$request->get('create_another')) {
// @codeCoverageIgnoreStart
session()->put('tags.create.fromStore', true);
@@ -354,7 +354,7 @@ class TagController extends Controller
$data = $request->collectTagData();
$tag = $this->repository->update($tag, $data);
- session()->flash('success', (string) trans('firefly.updated_tag', ['tag' => $data['tag']]));
+ session()->flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']]));
app('preferences')->mark();
// store new attachment(s):
@@ -364,14 +364,14 @@ class TagController extends Controller
$this->attachmentsHelper->saveAttachmentsForModel($tag, $files);
}
if (null !== $files && auth()->user()->hasRole('demo')) {
- session()->flash('info',(string)trans('firefly.no_att_demo_user'));
+ session()->flash('info', (string)trans('firefly.no_att_demo_user'));
}
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments')); // @codeCoverageIgnore
}
$redirect = redirect($this->getPreviousUri('tags.edit.uri'));
- if (1 === (int) $request->get('return_to_edit')) {
+ if (1 === (int)$request->get('return_to_edit')) {
// @codeCoverageIgnoreStart
session()->put('tags.edit.fromUpdate', true);
diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php
index 70e4c86231..18a6ec6e75 100644
--- a/app/Http/Controllers/Transaction/BulkController.php
+++ b/app/Http/Controllers/Transaction/BulkController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\BulkEditJournalRequest;
use FireflyIII\Models\TransactionJournal;
@@ -38,6 +39,7 @@ class BulkController extends Controller
{
/** @var JournalRepositoryInterface Journals and transactions overview */
private $repository;
+
/**
* BulkController constructor.
*
@@ -78,10 +80,11 @@ class BulkController extends Controller
// get list of budgets:
/** @var BudgetRepositoryInterface $budgetRepos */
$budgetRepos = app(BudgetRepositoryInterface::class);
- $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets());
+ $budgetList = app('expandedform')->makeSelectListWithEmpty($budgetRepos->getActiveBudgets());
return prefixView('transactions.bulk.edit', compact('journals', 'subTitle', 'budgetList'));
}
+
/**
* Update all journals.
*
@@ -136,24 +139,6 @@ class BulkController extends Controller
return true;
}
- /**
- * @param TransactionJournal $journal
- * @param bool $ignoreUpdate
- * @param string $category
- *
- * @return bool
- */
- private function updateJournalCategory(TransactionJournal $journal, bool $ignoreUpdate, string $category): bool
- {
- if (true === $ignoreUpdate) {
- return false;
- }
- Log::debug(sprintf('Set budget to %s', $category));
- $this->repository->updateCategory($journal, $category);
-
- return true;
- }
-
/**
* @param TransactionJournal $journal
* @param string $action
@@ -172,6 +157,25 @@ class BulkController extends Controller
$new = array_unique(array_merge($tags, $existing));
$this->repository->updateTags($journal, $new);
}
+
+ return true;
+ }
+
+ /**
+ * @param TransactionJournal $journal
+ * @param bool $ignoreUpdate
+ * @param string $category
+ *
+ * @return bool
+ */
+ private function updateJournalCategory(TransactionJournal $journal, bool $ignoreUpdate, string $category): bool
+ {
+ if (true === $ignoreUpdate) {
+ return false;
+ }
+ Log::debug(sprintf('Set budget to %s', $category));
+ $this->repository->updateCategory($journal, $category);
+
return true;
}
}
diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php
index 58eb195abb..d7ddfbd8f6 100644
--- a/app/Http/Controllers/Transaction/ConvertController.php
+++ b/app/Http/Controllers/Transaction/ConvertController.php
@@ -38,9 +38,11 @@ use FireflyIII\Support\Http\Controllers\ModelInformation;
use FireflyIII\Support\Http\Controllers\UserNavigation;
use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\Validation\AccountValidator;
+use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
+use Illuminate\View\View;
use Log;
/**
@@ -52,8 +54,8 @@ class ConvertController extends Controller
{
use ModelInformation, UserNavigation;
- private JournalRepositoryInterface $repository;
private AccountRepositoryInterface $accountRepository;
+ private JournalRepositoryInterface $repository;
/**
* ConvertController constructor.
@@ -76,13 +78,14 @@ class ConvertController extends Controller
}
);
}
+
/**
* Show overview of a to be converted transaction.
*
* @param TransactionType $destinationType
* @param TransactionGroup $group
*
- * @return RedirectResponse|Redirector|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @return RedirectResponse|Redirector|Factory|View
* @throws Exception
*
*/
@@ -141,6 +144,137 @@ class ConvertController extends Controller
);
}
+ /**
+ * @return array
+ */
+ private function getValidDepositSources(): array
+ {
+ // make repositories
+ $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
+ $accountList = $this->accountRepository
+ ->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
+ $grouped = [];
+ // group accounts:
+ /** @var Account $account */
+ foreach ($accountList as $account) {
+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
+ $name = $account->name;
+ if ('' === $role) {
+ $role = 'no_account_type'; // @codeCoverageIgnore
+ }
+
+ // maybe it's a liability thing:
+ if (in_array($account->accountType->type, $liabilityTypes, true)) {
+ $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
+ }
+ if (AccountType::CASH === $account->accountType->type) {
+ // @codeCoverageIgnoreStart
+ $role = 'cash_account';
+ $name = sprintf('(%s)', trans('firefly.cash'));
+ // @codeCoverageIgnoreEnd
+ }
+ if (AccountType::REVENUE === $account->accountType->type) {
+ $role = 'revenue_account'; // @codeCoverageIgnore
+ }
+
+ $key = (string)trans('firefly.opt_group_' . $role);
+ $grouped[$key][$account->id] = $name;
+ }
+
+ return $grouped;
+ }
+
+ /**
+ * @return array
+ */
+ private function getValidWithdrawalDests(): array
+ {
+ // make repositories
+ $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
+ $accountList = $this->accountRepository->getActiveAccountsByType(
+ [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]
+ );
+ $grouped = [];
+ // group accounts:
+ /** @var Account $account */
+ foreach ($accountList as $account) {
+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
+ $name = $account->name;
+ if ('' === $role) {
+ $role = 'no_account_type'; // @codeCoverageIgnore
+ }
+
+ // maybe it's a liability thing:
+ if (in_array($account->accountType->type, $liabilityTypes, true)) {
+ $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
+ }
+ if (AccountType::CASH === $account->accountType->type) {
+ // @codeCoverageIgnoreStart
+ $role = 'cash_account';
+ $name = sprintf('(%s)', trans('firefly.cash'));
+ // @codeCoverageIgnoreEnd
+ }
+ if (AccountType::EXPENSE === $account->accountType->type) {
+ $role = 'expense_account'; // @codeCoverageIgnore
+ }
+
+ $key = (string)trans('firefly.opt_group_' . $role);
+ $grouped[$key][$account->id] = $name;
+ }
+
+ return $grouped;
+ }
+
+ /**
+ * @return array
+ * @throws Exception
+ */
+ private function getLiabilities(): array
+ {
+ // make repositories
+ $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
+ $defaultCurrency = app('amount')->getDefaultCurrency();
+ $grouped = [];
+ // group accounts:
+ /** @var Account $account */
+ foreach ($accountList as $account) {
+ $balance = app('steam')->balance($account, today());
+ $currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
+ $role = 'l_' . $account->accountType->type;
+ $key = (string)trans('firefly.opt_group_' . $role);
+ $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
+ }
+
+ return $grouped;
+ }
+
+ /**
+ * @return array
+ * @throws Exception
+ */
+ private function getAssetAccounts(): array
+ {
+ // make repositories
+ $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);
+ $defaultCurrency = app('amount')->getDefaultCurrency();
+ $grouped = [];
+ // group accounts:
+ /** @var Account $account */
+ foreach ($accountList as $account) {
+ $balance = app('steam')->balance($account, today());
+ $currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
+ $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
+ if ('' === $role) {
+ $role = 'no_account_type'; // @codeCoverageIgnore
+ }
+
+ $key = (string)trans('firefly.opt_group_' . $role);
+ $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
+ }
+
+ return $grouped;
+ }
+
/**
* Do the conversion.
*
@@ -232,135 +366,4 @@ class ConvertController extends Controller
return $journal;
}
-
- /**
- * @return array
- * @throws Exception
- */
- private function getAssetAccounts(): array
- {
- // make repositories
- $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);
- $defaultCurrency = app('amount')->getDefaultCurrency();
- $grouped = [];
- // group accounts:
- /** @var Account $account */
- foreach ($accountList as $account) {
- $balance = app('steam')->balance($account, today());
- $currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
- $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
- if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
- }
-
- $key = (string)trans('firefly.opt_group_' . $role);
- $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
- }
-
- return $grouped;
- }
-
- /**
- * @return array
- * @throws Exception
- */
- private function getLiabilities(): array
- {
- // make repositories
- $accountList = $this->accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
- $defaultCurrency = app('amount')->getDefaultCurrency();
- $grouped = [];
- // group accounts:
- /** @var Account $account */
- foreach ($accountList as $account) {
- $balance = app('steam')->balance($account, today());
- $currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
- $role = 'l_' . $account->accountType->type;
- $key = (string)trans('firefly.opt_group_' . $role);
- $grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
- }
-
- return $grouped;
- }
-
- /**
- * @return array
- */
- private function getValidDepositSources(): array
- {
- // make repositories
- $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
- $accountList = $this->accountRepository
- ->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
- $grouped = [];
- // group accounts:
- /** @var Account $account */
- foreach ($accountList as $account) {
- $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
- $name = $account->name;
- if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
- }
-
- // maybe it's a liability thing:
- if (in_array($account->accountType->type, $liabilityTypes, true)) {
- $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
- }
- if (AccountType::CASH === $account->accountType->type) {
- // @codeCoverageIgnoreStart
- $role = 'cash_account';
- $name = sprintf('(%s)', trans('firefly.cash'));
- // @codeCoverageIgnoreEnd
- }
- if (AccountType::REVENUE === $account->accountType->type) {
- $role = 'revenue_account'; // @codeCoverageIgnore
- }
-
- $key = (string)trans('firefly.opt_group_' . $role);
- $grouped[$key][$account->id] = $name;
- }
-
- return $grouped;
- }
-
- /**
- * @return array
- */
- private function getValidWithdrawalDests(): array
- {
- // make repositories
- $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
- $accountList = $this->accountRepository->getActiveAccountsByType(
- [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]
- );
- $grouped = [];
- // group accounts:
- /** @var Account $account */
- foreach ($accountList as $account) {
- $role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
- $name = $account->name;
- if ('' === $role) {
- $role = 'no_account_type'; // @codeCoverageIgnore
- }
-
- // maybe it's a liability thing:
- if (in_array($account->accountType->type, $liabilityTypes, true)) {
- $role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
- }
- if (AccountType::CASH === $account->accountType->type) {
- // @codeCoverageIgnoreStart
- $role = 'cash_account';
- $name = sprintf('(%s)', trans('firefly.cash'));
- // @codeCoverageIgnoreEnd
- }
- if (AccountType::EXPENSE === $account->accountType->type) {
- $role = 'expense_account'; // @codeCoverageIgnore
- }
-
- $key = (string)trans('firefly.opt_group_' . $role);
- $grouped[$key][$account->id] = $name;
- }
-
- return $grouped;
- }
}
diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php
index 9ef84adbef..4858a8f454 100644
--- a/app/Http/Controllers/Transaction/CreateController.php
+++ b/app/Http/Controllers/Transaction/CreateController.php
@@ -49,7 +49,7 @@ class CreateController extends Controller
$this->middleware(
static function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
return $next($request);
@@ -75,7 +75,7 @@ class CreateController extends Controller
app('preferences')->mark();
$title = $newGroup->title ?? $newGroup->transactionJournals->first()->description;
- $link = route('transactions.show', [$newGroup->id]);
+ $link = route('transactions.show', [$newGroup->id]);
session()->flash('success', trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success_uri', $link);
@@ -93,14 +93,14 @@ class CreateController extends Controller
{
app('preferences')->mark();
- $sourceId = (int) request()->get('source');
- $destinationId = (int) request()->get('destination');
+ $sourceId = (int)request()->get('source');
+ $destinationId = (int)request()->get('destination');
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$cash = $repository->getCashAccount();
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
- $subTitle = (string) trans('breadcrumbs.create_new_transaction');
+ $subTitle = (string)trans('breadcrumbs.create_new_transaction');
$subTitleIcon = 'fa-plus';
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
@@ -112,6 +112,7 @@ class CreateController extends Controller
$previousUri = str_replace($search, '', $previousUri);
session()->put('preFilled', $preFilled);
+
return prefixView(
'transactions.create',
compact(
diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.php
index e82fe335b4..0c8ca3785a 100644
--- a/app/Http/Controllers/Transaction/DeleteController.php
+++ b/app/Http/Controllers/Transaction/DeleteController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
@@ -38,6 +39,7 @@ use URL;
class DeleteController extends Controller
{
use UserNavigation;
+
/** @var TransactionGroupRepositoryInterface */
private $repository;
@@ -53,7 +55,7 @@ class DeleteController extends Controller
// translations:
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
$this->repository = app(TransactionGroupRepositoryInterface::class);
@@ -83,7 +85,7 @@ class DeleteController extends Controller
throw new NotFoundHttpException;
}
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
- $subTitle = (string) trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
+ $subTitle = (string)trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
$previous = URL::previous(route('index'));
// put previous url in session
Log::debug('Will try to remember previous URI');
@@ -110,7 +112,7 @@ class DeleteController extends Controller
throw new NotFoundHttpException;
}
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
- session()->flash('success', (string) trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));
+ session()->flash('success', (string)trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));
$this->repository->destroy($group);
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.php
index 4c08faa222..4c5657ed80 100644
--- a/app/Http/Controllers/Transaction/EditController.php
+++ b/app/Http/Controllers/Transaction/EditController.php
@@ -22,11 +22,14 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
+
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Controllers\UserNavigation;
use Illuminate\Contracts\View\Factory;
+use Illuminate\Http\RedirectResponse;
+use Illuminate\Routing\Redirector;
use Illuminate\View\View;
/**
@@ -49,17 +52,18 @@ class EditController extends Controller
$this->middleware(
static function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
return $next($request);
}
);
}
+
/**
* @param TransactionGroup $transactionGroup
*
- * @return Factory|View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ * @return Factory|View|RedirectResponse|Redirector
*/
public function edit(TransactionGroup $transactionGroup)
{
@@ -83,6 +87,7 @@ class EditController extends Controller
$parts = parse_url($previousUri);
$search = sprintf('?%s', $parts['query'] ?? '');
$previousUri = str_replace($search, '', $previousUri);
+
return prefixView(
'transactions.edit',
compact(
diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php
index bde64ee96e..fcec1abf82 100644
--- a/app/Http/Controllers/Transaction/IndexController.php
+++ b/app/Http/Controllers/Transaction/IndexController.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
+
use Carbon\Carbon;
use Exception;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -54,7 +55,7 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-exchange');
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
$this->repository = app(JournalRepositoryInterface::class);
@@ -71,15 +72,15 @@ class IndexController extends Controller
* @param Carbon|null $start
* @param Carbon|null $end
*
- * @throws Exception
* @return Factory|View
+ * @throws Exception
*/
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
{
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
$types = config('firefly.transactionTypesByType.' . $objectType);
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
if (null === $start) {
$start = session('start');
$end = session('end');
@@ -94,7 +95,7 @@ class IndexController extends Controller
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$startStr = $start->formatLocalized($this->monthAndDayFormat);
$endStr = $end->formatLocalized($this->monthAndDayFormat);
- $subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
+ $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
$firstJournal = $this->repository->firstNull();
$startPeriod = null === $firstJournal ? new Carbon : $firstJournal->date;
@@ -124,21 +125,21 @@ class IndexController extends Controller
* @param Request $request
* @param string $objectType
*
- * @throws Exception
* @return Factory|View
+ * @throws Exception
*/
public function indexAll(Request $request, string $objectType)
{
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
$types = config('firefly.transactionTypesByType.' . $objectType);
- $page = (int) $request->get('page');
- $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
+ $page = (int)$request->get('page');
+ $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$path = route('transactions.index.all', [$objectType]);
$first = $this->repository->firstNull();
$start = null === $first ? new Carbon : $first->date;
$last = $this->repository->getLast();
$end = $last ? $last->date : today(config('app.timezone'));
- $subTitle = (string) trans('firefly.all_' . $objectType);
+ $subTitle = (string)trans('firefly.all_' . $objectType);
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php
index ee6063405d..b174811293 100644
--- a/app/Http/Controllers/Transaction/LinkController.php
+++ b/app/Http/Controllers/Transaction/LinkController.php
@@ -40,7 +40,7 @@ use URL;
*/
class LinkController extends Controller
{
- private JournalRepositoryInterface $journalRepository;
+ private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -54,7 +54,7 @@ class LinkController extends Controller
// some useful repositories:
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
$this->journalRepository = app(JournalRepositoryInterface::class);
@@ -75,7 +75,7 @@ class LinkController extends Controller
public function delete(TransactionJournalLink $link)
{
$subTitleIcon = 'fa-link';
- $subTitle = (string) trans('breadcrumbs.delete_journal_link');
+ $subTitle = (string)trans('breadcrumbs.delete_journal_link');
$this->rememberPreviousUri('journal_links.delete.uri');
return prefixView('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
@@ -92,10 +92,10 @@ class LinkController extends Controller
{
$this->repository->destroyLink($link);
- session()->flash('success', (string) trans('firefly.deleted_link'));
+ session()->flash('success', (string)trans('firefly.deleted_link'));
app('preferences')->mark();
- return redirect((string) session('journal_links.delete.uri'));
+ return redirect((string)session('journal_links.delete.uri'));
}
/**
@@ -125,7 +125,7 @@ class LinkController extends Controller
Log::debug('We are here (store)');
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
if (null === $other) {
- session()->flash('error', (string) trans('firefly.invalid_link_selection'));
+ session()->flash('error', (string)trans('firefly.invalid_link_selection'));
return redirect(route('transactions.show', [$journal->transaction_group_id]));
}
@@ -133,19 +133,19 @@ class LinkController extends Controller
$alreadyLinked = $this->repository->findLink($journal, $other);
if ($other->id === $journal->id) {
- session()->flash('error', (string) trans('firefly.journals_link_to_self'));
+ session()->flash('error', (string)trans('firefly.journals_link_to_self'));
return redirect(route('transactions.show', [$journal->transaction_group_id]));
}
if ($alreadyLinked) {
- session()->flash('error', (string) trans('firefly.journals_error_linked'));
+ session()->flash('error', (string)trans('firefly.journals_error_linked'));
return redirect(route('transactions.show', [$journal->transaction_group_id]));
}
Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
$this->repository->storeLink($linkInfo, $other, $journal);
- session()->flash('success', (string) trans('firefly.journals_linked'));
+ session()->flash('success', (string)trans('firefly.journals_linked'));
return redirect(route('transactions.show', [$journal->transaction_group_id]));
}
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index d8a5d3d2f0..b3a3bb7c28 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -60,7 +60,7 @@ class MassController extends Controller
$this->middleware(
function ($request, $next) {
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
$this->repository = app(JournalRepositoryInterface::class);
@@ -78,7 +78,7 @@ class MassController extends Controller
*/
public function delete(array $journals): IlluminateView
{
- $subTitle = (string) trans('firefly.mass_delete_journals');
+ $subTitle = (string)trans('firefly.mass_delete_journals');
// put previous url in session
$this->rememberPreviousUri('transactions.mass-delete.uri');
@@ -103,15 +103,15 @@ class MassController extends Controller
foreach ($ids as $journalId) {
/** @var TransactionJournal $journal */
- $journal = $this->repository->findNull((int) $journalId);
- if (null !== $journal && (int) $journalId === $journal->id) {
+ $journal = $this->repository->findNull((int)$journalId);
+ if (null !== $journal && (int)$journalId === $journal->id) {
$this->repository->destroyJournal($journal);
++$count;
}
}
}
app('preferences')->mark();
- session()->flash('success', (string) trans_choice('firefly.mass_deleted_transactions_success', $count));
+ session()->flash('success', (string)trans_choice('firefly.mass_deleted_transactions_success', $count));
// redirect to previous URL:
return redirect($this->getPreviousUri('transactions.mass-delete.uri'));
@@ -126,7 +126,7 @@ class MassController extends Controller
*/
public function edit(array $journals): IlluminateView
{
- $subTitle = (string) trans('firefly.mass_edit_journals');
+ $subTitle = (string)trans('firefly.mass_edit_journals');
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
@@ -160,8 +160,8 @@ class MassController extends Controller
*
* @param MassEditJournalRequest $request
*
- * @throws FireflyException
* @return RedirectResponse|Redirector
+ * @throws FireflyException
*/
public function update(MassEditJournalRequest $request)
{
@@ -173,7 +173,7 @@ class MassController extends Controller
$count = 0;
/** @var string $journalId */
foreach ($journalIds as $journalId) {
- $integer = (int) $journalId;
+ $integer = (int)$journalId;
try {
$this->updateJournal($integer, $request);
$count++;
@@ -183,12 +183,49 @@ class MassController extends Controller
}
app('preferences')->mark();
- session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count ));
+ session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
// redirect to previous URL:
return redirect($this->getPreviousUri('transactions.mass-edit.uri'));
}
+ /**
+ * @param int $journalId
+ * @param MassEditJournalRequest $request
+ *
+ * @throws FireflyException
+ */
+ private function updateJournal(int $journalId, MassEditJournalRequest $request): void
+ {
+ $journal = $this->repository->findNull($journalId);
+ if (null === $journal) {
+ throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId)); // @codeCoverageIgnore
+ }
+ $service = app(JournalUpdateService::class);
+ // for each field, call the update service.
+ $service->setTransactionJournal($journal);
+
+ $data = [
+ 'date' => $this->getDateFromRequest($request, $journal->id, 'date'),
+ 'description' => $this->getStringFromRequest($request, $journal->id, 'description'),
+ 'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'),
+ 'source_name' => $this->getStringFromRequest($request, $journal->id, 'source_name'),
+ 'destination_id' => $this->getIntFromRequest($request, $journal->id, 'destination_id'),
+ 'destination_name' => $this->getStringFromRequest($request, $journal->id, 'destination_name'),
+ 'budget_id' => $this->getIntFromRequest($request, $journal->id, 'budget_id'),
+ 'category_name' => $this->getStringFromRequest($request, $journal->id, 'category'),
+ 'amount' => $this->getStringFromRequest($request, $journal->id, 'amount'),
+ 'foreign_amount' => $this->getStringFromRequest($request, $journal->id, 'foreign_amount'),
+ ];
+ Log::debug(sprintf('Will update journal #%d with data.', $journal->id), $data);
+
+ // call service to update.
+ $service->setData($data);
+ $service->update();
+ // trigger rules
+ event(new UpdatedTransactionGroup($journal->transactionGroup));
+ }
+
/**
* @param MassEditJournalRequest $request
* @param int $journalId
@@ -222,10 +259,10 @@ class MassController extends Controller
* @param int $journalId
* @param string $string
*
- * @return int|null
+ * @return string|null
* @codeCoverageIgnore
*/
- private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
+ private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?string
{
$value = $request->get($string);
if (!is_array($value)) {
@@ -235,7 +272,7 @@ class MassController extends Controller
return null;
}
- return (int) $value[$journalId];
+ return (string)$value[$journalId];
}
/**
@@ -243,10 +280,10 @@ class MassController extends Controller
* @param int $journalId
* @param string $string
*
- * @return string|null
+ * @return int|null
* @codeCoverageIgnore
*/
- private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?string
+ private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
{
$value = $request->get($string);
if (!is_array($value)) {
@@ -256,43 +293,6 @@ class MassController extends Controller
return null;
}
- return (string) $value[$journalId];
- }
-
- /**
- * @param int $journalId
- * @param MassEditJournalRequest $request
- *
- * @throws FireflyException
- */
- private function updateJournal(int $journalId, MassEditJournalRequest $request): void
- {
- $journal = $this->repository->findNull($journalId);
- if (null === $journal) {
- throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId)); // @codeCoverageIgnore
- }
- $service = app(JournalUpdateService::class);
- // for each field, call the update service.
- $service->setTransactionJournal($journal);
-
- $data = [
- 'date' => $this->getDateFromRequest($request, $journal->id, 'date'),
- 'description' => $this->getStringFromRequest($request, $journal->id, 'description'),
- 'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'),
- 'source_name' => $this->getStringFromRequest($request, $journal->id, 'source_name'),
- 'destination_id' => $this->getIntFromRequest($request, $journal->id, 'destination_id'),
- 'destination_name' => $this->getStringFromRequest($request, $journal->id, 'destination_name'),
- 'budget_id' => $this->getIntFromRequest($request, $journal->id, 'budget_id'),
- 'category_name' => $this->getStringFromRequest($request, $journal->id, 'category'),
- 'amount' => $this->getStringFromRequest($request, $journal->id, 'amount'),
- 'foreign_amount' => $this->getStringFromRequest($request, $journal->id, 'foreign_amount'),
- ];
- Log::debug(sprintf('Will update journal #%d with data.', $journal->id), $data);
-
- // call service to update.
- $service->setData($data);
- $service->update();
- // trigger rules
- event(new UpdatedTransactionGroup($journal->transactionGroup));
+ return (int)$value[$journalId];
}
}
diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.php
index 2afcf381fb..1b5e3901cf 100644
--- a/app/Http/Controllers/Transaction/ShowController.php
+++ b/app/Http/Controllers/Transaction/ShowController.php
@@ -54,7 +54,7 @@ class ShowController extends Controller
function ($request, $next) {
$this->repository = app(TransactionGroupRepositoryInterface::class);
- app('view')->share('title', (string) trans('firefly.transactions'));
+ app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
return $next($request);
@@ -75,8 +75,8 @@ class ShowController extends Controller
/**
* @param TransactionGroup $transactionGroup
*
- * @throws FireflyException
* @return Factory|View
+ * @throws FireflyException
*/
public function show(Request $request, TransactionGroup $transactionGroup)
{
@@ -88,7 +88,7 @@ class ShowController extends Controller
throw new FireflyException('This transaction is broken :(.');
}
- $type = (string) trans(sprintf('firefly.%s', $first->transactionType->type));
+ $type = (string)trans(sprintf('firefly.%s', $first->transactionType->type));
$title = 1 === $splits ? $first->description : $transactionGroup->title;
$subTitle = sprintf('%s: "%s"', $type, $title);
@@ -98,7 +98,7 @@ class ShowController extends Controller
$groupArray = $transformer->transformObject($transactionGroup);
// do some calculations:
- $amounts = $this->getAmounts($groupArray);
+ $amounts = $this->getAmounts($groupArray);
$accounts = $this->getAccounts($groupArray);
foreach ($groupArray['transactions'] as $index => $transaction) {
@@ -161,7 +161,7 @@ class ShowController extends Controller
return $amounts;
}
-
+
/**
* @param array $group
*
@@ -170,22 +170,23 @@ class ShowController extends Controller
private function getAccounts(array $group): array
{
$accounts = [];
-
+
foreach ($group['transactions'] as $transaction) {
- $accounts['source'][] = [
+ $accounts['source'][] = [
'type' => $transaction['source_type'],
- 'id' => $transaction['source_id'],
+ 'id' => $transaction['source_id'],
'name' => $transaction['source_name'],
- 'iban' => $transaction['source_iban'] ];
- $accounts['destination'][] = [
+ 'iban' => $transaction['source_iban']];
+ $accounts['destination'][] = [
'type' => $transaction['destination_type'],
- 'id' => $transaction['destination_id'],
+ 'id' => $transaction['destination_id'],
'name' => $transaction['destination_name'],
- 'iban' => $transaction['destination_iban'] ];
+ 'iban' => $transaction['destination_iban']];
}
- $accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);
+ $accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);
$accounts['destination'] = array_unique($accounts['destination'], SORT_REGULAR);
+
return $accounts;
}
}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 7ddba39dff..bfc785315f 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -73,6 +73,7 @@ class Authenticate
return $next($request);
}
+
/**
* Determine if the user is logged in to any of the given guards.
*
diff --git a/app/Http/Middleware/InstallationId.php b/app/Http/Middleware/InstallationId.php
index a15e528ccb..0b70627f28 100644
--- a/app/Http/Middleware/InstallationId.php
+++ b/app/Http/Middleware/InstallationId.php
@@ -20,6 +20,7 @@
*/
declare(strict_types=1);
+
namespace FireflyIII\Http\Middleware;
use Closure;
@@ -39,7 +40,7 @@ class InstallationId
* Handle an incoming request.
*
* @param Request $request
- * @param Closure $next
+ * @param Closure $next
*
* @return mixed
*
diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.php
index cbd18c0fdb..c2e729c3e3 100644
--- a/app/Http/Middleware/InterestingMessage.php
+++ b/app/Http/Middleware/InterestingMessage.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
+
use Closure;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
@@ -114,7 +115,7 @@ class InterestingMessage
session()->flash('success_uri', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
}
- if('no_change' === $message) {
+ if ('no_change' === $message) {
$type = strtolower($journal->transactionType->type);
session()->flash('warning_uri', route('transactions.show', [$transactionGroupId]));
session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.php
index f32c81c336..82bf301873 100644
--- a/app/Http/Middleware/SecureHeaders.php
+++ b/app/Http/Middleware/SecureHeaders.php
@@ -48,9 +48,9 @@ class SecureHeaders
$nonce = base64_encode(random_bytes(16));
app('view')->share('JS_NONCE', $nonce);
- $response = $next($request);
+ $response = $next($request);
$trackingScriptSrc = $this->getTrackingScriptSource();
- $csp = [
+ $csp = [
"default-src 'none'",
"object-src 'self'",
sprintf("script-src 'unsafe-inline' 'nonce-%1s' %2s", $nonce, $trackingScriptSrc),
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index a357525f66..37e5471b77 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -73,7 +73,7 @@ class CreateRecurringTransactions implements ShouldQueue
$newDate->startOfDay();
$this->date = $newDate;
}
- if(null === $date) {
+ if (null === $date) {
$newDate = new Carbon;
$newDate->startOfDay();
$this->date = $newDate;
diff --git a/app/Jobs/SubmitTelemetryData.php b/app/Jobs/SubmitTelemetryData.php
index 323d5fe409..7054d68a17 100644
--- a/app/Jobs/SubmitTelemetryData.php
+++ b/app/Jobs/SubmitTelemetryData.php
@@ -23,6 +23,7 @@
declare(strict_types=1);
namespace FireflyIII\Jobs;
+
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
diff --git a/app/Mail/AccessTokenCreatedMail.php b/app/Mail/AccessTokenCreatedMail.php
index 0d1da11266..5ffd04bacc 100644
--- a/app/Mail/AccessTokenCreatedMail.php
+++ b/app/Mail/AccessTokenCreatedMail.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Mail;
+
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
diff --git a/app/Mail/OAuthTokenCreatedMail.php b/app/Mail/OAuthTokenCreatedMail.php
index 9a5342bd57..b999af725f 100644
--- a/app/Mail/OAuthTokenCreatedMail.php
+++ b/app/Mail/OAuthTokenCreatedMail.php
@@ -27,6 +27,7 @@ use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Laravel\Passport\Client;
+
/**
* Class OAuthTokenCreatedMail
*
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 16e1afe35b..5714a23d50 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -39,36 +39,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Account
*
- * @property int $id
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property int $user_id
- * @property int $account_type_id
- * @property string $name
- * @property string|null $virtual_balance
- * @property string|null $iban
- * @property bool $active
- * @property bool $encrypted
- * @property int $order
+ * @property int $id
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @property \Illuminate\Support\Carbon|null $deleted_at
+ * @property int $user_id
+ * @property int $account_type_id
+ * @property string $name
+ * @property string|null $virtual_balance
+ * @property string|null $iban
+ * @property bool $active
+ * @property bool $encrypted
+ * @property int $order
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AccountMeta[] $accountMeta
- * @property-read int|null $account_meta_count
- * @property-read \FireflyIII\Models\AccountType $accountType
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
- * @property-read int|null $attachments_count
- * @property-read string $account_number
- * @property-read string $edit_name
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Location[] $locations
- * @property-read int|null $locations_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Note[] $notes
- * @property-read int|null $notes_count
+ * @property-read int|null $account_meta_count
+ * @property-read \FireflyIII\Models\AccountType $accountType
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
+ * @property-read int|null $attachments_count
+ * @property-read string $account_number
+ * @property-read string $edit_name
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Location[] $locations
+ * @property-read int|null $locations_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Note[] $notes
+ * @property-read int|null $notes_count
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\ObjectGroup[] $objectGroups
- * @property-read int|null $object_groups_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
- * @property-read int|null $piggy_banks_count
+ * @property-read int|null $object_groups_count
+ * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\PiggyBank[] $piggyBanks
+ * @property-read int|null $piggy_banks_count
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
- * @property-read int|null $transactions_count
- * @property-read User $user
+ * @property-read int|null $transactions_count
+ * @property-read User $user
* @method static EloquentBuilder|Account accountTypeIn($types)
* @method static EloquentBuilder|Account newModelQuery()
* @method static EloquentBuilder|Account newQuery()
@@ -120,13 +120,13 @@ class Account extends Model
*
* @param string $value
*
- * @throws NotFoundHttpException
* @return Account
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Account
{
if (auth()->check()) {
- $accountId = (int) $value;
+ $accountId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Account $account */
@@ -255,7 +255,7 @@ class Account extends Model
public function setVirtualBalanceAttribute($value): void
{
$value = (string)$value;
- if('' === $value) {
+ if ('' === $value) {
$value = null;
}
$this->attributes['virtual_balance'] = $value;
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index ee6c10be43..46a48a8b73 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -22,51 +22,51 @@ declare(strict_types=1);
namespace FireflyIII\Models;
-use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Illuminate\Support\Collection;
+use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Bill
*
- * @property int $id
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property int $user_id
- * @property int|null $transaction_currency_id
- * @property string $name
- * @property string $match
- * @property string $amount_min
- * @property string $amount_max
- * @property \Illuminate\Support\Carbon $date
- * @property string|null $end_date
- * @property string|null $extension_date
- * @property string $repeat_freq
- * @property int $skip
- * @property bool $automatch
- * @property bool $active
- * @property bool $name_encrypted
- * @property bool $match_encrypted
- * @property int $order
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
- * @property-read int|null $attachments_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Note[] $notes
- * @property-read int|null $notes_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\ObjectGroup[] $objectGroups
- * @property-read int|null $object_groups_count
- * @property-read \FireflyIII\Models\TransactionCurrency|null $transactionCurrency
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals
- * @property-read int|null $transaction_journals_count
- * @property-read User $user
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $user_id
+ * @property int|null $transaction_currency_id
+ * @property string $name
+ * @property string $match
+ * @property string $amount_min
+ * @property string $amount_max
+ * @property Carbon $date
+ * @property string|null $end_date
+ * @property string|null $extension_date
+ * @property string $repeat_freq
+ * @property int $skip
+ * @property bool $automatch
+ * @property bool $active
+ * @property bool $name_encrypted
+ * @property bool $match_encrypted
+ * @property int $order
+ * @property-read Collection|Attachment[] $attachments
+ * @property-read int|null $attachments_count
+ * @property-read Collection|Note[] $notes
+ * @property-read int|null $notes_count
+ * @property-read Collection|ObjectGroup[] $objectGroups
+ * @property-read int|null $object_groups_count
+ * @property-read TransactionCurrency|null $transactionCurrency
+ * @property-read Collection|TransactionJournal[] $transactionJournals
+ * @property-read int|null $transaction_journals_count
+ * @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Bill newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Bill newQuery()
* @method static Builder|Bill onlyTrashed()
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 826567ef12..d5a48c2f5a 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -22,9 +22,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
-use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -32,32 +32,32 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Illuminate\Support\Collection;
+use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Budget
*
- * @property int $id
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property int $user_id
- * @property string $name
- * @property bool $active
- * @property bool $encrypted
- * @property int $order
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Attachment[] $attachments
- * @property-read int|null $attachments_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\AutoBudget[] $autoBudgets
- * @property-read int|null $auto_budgets_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\BudgetLimit[] $budgetlimits
- * @property-read int|null $budgetlimits_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\TransactionJournal[] $transactionJournals
- * @property-read int|null $transaction_journals_count
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Transaction[] $transactions
- * @property-read int|null $transactions_count
- * @property-read User $user
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $user_id
+ * @property string $name
+ * @property bool $active
+ * @property bool $encrypted
+ * @property int $order
+ * @property-read Collection|Attachment[] $attachments
+ * @property-read int|null $attachments_count
+ * @property-read Collection|AutoBudget[] $autoBudgets
+ * @property-read int|null $auto_budgets_count
+ * @property-read Collection|BudgetLimit[] $budgetlimits
+ * @property-read int|null $budgetlimits_count
+ * @property-read Collection|TransactionJournal[] $transactionJournals
+ * @property-read int|null $transaction_journals_count
+ * @property-read Collection|Transaction[] $transactions
+ * @property-read int|null $transactions_count
+ * @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Budget newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Budget newQuery()
* @method static Builder|Budget onlyTrashed()
@@ -102,13 +102,13 @@ class Budget extends Model
*
* @param string $value
*
- * @throws NotFoundHttpException
* @return Budget
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Budget
{
if (auth()->check()) {
- $budgetId = (int) $value;
+ $budgetId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Budget $budget */
@@ -122,28 +122,29 @@ class Budget extends Model
/**
* @codeCoverageIgnore
- * @return HasMany
+ * @return MorphMany
*/
- public function autoBudgets(): HasMany
+ public function attachments(): MorphMany
{
- return $this->hasMany(AutoBudget::class);
+ return $this->morphMany(Attachment::class, 'attachable');
}
/**
* @codeCoverageIgnore
* @return HasMany
*/
- public function budgetlimits(): HasMany
+ public function autoBudgets(): HasMany
{
- return $this->hasMany(BudgetLimit::class);
+ return $this->hasMany(AutoBudget::class);
}
+
/**
* @codeCoverageIgnore
- * @return MorphMany
+ * @return HasMany
*/
- public function attachments(): MorphMany
+ public function budgetlimits(): HasMany
{
- return $this->morphMany(Attachment::class, 'attachable');
+ return $this->hasMany(BudgetLimit::class);
}
/**
diff --git a/app/Models/Note.php b/app/Models/Note.php
index 245dbaf4b4..2090715d3b 100644
--- a/app/Models/Note.php
+++ b/app/Models/Note.php
@@ -22,26 +22,25 @@ declare(strict_types=1);
namespace FireflyIII\Models;
-use Carbon\Carbon;
use Eloquent;
-use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
+use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\Note
*
- * @property int $id
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property int $noteable_id
- * @property string $noteable_type
- * @property string|null $title
- * @property string|null $text
- * @property-read Model|\Eloquent $noteable
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $noteable_id
+ * @property string $noteable_type
+ * @property string|null $title
+ * @property string|null $text
+ * @property-read Model|Eloquent $noteable
* @method static \Illuminate\Database\Eloquent\Builder|Note newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Note newQuery()
* @method static Builder|Note onlyTrashed()
diff --git a/app/Models/Role.php b/app/Models/Role.php
index 5d31825cb6..1462fb2e30 100644
--- a/app/Models/Role.php
+++ b/app/Models/Role.php
@@ -33,14 +33,14 @@ use Illuminate\Support\Carbon;
/**
* FireflyIII\Models\Role
*
- * @property int $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property string $name
- * @property string|null $display_name
- * @property string|null $description
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property string $name
+ * @property string|null $display_name
+ * @property string|null $description
* @property-read Collection|User[] $users
- * @property-read int|null $users_count
+ * @property-read int|null $users_count
* @method static Builder|Role newModelQuery()
* @method static Builder|Role newQuery()
* @method static Builder|Role query()
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index ba8cb32306..5a15335d6f 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -22,38 +22,38 @@ declare(strict_types=1);
namespace FireflyIII\Models;
-use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Illuminate\Support\Collection;
+use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Rule
*
- * @property int $id
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
- * @property \Illuminate\Support\Carbon|null $deleted_at
- * @property int $user_id
- * @property int $rule_group_id
- * @property string $title
- * @property string|null $description
- * @property int $order
- * @property bool $active
- * @property bool $stop_processing
- * @property bool $strict
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleAction[] $ruleActions
- * @property-read int|null $rule_actions_count
- * @property-read \FireflyIII\Models\RuleGroup $ruleGroup
- * @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\RuleTrigger[] $ruleTriggers
- * @property-read int|null $rule_triggers_count
- * @property-read User $user
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $user_id
+ * @property int $rule_group_id
+ * @property string $title
+ * @property string|null $description
+ * @property int $order
+ * @property bool $active
+ * @property bool $stop_processing
+ * @property bool $strict
+ * @property-read Collection|RuleAction[] $ruleActions
+ * @property-read int|null $rule_actions_count
+ * @property-read RuleGroup $ruleGroup
+ * @property-read Collection|RuleTrigger[] $ruleTriggers
+ * @property-read int|null $rule_triggers_count
+ * @property-read User $user
* @method static \Illuminate\Database\Eloquent\Builder|Rule newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Rule newQuery()
* @method static Builder|Rule onlyTrashed()
@@ -102,13 +102,13 @@ class Rule extends Model
*
* @param string $value
*
- * @throws NotFoundHttpException
* @return Rule
+ * @throws NotFoundHttpException
*/
public static function routeBinder(string $value): Rule
{
if (auth()->check()) {
- $ruleId = (int) $value;
+ $ruleId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Rule $rule */
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index fda812145d..7546cfd5ab 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -37,14 +37,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Tag
*
- * @property int $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
* @property int $user_id
* @property string $tag
* @property string $tagMode
- * @property Carbon|null $date
+ * @property Carbon|null $date
* @property string|null $description
* @property float|null $latitude
* @property float|null $longitude
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 60e454d222..71dbda25c4 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -630,7 +630,7 @@ class AccountRepository implements AccountRepositoryInterface
$list = $this->getAccountsByType($set);
$index = 1;
foreach ($list as $account) {
- if(false === $account->active) {
+ if (false === $account->active) {
$account->order = 0;
continue;
}
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 36851b406f..99385c33e4 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Support\Collection;
+
/**
* Interface AccountRepositoryInterface.
*/
diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php
index 85c9c76a4d..90e606a992 100644
--- a/app/Repositories/Account/AccountTasker.php
+++ b/app/Repositories/Account/AccountTasker.php
@@ -76,7 +76,7 @@ class AccountTasker implements AccountTaskerInterface
'currency_symbol' => $currency->symbol,
'currency_name' => $currency->name,
'currency_decimal_places' => $currency->decimal_places,];
- $entry = [
+ $entry = [
'name' => $account->name,
'id' => $account->id,
'currency_id' => $currency->id,