Various PSR12 code cleanup

This commit is contained in:
James Cole 2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
415 changed files with 7462 additions and 6874 deletions

View File

@ -50,7 +50,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);
@ -62,13 +62,13 @@ class DeleteController extends Controller
/**
* Delete a piggy bank.
*
* @param ObjectGroup $objectGroup
* @param ObjectGroup $objectGroup
*
* @return Factory|View
*/
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
@ -80,13 +80,13 @@ class DeleteController extends Controller
/**
* Destroy the piggy bank.
*
* @param ObjectGroup $objectGroup
* @param ObjectGroup $objectGroup
*
* @return RedirectResponse
*/
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);

View File

@ -53,7 +53,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);
@ -65,13 +65,13 @@ class EditController extends Controller
/**
* Edit an object group.
*
* @param ObjectGroup $objectGroup
* @param ObjectGroup $objectGroup
*
* @return Factory|View
*/
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')) {
@ -85,8 +85,8 @@ class EditController extends Controller
/**
* Update a piggy bank.
*
* @param ObjectGroupFormRequest $request
* @param ObjectGroup $objectGroup
* @param ObjectGroupFormRequest $request
* @param ObjectGroup $objectGroup
*
* @return Application|RedirectResponse|Redirector
*/
@ -95,12 +95,12 @@ class EditController extends Controller
$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->getPreviousUrl('object-groups.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
if (1 === (int)$request->get('return_to_edit')) {
session()->put('object-groups.edit.fromUpdate', true);
$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));

View File

@ -53,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);
@ -68,22 +68,22 @@ class IndexController extends Controller
{
$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 view('object-groups.index', compact('subTitle', 'objectGroups'));
}
/**
* @param Request $request
* @param ObjectGroup $objectGroup
* @param Request $request
* @param ObjectGroup $objectGroup
*
* @return JsonResponse
*/
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([]);

View File

@ -54,7 +54,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);
@ -68,7 +68,7 @@ class AmountController extends Controller
/**
* Add money to piggy bank.
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/
@ -89,7 +89,7 @@ class AmountController extends Controller
/**
* Add money to piggy bank (for mobile devices).
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/
@ -113,8 +113,8 @@ class AmountController extends Controller
/**
* Add money to piggy bank.
*
* @param Request $request
* @param PiggyBank $piggyBank
* @param Request $request
* @param PiggyBank $piggyBank
*
* @return RedirectResponse
*/
@ -130,7 +130,7 @@ class AmountController extends Controller
$this->piggyRepos->addAmount($piggyBank, $amount);
session()->flash(
'success',
(string) trans(
(string)trans(
'firefly.added_amount_to_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
)
@ -140,10 +140,10 @@ class AmountController extends Controller
return redirect(route('piggy-banks.index'));
}
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
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)]
)
@ -155,8 +155,8 @@ class AmountController extends Controller
/**
* Remove money from piggy bank.
*
* @param Request $request
* @param PiggyBank $piggyBank
* @param Request $request
* @param PiggyBank $piggyBank
*
* @return RedirectResponse
*/
@ -172,7 +172,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]
)
@ -181,11 +181,11 @@ class AmountController extends Controller
return redirect(route('piggy-banks.index'));
}
$amount = (string) $request->get('amount');
$amount = (string)$request->get('amount');
session()->flash(
'error',
(string) trans(
(string)trans(
'firefly.cannot_remove_from_piggy',
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
)
@ -197,7 +197,7 @@ class AmountController extends Controller
/**
* Remove money from piggy bank form.
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/
@ -212,7 +212,7 @@ class AmountController extends Controller
/**
* Remove money from piggy bank (for mobile devices).
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/

View File

@ -53,7 +53,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);
@ -71,7 +71,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").
@ -86,7 +86,7 @@ class CreateController extends Controller
/**
* Store a new piggy bank.
*
* @param PiggyBankStoreRequest $request
* @param PiggyBankStoreRequest $request
*
* @return RedirectResponse|Redirector
* @throws FireflyException
@ -99,7 +99,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):
@ -109,7 +109,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) {
@ -117,7 +117,7 @@ class CreateController extends Controller
}
$redirect = redirect($this->getPreviousUrl('piggy-banks.create.url'));
if (1 === (int) $request->get('create_another')) {
if (1 === (int)$request->get('create_another')) {
session()->put('piggy-banks.create.fromStore', true);
$redirect = redirect(route('piggy-banks.create'))->withInput();

View File

@ -49,7 +49,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);
@ -62,13 +62,13 @@ class DeleteController extends Controller
/**
* Delete a piggy bank.
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/
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->rememberPreviousUrl('piggy-banks.delete.url');
@ -79,13 +79,13 @@ class DeleteController extends Controller
/**
* Destroy the piggy bank.
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return RedirectResponse
*/
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);

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\PiggyBank;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
@ -35,6 +36,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
use JsonException;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
@ -57,7 +59,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);
@ -72,11 +74,11 @@ class IndexController extends Controller
*
* TODO very complicated function.
*
* @param Request $request
* @param Request $request
*
* @return Factory|View
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \JsonException
* @throws FireflyException
* @throws JsonException
*/
public function index(Request $request)
{
@ -104,16 +106,16 @@ 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,
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
'piggy_banks' => [],
];
'object_group_id' => $array['object_group_id'] ?? 0,
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
'piggy_banks' => [],
];
$account = $accountTransformer->transform($piggy->account);
$accountId = (int) $account['id'];
$accountId = (int)$account['id'];
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
if (!array_key_exists($accountId, $accounts)) {
// create new:
@ -143,7 +145,7 @@ class IndexController extends Controller
}
/**
* @param array $piggyBanks
* @param array $piggyBanks
*
* @return array
*/
@ -155,23 +157,23 @@ class IndexController extends Controller
foreach ($group['piggy_banks'] as $piggy) {
$currencyId = $piggy['currency_id'];
$sums[$groupId][$currencyId] = $sums[$groupId][$currencyId] ?? [
'target' => '0',
'saved' => '0',
'left_to_save' => '0',
'save_per_month' => '0',
'currency_id' => $currencyId,
'currency_code' => $piggy['currency_code'],
'currency_symbol' => $piggy['currency_symbol'],
'currency_decimal_places' => $piggy['currency_decimal_places'],
];
'target' => '0',
'saved' => '0',
'left_to_save' => '0',
'save_per_month' => '0',
'currency_id' => $currencyId,
'currency_code' => $piggy['currency_code'],
'currency_symbol' => $piggy['currency_symbol'],
'currency_decimal_places' => $piggy['currency_decimal_places'],
];
// target_amount
// 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) {
@ -185,15 +187,15 @@ class IndexController extends Controller
/**
* Set the order of a piggy bank.
*
* @param Request $request
* @param PiggyBank $piggyBank
* @param Request $request
* @param PiggyBank $piggyBank
*
* @return JsonResponse
*/
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);

View File

@ -51,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);
@ -64,7 +64,7 @@ class ShowController extends Controller
/**
* Show a single piggy bank.
*
* @param PiggyBank $piggyBank
* @param PiggyBank $piggyBank
*
* @return Factory|View
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* ReportController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -38,7 +39,7 @@ class ReportController extends Controller
/**
* Generate popup view.
*
* @param Request $request
* @param Request $request
*
* @return JsonResponse
*

View File

@ -63,8 +63,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);
@ -79,7 +79,7 @@ class CreateController extends Controller
/**
* Create a new recurring transaction.
*
* @param Request $request
* @param Request $request
*
* @return Factory|View
*/
@ -98,22 +98,22 @@ 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'),
];
$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,
'active' => $hasOldInput ? (bool)$request->old('active') : true,
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,
];
$request->session()->flash('preFilled', $preFilled);
@ -124,8 +124,8 @@ class CreateController extends Controller
}
/**
* @param Request $request
* @param TransactionJournal $journal
* @param Request $request
* @param TransactionJournal $journal
*
* @return Factory|\Illuminate\Contracts\View\View
*/
@ -144,15 +144,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'),
];
@ -185,8 +185,8 @@ class CreateController extends Controller
'category' => $request->old('category'),
'budget_id' => $request->old('budget_id'),
'bill_id' => $request->old('bill_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) {
@ -221,7 +221,7 @@ class CreateController extends Controller
/**
* Store a recurring transaction.
*
* @param RecurrenceFormRequest $request
* @param RecurrenceFormRequest $request
*
* @return RedirectResponse|Redirector
* @throws FireflyException
@ -237,7 +237,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):
@ -247,7 +247,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) {
@ -255,7 +255,7 @@ class CreateController extends Controller
}
$redirect = redirect($this->getPreviousUrl('recurring.create.url'));
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);

View File

@ -53,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);
@ -65,13 +65,13 @@ class DeleteController extends Controller
/**
* Delete a recurring transaction form.
*
* @param Recurrence $recurrence
* @param Recurrence $recurrence
*
* @return Factory|View
*/
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->rememberPreviousUrl('recurrences.delete.url');
@ -83,16 +83,16 @@ class DeleteController extends Controller
/**
* Destroy the recurring transaction.
*
* @param RecurringRepositoryInterface $repository
* @param Request $request
* @param Recurrence $recurrence
* @param RecurringRepositoryInterface $repository
* @param Request $request
* @param Recurrence $recurrence
*
* @return RedirectResponse|Redirector
*/
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->getPreviousUrl('recurrences.delete.url'));

View File

@ -64,8 +64,8 @@ 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);
@ -80,8 +80,8 @@ class EditController extends Controller
/**
* Edit a recurring transaction.
*
* @param Request $request
* @param Recurrence $recurrence
* @param Request $request
* @param Recurrence $recurrence
*
* @return Factory|View
* @throws FireflyException
@ -107,7 +107,7 @@ class EditController extends Controller
$repetition = $recurrence->recurrenceRepetitions()->first();
$currentRepType = $repetition->repetition_type;
if ('' !== $repetition->repetition_moment) {
$currentRepType .= ',' . $repetition->repetition_moment;
$currentRepType .= ','.$repetition->repetition_moment;
}
// put previous url in session if not redirect from store (not "return_to_edit").
@ -118,9 +118,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';
@ -130,22 +130,22 @@ 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'],
];
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
$array['first_date'] = substr((string)$array['first_date'], 0, 10);
$array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
return view(
@ -167,8 +167,8 @@ class EditController extends Controller
/**
* Update the recurring transaction.
*
* @param RecurrenceFormRequest $request
* @param Recurrence $recurrence
* @param RecurrenceFormRequest $request
* @param Recurrence $recurrence
*
* @return RedirectResponse|Redirector
* @throws FireflyException
@ -178,7 +178,7 @@ class EditController extends Controller
$data = $request->getAll();
$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;
@ -186,7 +186,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) {
@ -194,7 +194,7 @@ class EditController extends Controller
}
app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
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);

View File

@ -1,4 +1,5 @@
<?php
/**
* IndexController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -33,6 +34,8 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
@ -58,7 +61,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);
@ -71,17 +74,17 @@ class IndexController extends Controller
* TODO the notes of a recurrence are pretty pointless at this moment.
* Show all recurring transactions.
*
* @param Request $request
* @param Request $request
*
* @return Factory|View
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
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'));

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* TriggerController.php

View File

@ -1,4 +1,5 @@
<?php
/**
* AccountController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use JsonException;
use Log;
use Throwable;
@ -40,9 +40,9 @@ class AccountController extends Controller
/**
* Show partial overview for account balances.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* BalanceController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -61,9 +62,9 @@ class BalanceController extends Controller
/**
* Show overview of budget balances.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -104,25 +105,25 @@ class BalanceController extends Controller
$sourceAccount = $journal['source_account_id'];
$currencyId = $journal['currency_id'];
$spent[$sourceAccount] = $spent[$sourceAccount] ?? [
'source_account_id' => $sourceAccount,
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
'spent' => '0',
];
'source_account_id' => $sourceAccount,
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
'spent' => '0',
];
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']);
// also fix sum:
$report['sums'][$budgetId][$currencyId] = $report['sums'][$budgetId][$currencyId] ?? [
'sum' => '0',
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
];
'sum' => '0',
'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'],
'currency_symbol' => $journal['currency_symbol'],
'currency_decimal_places' => $journal['currency_decimal_places'],
];
$report['sums'][$budgetId][$currencyId]['sum'] = bcadd($report['sums'][$budgetId][$currencyId]['sum'], $journal['amount']);
$report['accounts'][$sourceAccount]['sum'] = bcadd($report['accounts'][$sourceAccount]['sum'], $journal['amount']);

View File

@ -29,7 +29,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use JsonException;
use Log;
use Throwable;
@ -39,9 +38,9 @@ use Throwable;
class BillController extends Controller
{
/**
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* BudgetController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -76,10 +77,10 @@ class BudgetController extends Controller
/**
* Partial used in the budget report.
*
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -101,10 +102,10 @@ class BudgetController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -117,33 +118,33 @@ class BudgetController extends Controller
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
$report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['sum'],
$journal['amount']
@ -157,10 +158,10 @@ class BudgetController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -174,21 +175,21 @@ class BudgetController extends Controller
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
}
}
}
@ -209,10 +210,10 @@ class BudgetController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -225,20 +226,20 @@ class BudgetController extends Controller
foreach ($budgets as $budget) {
$budgetId = $budget->id;
$report[$budgetId] = $report[$budgetId] ?? [
'name' => $budget->name,
'id' => $budget->id,
'currencies' => [],
];
'name' => $budget->name,
'id' => $budget->id,
'currencies' => [],
];
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
];
/** @var array $budget */
foreach ($currency['budgets'] as $budget) {
$budgetId = $budget['id'];
@ -246,14 +247,14 @@ class BudgetController extends Controller
foreach ($budget['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$budgetId]['currencies'][$currencyId] = $report[$budgetId]['currencies'][$currencyId] ?? [
'sum' => '0',
'sum_pct' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'sum' => '0',
'sum_pct' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
];
$report[$budgetId]['currencies'][$currencyId]['sum'] = bcadd($report[$budgetId]['currencies'][$currencyId]['sum'], $journal['amount']);
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
}
@ -267,7 +268,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')); // intentional float
$pct = round((float)bcmul(bcdiv($sum, $total), '100')); // intentional float
}
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
}
@ -279,9 +280,9 @@ class BudgetController extends Controller
/**
* Show partial overview of budgets.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -304,9 +305,9 @@ class BudgetController extends Controller
/**
* Show budget overview for a period.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
* @throws JsonException
@ -336,20 +337,20 @@ class BudgetController extends Controller
$key = sprintf('%d-%d', $budget['id'], $currency['currency_id']);
$dateKey = $journal['date']->format($keyFormat);
$report[$key] = $report[$key] ?? [
'id' => $budget['id'],
'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'entries' => [],
];
'id' => $budget['id'],
'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'entries' => [],
];
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string) count($periods));
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods));
}
}
}
@ -367,10 +368,10 @@ class BudgetController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -384,7 +385,7 @@ class BudgetController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'], // intentional float
'amount_float' => (float)$journal['amount'], // intentional float
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),

View File

@ -1,4 +1,5 @@
<?php
/**
* CategoryController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -68,10 +69,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -84,11 +85,11 @@ class CategoryController extends Controller
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
@ -100,12 +101,12 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['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' => [],
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'categories' => [],
];
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]
@ -167,10 +168,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -184,37 +185,37 @@ class CategoryController extends Controller
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['spent'],
$journal['amount']
@ -233,26 +234,26 @@ class CategoryController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd(
$report[$destinationAccountId]['currencies'][$currencyId]['earned'],
$journal['amount']
@ -271,10 +272,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -288,21 +289,21 @@ class CategoryController extends Controller
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
}
}
}
@ -323,10 +324,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -340,21 +341,21 @@ class CategoryController extends Controller
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
}
}
}
@ -375,10 +376,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -392,22 +393,22 @@ class CategoryController extends Controller
foreach ($categories as $category) {
$categoryId = $category->id;
$report[$categoryId] = $report[$categoryId] ?? [
'name' => $category->name,
'id' => $category->id,
'currencies' => [],
];
'name' => $category->name,
'id' => $category->id,
'currencies' => [],
];
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
/** @var array $category */
foreach ($currency['categories'] as $category) {
$categoryId = $category['id'];
@ -415,14 +416,14 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$report[$categoryId]['currencies'][$currencyId]['spent'] = bcadd(
$report[$categoryId]['currencies'][$currencyId]['spent'],
$journal['amount']
@ -441,14 +442,14 @@ class CategoryController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
/** @var array $category */
foreach ($currency['categories'] as $category) {
$categoryId = $category['id'];
@ -456,14 +457,14 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$report[$categoryId]['currencies'][$currencyId]['earned'] = bcadd(
$report[$categoryId]['currencies'][$currencyId]['earned'],
$journal['amount']
@ -485,9 +486,9 @@ class CategoryController extends Controller
/**
* Show overview of expenses in category.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
* @throws JsonException
@ -523,17 +524,17 @@ class CategoryController extends Controller
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'sum' => '0',
'entries' => [],
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'sum' => '0',
'entries' => [],
];
];
foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
@ -565,10 +566,10 @@ class CategoryController extends Controller
/**
* Show overview of income in category.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @param Carbon $start
* @param Carbon $end
* @param Carbon $start
* @param Carbon $end
*
* @return string
* @throws JsonException
@ -604,17 +605,17 @@ class CategoryController extends Controller
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'sum' => '0',
'entries' => [],
'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'],
'currency_symbol' => $currencyRow['currency_symbol'],
'currency_name' => $currencyRow['currency_name'],
'currency_code' => $currencyRow['currency_code'],
'currency_decimal_places' => $currencyRow['currency_decimal_places'],
'sum' => '0',
'entries' => [],
];
];
foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0';
@ -645,9 +646,9 @@ class CategoryController extends Controller
/**
* Show overview of category transactions on the default report.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -673,7 +674,7 @@ class CategoryController extends Controller
try {
$result = (string) view('reports.partials.categories', compact('report'))->render();
$result = (string)view('reports.partials.categories', compact('report'))->render();
$cache->store($result);
} catch (Throwable $e) {
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
@ -685,10 +686,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -702,7 +703,7 @@ class CategoryController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'],
'amount_float' => (float)$journal['amount'],
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),
@ -735,10 +736,10 @@ class CategoryController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $categories
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -752,7 +753,7 @@ class CategoryController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'],
'amount_float' => (float)$journal['amount'],
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),

View File

@ -1,4 +1,5 @@
<?php
/**
* DoubleController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -70,10 +71,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -88,21 +89,21 @@ class DoubleController extends Controller
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
}
}
// sort by amount_float
@ -122,10 +123,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -140,21 +141,21 @@ class DoubleController extends Controller
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
}
}
// sort by amount_float
@ -174,10 +175,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $double
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $double
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -197,15 +198,15 @@ class DoubleController extends Controller
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
@ -215,19 +216,19 @@ class DoubleController extends Controller
$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
'source_iban' => '',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
'source_iban' => '',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
// set name
$report[$objectName]['dest_name'] = $destName;
$report[$objectName]['dest_iban'] = $destIban;
@ -245,15 +246,15 @@ class DoubleController extends Controller
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
@ -263,19 +264,19 @@ class DoubleController extends Controller
$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
'source_iban' => '',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'dest_name' => '',
'dest_iban' => '',
'source_name' => '',
'source_iban' => '',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
// set name
$report[$objectName]['source_name'] = $sourceName;
@ -295,10 +296,10 @@ class DoubleController extends Controller
/**
* TODO this method is duplicated.
*
* @param Collection $accounts
* @param int $id
* @param string $name
* @param string|null $iban
* @param Collection $accounts
* @param int $id
* @param string $name
* @param string|null $iban
*
* @return string
*/
@ -318,10 +319,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $double
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $double
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -341,31 +342,31 @@ class DoubleController extends Controller
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
'account_id' => $journal['source_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'account_id' => $journal['source_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
// set name
// add amounts:
$report[$objectName]['spent'] = bcadd($report[$objectName]['spent'], $journal['amount']);
@ -380,31 +381,31 @@ class DoubleController extends Controller
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
/** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [
'account_id' => $journal['destination_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'account_id' => $journal['destination_account_id'],
'account_name' => $objectName,
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
// add amounts:
$report[$objectName]['earned'] = bcadd($report[$objectName]['earned'], $journal['amount']);
@ -418,10 +419,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -436,7 +437,7 @@ class DoubleController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'],
'amount_float' => (float)$journal['amount'],
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),
@ -468,10 +469,10 @@ class DoubleController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $doubles
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -486,7 +487,7 @@ class DoubleController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'],
'amount_float' => (float)$journal['amount'],
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),

View File

@ -1,4 +1,5 @@
<?php
/**
* OperationsController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection;
use JsonException;
use Log;
use Throwable;
@ -62,9 +62,9 @@ class OperationsController extends Controller
/**
* View of income and expense.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
*/
@ -97,9 +97,9 @@ class OperationsController extends Controller
/**
* View of income.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -132,9 +132,9 @@ class OperationsController extends Controller
/**
* Overview of income and expense.
*
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Carbon $start
* @param Carbon $end
*
* @return mixed|string
*/
@ -159,15 +159,15 @@ class OperationsController extends Controller
foreach ($keys as $currencyId) {
$currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currencyId,
'currency_name' => $currencyInfo['currency_name'],
'currency_code' => $currencyInfo['currency_code'],
'currency_symbol' => $currencyInfo['currency_symbol'],
'currency_decimal_places' => $currencyInfo['currency_decimal_places'],
'in' => $incomes['sums'][$currencyId]['sum'] ?? '0',
'out' => $expenses['sums'][$currencyId]['sum'] ?? '0',
'sum' => '0',
];
'currency_id' => $currencyId,
'currency_name' => $currencyInfo['currency_name'],
'currency_code' => $currencyInfo['currency_code'],
'currency_symbol' => $currencyInfo['currency_symbol'],
'currency_decimal_places' => $currencyInfo['currency_decimal_places'],
'in' => $incomes['sums'][$currencyId]['sum'] ?? '0',
'out' => $expenses['sums'][$currencyId]['sum'] ?? '0',
'sum' => '0',
];
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['in'], $sums[$currencyId]['out']);
}

View File

@ -61,10 +61,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -77,11 +77,11 @@ class TagController extends Controller
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
@ -93,12 +93,12 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['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' => [],
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'tags' => [],
];
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]
@ -160,10 +160,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -177,37 +177,37 @@ class TagController extends Controller
foreach ($accounts as $account) {
$accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
'name' => $account->name,
'id' => $account->id,
'iban' => $account->iban,
'currencies' => [],
];
}
// loop expenses.
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
$report[$sourceAccountId]['currencies'][$currencyId]['spent'] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['spent'],
$journal['amount']
@ -226,26 +226,26 @@ class TagController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent_sum' => '0',
'earned_sum' => '0',
'total_sum' => '0',
];
foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'spent' => '0',
'earned' => '0',
'sum' => '0',
];
$report[$destinationAccountId]['currencies'][$currencyId]['earned'] = bcadd(
$report[$destinationAccountId]['currencies'][$currencyId]['earned'],
$journal['amount']
@ -264,10 +264,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -281,21 +281,21 @@ class TagController extends Controller
$destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'destination_account_name' => $journal['destination_account_name'],
'destination_account_id' => $journal['destination_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
}
}
}
@ -316,10 +316,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -333,21 +333,21 @@ class TagController extends Controller
$sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'transactions' => 0,
'sum' => '0',
'avg' => '0',
'avg_float' => 0,
'source_account_name' => $journal['source_account_name'],
'source_account_id' => $journal['source_account_id'],
'currency_id' => $currency['currency_id'],
'currency_name' => $currency['currency_name'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$result[$key]['transactions']++;
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
}
}
}
@ -368,10 +368,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return Factory|View
*/
@ -385,22 +385,22 @@ class TagController extends Controller
foreach ($tags as $tag) {
$tagId = $tag->id;
$report[$tagId] = $report[$tagId] ?? [
'name' => $tag->tag,
'id' => $tag->id,
'currencies' => [],
];
'name' => $tag->tag,
'id' => $tag->id,
'currencies' => [],
];
}
foreach ($spent as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
/** @var array $tag */
foreach ($currency['tags'] as $tag) {
$tagId = $tag['id'];
@ -408,14 +408,14 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$report[$tagId]['currencies'][$currencyId]['spent'] = bcadd(
$report[$tagId]['currencies'][$currencyId]['spent'],
$journal['amount']
@ -434,14 +434,14 @@ class TagController extends Controller
foreach ($earned as $currency) {
$currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'earned_sum' => '0',
'spent_sum' => '0',
'total_sum' => '0',
];
/** @var array $tag */
foreach ($currency['tags'] as $tag) {
$tagId = $tag['id'];
@ -449,14 +449,14 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
'spent' => '0',
'earned' => '0',
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$report[$tagId]['currencies'][$currencyId]['earned'] = bcadd(
$report[$tagId]['currencies'][$currencyId]['earned'],
$journal['amount']
@ -476,10 +476,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -493,7 +493,7 @@ class TagController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'],
'amount_float' => (float)$journal['amount'],
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),
@ -526,10 +526,10 @@ class TagController extends Controller
}
/**
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
* @param Collection $accounts
* @param Collection $tags
* @param Carbon $start
* @param Carbon $end
*
* @return string
*/
@ -543,7 +543,7 @@ class TagController extends Controller
$result[] = [
'description' => $journal['description'],
'transaction_group_id' => $journal['transaction_group_id'],
'amount_float' => (float) $journal['amount'], // intentional float.
'amount_float' => (float)$journal['amount'], // intentional float.
'amount' => $journal['amount'],
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
'date_sort' => $journal['date']->format('Y-m-d'),

View File

@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Rule;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
@ -61,7 +60,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->ruleRepos = app(RuleRepositoryInterface::class);
@ -74,8 +73,8 @@ class CreateController extends Controller
/**
* Create a new rule. It will be stored under the given $ruleGroup.
*
* @param Request $request
* @param RuleGroup|null $ruleGroup
* @param Request $request
* @param RuleGroup|null $ruleGroup
*
* @return Factory|View
*/
@ -89,7 +88,7 @@ class CreateController extends Controller
$oldActions = [];
// build triggers from query, if present.
$query = (string) $request->get('from_query');
$query = (string)$request->get('from_query');
if ('' !== $query) {
$search = app(SearchInterface::class);
$search->parseQuery($query);
@ -113,9 +112,9 @@ class CreateController extends Controller
$subTitleIcon = 'fa-clone';
// title depends on whether or not there is a rule group:
$subTitle = (string) trans('firefly.make_new_rule_no_group');
$subTitle = (string)trans('firefly.make_new_rule_no_group');
if (null !== $ruleGroup) {
$subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
$subTitle = (string)trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
}
// flash old data
@ -136,20 +135,20 @@ class CreateController extends Controller
/**
* Create a new rule. It will be stored under the given $ruleGroup.
*
* @param Request $request
* @param Bill $bill
* @param Request $request
* @param Bill $bill
*
* @return Factory|View
*/
public function createFromBill(Request $request, Bill $bill)
{
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
$this->createDefaultRuleGroup();
$preFilled = [
'strict' => true,
'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
];
// make triggers and actions from the bill itself.
@ -169,7 +168,7 @@ class CreateController extends Controller
$subTitleIcon = 'fa-clone';
// title depends on whether or not there is a rule group:
$subTitle = (string) trans('firefly.make_new_rule_no_group');
$subTitle = (string)trans('firefly.make_new_rule_no_group');
// flash old data
$request->session()->flash('preFilled', $preFilled);
@ -187,17 +186,17 @@ class CreateController extends Controller
}
/**
* @param Request $request
* @param TransactionJournal $journal
* @param Request $request
* @param TransactionJournal $journal
*
* @return Factory|\Illuminate\Contracts\View\View
*/
public function createFromJournal(Request $request, TransactionJournal $journal)
{
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
$subTitleIcon = 'fa-clone';
$subTitle = (string) trans('firefly.make_new_rule_no_group');
$subTitle = (string)trans('firefly.make_new_rule_no_group');
// get triggers and actions for journal.
$oldTriggers = $this->getTriggersForJournal($journal);
@ -208,8 +207,8 @@ class CreateController extends Controller
// collect pre-filled information:
$preFilled = [
'strict' => true,
'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
'title' => (string)trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
];
// restore actions and triggers from old input:
@ -237,12 +236,12 @@ class CreateController extends Controller
}
/**
* @param Request $request
* @param Request $request
* @return JsonResponse
*/
public function duplicate(Request $request): JsonResponse
{
$ruleId = (int) $request->get('id');
$ruleId = (int)$request->get('id');
$rule = $this->ruleRepos->find($ruleId);
if (null !== $rule) {
$this->ruleRepos->duplicate($rule);
@ -254,7 +253,7 @@ class CreateController extends Controller
/**
* Store the new rule.
*
* @param RuleFormRequest $request
* @param RuleFormRequest $request
*
* @return RedirectResponse|Redirector
*
@ -264,22 +263,22 @@ class CreateController extends Controller
$data = $request->getRuleData();
$rule = $this->ruleRepos->store($data);
session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));
session()->flash('success', (string)trans('firefly.stored_new_rule', ['title' => $rule->title]));
app('preferences')->mark();
// redirect to show bill.
if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {
return redirect(route('bills.show', [(int) $request->get('bill_id')]));
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
return redirect(route('bills.show', [(int)$request->get('bill_id')]));
}
// redirect to new bill creation.
if ((int) $request->get('bill_id') > 0) {
if ((int)$request->get('bill_id') > 0) {
return redirect($this->getPreviousUrl('bills.create.url'));
}
$redirect = redirect($this->getPreviousUrl('rules.create.url'));
if (1 === (int) $request->get('create_another')) {
if (1 === (int)$request->get('create_another')) {
session()->put('rules.create.fromStore', true);
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
}

View File

@ -49,7 +49,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->ruleRepos = app(RuleRepositoryInterface::class);
@ -62,13 +62,13 @@ class DeleteController extends Controller
/**
* Delete a given rule.
*
* @param Rule $rule
* @param Rule $rule
*
* @return Factory|View
*/
public function delete(Rule $rule)
{
$subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]);
$subTitle = (string)trans('firefly.delete_rule', ['title' => $rule->title]);
// put previous url in session
$this->rememberPreviousUrl('rules.delete.url');
@ -79,7 +79,7 @@ class DeleteController extends Controller
/**
* Actually destroy the given rule.
*
* @param Rule $rule
* @param Rule $rule
*
* @return RedirectResponse
*/
@ -88,7 +88,7 @@ class DeleteController extends Controller
$title = $rule->title;
$this->ruleRepos->destroy($rule);
session()->flash('success', (string) trans('firefly.deleted_rule', ['title' => $title]));
session()->flash('success', (string)trans('firefly.deleted_rule', ['title' => $title]));
app('preferences')->mark();
return redirect($this->getPreviousUrl('rules.delete.url'));

View File

@ -61,7 +61,7 @@ class EditController 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->ruleRepos = app(RuleRepositoryInterface::class);
@ -74,8 +74,8 @@ class EditController extends Controller
/**
* Edit a rule.
*
* @param Request $request
* @param Rule $rule
* @param Request $request
* @param Rule $rule
*
* @return Factory|View
*/
@ -87,7 +87,7 @@ class EditController extends Controller
$oldTriggers = [];
// build triggers from query, if present.
$query = (string) $request->get('from_query');
$query = (string)$request->get('from_query');
if ('' !== $query) {
$search = app(SearchInterface::class);
$search->parseQuery($query);
@ -117,15 +117,15 @@ class EditController extends Controller
$hasOldInput = null !== $request->old('_token');
$preFilled = [
'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,
'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,
'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,
'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,
'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,
];
// get rule trigger for update / store-journal:
$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);
$subTitle = (string) trans('firefly.edit_rule', ['title' => $rule->title]);
$subTitle = (string)trans('firefly.edit_rule', ['title' => $rule->title]);
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('rules.edit.fromUpdate')) {
@ -139,7 +139,7 @@ class EditController extends Controller
}
/**
* @param array $submittedOperators
* @param array $submittedOperators
*
* @return array
*/
@ -151,7 +151,7 @@ class EditController extends Controller
$triggers = [];
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@ -183,8 +183,8 @@ class EditController extends Controller
/**
* Update the rule.
*
* @param RuleFormRequest $request
* @param Rule $rule
* @param RuleFormRequest $request
* @param Rule $rule
*
* @return RedirectResponse|Redirector
*/
@ -194,10 +194,10 @@ class EditController extends Controller
$this->ruleRepos->update($rule, $data);
session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));
session()->flash('success', (string)trans('firefly.updated_rule', ['title' => $rule->title]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('rules.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
if (1 === (int)$request->get('return_to_edit')) {
session()->put('rules.edit.fromUpdate', true);
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);

View File

@ -1,4 +1,5 @@
<?php
/**
* IndexController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -54,7 +55,7 @@ class IndexController extends Controller
parent::__construct();
$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->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
$this->ruleRepos = app(RuleRepositoryInterface::class);
@ -79,22 +80,22 @@ class IndexController extends Controller
}
/**
* @param Request $request
* @param Rule $rule
* @param RuleGroup $ruleGroup
* @param Request $request
* @param Rule $rule
* @param RuleGroup $ruleGroup
*
* @return JsonResponse
*/
public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse
{
$order = (int) $request->get('order');
$this->ruleRepos->moveRule($rule, $ruleGroup, (int) $order);
$order = (int)$request->get('order');
$this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);
return response()->json([]);
}
/**
* @param Rule $rule
* @param Rule $rule
*
* @return RedirectResponse
*/

View File

@ -59,7 +59,7 @@ class SelectController 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');
return $next($request);
@ -70,8 +70,8 @@ class SelectController extends Controller
/**
* Execute the given rule on a set of existing transactions.
*
* @param SelectTransactionsRequest $request
* @param Rule $rule
* @param SelectTransactionsRequest $request
* @param Rule $rule
*
* @return RedirectResponse
*/
@ -98,7 +98,7 @@ class SelectController extends Controller
$newRuleEngine->fire();
$resultCount = $newRuleEngine->getResults();
session()->flash('success', (string) trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
return redirect()->route('rules.index');
}
@ -106,7 +106,7 @@ class SelectController extends Controller
/**
* View to select transactions by a rule.
*
* @param Rule $rule
* @param Rule $rule
*
* @return Factory|View
*/
@ -120,7 +120,7 @@ class SelectController extends Controller
// does the user have shared accounts?
$first = session('first', Carbon::now()->subYear())->format('Y-m-d');
$today = Carbon::now()->format('Y-m-d');
$subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
}
@ -129,7 +129,7 @@ class SelectController extends Controller
* This method allows the user to test a certain set of rule triggers. The rule triggers are passed along
* using the URL parameters (GET), and are usually put there using a Javascript thing.
*
* @param TestRuleFormRequest $request
* @param TestRuleFormRequest $request
*
* @return JsonResponse
*
@ -146,7 +146,7 @@ class SelectController extends Controller
// warn if nothing.
if (0 === count($textTriggers)) {
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
foreach ($textTriggers as $textTrigger) {
@ -170,7 +170,7 @@ class SelectController extends Controller
// Warn the user if only a subset of transactions is returned
$warning = '';
if (0 === count($collection)) {
$warning = (string) trans('firefly.warning_no_matching_transactions');
$warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response
@ -191,7 +191,7 @@ class SelectController extends Controller
* This method allows the user to test a certain set of rule triggers. The rule triggers are grabbed from
* the rule itself.
*
* @param Rule $rule
* @param Rule $rule
*
* @return JsonResponse
*
@ -201,7 +201,7 @@ class SelectController extends Controller
$triggers = $rule->ruleTriggers;
if (0 === count($triggers)) {
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
}
// create new rule engine:
$newRuleEngine = app(RuleEngineInterface::class);
@ -213,7 +213,7 @@ class SelectController extends Controller
$warning = '';
if (0 === count($collection)) {
$warning = (string) trans('firefly.warning_no_matching_transactions');
$warning = (string)trans('firefly.warning_no_matching_transactions');
}
// Return json response

View File

@ -50,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);
@ -68,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')) {
@ -82,7 +82,7 @@ class CreateController extends Controller
/**
* Store the rule group.
*
* @param RuleGroupFormRequest $request
* @param RuleGroupFormRequest $request
*
* @return RedirectResponse|Redirector
*/
@ -91,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->getPreviousUrl('rule-groups.create.url'));
if (1 === (int) $request->get('create_another')) {
if (1 === (int)$request->get('create_another')) {
session()->put('rule-groups.create.fromStore', true);
$redirect = redirect(route('rule-groups.create'))->withInput();

View File

@ -51,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);
@ -64,13 +64,13 @@ class DeleteController extends Controller
/**
* Delete a rule group.
*
* @param RuleGroup $ruleGroup
* @param RuleGroup $ruleGroup
*
* @return Factory|View
*/
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->rememberPreviousUrl('rule-groups.delete.url');
@ -81,8 +81,8 @@ class DeleteController extends Controller
/**
* Actually destroy the rule group.
*
* @param Request $request
* @param RuleGroup $ruleGroup
* @param Request $request
* @param RuleGroup $ruleGroup
*
* @return RedirectResponse|Redirector
*/
@ -91,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->getPreviousUrl('rule-groups.delete.url'));

View File

@ -52,7 +52,7 @@ class EditController 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);
@ -65,18 +65,18 @@ class EditController extends Controller
/**
* Edit a rule group.
*
* @param Request $request
* @param RuleGroup $ruleGroup
* @param Request $request
* @param RuleGroup $ruleGroup
*
* @return Factory|View
*/
public function edit(Request $request, RuleGroup $ruleGroup)
{
$subTitle = (string) trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
$subTitle = (string)trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
$hasOldInput = null !== $request->old('_token');
$preFilled = [
'active' => $hasOldInput ? (bool) $request->old('active') : $ruleGroup->active,
'active' => $hasOldInput ? (bool)$request->old('active') : $ruleGroup->active,
];
// put previous url in session if not redirect from store (not "return_to_edit").
if (true !== session('rule-groups.edit.fromUpdate')) {
@ -91,26 +91,26 @@ class EditController extends Controller
/**
* Move a rule group in either direction.
*
* @param Request $request
* @param Request $request
*
* @return JsonResponse
*/
public function moveGroup(Request $request): JsonResponse
{
$groupId = (int) $request->get('id');
$groupId = (int)$request->get('id');
$ruleGroup = $this->repository->find($groupId);
if (null !== $ruleGroup) {
$direction = $request->get('direction');
if ('down' === $direction) {
$maxOrder = $this->repository->maxOrder();
$order = (int) $ruleGroup->order;
$order = (int)$ruleGroup->order;
if ($order < $maxOrder) {
$newOrder = $order + 1;
$this->repository->setOrder($ruleGroup, $newOrder);
}
}
if ('up' === $direction) {
$order = (int) $ruleGroup->order;
$order = (int)$ruleGroup->order;
if ($order > 1) {
$newOrder = $order - 1;
$this->repository->setOrder($ruleGroup, $newOrder);
@ -123,8 +123,8 @@ class EditController extends Controller
/**
* Update the rule group.
*
* @param RuleGroupFormRequest $request
* @param RuleGroup $ruleGroup
* @param RuleGroupFormRequest $request
* @param RuleGroup $ruleGroup
*
* @return $this|RedirectResponse|Redirector
*/
@ -133,15 +133,15 @@ class EditController extends Controller
$data = [
'title' => $request->convertString('title'),
'description' => $request->stringWithNewlines('description'),
'active' => 1 === (int) $request->input('active'),
'active' => 1 === (int)$request->input('active'),
];
$this->repository->update($ruleGroup, $data);
session()->flash('success', (string) trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
session()->flash('success', (string)trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('rule-groups.edit.url'));
if (1 === (int) $request->get('return_to_edit')) {
if (1 === (int)$request->get('return_to_edit')) {
session()->put('rule-groups.edit.fromUpdate', true);
$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);

View File

@ -53,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);
@ -66,8 +66,8 @@ class ExecutionController extends Controller
/**
* Execute the given rulegroup on a set of existing transactions.
*
* @param SelectTransactionsRequest $request
* @param RuleGroup $ruleGroup
* @param SelectTransactionsRequest $request
* @param RuleGroup $ruleGroup
*
* @return RedirectResponse
* @throws Exception
@ -95,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');
}
@ -103,7 +103,7 @@ class ExecutionController extends Controller
/**
* Select transactions to apply the group on.
*
* @param RuleGroup $ruleGroup
* @param RuleGroup $ruleGroup
*
* @return Factory|View
*/
@ -111,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 view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
}

View File

@ -1,4 +1,5 @@
<?php
/*
* HealthcheckController.php
* Copyright (c) 2021 https://github.com/ajgon

View File

@ -127,22 +127,22 @@ class InstallController extends Controller
public function index()
{
// index will set FF3 version.
app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
// set new DB version.
app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
return view('install.index');
}
/**
* @param Request $request
* @param Request $request
*
* @return JsonResponse
*/
public function runCommand(Request $request): JsonResponse
{
$requestIndex = (int) $request->get('index');
$requestIndex = (int)$request->get('index');
$response = [
'hasNextCommand' => false,
'done' => true,
@ -156,7 +156,7 @@ class InstallController extends Controller
$index = 0;
/**
* @var string $command
* @var array $args
* @var array $args
*/
foreach ($this->upgradeCommands as $command => $args) {
Log::debug(sprintf('Current command is "%s", index is %d', $command, $index));
@ -182,8 +182,8 @@ class InstallController extends Controller
}
/**
* @param string $command
* @param array $args
* @param string $command
* @param array $args
*
* @return bool
*/

View File

@ -57,7 +57,7 @@ class BulkController extends Controller
$this->middleware(
function ($request, $next) {
$this->repository = app(JournalRepositoryInterface::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);
@ -70,13 +70,13 @@ class BulkController extends Controller
*
* TODO user wont be able to tell if the journal is part of a split.
*
* @param array $journals
* @param array $journals
*
* @return Factory|View
*/
public function edit(array $journals)
{
$subTitle = (string) trans('firefly.mass_bulk_journals');
$subTitle = (string)trans('firefly.mass_bulk_journals');
$this->rememberPreviousUrl('transactions.bulk-edit.url');
@ -93,7 +93,7 @@ class BulkController extends Controller
/**
* Update all journals.
*
* @param BulkEditJournalRequest $request
* @param BulkEditJournalRequest $request
*
* @return Application|RedirectResponse|Redirector
*/
@ -101,14 +101,14 @@ class BulkController extends Controller
{
$journalIds = $request->get('journals');
$journalIds = is_array($journalIds) ? $journalIds : [];
$ignoreCategory = 1 === (int) $request->get('ignore_category');
$ignoreBudget = 1 === (int) $request->get('ignore_budget');
$ignoreCategory = 1 === (int)$request->get('ignore_category');
$ignoreBudget = 1 === (int)$request->get('ignore_budget');
$tagsAction = $request->get('tags_action');
$collection = new Collection();
$count = 0;
foreach ($journalIds as $journalId) {
$journalId = (int) $journalId;
$journalId = (int)$journalId;
$journal = $this->repository->find($journalId);
if (null !== $journal) {
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
@ -128,16 +128,16 @@ class BulkController extends Controller
}
app('preferences')->mark();
$request->session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));
$request->session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
// redirect to previous URL:
return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));
}
/**
* @param TransactionJournal $journal
* @param bool $ignoreUpdate
* @param int $budgetId
* @param TransactionJournal $journal
* @param bool $ignoreUpdate
* @param int $budgetId
*
* @return bool
*/
@ -153,9 +153,9 @@ class BulkController extends Controller
}
/**
* @param TransactionJournal $journal
* @param string $action
* @param array $tags
* @param TransactionJournal $journal
* @param string $action
* @param array $tags
*
* @return bool
*/
@ -175,9 +175,9 @@ class BulkController extends Controller
}
/**
* @param TransactionJournal $journal
* @param bool $ignoreUpdate
* @param string $category
* @param TransactionJournal $journal
* @param bool $ignoreUpdate
* @param string $category
*
* @return bool
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* ConvertController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -70,7 +71,7 @@ class ConvertController extends Controller
function ($request, $next) {
$this->repository = app(JournalRepositoryInterface::class);
$this->accountRepository = app(AccountRepositoryInterface::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);
@ -81,8 +82,8 @@ class ConvertController extends Controller
/**
* Show overview of a to be converted transaction.
*
* @param TransactionType $destinationType
* @param TransactionGroup $group
* @param TransactionType $destinationType
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector|Factory|View
* @throws Exception
@ -103,7 +104,7 @@ class ConvertController extends Controller
$groupTitle = $group->title ?? $first->description;
$groupArray = $transformer->transformObject($group);
$subTitle = (string) trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]);
$subTitle = (string)trans('firefly.convert_to_'.$destinationType->type, ['description' => $groupTitle]);
$subTitleIcon = 'fa-exchange';
// get a list of asset accounts and liabilities and stuff, in various combinations:
@ -119,7 +120,7 @@ class ConvertController extends Controller
if ($sourceType->type === $destinationType->type) { // cannot convert to its own type.
Log::debug('This is already a transaction of the expected type..');
session()->flash('info', (string) trans('firefly.convert_is_already_type_' . $destinationType->type));
session()->flash('info', (string)trans('firefly.convert_is_already_type_'.$destinationType->type));
return redirect(route('transactions.show', [$group->id]));
}
@ -156,7 +157,7 @@ class ConvertController extends Controller
// group accounts:
/** @var Account $account */
foreach ($accountList as $account) {
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
$name = $account->name;
if ('' === $role) {
$role = 'no_account_type';
@ -164,7 +165,7 @@ class ConvertController extends Controller
// maybe it's a liability thing:
if (in_array($account->accountType->type, $liabilityTypes, true)) {
$role = 'l_' . $account->accountType->type;
$role = 'l_'.$account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
$role = 'cash_account';
@ -174,7 +175,7 @@ class ConvertController extends Controller
$role = 'revenue_account';
}
$key = (string) trans('firefly.opt_group_' . $role);
$key = (string)trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $name;
}
@ -195,7 +196,7 @@ class ConvertController extends Controller
// group accounts:
/** @var Account $account */
foreach ($accountList as $account) {
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
$name = $account->name;
if ('' === $role) {
$role = 'no_account_type';
@ -203,7 +204,7 @@ class ConvertController extends Controller
// maybe it's a liability thing:
if (in_array($account->accountType->type, $liabilityTypes, true)) {
$role = 'l_' . $account->accountType->type;
$role = 'l_'.$account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
$role = 'cash_account';
@ -213,7 +214,7 @@ class ConvertController extends Controller
$role = 'expense_account';
}
$key = (string) trans('firefly.opt_group_' . $role);
$key = (string)trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $name;
}
@ -235,9 +236,9 @@ class ConvertController extends Controller
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) . ')';
$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;
@ -258,13 +259,13 @@ class ConvertController extends Controller
foreach ($accountList as $account) {
$balance = app('steam')->balance($account, today());
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
if ('' === $role) {
$role = 'no_account_type';
}
$key = (string) trans('firefly.opt_group_' . $role);
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
$key = (string)trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
}
return $grouped;
@ -273,9 +274,9 @@ class ConvertController extends Controller
/**
* Do the conversion.
*
* @param Request $request
* @param TransactionType $destinationType
* @param TransactionGroup $group
* @param Request $request
* @param TransactionType $destinationType
* @param TransactionGroup $group
*
* @return RedirectResponse|Redirector
*
@ -301,16 +302,16 @@ class ConvertController extends Controller
// correct transfers:
$group->refresh();
session()->flash('success', (string) trans('firefly.converted_to_' . $destinationType->type));
session()->flash('success', (string)trans('firefly.converted_to_'.$destinationType->type));
event(new UpdatedTransactionGroup($group, true, true));
return redirect(route('transactions.show', [$group->id]));
}
/**
* @param TransactionJournal $journal
* @param TransactionType $transactionType
* @param array $data
* @param TransactionJournal $journal
* @param TransactionType $transactionType
* @param array $data
*
* @return TransactionJournal
* @throws FireflyException
@ -328,10 +329,10 @@ class ConvertController extends Controller
$destinationName = $data['destination_name'][$journal->id] ?? null;
// double check its not an empty string.
$sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;
$sourceName = '' === $sourceName ? null : (string) $sourceName;
$destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId;
$destinationName = '' === $destinationName ? null : (string) $destinationName;
$sourceId = '' === $sourceId || null === $sourceId ? null : (int)$sourceId;
$sourceName = '' === $sourceName ? null : (string)$sourceName;
$destinationId = '' === $destinationId || null === $destinationId ? null : (int)$destinationId;
$destinationName = '' === $destinationName ? null : (string)$destinationName;
$validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName,]);
$validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName,]);

View File

@ -33,6 +33,9 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use JsonException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class CreateController
@ -52,7 +55,7 @@ class CreateController 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(TransactionGroupRepositoryInterface::class);
@ -62,13 +65,13 @@ class CreateController extends Controller
}
/**
* @param Request $request
* @param Request $request
*
* @return JsonResponse
*/
public function cloneGroup(Request $request): JsonResponse
{
$groupId = (int) $request->get('id');
$groupId = (int)$request->get('id');
if (0 !== $groupId) {
$group = $this->repository->find($groupId);
if (null !== $group) {
@ -96,26 +99,26 @@ class CreateController extends Controller
/**
* Create a new transaction group.
*
* @param string|null $objectType
* @param string|null $objectType
*
* @return Factory|View
* @throws FireflyException
* @throws \JsonException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws JsonException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function create(?string $objectType)
{
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 $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$cash = $accountRepository->getCashAccount();
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
$subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
$subTitle = (string)trans(sprintf('breadcrumbs.create_%s', strtolower((string)$objectType)));
$subTitleIcon = 'fa-plus';
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
$allowedOpposingTypes = config('firefly.allowed_opposing_types');

View File

@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use FireflyIII\Events\DestroyedTransactionGroup;
use FireflyIII\Events\UpdatedAccount;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
@ -57,7 +56,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);
@ -70,7 +69,7 @@ class DeleteController extends Controller
/**
* Shows the form that allows a user to delete a transaction journal.
*
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return Factory|View|Redirector|RedirectResponse
*/
@ -87,7 +86,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 = app('steam')->getSafePreviousUrl(route('index'));
// put previous url in session
Log::debug('Will try to remember previous URL');
@ -99,7 +98,7 @@ class DeleteController extends Controller
/**
* Actually destroys the journal.
*
* @param TransactionGroup $group
* @param TransactionGroup $group
*
* @return RedirectResponse
*/
@ -114,7 +113,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]));
// grab asset account(s) from group:
$accounts = [];

View File

@ -48,7 +48,7 @@ class EditController extends Controller
// some useful repositories:
$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);
@ -57,7 +57,7 @@ class EditController extends Controller
}
/**
* @param TransactionGroup $transactionGroup
* @param TransactionGroup $transactionGroup
*
* @return Factory|View|RedirectResponse|Redirector
*/

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@ -32,6 +32,8 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class IndexController
@ -55,7 +57,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);
@ -67,15 +69,15 @@ class IndexController extends Controller
/**
* Index for a range of transactions.
*
* @param Request $request
* @param string $objectType
* @param Carbon|null $start
* @param Carbon|null $end
* @param Request $request
* @param string $objectType
* @param Carbon|null $start
* @param Carbon|null $end
*
* @return Factory|View
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws FireflyException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
{
@ -83,10 +85,10 @@ class IndexController extends Controller
$objectType = 'transfer';
}
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
$types = config('firefly.transactionTypesByType.' . $objectType);
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
$types = config('firefly.transactionTypesByType.'.$objectType);
$page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
if (null === $start) {
$start = session('start');
$end = session('end');
@ -101,7 +103,7 @@ class IndexController extends Controller
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$startStr = $start->isoFormat($this->monthAndDayFormat);
$endStr = $end->isoFormat($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;
@ -128,26 +130,26 @@ class IndexController extends Controller
/**
* Index for ALL transactions.
*
* @param Request $request
* @param string $objectType
* @param Request $request
* @param string $objectType
*
* @return Factory|View
* @throws \FireflyIII\Exceptions\FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws FireflyException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
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;
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
$types = config('firefly.transactionTypesByType.'.$objectType);
$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);

View File

@ -1,4 +1,5 @@
<?php
/**
* LinkController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -54,7 +55,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);
@ -68,14 +69,14 @@ class LinkController extends Controller
/**
* Delete a link.
*
* @param TransactionJournalLink $link
* @param TransactionJournalLink $link
*
* @return Factory|View
*/
public function delete(TransactionJournalLink $link)
{
$subTitleIcon = 'fa-link';
$subTitle = (string) trans('breadcrumbs.delete_journal_link');
$subTitle = (string)trans('breadcrumbs.delete_journal_link');
$this->rememberPreviousUrl('journal_links.delete.url');
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
@ -84,7 +85,7 @@ class LinkController extends Controller
/**
* Actually destroy it.
*
* @param TransactionJournalLink $link
* @param TransactionJournalLink $link
*
* @return RedirectResponse|Redirector
*/
@ -92,14 +93,14 @@ 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.url'));
return redirect((string)session('journal_links.delete.url'));
}
/**
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @return Factory|View
*/
@ -113,8 +114,8 @@ class LinkController extends Controller
/**
* Store a new link.
*
* @param JournalLinkRequest $request
* @param TransactionJournal $journal
* @param JournalLinkRequest $request
* @param TransactionJournal $journal
*
* @return RedirectResponse|Redirector
*/
@ -125,7 +126,7 @@ class LinkController extends Controller
Log::debug('We are here (store)');
$other = $this->journalRepository->find($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 +134,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]));
}
@ -153,12 +154,12 @@ class LinkController extends Controller
/**
* Switch link from A <> B to B <> A.
*
* @param Request $request
* @param Request $request
* @return RedirectResponse|Redirector
*/
public function switchLink(Request $request)
{
$linkId = (int) $request->get('id');
$linkId = (int)$request->get('id');
$this->repository->switchLinkById($linkId);
return redirect(app('steam')->getSafePreviousUrl());

View File

@ -1,4 +1,5 @@
<?php
/**
* MassController.php
* Copyright (c) 2019 james@firefly-iii.org
@ -61,7 +62,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);
@ -73,13 +74,13 @@ class MassController extends Controller
/**
* Mass delete transactions.
*
* @param array $journals
* @param array $journals
*
* @return IlluminateView
*/
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->rememberPreviousUrl('transactions.mass-delete.url');
@ -90,7 +91,7 @@ class MassController extends Controller
/**
* Do the mass delete.
*
* @param MassDeleteJournalRequest $request
* @param MassDeleteJournalRequest $request
*
* @return Application|Redirector|RedirectResponse
*
@ -103,15 +104,15 @@ class MassController extends Controller
/** @var string $journalId */
foreach ($ids as $journalId) {
/** @var TransactionJournal $journal */
$journal = $this->repository->find((int) $journalId);
if (null !== $journal && (int) $journalId === $journal->id) {
$journal = $this->repository->find((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->getPreviousUrl('transactions.mass-delete.url'));
@ -120,13 +121,13 @@ class MassController extends Controller
/**
* Mass edit of journals.
*
* @param array $journals
* @param array $journals
*
* @return IlluminateView
*/
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);
@ -158,7 +159,7 @@ class MassController extends Controller
/**
* Mass update of journals.
*
* @param MassEditJournalRequest $request
* @param MassEditJournalRequest $request
*
* @return RedirectResponse|Redirector
* @throws FireflyException
@ -173,7 +174,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,15 +184,15 @@ 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->getPreviousUrl('transactions.mass-edit.url'));
}
/**
* @param int $journalId
* @param MassEditJournalRequest $request
* @param int $journalId
* @param MassEditJournalRequest $request
*
* @throws FireflyException
*/
@ -227,9 +228,9 @@ class MassController extends Controller
}
/**
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $key
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $key
*
* @return Carbon|null
* @codeCoverageIgnore
@ -255,9 +256,9 @@ class MassController extends Controller
}
/**
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $string
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $string
*
* @return string|null
* @codeCoverageIgnore
@ -272,13 +273,13 @@ class MassController extends Controller
return null;
}
return (string) $value[$journalId];
return (string)$value[$journalId];
}
/**
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $string
* @param MassEditJournalRequest $request
* @param int $journalId
* @param string $string
*
* @return int|null
* @codeCoverageIgnore
@ -293,6 +294,6 @@ class MassController extends Controller
return null;
}
return (int) $value[$journalId];
return (int)$value[$journalId];
}
}

View File

@ -41,8 +41,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;
*/
class ShowController extends Controller
{
private TransactionGroupRepositoryInterface $repository;
private ALERepositoryInterface $ALERepository;
private TransactionGroupRepositoryInterface $repository;
/**
* ShowController constructor.
@ -57,7 +57,7 @@ class ShowController extends Controller
$this->repository = app(TransactionGroupRepositoryInterface::class);
$this->ALERepository = app(ALERepositoryInterface::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);
@ -66,7 +66,7 @@ class ShowController extends Controller
}
/**
* @param TransactionGroup $transactionGroup
* @param TransactionGroup $transactionGroup
*
* @return JsonResponse
*/
@ -76,8 +76,8 @@ class ShowController extends Controller
}
/**
* @param Request $request
* @param TransactionGroup $transactionGroup
* @param Request $request
* @param TransactionGroup $transactionGroup
*
* @return Factory|View
* @throws FireflyException
@ -92,7 +92,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);
@ -140,7 +140,7 @@ class ShowController extends Controller
}
/**
* @param array $group
* @param array $group
*
* @return array
*/
@ -175,7 +175,7 @@ class ShowController extends Controller
}
/**
* @param array $group
* @param array $group
*
* @return array
*/
@ -188,12 +188,14 @@ class ShowController extends Controller
'type' => $transaction['source_type'],
'id' => $transaction['source_id'],
'name' => $transaction['source_name'],
'iban' => $transaction['source_iban']];
'iban' => $transaction['source_iban'],
];
$accounts['destination'][] = [
'type' => $transaction['destination_type'],
'id' => $transaction['destination_id'],
'name' => $transaction['destination_name'],
'iban' => $transaction['destination_iban']];
'iban' => $transaction['destination_iban'],
];
}
$accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);

View File

@ -45,8 +45,8 @@ class CreateController extends Controller
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-plus');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('subTitle', (string) trans('firefly.create_new_webhook'));
app('view')->share('title', (string)trans('firefly.webhooks'));
app('view')->share('subTitle', (string)trans('firefly.create_new_webhook'));
return $next($request);
}

View File

@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
@ -50,8 +49,8 @@ class DeleteController extends Controller
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-trash');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('subTitle', (string) trans('firefly.delete_webhook'));
app('view')->share('title', (string)trans('firefly.webhooks'));
app('view')->share('subTitle', (string)trans('firefly.delete_webhook'));
return $next($request);
}
@ -61,13 +60,13 @@ class DeleteController extends Controller
/**
* Delete account screen.
*
* @param Webhook $webhook
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->name]);
$subTitle = (string)trans('firefly.delete_webhook', ['title' => $webhook->name]);
$this->rememberPreviousUrl('webhooks.delete.url');
return view('webhooks.delete', compact('webhook', 'subTitle'));

View File

@ -24,12 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
@ -52,7 +49,7 @@ class EditController extends Controller
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-pencil');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('title', (string)trans('firefly.webhooks'));
return $next($request);
}
@ -62,13 +59,13 @@ class EditController extends Controller
/**
* Delete account screen.
*
* @param Webhook $webhook
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]);
$subTitle = (string)trans('firefly.edit_webhook', ['title' => $webhook->title]);
$this->rememberPreviousUrl('webhooks.delete.url');
return view('webhooks.edit', compact('webhook', 'subTitle'));

View File

@ -46,16 +46,17 @@ class IndexController extends Controller
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('title', (string)trans('firefly.webhooks'));
return $next($request);
}
);
}
/**
* Show debug info.
*
* @param Request $request
* @param Request $request
*
* @return Factory|View
* @throws FireflyException

View File

@ -24,12 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
@ -52,7 +49,7 @@ class ShowController extends Controller
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-bolt');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('title', (string)trans('firefly.webhooks'));
return $next($request);
}
@ -62,13 +59,13 @@ class ShowController extends Controller
/**
* Delete account screen.
*
* @param Webhook $webhook
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]);
$subTitle = (string)trans('firefly.show_webhook', ['title' => $webhook->title]);
return view('webhooks.show', compact('webhook', 'subTitle'));
}

View File

@ -27,7 +27,6 @@ namespace FireflyIII\Http\Middleware;
use FireflyIII\Exceptions\BadHttpHeaderException;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Log;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
/**
@ -38,8 +37,8 @@ class AcceptHeaders
/**
* Handle the incoming requests.
*
* @param Request $request
* @param callable $next
* @param Request $request
* @param callable $next
* @return Response
* @throws BadHttpHeaderException
*/
@ -50,7 +49,7 @@ class AcceptHeaders
if ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {
throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');
}
$allowed = ['application/x-www-form-urlencoded','application/json'];
$allowed = ['application/x-www-form-urlencoded', 'application/json'];
$submitted = (string)$request->header('Content-Type');
if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {
$error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));

View File

@ -47,7 +47,7 @@ class Authenticate
/**
* Create a new middleware instance.
*
* @param Auth $auth
* @param Auth $auth
*
* @return void
*/
@ -59,9 +59,9 @@ class Authenticate
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param string[] ...$guards
* @param Request $request
* @param Closure $next
* @param string[] ...$guards
*
* @return mixed
*
@ -78,8 +78,8 @@ class Authenticate
/**
* Determine if the user is logged in to any of the given guards.
*
* @param mixed $request
* @param array $guards
* @param mixed $request
* @param array $guards
*
* @return mixed
* @throws FireflyException
@ -94,10 +94,10 @@ class Authenticate
// do an extra check on user object.
/** @var User $user */
$user = $this->auth->authenticate();
if (1 === (int) $user->blocked) {
$message = (string) trans('firefly.block_account_logout');
if (1 === (int)$user->blocked) {
$message = (string)trans('firefly.block_account_logout');
if ('email_changed' === $user->blocked_code) {
$message = (string) trans('firefly.email_changed_logout');
$message = (string)trans('firefly.email_changed_logout');
}
app('session')->flash('logoutMessage', $message);
$this->auth->logout();

View File

@ -1,4 +1,5 @@
<?php
/**
* Binder.php
* Copyright (c) 2019 james@firefly-iii.org
@ -49,7 +50,7 @@ class Binder
/**
* Binder constructor.
*
* @param Auth $auth
* @param Auth $auth
*/
public function __construct(Auth $auth)
{
@ -60,8 +61,8 @@ class Binder
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*
@ -81,9 +82,9 @@ class Binder
/**
* Do the binding.
*
* @param string $key
* @param string $value
* @param Route $route
* @param string $key
* @param string $value
* @param Route $route
*
* @return mixed
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* EncryptCookies.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -38,8 +38,8 @@ class InstallationId
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*

View File

@ -43,8 +43,8 @@ class Installer
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*
@ -118,7 +118,7 @@ class Installer
/**
* Is access denied error.
*
* @param string $message
* @param string $message
*
* @return bool
*/
@ -130,7 +130,7 @@ class Installer
/**
* Is no tables exist error.
*
* @param string $message
* @param string $message
*
* @return bool
*/
@ -147,8 +147,8 @@ class Installer
private function oldDBVersion(): bool
{
// older version in config than database?
$configVersion = (int) config('firefly.db_version');
$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;
$configVersion = (int)config('firefly.db_version');
$dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;
if ($configVersion > $dbVersion) {
app('log')->warning(
sprintf(
@ -174,8 +174,8 @@ class Installer
private function oldVersion(): bool
{
// version compare thing.
$configVersion = (string) config('firefly.version');
$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
$configVersion = (string)config('firefly.version');
$dbVersion = (string)app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
if (1 === version_compare($configVersion, $dbVersion)) {
app('log')->warning(
sprintf(

View File

@ -40,8 +40,8 @@ class InterestingMessage
/**
* Flashes the user an interesting message if the URL parameters warrant it.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*
@ -82,7 +82,7 @@ class InterestingMessage
}
/**
* @param Request $request
* @param Request $request
*
* @return bool
*/
@ -96,7 +96,7 @@ class InterestingMessage
}
/**
* @param Request $request
* @param Request $request
*/
private function handleGroupMessage(Request $request): void
{
@ -106,7 +106,7 @@ class InterestingMessage
// send message about newly created transaction group.
/** @var TransactionGroup $group */
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int) $transactionGroupId);
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int)$transactionGroupId);
if (null === $group) {
return;
@ -122,22 +122,22 @@ class InterestingMessage
$title = $count > 1 ? $group->title : $journal->description;
if ('created' === $message) {
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string) trans('firefly.stored_journal', ['description' => $title]));
session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));
}
if ('updated' === $message) {
$type = strtolower($journal->transactionType->type);
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
session()->flash('success', (string) trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
}
if ('no_change' === $message) {
$type = strtolower($journal->transactionType->type);
session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));
session()->flash('warning', (string) trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
}
}
/**
* @param Request $request
* @param Request $request
*
* @return bool
*/
@ -151,7 +151,7 @@ class InterestingMessage
}
/**
* @param Request $request
* @param Request $request
*/
private function handleAccountMessage(Request $request): void
{
@ -166,18 +166,18 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string) trans('firefly.account_deleted', ['name' => $account->name]));
session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));
}
if ('created' === $message) {
session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
}
if ('updated' === $message) {
session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
}
}
/**
* @param Request $request
* @param Request $request
*
* @return bool
*/
@ -189,22 +189,9 @@ class InterestingMessage
return null !== $billId && null !== $message;
}
/**
* @param Request $request
*
* @return bool
*/
private function webhookMessage(Request $request): bool
{
// get parameters from request.
$billId = $request->get('webhook_id');
$message = $request->get('message');
return null !== $billId && null !== $message;
}
/**
* @param Request $request
* @param Request $request
*/
private function handleBillMessage(Request $request): void
{
@ -219,21 +206,35 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $bill->name]));
session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));
}
if ('created' === $message) {
session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));
session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
}
}
/**
* @param Request $request
* @param Request $request
*
* @return bool
*/
private function webhookMessage(Request $request): bool
{
// get parameters from request.
$billId = $request->get('webhook_id');
$message = $request->get('message');
return null !== $billId && null !== $message;
}
/**
* @param Request $request
*/
private function handleWebhookMessage(Request $request): void
{
// get parameters from request.
$webhookId = $request->get('webhook_id');
$message = $request->get('message');
$webhookId = $request->get('webhook_id');
$message = $request->get('message');
/** @var Webhook $webhook */
$webhook = auth()->user()->webhooks()->withTrashed()->find($webhookId);
@ -242,13 +243,13 @@ class InterestingMessage
return;
}
if ('deleted' === $message) {
session()->flash('success', (string) trans('firefly.deleted_webhook', ['title' => $webhook->title]));
session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));
}
if ('updated' === $message) {
session()->flash('success', (string) trans('firefly.updated_webhook', ['title' => $webhook->title]));
session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));
}
if ('created' === $message) {
session()->flash('success', (string) trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
}
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* IsAdmin.php
* Copyright (c) 2019 james@firefly-iii.org
@ -36,9 +37,9 @@ class IsAdmin
/**
* Handle an incoming request. Must be admin.
*
* @param Request $request
* @param Closure $next
* @param string|null $guard
* @param Request $request
* @param Closure $next
* @param string|null $guard
*
* @return mixed
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* IsDemoUser.php
* Copyright (c) 2019 james@firefly-iii.org
@ -36,8 +37,8 @@ class IsDemoUser
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
@ -53,7 +54,7 @@ class IsDemoUser
$repository = app(UserRepositoryInterface::class);
if ($repository->hasRole($user, 'demo')) {
Log::info('User is a demo user.');
$request->session()->flash('info', (string) trans('firefly.not_available_demo_user'));
$request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));
$current = $request->url();
$previous = $request->session()->previousUrl();
if ($current !== $previous) {

View File

@ -1,4 +1,5 @@
<?php
/**
* Range.php
* Copyright (c) 2019 james@firefly-iii.org
@ -40,8 +41,8 @@ class Range
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
@ -112,12 +113,12 @@ class Range
}
// save some formats:
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
$monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
$dateTimeFormat = (string)trans('config.date_time_js', [], $locale);
$defaultCurrency = app('amount')->getDefaultCurrency();
// also format for moment JS:
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
$madMomentJS = (string)trans('config.month_and_day_moment_js', [], $locale);
app('view')->share('madMomentJS', $madMomentJS);
app('view')->share('monthAndDayFormat', $monthAndDayFormat);

View File

@ -1,4 +1,5 @@
<?php
/**
* RedirectIfAuthenticated.php
* Copyright (c) 2019 james@firefly-iii.org
@ -36,9 +37,9 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param string|null $guard
* @param Request $request
* @param Closure $next
* @param string|null $guard
*
* @return mixed
*/

View File

@ -36,8 +36,8 @@ class SecureHeaders
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
* @throws Exception
@ -64,8 +64,8 @@ class SecureHeaders
$route = $request->route();
$customUrl = '';
$authGuard = (string) config('firefly.authentication_guard');
$logoutUrl = (string) config('firefly.custom_logout_url');
$authGuard = (string)config('firefly.authentication_guard');
$logoutUrl = (string)config('firefly.custom_logout_url');
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
$customUrl = $logoutUrl;
}
@ -115,8 +115,8 @@ class SecureHeaders
*/
private function getTrackingScriptSource(): string
{
if ('' !== (string) config('firefly.tracker_site_id') && '' !== (string) config('firefly.tracker_url')) {
return (string) config('firefly.tracker_url');
if ('' !== (string)config('firefly.tracker_site_id') && '' !== (string)config('firefly.tracker_url')) {
return (string)config('firefly.tracker_url');
}
return '';

View File

@ -1,4 +1,5 @@
<?php
/**
* StartFireflySession.php
* Copyright (c) 2019 james@firefly-iii.org
@ -36,8 +37,8 @@ class StartFireflySession extends StartSession
/**
* Store the current URL for the request if necessary.
*
* @param Request $request
* @param Session $session
* @param Request $request
* @param Session $session
*/
protected function storeCurrentUrl(Request $request, $session): void
{

View File

@ -1,4 +1,5 @@
<?php
/**
* TrimStrings.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* TrustProxies.php
* Copyright (c) 2019 james@firefly-iii.org
@ -45,6 +46,6 @@ class TrustProxies extends Middleware
*/
public function __construct()
{
$this->proxies = (string) config('firefly.trusted_proxies');
$this->proxies = (string)config('firefly.trusted_proxies');
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* VerifyCsrfToken.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* AccountFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -107,12 +108,12 @@ class AccountFormRequest extends FormRequest
'virtual_balance' => 'numeric|nullable|max:1000000000',
'currency_id' => 'exists:transaction_currencies,id',
'account_number' => 'between:1,255|uniqueAccountNumberForUser|nullable',
'account_role' => 'in:' . $accountRoles,
'account_role' => 'in:'.$accountRoles,
'active' => 'boolean',
'cc_type' => 'in:' . $ccPaymentTypes,
'cc_type' => 'in:'.$ccPaymentTypes,
'amount_currency_id_opening_balance' => 'exists:transaction_currencies,id',
'amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id',
'what' => 'in:' . $types,
'what' => 'in:'.$types,
'interest_period' => 'in:daily,monthly,yearly',
];
$rules = Location::requestRules($rules);
@ -122,7 +123,7 @@ class AccountFormRequest extends FormRequest
if (null !== $account) {
// add rules:
$rules['id'] = 'belongsToUser:accounts';
$rules['name'] = 'required|min:1|uniqueAccountForUser:' . $account->id;
$rules['name'] = 'required|min:1|uniqueAccountForUser:'.$account->id;
$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];
}

View File

@ -1,4 +1,5 @@
<?php
/**
* AttachmentFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* BillStoreRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* BillUpdateRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* BudgetFormStoreRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -75,7 +76,7 @@ class BudgetFormStoreRequest extends FormRequest
/**
* Configure the validator instance with special rules for after the basic validation rules.
*
* @param Validator $validator
* @param Validator $validator
*
* @return void
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* BudgetFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -69,7 +70,7 @@ class BudgetFormUpdateRequest extends FormRequest
$budget = $this->route()->parameter('budget');
if (null !== $budget) {
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . $budget->id;
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,'.$budget->id;
}
return [
@ -85,7 +86,7 @@ class BudgetFormUpdateRequest extends FormRequest
/**
* Configure the validator instance with special rules for after the basic validation rules.
*
* @param Validator $validator
* @param Validator $validator
*
* @return void
*/

View File

@ -1,4 +1,5 @@
<?php
/**
* BudgetIncomeRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* BulkEditJournalRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* CategoryFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -60,7 +61,7 @@ class CategoryFormRequest extends FormRequest
$category = $this->route()->parameter('category');
if (null !== $category) {
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,' . $category->id;
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,'.$category->id;
}
// fixed

View File

@ -1,4 +1,5 @@
<?php
/**
* ConfigurationRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* CurrencyFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* DeleteAccountFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* EmailFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* JournalLinkRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -45,7 +46,7 @@ class JournalLinkRequest extends FormRequest
$return = [];
$linkType = $this->get('link_type');
$parts = explode('_', $linkType);
$return['link_type_id'] = (int) $parts[0];
$return['link_type_id'] = (int)$parts[0];
$return['transaction_journal_id'] = $this->convertInteger('opposing');
$return['notes'] = $this->convertString('notes');
$return['direction'] = $parts[1];

View File

@ -1,4 +1,5 @@
<?php
/**
* LinkTypeFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* MassDeleteJournalRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* MassEditJournalRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* NewUserFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* ObjectGroupFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* PiggyBankStoreRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* PiggyBankUpdateRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* ProfileFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -191,7 +191,7 @@ class RecurrenceFormRequest extends FormRequest
$rules = [
// mandatory info for recurrence.
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
'first_date' => 'required|date|after:' . $today->format('Y-m-d'),
'first_date' => 'required|date|after:'.$today->format('Y-m-d'),
'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],
'skip' => 'required|numeric|integer|gte:0|lte:31',
@ -235,7 +235,7 @@ class RecurrenceFormRequest extends FormRequest
// if ends at date X, set another rule.
if ('until_date' === $this->convertString('repetition_end')) {
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
$rules['repeat_until'] = 'required|date|after:'.$tomorrow->format('Y-m-d');
}
// switch on type to expand rules for source and destination accounts:
@ -263,7 +263,7 @@ class RecurrenceFormRequest extends FormRequest
$recurrence = $this->route()->parameter('recurrence');
if ($recurrence instanceof Recurrence) {
$rules['id'] = 'required|numeric|exists:recurrences,id';
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,'.$recurrence->id;
$rules['first_date'] = 'required|date';
}
@ -273,7 +273,7 @@ class RecurrenceFormRequest extends FormRequest
/**
* Configure the validator instance with special rules for after the basic validation rules.
*
* @param Validator $validator
* @param Validator $validator
*
* @return void
*/
@ -290,7 +290,7 @@ class RecurrenceFormRequest extends FormRequest
/**
* Validates the given account information. Switches on given transaction type.
*
* @param Validator $validator
* @param Validator $validator
*
* @throws FireflyException
*/
@ -314,16 +314,16 @@ class RecurrenceFormRequest extends FormRequest
default:
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
case 'withdrawal':
$sourceId = (int) $data['source_id'];
$destinationId = (int) $data['withdrawal_destination_id'];
$sourceId = (int)$data['source_id'];
$destinationId = (int)$data['withdrawal_destination_id'];
break;
case 'deposit':
$sourceId = (int) $data['deposit_source_id'];
$destinationId = (int) $data['destination_id'];
$sourceId = (int)$data['deposit_source_id'];
$destinationId = (int)$data['destination_id'];
break;
case 'transfer':
$sourceId = (int) $data['source_id'];
$destinationId = (int) $data['destination_id'];
$sourceId = (int)$data['source_id'];
$destinationId = (int)$data['destination_id'];
break;
}
// validate source account.
@ -331,7 +331,7 @@ class RecurrenceFormRequest extends FormRequest
// do something with result:
if (false === $validSource) {
$message = (string) trans('validation.generic_invalid_source');
$message = (string)trans('validation.generic_invalid_source');
$validator->errors()->add('source_id', $message);
$validator->errors()->add('deposit_source_id', $message);
@ -342,7 +342,7 @@ class RecurrenceFormRequest extends FormRequest
$validDestination = $accountValidator->validateDestination(['id' => $destinationId,]);
// do something with result:
if (false === $validDestination) {
$message = (string) trans('validation.generic_invalid_destination');
$message = (string)trans('validation.generic_invalid_destination');
$validator->errors()->add('destination_id', $message);
$validator->errors()->add('withdrawal_destination_id', $message);
}

View File

@ -1,4 +1,5 @@
<?php
/**
* ReportFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -55,7 +56,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find((int) $accountId);
$account = $repository->find((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@ -78,7 +79,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $budgetId) {
$budget = $repository->find((int) $budgetId);
$budget = $repository->find((int)$budgetId);
if (null !== $budget) {
$collection->push($budget);
}
@ -101,7 +102,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find((int) $categoryId);
$category = $repository->find((int)$categoryId);
if (null !== $category) {
$collection->push($category);
}
@ -124,7 +125,7 @@ class ReportFormRequest extends FormRequest
$collection = new Collection();
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find((int) $accountId);
$account = $repository->find((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
@ -145,7 +146,7 @@ class ReportFormRequest extends FormRequest
{
$date = today(config('app.timezone'));
$range = $this->get('daterange');
$parts = explode(' - ', (string) $range);
$parts = explode(' - ', (string)$range);
if (2 === count($parts)) {
$string = $parts[1];
// validate as date
@ -179,7 +180,7 @@ class ReportFormRequest extends FormRequest
{
$date = today(config('app.timezone'));
$range = $this->get('daterange');
$parts = explode(' - ', (string) $range);
$parts = explode(' - ', (string)$range);
if (2 === count($parts)) {
$string = $parts[0];
// validate as date
@ -223,7 +224,7 @@ class ReportFormRequest extends FormRequest
$collection->push($tag);
continue;
}
$tag = $repository->find((int) $tagTag);
$tag = $repository->find((int)$tagTag);
if (null !== $tag) {
$collection->push($tag);
}

View File

@ -1,4 +1,5 @@
<?php
/**
* RuleGroupFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -68,7 +69,7 @@ class RuleGroupFormRequest extends FormRequest
$ruleGroup = $this->route()->parameter('ruleGroup');
if (null !== $ruleGroup) {
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id;
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id;
}
return [

View File

@ -1,4 +1,5 @@
<?php
/**
* SelectTransactionsRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -49,8 +50,8 @@ class SelectTransactionsRequest extends FormRequest
$today = Carbon::now()->addDay()->format('Y-m-d');
return [
'start' => 'required|date|after:' . $first,
'end' => 'required|date|before:' . $today,
'start' => 'required|date|after:'.$first,
'end' => 'required|date|before:'.$today,
'accounts' => 'required',
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
];

View File

@ -1,4 +1,5 @@
<?php
/**
* TagFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -68,7 +69,7 @@ class TagFormRequest extends FormRequest
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
if (null !== $tag) {
$idRule = 'belongsToUser:tags';
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $tag->id;
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,'.$tag->id;
}
$rules = [

View File

@ -1,4 +1,5 @@
<?php
/**
* TestRuleFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org
@ -48,7 +49,7 @@ class TestRuleFormRequest extends FormRequest
$validTriggers = $this->getTriggers();
return [
'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers),
'rule-trigger.*' => 'required|min:1|in:'.implode(',', $validTriggers),
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
];
}

View File

@ -1,4 +1,5 @@
<?php
/**
* TokenFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* TriggerRecurrenceRequest.php

View File

@ -1,4 +1,5 @@
<?php
/**
* UserFormRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* UserRegistrationRequest.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -55,7 +55,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@ -83,7 +83,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @throws FireflyException
*/
@ -133,7 +133,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
// find budget limit:
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int)$autoBudget->auto_budget_type) {
// that's easy: create one.
// do nothing else.
$this->createBudgetLimit($autoBudget, $start, $end);
@ -142,7 +142,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
return;
}
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int)$autoBudget->auto_budget_type) {
// budget limit exists already,
$this->createRollover($autoBudget);
Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));
@ -153,7 +153,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @return bool
* @throws FireflyException
@ -190,9 +190,9 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
* @param Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return BudgetLimit|null
*/
@ -214,10 +214,10 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param Carbon $start
* @param Carbon $end
* @param string|null $amount
* @param AutoBudget $autoBudget
* @param Carbon $start
* @param Carbon $end
* @param string|null $amount
*/
private function createBudgetLimit(AutoBudget $autoBudget, Carbon $start, Carbon $end, ?string $amount = null)
{
@ -239,7 +239,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param AutoBudget $autoBudget
* @param AutoBudget $autoBudget
*
* @throws FireflyException
*/
@ -280,7 +280,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
$repository = app(OperationsRepositoryInterface::class);
$repository->setUser($autoBudget->budget->user);
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
$currencyId = (int) $autoBudget->transaction_currency_id;
$currencyId = (int)$autoBudget->transaction_currency_id;
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
@ -304,7 +304,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
}
/**
* @param Carbon $date
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{

View File

@ -61,10 +61,10 @@ class CreateRecurringTransactions implements ShouldQueue
private Carbon $date;
private bool $force;
private TransactionGroupRepositoryInterface $groupRepository;
private JournalRepositoryInterface $journalRepository;
private RecurringRepositoryInterface $repository;
private Collection $recurrences;
private Collection $groups;
private JournalRepositoryInterface $journalRepository;
private Collection $recurrences;
private RecurringRepositoryInterface $repository;
/**
* Create a new job instance.
@ -97,6 +97,14 @@ class CreateRecurringTransactions implements ShouldQueue
Log::debug(sprintf('Created new CreateRecurringTransactions("%s")', $this->date->format('Y-m-d')));
}
/**
* @return Collection
*/
public function getGroups(): Collection
{
return $this->groups;
}
/**
* Execute the job.
*/
@ -520,12 +528,4 @@ class CreateRecurringTransactions implements ShouldQueue
{
$this->recurrences = $recurrences;
}
/**
* @return Collection
*/
public function getGroups(): Collection
{
return $this->groups;
}
}

View File

@ -47,9 +47,9 @@ class DownloadExchangeRates implements ShouldQueue
use Queueable;
use SerializesModels;
private array $active;
private Carbon $date;
private CurrencyRepositoryInterface $repository;
private array $active;
private Collection $users;
/**
@ -57,7 +57,7 @@ class DownloadExchangeRates implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@ -92,23 +92,13 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
/**
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
* @return void
*/
private function downloadRates(TransactionCurrency $currency): void
{
Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));
$base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);
$base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);
$client = new Client();
$url = sprintf('%s/%s.json', $base, $currency->code);
$res = $client->get($url);
@ -117,7 +107,7 @@ class DownloadExchangeRates implements ShouldQueue
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));
return;
}
$body = (string) $res->getBody();
$body = (string)$res->getBody();
$json = json_decode($body, true);
if (false === $json || null === $json) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
@ -128,8 +118,8 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param TransactionCurrency $currency
* @param array $rates
* @param TransactionCurrency $currency
* @param array $rates
* @return void
*/
private function saveRates(TransactionCurrency $currency, Carbon $date, array $rates): void
@ -146,7 +136,7 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param string $code
* @param string $code
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
@ -185,4 +175,14 @@ class DownloadExchangeRates implements ShouldQueue
}
}
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* Job.php
* Copyright (c) 2019 james@firefly-iii.org

View File

@ -1,4 +1,5 @@
<?php
/**
* MailError.php
* Copyright (c) 2019 james@firefly-iii.org
@ -48,10 +49,10 @@ class MailError extends Job implements ShouldQueue
/**
* MailError constructor.
*
* @param array $userData
* @param string $destination
* @param string $ipAddress
* @param array $exceptionData
* @param array $userData
* @param string $destination
* @param string $ipAddress
* @param array $exceptionData
*/
public function __construct(array $userData, string $destination, string $ipAddress, array $exceptionData)
{
@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueue
*/
public function handle()
{
$email = (string) config('firefly.site_owner');
$email = (string)config('firefly.site_owner');
$args = $this->exception;
$args['loggedIn'] = $this->userData['id'] > 0;
$args['user'] = $this->userData;
@ -83,12 +84,12 @@ class MailError extends Job implements ShouldQueue
$args,
function (Message $message) use ($email) {
if ('mail@example.com' !== $email) {
$message->to($email, $email)->subject((string) trans('email.error_subject'));
$message->to($email, $email)->subject((string)trans('email.error_subject'));
}
}
);
} catch (Exception $e) {
Log::error('Exception when mailing: ' . $e->getMessage());
Log::error('Exception when mailing: '.$e->getMessage());
}
}
}

Some files were not shown because too many files have changed in this diff Show More