mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 00:20:03 +00:00
Various PSR12 code cleanup
This commit is contained in:
@@ -36,6 +36,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -136,8 +138,8 @@ class CreateController extends Controller
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function store(AccountFormRequest $request)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
@@ -65,7 +65,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete account screen.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class DeleteController extends Controller
|
||||
}
|
||||
|
||||
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$subTitle = (string) trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);
|
||||
$subTitle = (string)trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);
|
||||
$accountList = app('expandedform')->makeSelectListWithEmpty($this->repository->getAccountsByType([$account->accountType->type]));
|
||||
$objectType = $typeName;
|
||||
unset($accountList[$account->id]);
|
||||
@@ -90,8 +90,8 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete the account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -104,11 +104,11 @@ class DeleteController extends Controller
|
||||
$type = $account->accountType->type;
|
||||
$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type));
|
||||
$name = $account->name;
|
||||
$moveTo = $this->repository->find((int) $request->get('move_account_before_delete'));
|
||||
$moveTo = $this->repository->find((int)$request->get('move_account_before_delete'));
|
||||
|
||||
$this->repository->destroy($account, $moveTo);
|
||||
|
||||
$request->session()->flash('success', (string) trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('accounts.delete.url'));
|
||||
|
||||
@@ -59,7 +59,7 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
@@ -73,9 +73,9 @@ class EditController extends Controller
|
||||
/**
|
||||
* Edit account overview.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];
|
||||
$subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
|
||||
$subTitle = (string)trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
@@ -111,9 +111,9 @@ class EditController extends Controller
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
'daily' => (string) trans('firefly.interest_calc_daily'),
|
||||
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
||||
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
||||
'daily' => (string)trans('firefly.interest_calc_daily'),
|
||||
'monthly' => (string)trans('firefly.interest_calc_monthly'),
|
||||
'yearly' => (string)trans('firefly.interest_calc_yearly'),
|
||||
];
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
@@ -122,7 +122,7 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('accounts.edit.fromUpdate');
|
||||
|
||||
$openingBalanceAmount = (string) $repository->getOpeningBalanceAmount($account);
|
||||
$openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
|
||||
if ('0' === $openingBalanceAmount) {
|
||||
$openingBalanceAmount = '';
|
||||
}
|
||||
@@ -134,9 +134,9 @@ class EditController extends Controller
|
||||
$includeNetWorth = null === $includeNetWorth ? true : '1' === $includeNetWorth;
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$virtualBalance = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'account_number' => $repository->getMetaValue($account, 'account_number'),
|
||||
'account_role' => $repository->getMetaValue($account, 'account_role'),
|
||||
'cc_type' => $repository->getMetaValue($account, 'cc_type'),
|
||||
@@ -152,7 +152,7 @@ class EditController extends Controller
|
||||
'interest' => $repository->getMetaValue($account, 'interest'),
|
||||
'interest_period' => $repository->getMetaValue($account, 'interest_period'),
|
||||
'notes' => $this->repository->getNoteText($account),
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $account->active,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $account->active,
|
||||
];
|
||||
if ('' === $openingBalanceAmount) {
|
||||
$preFilled['opening_balance'] = '';
|
||||
@@ -181,8 +181,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Update the account.
|
||||
*
|
||||
* @param AccountFormRequest $request
|
||||
* @param Account $account
|
||||
* @param AccountFormRequest $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -195,7 +195,7 @@ class EditController extends Controller
|
||||
$data = $request->getAccountData();
|
||||
$this->repository->update($account, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
|
||||
|
||||
// store new attachment(s):
|
||||
|
||||
@@ -204,7 +204,7 @@ class EditController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($account, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -213,7 +213,7 @@ class EditController extends Controller
|
||||
|
||||
// redirect
|
||||
$redirect = redirect($this->getPreviousUrl('accounts.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('accounts.edit.fromUpdate', true);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IndexController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -23,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -33,7 +33,10 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -58,7 +61,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
|
||||
@@ -68,25 +71,25 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function inactive(Request $request, string $objectType)
|
||||
{
|
||||
$inactivePage = true;
|
||||
$subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType));
|
||||
$subTitle = (string)trans(sprintf('firefly.%s_accounts_inactive', $objectType));
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
||||
$collection = $this->repository->getInactiveAccountsByType($types);
|
||||
$total = $collection->count();
|
||||
$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;
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
unset($collection);
|
||||
/** @var Carbon $start */
|
||||
@@ -107,10 +110,10 @@ class IndexController extends Controller
|
||||
$account->endBalance = $this->isInArray($endBalances, $account->id);
|
||||
$account->difference = bcsub($account->endBalance, $account->startBalance);
|
||||
$account->interest = app('steam')->bcround($this->repository->getMetaValue($account, 'interest'), 4);
|
||||
$account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->current_debt = '0';
|
||||
$account->iban = implode(' ', str_split((string) $account->iban, 4));
|
||||
$account->iban = implode(' ', str_split((string)$account->iban, 4));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -124,19 +127,19 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show list of accounts.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index(Request $request, string $objectType)
|
||||
{
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
$subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));
|
||||
$subTitle = (string)trans(sprintf('firefly.%s_accounts', $objectType));
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));
|
||||
|
||||
@@ -144,8 +147,8 @@ class IndexController extends Controller
|
||||
|
||||
$collection = $this->repository->getActiveAccountsByType($types);
|
||||
$total = $collection->count();
|
||||
$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;
|
||||
$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count();
|
||||
|
||||
@@ -175,14 +178,14 @@ class IndexController extends Controller
|
||||
$account->endBalance = $this->isInArray($endBalances, $account->id);
|
||||
$account->difference = bcsub($account->endBalance, $account->startBalance);
|
||||
$account->interest = app('steam')->bcround($interest, 4);
|
||||
$account->interestPeriod = (string) trans(
|
||||
$account->interestPeriod = (string)trans(
|
||||
sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))
|
||||
);
|
||||
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->location = $this->repository->getLocation($account);
|
||||
$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');
|
||||
$account->current_debt = $this->repository->getMetaValue($account, 'current_debt') ?? '-';
|
||||
$account->iban = implode(' ', str_split((string) $account->iban, 4));
|
||||
$account->iban = implode(' ', str_split((string)$account->iban, 4));
|
||||
}
|
||||
);
|
||||
// make paginator:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ReconcileController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -23,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\DuplicateTransactionException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionGroupFactory;
|
||||
@@ -40,7 +40,10 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ReconcileController.
|
||||
@@ -67,7 +70,7 @@ class ReconcileController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
@@ -80,15 +83,15 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Reconciliation overview.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function reconcile(Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||
{
|
||||
@@ -96,7 +99,7 @@ class ReconcileController extends Controller
|
||||
return $this->redirectAccountToAccount($account);
|
||||
}
|
||||
if (AccountType::ASSET !== $account->accountType->type) {
|
||||
session()->flash('error', (string) trans('firefly.must_be_asset_account'));
|
||||
session()->flash('error', (string)trans('firefly.must_be_asset_account'));
|
||||
|
||||
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
|
||||
}
|
||||
@@ -127,7 +130,7 @@ class ReconcileController extends Controller
|
||||
$startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places);
|
||||
$endBalance = app('steam')->bcround(app('steam')->balance($account, $end), $currency->decimal_places);
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
$subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);
|
||||
$subTitle = (string)trans('firefly.reconcile_account', ['account' => $account->name]);
|
||||
|
||||
// various links
|
||||
$transactionsUrl = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);
|
||||
@@ -157,10 +160,10 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Submit a new reconciliation.
|
||||
*
|
||||
* @param ReconciliationStoreRequest $request
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param ReconciliationStoreRequest $request
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws DuplicateTransactionException
|
||||
@@ -176,7 +179,7 @@ class ReconcileController extends Controller
|
||||
|
||||
/** @var string $journalId */
|
||||
foreach ($data['journals'] as $journalId) {
|
||||
$this->repository->reconcileById((int) $journalId);
|
||||
$this->repository->reconcileById((int)$journalId);
|
||||
}
|
||||
Log::debug('Reconciled all transactions.');
|
||||
|
||||
@@ -193,10 +196,10 @@ class ReconcileController extends Controller
|
||||
Log::debug('End of routine.');
|
||||
app('preferences')->mark();
|
||||
if ('' === $result) {
|
||||
session()->flash('success', (string) trans('firefly.reconciliation_stored'));
|
||||
session()->flash('success', (string)trans('firefly.reconciliation_stored'));
|
||||
}
|
||||
if ('' !== $result) {
|
||||
session()->flash('error', (string) trans('firefly.reconciliation_error', ['error' => $result]));
|
||||
session()->flash('error', (string)trans('firefly.reconciliation_error', ['error' => $result]));
|
||||
}
|
||||
|
||||
return redirect(route('accounts.show', [$account->id]));
|
||||
@@ -205,10 +208,10 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Creates a reconciliation group.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $difference
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $difference
|
||||
*
|
||||
* @return RedirectResponse|Redirector|string
|
||||
* @throws DuplicateTransactionException
|
||||
@@ -236,8 +239,10 @@ class ReconcileController extends Controller
|
||||
// title:
|
||||
$description = trans(
|
||||
'firefly.reconciliation_transaction_title',
|
||||
['from' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'to' => $end->isoFormat($this->monthAndDayFormat)]
|
||||
[
|
||||
'from' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'to' => $end->isoFormat($this->monthAndDayFormat),
|
||||
]
|
||||
);
|
||||
$submission = [
|
||||
'user' => auth()->user()->id,
|
||||
|
||||
@@ -24,7 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
@@ -37,6 +37,9 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ShowController
|
||||
@@ -64,7 +67,7 @@ class ShowController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
@@ -77,16 +80,16 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Factory|View
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Account $account, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||
{
|
||||
@@ -108,19 +111,19 @@ class ShowController extends Controller
|
||||
$attachments = $this->repository->getAttachments($account);
|
||||
$today = today(config('app.timezone'));
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
$fStart = $start->isoFormat($this->monthAndDayFormat);
|
||||
$fEnd = $end->isoFormat($this->monthAndDayFormat);
|
||||
$subTitle = (string) trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||
$subTitle = (string)trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||
$chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$firstTransaction = $this->repository->oldestJournalDate($account) ?? $start;
|
||||
$periods = $this->getAccountPeriodOverview($account, $firstTransaction, $end);
|
||||
|
||||
// if layout = v2, overrule the page title.
|
||||
if ('v1' !== config('firefly.layout')) {
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,14 +165,14 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show an account.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
* @param Request $request
|
||||
* @param Account $account
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Factory|View
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showAll(Request $request, Account $account)
|
||||
{
|
||||
@@ -183,11 +186,11 @@ class ShowController extends Controller
|
||||
$end = today(config('app.timezone'));
|
||||
$today = today(config('app.timezone'));
|
||||
$start = $this->repository->oldestJournalDate($account) ?? Carbon::now()->startOfMonth();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection();
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ConfigurationController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -30,6 +31,8 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ConfigurationController.
|
||||
@@ -47,7 +50,7 @@ class ConfigurationController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
|
||||
return $next($request);
|
||||
@@ -61,12 +64,12 @@ class ConfigurationController extends Controller
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.instance_configuration');
|
||||
$subTitle = (string)trans('firefly.instance_configuration');
|
||||
$subTitleIcon = 'fa-wrench';
|
||||
|
||||
Log::channel('audit')->info('User visits admin config index.');
|
||||
@@ -86,7 +89,7 @@ class ConfigurationController extends Controller
|
||||
/**
|
||||
* Store new configuration values.
|
||||
*
|
||||
* @param ConfigurationRequest $request
|
||||
* @param ConfigurationRequest $request
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -102,7 +105,7 @@ class ConfigurationController extends Controller
|
||||
app('fireflyconfig')->set('is_demo_site', $data['is_demo_site']);
|
||||
|
||||
// flash message
|
||||
session()->flash('success', (string) trans('firefly.configuration_updated'));
|
||||
session()->flash('success', (string)trans('firefly.configuration_updated'));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect()->route('admin.configuration.index');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HomeController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -34,6 +35,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class HomeController.
|
||||
@@ -56,13 +59,13 @@ class HomeController extends Controller
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
Log::channel('audit')->info('User visits admin index.');
|
||||
$title = (string) trans('firefly.administration');
|
||||
$title = (string)trans('firefly.administration');
|
||||
$mainTitleIcon = 'fa-hand-spock-o';
|
||||
$email = auth()->user()->email;
|
||||
$pref = app('preferences')->get('remote_guard_alt_email');
|
||||
@@ -89,7 +92,7 @@ class HomeController extends Controller
|
||||
}
|
||||
FireflyConfig::set(sprintf('notification_%s', $item), $value);
|
||||
}
|
||||
$url = (string) $request->get('slackUrl');
|
||||
$url = (string)$request->get('slackUrl');
|
||||
if ('' === $url) {
|
||||
FireflyConfig::delete('slack_webhook_url');
|
||||
}
|
||||
@@ -97,14 +100,14 @@ class HomeController extends Controller
|
||||
FireflyConfig::set('slack_webhook_url', $url);
|
||||
}
|
||||
|
||||
session()->flash('success', (string) trans('firefly.notification_settings_saved'));
|
||||
session()->flash('success', (string)trans('firefly.notification_settings_saved'));
|
||||
return redirect(route('admin.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a test message to the admin.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -115,7 +118,7 @@ class HomeController extends Controller
|
||||
$user = auth()->user();
|
||||
Log::debug('Now in testMessage() controller.');
|
||||
event(new AdminRequestedTestMessage($user));
|
||||
session()->flash('info', (string) trans('firefly.send_test_triggered'));
|
||||
session()->flash('info', (string)trans('firefly.send_test_triggered'));
|
||||
|
||||
return redirect(route('admin.index'));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LinkController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -52,7 +53,7 @@ class LinkController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
$this->repository = app(LinkTypeRepositoryInterface::class);
|
||||
|
||||
@@ -71,7 +72,7 @@ class LinkController extends Controller
|
||||
{
|
||||
Log::channel('audit')->info('User visits link index.');
|
||||
|
||||
$subTitle = (string) trans('firefly.create_new_link_type');
|
||||
$subTitle = (string)trans('firefly.create_new_link_type');
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
@@ -85,25 +86,25 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Delete a link form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function delete(Request $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
|
||||
Log::channel('audit')->info(sprintf('User wants to delete link type #%d', $linkType->id));
|
||||
$subTitle = (string) trans('firefly.delete_link_type', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.delete_link_type', ['name' => $linkType->name]);
|
||||
$otherTypes = $this->repository->get();
|
||||
$count = $this->repository->countJournals($linkType);
|
||||
$moveTo = [];
|
||||
$moveTo[0] = (string) trans('firefly.do_not_save_connection');
|
||||
$moveTo[0] = (string)trans('firefly.do_not_save_connection');
|
||||
|
||||
/** @var LinkType $otherType */
|
||||
foreach ($otherTypes as $otherType) {
|
||||
@@ -121,8 +122,8 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Actually destroy the link.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -130,10 +131,10 @@ class LinkController extends Controller
|
||||
{
|
||||
Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id));
|
||||
$name = $linkType->name;
|
||||
$moveTo = $this->repository->find((int) $request->get('move_link_type_before_delete'));
|
||||
$moveTo = $this->repository->find((int)$request->get('move_link_type_before_delete'));
|
||||
$this->repository->destroy($linkType, $moveTo);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_link_type', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('link-types.delete.url'));
|
||||
@@ -142,19 +143,19 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Edit a link form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function edit(Request $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
$subTitle = (string) trans('firefly.edit_link_type', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.edit_link_type', ['name' => $linkType->name]);
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
Log::channel('audit')->info(sprintf('User wants to edit link type #%d', $linkType->id));
|
||||
@@ -175,7 +176,7 @@ class LinkController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.journal_link_configuration');
|
||||
$subTitle = (string)trans('firefly.journal_link_configuration');
|
||||
$subTitleIcon = 'fa-link';
|
||||
$linkTypes = $this->repository->get();
|
||||
|
||||
@@ -192,13 +193,13 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Show a single link.
|
||||
*
|
||||
* @param LinkType $linkType
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function show(LinkType $linkType)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.overview_for_link', ['name' => $linkType->name]);
|
||||
$subTitleIcon = 'fa-link';
|
||||
$links = $this->repository->getJournalLinks($linkType);
|
||||
|
||||
@@ -210,7 +211,7 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Store the new link.
|
||||
*
|
||||
* @param LinkTypeFormRequest $request
|
||||
* @param LinkTypeFormRequest $request
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -225,9 +226,9 @@ class LinkController extends Controller
|
||||
|
||||
Log::channel('audit')->info('User stored new link type.', $linkType->toArray());
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
|
||||
$redirect = redirect($this->getPreviousUrl('link-types.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('link-types.create.fromStore', true);
|
||||
|
||||
@@ -241,15 +242,15 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Update an existing link.
|
||||
*
|
||||
* @param LinkTypeFormRequest $request
|
||||
* @param LinkType $linkType
|
||||
* @param LinkTypeFormRequest $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
public function update(LinkTypeFormRequest $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
@@ -263,10 +264,10 @@ class LinkController extends Controller
|
||||
|
||||
Log::channel('audit')->info(sprintf('User update link type #%d.', $linkType->id), $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_link_type', ['name' => $linkType->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('link-types.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('link-types.edit.fromUpdate', true);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UpdateController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -31,6 +32,8 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class HomeController.
|
||||
@@ -47,7 +50,7 @@ class UpdateController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
|
||||
return $next($request);
|
||||
@@ -61,27 +64,27 @@ class UpdateController extends Controller
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.update_check_title');
|
||||
$subTitle = (string)trans('firefly.update_check_title');
|
||||
$subTitleIcon = 'fa-star';
|
||||
$permission = app('fireflyconfig')->get('permission_update_check', -1);
|
||||
$channel = app('fireflyconfig')->get('update_channel', 'stable');
|
||||
$selected = $permission->data;
|
||||
$channelSelected = $channel->data;
|
||||
$options = [
|
||||
-1 => (string) trans('firefly.updates_ask_me_later'),
|
||||
0 => (string) trans('firefly.updates_do_not_check'),
|
||||
1 => (string) trans('firefly.updates_enable_check'),
|
||||
-1 => (string)trans('firefly.updates_ask_me_later'),
|
||||
0 => (string)trans('firefly.updates_do_not_check'),
|
||||
1 => (string)trans('firefly.updates_enable_check'),
|
||||
];
|
||||
|
||||
$channelOptions = [
|
||||
'stable' => (string) trans('firefly.update_channel_stable'),
|
||||
'beta' => (string) trans('firefly.update_channel_beta'),
|
||||
'alpha' => (string) trans('firefly.update_channel_alpha'),
|
||||
'stable' => (string)trans('firefly.update_channel_stable'),
|
||||
'beta' => (string)trans('firefly.update_channel_beta'),
|
||||
'alpha' => (string)trans('firefly.update_channel_alpha'),
|
||||
];
|
||||
|
||||
return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions'));
|
||||
@@ -90,20 +93,20 @@ class UpdateController extends Controller
|
||||
/**
|
||||
* Post new settings.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function post(Request $request)
|
||||
{
|
||||
$checkForUpdates = (int) $request->get('check_for_updates');
|
||||
$checkForUpdates = (int)$request->get('check_for_updates');
|
||||
$channel = $request->get('update_channel');
|
||||
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
|
||||
|
||||
app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
|
||||
app('fireflyconfig')->set('last_update_check', time());
|
||||
app('fireflyconfig')->set('update_channel', $channel);
|
||||
session()->flash('success', (string) trans('firefly.configuration_updated'));
|
||||
session()->flash('success', (string)trans('firefly.configuration_updated'));
|
||||
|
||||
return redirect(route('admin.update-check'));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* UserController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -32,7 +33,6 @@ use FireflyIII\User;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
@@ -54,7 +54,7 @@ class UserController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
|
||||
@@ -68,7 +68,7 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return Application|Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ class UserController extends Controller
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
|
||||
$subTitle = (string) trans('firefly.delete_user', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.delete_user', ['email' => $user->email]);
|
||||
|
||||
return view('admin.users.delete', compact('user', 'subTitle'));
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class UserController extends Controller
|
||||
/**
|
||||
* Destroy a user.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ class UserController extends Controller
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
$this->repository->destroy($user);
|
||||
session()->flash('success', (string) trans('firefly.user_deleted'));
|
||||
session()->flash('success', (string)trans('firefly.user_deleted'));
|
||||
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class UserController extends Controller
|
||||
/**
|
||||
* Edit user form.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -124,15 +124,15 @@ class UserController extends Controller
|
||||
}
|
||||
session()->forget('users.edit.fromUpdate');
|
||||
|
||||
$subTitle = (string) trans('firefly.edit_user', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]);
|
||||
$subTitleIcon = 'fa-user-o';
|
||||
$currentUser = auth()->user();
|
||||
$isAdmin = $this->repository->hasRole($user, 'owner');
|
||||
$codes = [
|
||||
'' => (string) trans('firefly.no_block_code'),
|
||||
'bounced' => (string) trans('firefly.block_code_bounced'),
|
||||
'expired' => (string) trans('firefly.block_code_expired'),
|
||||
'email_changed' => (string) trans('firefly.block_code_email_changed'),
|
||||
'' => (string)trans('firefly.no_block_code'),
|
||||
'bounced' => (string)trans('firefly.block_code_bounced'),
|
||||
'expired' => (string)trans('firefly.block_code_expired'),
|
||||
'email_changed' => (string)trans('firefly.block_code_email_changed'),
|
||||
];
|
||||
|
||||
return view('admin.users.edit', compact('user', 'canEditDetails', 'subTitle', 'subTitleIcon', 'codes', 'currentUser', 'isAdmin'));
|
||||
@@ -145,7 +145,7 @@ class UserController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.user_administration');
|
||||
$subTitle = (string)trans('firefly.user_administration');
|
||||
$subTitleIcon = 'fa-users';
|
||||
$users = $this->repository->all();
|
||||
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
@@ -168,18 +168,34 @@ class UserController extends Controller
|
||||
return view('admin.users.index', compact('subTitle', 'subTitleIcon', 'users', 'allowInvites', 'invitedUsers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InviteUserFormRequest $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function invite(InviteUserFormRequest $request): RedirectResponse
|
||||
{
|
||||
$address = (string)$request->get('invited_user');
|
||||
$invitee = $this->repository->inviteUser(auth()->user(), $address);
|
||||
session()->flash('info', trans('firefly.user_is_invited', ['address' => $address]));
|
||||
|
||||
// event!
|
||||
event(new InvitationCreated($invitee));
|
||||
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show single user.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
$title = (string) trans('firefly.administration');
|
||||
$title = (string)trans('firefly.administration');
|
||||
$mainTitleIcon = 'fa-hand-spock-o';
|
||||
$subTitle = (string) trans('firefly.single_user_administration', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]);
|
||||
$subTitleIcon = 'fa-user';
|
||||
$information = $this->repository->getUserData($user);
|
||||
|
||||
@@ -196,27 +212,11 @@ class UserController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InviteUserFormRequest $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function invite(InviteUserFormRequest $request): RedirectResponse
|
||||
{
|
||||
$address = (string) $request->get('invited_user');
|
||||
$invitee = $this->repository->inviteUser(auth()->user(), $address);
|
||||
session()->flash('info', trans('firefly.user_is_invited', ['address' => $address]));
|
||||
|
||||
// event!
|
||||
event(new InvitationCreated($invitee));
|
||||
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single user.
|
||||
*
|
||||
* @param UserFormRequest $request
|
||||
* @param User $user
|
||||
* @param UserFormRequest $request
|
||||
* @param User $user
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -242,10 +242,10 @@ class UserController extends Controller
|
||||
$this->repository->changeStatus($user, $data['blocked'], $data['blocked_code']);
|
||||
$this->repository->updateEmail($user, $data['email']);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.updated_user', ['email' => $user->email]));
|
||||
session()->flash('success', (string)trans('firefly.updated_user', ['email' => $user->email]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('users.edit.url'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
session()->put('users.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AttachmentController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -56,7 +57,7 @@ class AttachmentController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paperclip');
|
||||
app('view')->share('title', (string) trans('firefly.attachments'));
|
||||
app('view')->share('title', (string)trans('firefly.attachments'));
|
||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -67,13 +68,13 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* Form to delete an attachment.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(Attachment $attachment)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]);
|
||||
$subTitle = (string)trans('firefly.delete_attachment', ['name' => $attachment->filename]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('attachments.delete.url');
|
||||
@@ -84,8 +85,8 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* Destroy attachment.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -95,7 +96,7 @@ class AttachmentController extends Controller
|
||||
|
||||
$this->repository->destroy($attachment);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.attachment_deleted', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('attachments.delete.url'));
|
||||
@@ -104,7 +105,7 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* Download attachment to PC.
|
||||
*
|
||||
* @param Attachment $attachment
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return LaravelResponse
|
||||
*
|
||||
@@ -121,7 +122,7 @@ class AttachmentController extends Controller
|
||||
$response
|
||||
->header('Content-Description', 'File Transfer')
|
||||
->header('Content-Type', 'application/octet-stream')
|
||||
->header('Content-Disposition', 'attachment; filename=' . $quoted)
|
||||
->header('Content-Disposition', 'attachment; filename='.$quoted)
|
||||
->header('Content-Transfer-Encoding', 'binary')
|
||||
->header('Connection', 'Keep-Alive')
|
||||
->header('Expires', '0')
|
||||
@@ -137,15 +138,15 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* Edit an attachment.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Request $request, Attachment $attachment)
|
||||
{
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]);
|
||||
$subTitle = (string)trans('firefly.edit_attachment', ['name' => $attachment->filename]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('attachments.edit.fromUpdate')) {
|
||||
@@ -182,8 +183,8 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* Update attachment.
|
||||
*
|
||||
* @param AttachmentFormRequest $request
|
||||
* @param Attachment $attachment
|
||||
* @param AttachmentFormRequest $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -192,11 +193,11 @@ class AttachmentController extends Controller
|
||||
$data = $request->getAttachmentData();
|
||||
$this->repository->update($attachment, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.attachment_updated', ['name' => $attachment->filename]));
|
||||
$request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));
|
||||
app('preferences')->mark();
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('attachments.edit.url'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
$request->session()->put('attachments.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);
|
||||
@@ -209,8 +210,8 @@ class AttachmentController extends Controller
|
||||
/**
|
||||
* View attachment in browser.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
* @param Request $request
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
* @return LaravelResponse
|
||||
* @throws FireflyException
|
||||
@@ -240,7 +241,7 @@ class AttachmentController extends Controller
|
||||
[
|
||||
'Content-Security-Policy' => implode('; ', $csp),
|
||||
'Content-Type' => $attachment->mime,
|
||||
'Content-Disposition' => 'inline; filename="' . $attachment->filename . '"',
|
||||
'Content-Disposition' => 'inline; filename="'.$attachment->filename.'"',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ForgotPasswordController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -32,6 +33,8 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ForgotPasswordController
|
||||
@@ -61,8 +64,8 @@ class ForgotPasswordController extends Controller
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param Request $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|RedirectResponse|View
|
||||
*/
|
||||
@@ -86,7 +89,7 @@ class ForgotPasswordController extends Controller
|
||||
$user = User::where('email', $request->get('email'))->first();
|
||||
|
||||
if (null !== $user && $repository->hasRole($user, 'demo')) {
|
||||
return back()->withErrors(['email' => (string) trans('firefly.cannot_reset_demo_user')]);
|
||||
return back()->withErrors(['email' => (string)trans('firefly.cannot_reset_demo_user')]);
|
||||
}
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
@@ -110,8 +113,8 @@ class ForgotPasswordController extends Controller
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
@@ -126,7 +129,7 @@ class ForgotPasswordController extends Controller
|
||||
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
$allowRegistration = true;
|
||||
$pageTitle = (string) trans('firefly.forgot_pw_page_title');
|
||||
$pageTitle = (string)trans('firefly.forgot_pw_page_title');
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LoginController.php
|
||||
* Copyright (c) 2020 james@firefly-iii.org
|
||||
@@ -33,13 +34,14 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class LoginController
|
||||
@@ -79,7 +81,7 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Handle a login request to the application.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@@ -140,7 +142,7 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Get the failed login response instance.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -161,7 +163,7 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@@ -198,12 +200,12 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Show the application's login form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|Application|View|Redirector|RedirectResponse
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showLoginForm(Request $request)
|
||||
{
|
||||
@@ -211,7 +213,7 @@ class LoginController extends Controller
|
||||
|
||||
$count = DB::table('users')->count();
|
||||
$guard = config('auth.defaults.guard');
|
||||
$title = (string) trans('firefly.login_page_title');
|
||||
$title = (string)trans('firefly.login_page_title');
|
||||
|
||||
if (0 === $count && 'web' === $guard) {
|
||||
return redirect(route('register'));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RegisterController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -80,7 +81,7 @@ class RegisterController extends Controller
|
||||
/**
|
||||
* Handle a registration request for the application.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Application|Redirector|RedirectResponse
|
||||
* @throws FireflyException
|
||||
@@ -89,7 +90,7 @@ class RegisterController extends Controller
|
||||
public function register(Request $request)
|
||||
{
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
$inviteCode = (string) $request->get('invite_code');
|
||||
$inviteCode = (string)$request->get('invite_code');
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$validCode = $repository->validateInviteCode($inviteCode);
|
||||
|
||||
@@ -105,7 +106,7 @@ class RegisterController extends Controller
|
||||
|
||||
$this->guard()->login($user);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.registered'));
|
||||
session()->flash('success', (string)trans('firefly.registered'));
|
||||
|
||||
$this->registered($request, $user);
|
||||
|
||||
@@ -140,37 +141,10 @@ class RegisterController extends Controller
|
||||
return $allowRegistration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application registration form.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showRegistrationForm(Request $request)
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
|
||||
if (false === $allowRegistration) {
|
||||
$message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
||||
$email = $request->old('email');
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application registration form if the invitation code is valid.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -180,7 +154,7 @@ class RegisterController extends Controller
|
||||
public function showInviteForm(Request $request, string $code)
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
$pageTitle = (string)trans('firefly.register_page_title');
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
$inviteCode = $code;
|
||||
@@ -201,4 +175,31 @@ class RegisterController extends Controller
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle', 'inviteCode'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application registration form.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showRegistrationForm(Request $request)
|
||||
{
|
||||
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
||||
$pageTitle = (string)trans('firefly.register_page_title');
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
|
||||
if (false === $allowRegistration) {
|
||||
$message = 'Registration is currently not available. If you are the administrator, you can enable this in the administration.';
|
||||
|
||||
return view('error', compact('message'));
|
||||
}
|
||||
|
||||
$email = $request->old('email');
|
||||
|
||||
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ResetPasswordController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -33,6 +34,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ResetPasswordController
|
||||
@@ -73,7 +76,7 @@ class ResetPasswordController extends Controller
|
||||
/**
|
||||
* Reset the given user's password.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|JsonResponse|RedirectResponse|View
|
||||
* @throws ValidationException
|
||||
@@ -118,13 +121,13 @@ class ResetPasswordController extends Controller
|
||||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param null $token
|
||||
* @param Request $request
|
||||
* @param null $token
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showResetForm(Request $request, $token = null) // @phpstan-ignore-line
|
||||
{
|
||||
@@ -139,7 +142,7 @@ class ResetPasswordController extends Controller
|
||||
$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$userCount = User::count();
|
||||
$allowRegistration = true;
|
||||
$pageTitle = (string) trans('firefly.reset_pw_page_title');
|
||||
$pageTitle = (string)trans('firefly.reset_pw_page_title');
|
||||
if (true === $singleUserMode && $userCount > 0) {
|
||||
$allowRegistration = false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TwoFactorController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -47,13 +48,13 @@ class TwoFactorController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$siteOwner = config('firefly.site_owner');
|
||||
$title = (string) trans('firefly.two_factor_forgot_title');
|
||||
$title = (string)trans('firefly.two_factor_forgot_title');
|
||||
|
||||
return view('auth.lost-two-factor', compact('user', 'siteOwner', 'title'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -61,7 +62,7 @@ class TwoFactorController extends Controller
|
||||
{
|
||||
/** @var array $mfaHistory */
|
||||
$mfaHistory = Preferences::get('mfa_history', [])->data;
|
||||
$mfaCode = (string) $request->get('one_time_password');
|
||||
$mfaCode = (string)$request->get('one_time_password');
|
||||
|
||||
// is in history? then refuse to use it.
|
||||
if ($this->inMFAHistory($mfaCode, $mfaHistory)) {
|
||||
@@ -101,8 +102,8 @@ class TwoFactorController extends Controller
|
||||
* Each MFA history has a timestamp and a code, saving the MFA entries for 5 minutes. So if the
|
||||
* submitted MFA code has been submitted in the last 5 minutes, it won't work despite being valid.
|
||||
*
|
||||
* @param string $mfaCode
|
||||
* @param array $mfaHistory
|
||||
* @param string $mfaCode
|
||||
* @param array $mfaHistory
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -143,7 +144,7 @@ class TwoFactorController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mfaCode
|
||||
* @param string $mfaCode
|
||||
*/
|
||||
private function addToMFAHistory(string $mfaCode): void
|
||||
{
|
||||
@@ -162,7 +163,7 @@ class TwoFactorController extends Controller
|
||||
/**
|
||||
* Checks if code is in users backup codes.
|
||||
*
|
||||
* @param string $mfaCode
|
||||
* @param string $mfaCode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -179,7 +180,7 @@ class TwoFactorController extends Controller
|
||||
/**
|
||||
* Remove the used code from the list of backup codes.
|
||||
*
|
||||
* @param string $mfaCode
|
||||
* @param string $mfaCode
|
||||
*/
|
||||
private function removeFromBackupCodes(string $mfaCode): void
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.bills'));
|
||||
app('view')->share('title', (string)trans('firefly.bills'));
|
||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
@@ -67,7 +67,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create a new bill.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -77,9 +77,9 @@ class CreateController extends Controller
|
||||
/** @var array $billPeriods */
|
||||
$billPeriods = config('firefly.bill_periods');
|
||||
foreach ($billPeriods as $current) {
|
||||
$periods[$current] = (string) trans('firefly.repeat_freq_' . $current);
|
||||
$periods[$current] = (string)trans('firefly.repeat_freq_'.$current);
|
||||
}
|
||||
$subTitle = (string) trans('firefly.create_new_bill');
|
||||
$subTitle = (string)trans('firefly.create_new_bill');
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
@@ -94,7 +94,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Store a new bill.
|
||||
*
|
||||
* @param BillStoreRequest $request
|
||||
* @param BillStoreRequest $request
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*
|
||||
@@ -108,11 +108,11 @@ class CreateController extends Controller
|
||||
$bill = $this->repository->store($billData);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
$request->session()->flash('error', (string) trans('firefly.bill_store_error'));
|
||||
$request->session()->flash('error', (string)trans('firefly.bill_store_error'));
|
||||
|
||||
return redirect(route('bills.create'))->withInput();
|
||||
}
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
/** @var array $files */
|
||||
@@ -121,7 +121,7 @@ class CreateController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($bill, $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) {
|
||||
|
||||
@@ -53,7 +53,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.bills'));
|
||||
app('view')->share('title', (string)trans('firefly.bills'));
|
||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
|
||||
@@ -65,7 +65,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete a bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -73,7 +73,7 @@ class DeleteController extends Controller
|
||||
{
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('bills.delete.url');
|
||||
$subTitle = (string) trans('firefly.delete_bill', ['name' => $bill->name]);
|
||||
$subTitle = (string)trans('firefly.delete_bill', ['name' => $bill->name]);
|
||||
|
||||
return view('bills.delete', compact('bill', 'subTitle'));
|
||||
}
|
||||
@@ -81,8 +81,8 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Destroy a bill.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ class DeleteController extends Controller
|
||||
$name = $bill->name;
|
||||
$this->repository->destroy($bill);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('bills.delete.url'));
|
||||
|
||||
@@ -53,7 +53,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.bills'));
|
||||
app('view')->share('title', (string)trans('firefly.bills'));
|
||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
@@ -66,8 +66,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Edit a bill.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -78,10 +78,10 @@ class EditController extends Controller
|
||||
$billPeriods = config('firefly.bill_periods');
|
||||
|
||||
foreach ($billPeriods as $current) {
|
||||
$periods[$current] = (string) trans('firefly.' . $current);
|
||||
$periods[$current] = (string)trans('firefly.'.$current);
|
||||
}
|
||||
|
||||
$subTitle = (string) trans('firefly.edit_bill', ['name' => $bill->name]);
|
||||
$subTitle = (string)trans('firefly.edit_bill', ['name' => $bill->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('bills.edit.fromUpdate')) {
|
||||
@@ -102,7 +102,7 @@ class EditController extends Controller
|
||||
'extension_date' => $bill->extension_date,
|
||||
'notes' => $this->repository->getNoteText($bill),
|
||||
'transaction_currency_id' => $bill->transaction_currency_id,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $bill->active,
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $bill->active,
|
||||
'object_group' => $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '',
|
||||
];
|
||||
|
||||
@@ -115,8 +115,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Update a bill.
|
||||
*
|
||||
* @param BillUpdateRequest $request
|
||||
* @param Bill $bill
|
||||
* @param BillUpdateRequest $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -125,7 +125,7 @@ class EditController extends Controller
|
||||
$billData = $request->getBillData();
|
||||
$bill = $this->repository->update($bill, $billData);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_bill', ['name' => $bill->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
/** @var array $files */
|
||||
@@ -134,7 +134,7 @@ class EditController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($bill, $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'));
|
||||
}
|
||||
|
||||
// flash messages
|
||||
@@ -143,7 +143,7 @@ class EditController extends Controller
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('bills.edit.url'));
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
$request->session()->put('bills.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -33,6 +33,8 @@ use FireflyIII\Transformers\BillTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
@@ -55,7 +57,7 @@ class IndexController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.bills'));
|
||||
app('view')->share('title', (string)trans('firefly.bills'));
|
||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
|
||||
@@ -92,20 +94,20 @@ class IndexController extends Controller
|
||||
$bills = [
|
||||
0 => [ // the index is the order, not the ID.
|
||||
'object_group_id' => 0,
|
||||
'object_group_title' => (string) trans('firefly.default_group_title_name'),
|
||||
'object_group_title' => (string)trans('firefly.default_group_title_name'),
|
||||
'bills' => [],
|
||||
],
|
||||
];
|
||||
/** @var Bill $bill */
|
||||
foreach ($collection as $bill) {
|
||||
$array = $transformer->transform($bill);
|
||||
$groupOrder = (int) $array['object_group_order'];
|
||||
$groupOrder = (int)$array['object_group_order'];
|
||||
// make group array if necessary:
|
||||
$bills[$groupOrder] = $bills[$groupOrder] ?? [
|
||||
'object_group_id' => $array['object_group_id'],
|
||||
'object_group_title' => $array['object_group_title'],
|
||||
'bills' => [],
|
||||
];
|
||||
'object_group_id' => $array['object_group_id'],
|
||||
'object_group_title' => $array['object_group_title'],
|
||||
'bills' => [],
|
||||
];
|
||||
// var_dump($array);exit;
|
||||
// // expected today? default:
|
||||
// $array['next_expected_match_diff'] = trans('firefly.not_expected_period');
|
||||
@@ -142,12 +144,12 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $bills
|
||||
* @param array $bills
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function getSums(array $bills): array
|
||||
{
|
||||
@@ -164,19 +166,19 @@ class IndexController extends Controller
|
||||
|
||||
$currencyId = $bill['currency_id'];
|
||||
$sums[$groupOrder][$currencyId] = $sums[$groupOrder][$currencyId] ?? [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $bill['currency_code'],
|
||||
'currency_name' => $bill['currency_name'],
|
||||
'currency_symbol' => $bill['currency_symbol'],
|
||||
'currency_decimal_places' => $bill['currency_decimal_places'],
|
||||
'avg' => '0',
|
||||
'period' => $range,
|
||||
'per_period' => '0',
|
||||
];
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $bill['currency_code'],
|
||||
'currency_name' => $bill['currency_name'],
|
||||
'currency_symbol' => $bill['currency_symbol'],
|
||||
'currency_decimal_places' => $bill['currency_decimal_places'],
|
||||
'avg' => '0',
|
||||
'period' => $range,
|
||||
'per_period' => '0',
|
||||
];
|
||||
// only fill in avg when bill is active.
|
||||
if (count($bill['pay_dates']) > 0) {
|
||||
$avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2');
|
||||
$avg = bcmul($avg, (string) count($bill['pay_dates']));
|
||||
$avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2');
|
||||
$avg = bcmul($avg, (string)count($bill['pay_dates']));
|
||||
$sums[$groupOrder][$currencyId]['avg'] = bcadd($sums[$groupOrder][$currencyId]['avg'], $avg);
|
||||
}
|
||||
// fill in per period regardless:
|
||||
@@ -188,14 +190,14 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $bill
|
||||
* @param string $range
|
||||
* @param array $bill
|
||||
* @param string $range
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function amountPerPeriod(array $bill, string $range): string
|
||||
{
|
||||
$avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2');
|
||||
$avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2');
|
||||
|
||||
Log::debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name']));
|
||||
Log::debug(sprintf('Average is %s', $avg));
|
||||
@@ -208,8 +210,8 @@ class IndexController extends Controller
|
||||
'weekly' => '52.17',
|
||||
'daily' => '365.24',
|
||||
];
|
||||
$yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1)));
|
||||
Log::debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1)));
|
||||
$yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1)));
|
||||
Log::debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1)));
|
||||
|
||||
// per period:
|
||||
$division = [
|
||||
@@ -228,7 +230,7 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sums
|
||||
* @param array $sums
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -243,20 +245,20 @@ class IndexController extends Controller
|
||||
*/
|
||||
foreach ($sums as $array) {
|
||||
/**
|
||||
* @var int $currencyId
|
||||
* @var int $currencyId
|
||||
* @var array $entry
|
||||
*/
|
||||
foreach ($array as $currencyId => $entry) {
|
||||
$totals[$currencyId] = $totals[$currencyId] ?? [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $entry['currency_code'],
|
||||
'currency_name' => $entry['currency_name'],
|
||||
'currency_symbol' => $entry['currency_symbol'],
|
||||
'currency_decimal_places' => $entry['currency_decimal_places'],
|
||||
'avg' => '0',
|
||||
'period' => $entry['period'],
|
||||
'per_period' => '0',
|
||||
];
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $entry['currency_code'],
|
||||
'currency_name' => $entry['currency_name'],
|
||||
'currency_symbol' => $entry['currency_symbol'],
|
||||
'currency_decimal_places' => $entry['currency_decimal_places'],
|
||||
'avg' => '0',
|
||||
'period' => $entry['period'],
|
||||
'per_period' => '0',
|
||||
];
|
||||
$totals[$currencyId]['avg'] = bcadd($totals[$currencyId]['avg'], $entry['avg']);
|
||||
$totals[$currencyId]['per_period'] = bcadd($totals[$currencyId]['per_period'], $entry['per_period']);
|
||||
}
|
||||
@@ -268,15 +270,15 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Set the order of a bill.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function setOrder(Request $request, Bill $bill): JsonResponse
|
||||
{
|
||||
$objectGroupTitle = (string) $request->get('objectGroupTitle');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$objectGroupTitle = (string)$request->get('objectGroupTitle');
|
||||
$newOrder = (int)$request->get('order');
|
||||
$this->repository->setOrder($bill, $newOrder);
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$this->repository->setObjectGroup($bill, $objectGroupTitle);
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Bill;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Attachment;
|
||||
@@ -41,6 +42,8 @@ use Illuminate\View\View;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\DataArraySerializer;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
|
||||
/**
|
||||
@@ -63,7 +66,7 @@ class ShowController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.bills'));
|
||||
app('view')->share('title', (string)trans('firefly.bills'));
|
||||
app('view')->share('mainTitleIcon', 'fa-calendar-o');
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
|
||||
@@ -75,8 +78,8 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Rescan bills for transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -84,7 +87,7 @@ class ShowController extends Controller
|
||||
{
|
||||
$total = 0;
|
||||
if (false === $bill->active) {
|
||||
$request->session()->flash('warning', (string) trans('firefly.cannot_scan_inactive_bill'));
|
||||
$request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill'));
|
||||
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
}
|
||||
@@ -94,7 +97,7 @@ class ShowController extends Controller
|
||||
$total = 0;
|
||||
}
|
||||
if (0 === $set->count()) {
|
||||
$request->session()->flash('error', (string) trans('firefly.no_rules_for_bill'));
|
||||
$request->session()->flash('error', (string)trans('firefly.no_rules_for_bill'));
|
||||
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
}
|
||||
@@ -110,7 +113,7 @@ class ShowController extends Controller
|
||||
// file the rule(s)
|
||||
$ruleEngine->fire();
|
||||
|
||||
$request->session()->flash('success', (string) trans_choice('firefly.rescanned_bill', $total));
|
||||
$request->session()->flash('success', (string)trans_choice('firefly.rescanned_bill', $total));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect(route('bills.show', [$bill->id]));
|
||||
@@ -119,13 +122,13 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a bill.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
* @param Request $request
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws FireflyException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Bill $bill)
|
||||
{
|
||||
@@ -137,8 +140,8 @@ class ShowController extends Controller
|
||||
/** @var Carbon $end */
|
||||
$end = session('end');
|
||||
$year = $start->year;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$yearAverage = $this->repository->getYearAverage($bill, $start);
|
||||
$overallAverage = $this->repository->getOverallAverage($bill);
|
||||
$manager = new Manager();
|
||||
|
||||
@@ -52,7 +52,7 @@ class CreateController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -65,7 +65,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Form to create a budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -75,23 +75,23 @@ class CreateController extends Controller
|
||||
|
||||
// auto budget types
|
||||
$autoBudgetTypes = [
|
||||
0 => (string) trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),
|
||||
0 => (string)trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
|
||||
];
|
||||
$autoBudgetPeriods = [
|
||||
'daily' => (string) trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string) trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string) trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string) trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string) trans('firefly.auto_budget_period_yearly'),
|
||||
'daily' => (string)trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string)trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string)trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string)trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string)trans('firefly.auto_budget_period_yearly'),
|
||||
];
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
$preFilled = [
|
||||
'auto_budget_period' => $hasOldInput ? (bool) $request->old('auto_budget_period') : 'monthly',
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,
|
||||
'auto_budget_period' => $hasOldInput ? (bool)$request->old('auto_budget_period') : 'monthly',
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
|
||||
];
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
@@ -101,7 +101,7 @@ class CreateController extends Controller
|
||||
$this->rememberPreviousUrl('budgets.create.url');
|
||||
}
|
||||
$request->session()->forget('budgets.create.fromStore');
|
||||
$subTitle = (string) trans('firefly.create_new_budget');
|
||||
$subTitle = (string)trans('firefly.create_new_budget');
|
||||
|
||||
return view('budgets.create', compact('subTitle', 'autoBudgetTypes', 'autoBudgetPeriods'));
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Stores a budget.
|
||||
*
|
||||
* @param BudgetFormStoreRequest $request
|
||||
* @param BudgetFormStoreRequest $request
|
||||
*
|
||||
* @return RedirectResponse
|
||||
* @throws FireflyException
|
||||
@@ -120,7 +120,7 @@ class CreateController extends Controller
|
||||
|
||||
$budget = $this->repository->store($data);
|
||||
$this->repository->cleanupBudgets();
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -129,7 +129,7 @@ class CreateController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($budget, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -138,7 +138,7 @@ class CreateController extends Controller
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('budgets.create.url'));
|
||||
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
$request->session()->put('budgets.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('budgets.create'))->withInput();
|
||||
|
||||
@@ -52,7 +52,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
|
||||
@@ -64,13 +64,13 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Deletes a budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]);
|
||||
$subTitle = (string)trans('firefly.delete_budget', ['name' => $budget->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('budgets.delete.url');
|
||||
@@ -81,8 +81,8 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Destroys a budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ class DeleteController extends Controller
|
||||
{
|
||||
$name = $budget->name;
|
||||
$this->repository->destroy($budget);
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_budget', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('budgets.delete.url'));
|
||||
|
||||
@@ -41,7 +41,10 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -68,7 +71,7 @@ class IndexController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
@@ -85,23 +88,23 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show all budgets.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index(Request $request, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||
{
|
||||
Log::debug('Start of IndexController::index()');
|
||||
|
||||
// collect some basic vars:
|
||||
$range = (string) app('preferences')->get('viewRange', '1M')->data;
|
||||
$range = (string)app('preferences')->get('viewRange', '1M')->data;
|
||||
$start = $start ?? session('start', Carbon::now()->startOfMonth());
|
||||
$end = $end ?? app('navigation')->endOfPeriod($start, $range);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
@@ -160,8 +163,8 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -192,10 +195,10 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $currencies
|
||||
* @param TransactionCurrency $defaultCurrency
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $currencies
|
||||
* @param TransactionCurrency $defaultCurrency
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -250,7 +253,7 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $budgets
|
||||
* @param array $budgets
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -312,8 +315,8 @@ class IndexController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
* @param Request $request
|
||||
* @param BudgetRepositoryInterface $repository
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -322,7 +325,7 @@ class IndexController extends Controller
|
||||
$budgetIds = $request->get('budgetIds');
|
||||
|
||||
foreach ($budgetIds as $index => $budgetId) {
|
||||
$budgetId = (int) $budgetId;
|
||||
$budgetId = (int)$budgetId;
|
||||
$budget = $repository->find($budgetId);
|
||||
if (null !== $budget) {
|
||||
Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
|
||||
|
||||
@@ -37,6 +37,9 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,7 +64,7 @@ class ShowController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->journalRepos = app(JournalRepositoryInterface::class);
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
@@ -74,15 +77,15 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show transactions without a budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
|
||||
{
|
||||
@@ -99,8 +102,8 @@ class ShowController extends Controller
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$firstDate = null !== $first ? $first->date : $start;
|
||||
$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -115,21 +118,21 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Shows ALL transactions without a budget.
|
||||
*
|
||||
* @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 noBudgetAll(Request $request)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.all_journals_without_budget');
|
||||
$subTitle = (string)trans('firefly.all_journals_without_budget');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$end = today(config('app.timezone'));
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -144,22 +147,22 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a single budget.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Budget $budget)
|
||||
{
|
||||
/** @var Carbon $allStart */
|
||||
$allStart = session('first', Carbon::now()->startOfYear());
|
||||
$allEnd = today();
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$limits = $this->getLimits($budget, $allStart, $allEnd);
|
||||
$repetition = null;
|
||||
$attachments = $this->repository->getAttachments($budget);
|
||||
@@ -173,7 +176,7 @@ class ShowController extends Controller
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
$groups->setPath(route('budgets.show', [$budget->id]));
|
||||
|
||||
$subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
|
||||
$subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
|
||||
|
||||
return view('budgets.show', compact('limits', 'attachments', 'budget', 'repetition', 'groups', 'subTitle'));
|
||||
}
|
||||
@@ -181,15 +184,15 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a single budget by a budget limit.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param Request $request
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showByBudgetLimit(Request $request, Budget $budget, BudgetLimit $budgetLimit)
|
||||
{
|
||||
@@ -197,8 +200,8 @@ class ShowController extends Controller
|
||||
throw new FireflyException('This budget limit is not part of this budget.');
|
||||
}
|
||||
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$subTitle = trans(
|
||||
'firefly.budget_in_period',
|
||||
[
|
||||
|
||||
@@ -53,7 +53,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -66,7 +66,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class CreateController extends Controller
|
||||
$this->rememberPreviousUrl('categories.create.url');
|
||||
}
|
||||
$request->session()->forget('categories.create.fromStore');
|
||||
$subTitle = (string) trans('firefly.create_new_category');
|
||||
$subTitle = (string)trans('firefly.create_new_category');
|
||||
|
||||
return view('categories.create', compact('subTitle'));
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Store new category.
|
||||
*
|
||||
* @param CategoryFormRequest $request
|
||||
* @param CategoryFormRequest $request
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
@@ -94,7 +94,7 @@ class CreateController extends Controller
|
||||
$data = $request->getCategoryData();
|
||||
$category = $this->repository->store($data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -103,7 +103,7 @@ class CreateController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -111,7 +111,7 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
$redirect = redirect(route('categories.index'));
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
$request->session()->put('categories.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('categories.create'))->withInput();
|
||||
|
||||
@@ -51,7 +51,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
@@ -63,13 +63,13 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Delete a category.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param Category $category
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(Category $category)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]);
|
||||
$subTitle = (string)trans('firefly.delete_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('categories.delete.url');
|
||||
@@ -80,8 +80,8 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Destroy a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -90,7 +90,7 @@ class DeleteController extends Controller
|
||||
$name = $category->name;
|
||||
$this->repository->destroy($category);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_category', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('categories.delete.url'));
|
||||
|
||||
@@ -53,7 +53,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -66,14 +66,14 @@ class EditController extends Controller
|
||||
/**
|
||||
* Edit a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Request $request, Category $category)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.edit_category', ['name' => $category->name]);
|
||||
$subTitle = (string)trans('firefly.edit_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('categories.edit.fromUpdate')) {
|
||||
@@ -91,8 +91,8 @@ class EditController extends Controller
|
||||
/**
|
||||
* Update category.
|
||||
*
|
||||
* @param CategoryFormRequest $request
|
||||
* @param Category $category
|
||||
* @param CategoryFormRequest $request
|
||||
* @param Category $category
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ class EditController extends Controller
|
||||
$data = $request->getCategoryData();
|
||||
$this->repository->update($category, $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_category', ['name' => $category->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -110,7 +110,7 @@ class EditController extends Controller
|
||||
$this->attachments->saveAttachmentsForModel($category, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -118,7 +118,7 @@ class EditController extends Controller
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('categories.edit.url'));
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
$request->session()->put('categories.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('categories.edit', [$category->id]));
|
||||
|
||||
@@ -32,6 +32,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
@@ -52,7 +54,7 @@ class IndexController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
@@ -64,17 +66,17 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Show all categories.
|
||||
*
|
||||
* @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->repository->getCategories();
|
||||
$total = $collection->count();
|
||||
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
|
||||
@@ -34,7 +34,10 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -58,7 +61,7 @@ class NoCategoryController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->journalRepos = app(JournalRepositoryInterface::class);
|
||||
|
||||
@@ -70,15 +73,15 @@ class NoCategoryController extends Controller
|
||||
/**
|
||||
* Show transactions without a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Carbon $start = null, Carbon $end = null)// @phpstan-ignore-line
|
||||
{
|
||||
@@ -87,8 +90,8 @@ class NoCategoryController extends Controller
|
||||
$start = $start ?? session('start');
|
||||
/** @var Carbon $end */
|
||||
$end = $end ?? session('end');
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$subTitle = trans(
|
||||
'firefly.without_category_between',
|
||||
['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]
|
||||
@@ -113,12 +116,12 @@ class NoCategoryController extends Controller
|
||||
/**
|
||||
* Show all transactions without a category.
|
||||
*
|
||||
* @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 showAll(Request $request)
|
||||
{
|
||||
@@ -126,10 +129,10 @@ class NoCategoryController extends Controller
|
||||
$start = null;
|
||||
$end = null;
|
||||
$periods = new Collection();
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
Log::debug('Start of noCategory()');
|
||||
$subTitle = (string) trans('firefly.all_journals_without_category');
|
||||
$subTitle = (string)trans('firefly.all_journals_without_category');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$end = today(config('app.timezone'));
|
||||
|
||||
@@ -34,6 +34,9 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -59,7 +62,7 @@ class ShowController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.categories'));
|
||||
app('view')->share('title', (string)trans('firefly.categories'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bookmark');
|
||||
$this->repository = app(CategoryRepositoryInterface::class);
|
||||
|
||||
@@ -71,16 +74,16 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show a single category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) // @phpstan-ignore-line
|
||||
{
|
||||
@@ -89,16 +92,19 @@ class ShowController extends Controller
|
||||
/** @var Carbon $end */
|
||||
$end = $end ?? session('end', Carbon::now()->endOfMonth());
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int) $request->get('page');
|
||||
$page = (int)$request->get('page');
|
||||
$attachments = $this->repository->getAttachments($category);
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$oldest = $this->repository->firstUseDate($category) ?? Carbon::now()->startOfYear();
|
||||
$periods = $this->getCategoryPeriodOverview($category, $oldest, $end);
|
||||
$path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_category',
|
||||
['name' => $category->name, 'start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat),]
|
||||
[
|
||||
'name' => $category->name,
|
||||
'start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat),
|
||||
]
|
||||
);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
@@ -116,25 +122,25 @@ class ShowController extends Controller
|
||||
/**
|
||||
* Show all transactions within a category.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
* @param Request $request
|
||||
* @param Category $category
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showAll(Request $request, Category $category)
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$start = null;
|
||||
$end = null;
|
||||
$periods = new Collection();
|
||||
|
||||
$subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$first = $this->repository->firstUseDate($category);
|
||||
/** @var Carbon $start */
|
||||
$start = $first ?? today(config('app.timezone'));
|
||||
|
||||
@@ -42,6 +42,8 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class AccountController.
|
||||
@@ -130,7 +132,7 @@ class AccountController extends Controller
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'diff_float' => (float)$diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
@@ -327,8 +329,8 @@ class AccountController extends Controller
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function frontpage(AccountRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
@@ -580,7 +582,7 @@ class AccountController extends Controller
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'diff_float' => (float)$diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BillController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -23,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -54,7 +56,7 @@ class BillController extends Controller
|
||||
/**
|
||||
* Shows all bills and whether or not they've been paid this month (pie chart).
|
||||
*
|
||||
* @param BillRepositoryInterface $repository
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -79,15 +81,21 @@ class BillController extends Controller
|
||||
|
||||
foreach ($paid as $currencyId => $amount) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId);
|
||||
$label = (string) trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code];
|
||||
$label = (string)trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = [
|
||||
'amount' => $amount,
|
||||
'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code,
|
||||
];
|
||||
}
|
||||
foreach ($unpaid as $currencyId => $amount) {
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId);
|
||||
$label = (string) trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code];
|
||||
$label = (string)trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]);
|
||||
$chartData[$label] = [
|
||||
'amount' => $amount,
|
||||
'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_code' => $currencies[$currencyId]->code,
|
||||
];
|
||||
}
|
||||
|
||||
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||
@@ -99,10 +107,10 @@ class BillController extends Controller
|
||||
/**
|
||||
* Shows overview for a single bill.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function single(Bill $bill): JsonResponse
|
||||
{
|
||||
@@ -134,16 +142,31 @@ class BillController extends Controller
|
||||
);
|
||||
|
||||
$chartData = [
|
||||
['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
|
||||
['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
|
||||
['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code, 'entries' => []],
|
||||
[
|
||||
'type' => 'line',
|
||||
'label' => (string)trans('firefly.min-amount'),
|
||||
'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code,
|
||||
'entries' => [],
|
||||
],
|
||||
[
|
||||
'type' => 'line',
|
||||
'label' => (string)trans('firefly.max-amount'),
|
||||
'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code,
|
||||
'entries' => [],
|
||||
],
|
||||
[
|
||||
'type' => 'bar',
|
||||
'label' => (string)trans('firefly.journal-amount'),
|
||||
'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code,
|
||||
'entries' => [],
|
||||
],
|
||||
];
|
||||
$currencyId = (int) $bill->transaction_currency_id;
|
||||
$currencyId = (int)$bill->transaction_currency_id;
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$date = $journal['date']->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
|
||||
$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of bill
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BudgetController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -41,7 +42,6 @@ use FireflyIII\Support\Http\Controllers\AugumentData;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class BudgetController.
|
||||
@@ -83,7 +83,7 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows overview of a single budget.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -148,8 +148,8 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows the amount left in a specific budget limit.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -181,14 +181,14 @@ class BudgetController extends Controller
|
||||
while ($start <= $end) {
|
||||
$current = clone $start;
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency);
|
||||
$spent = $expenses[(int) $currency->id]['sum'] ?? '0';
|
||||
$spent = $expenses[(int)$currency->id]['sum'] ?? '0';
|
||||
$amount = bcadd($amount, $spent);
|
||||
$format = $start->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$format = $start->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$entries[$format] = $amount;
|
||||
|
||||
$start->addDay();
|
||||
}
|
||||
$data = $this->generator->singleSet((string) trans('firefly.left'), $entries);
|
||||
$data = $this->generator->singleSet((string)trans('firefly.left'), $entries);
|
||||
// add currency symbol from budget limit:
|
||||
$data['datasets'][0]['currency_symbol'] = $budgetLimit->transactionCurrency->symbol;
|
||||
$data['datasets'][0]['currency_code'] = $budgetLimit->transactionCurrency->code;
|
||||
@@ -200,8 +200,8 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows how much is spent per asset account.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -236,20 +236,20 @@ class BudgetController extends Controller
|
||||
|
||||
// group by asset account ID:
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', (int) $journal['source_account_id'], $journal['currency_id']);
|
||||
$key = sprintf('%d-%d', (int)$journal['source_account_id'], $journal['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
$result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']);
|
||||
}
|
||||
|
||||
$names = $this->getAccountNames(array_keys($result));
|
||||
foreach ($result as $combinedId => $info) {
|
||||
$parts = explode('-', $combinedId);
|
||||
$assetId = (int) $parts[0];
|
||||
$assetId = (int)$parts[0];
|
||||
$title = sprintf('%s (%s)', $names[$assetId] ?? '(empty)', $info['currency_name']);
|
||||
$chartData[$title]
|
||||
= [
|
||||
@@ -268,8 +268,8 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows how much is spent per category.
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -303,18 +303,18 @@ class BudgetController extends Controller
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
$result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']);
|
||||
}
|
||||
|
||||
$names = $this->getCategoryNames(array_keys($result));
|
||||
foreach ($result as $combinedId => $info) {
|
||||
$parts = explode('-', $combinedId);
|
||||
$categoryId = (int) $parts[0];
|
||||
$categoryId = (int)$parts[0];
|
||||
$title = sprintf('%s (%s)', $names[$categoryId] ?? '(empty)', $info['currency_name']);
|
||||
$chartData[$title] = [
|
||||
'amount' => $info['amount'],
|
||||
@@ -332,8 +332,8 @@ class BudgetController extends Controller
|
||||
* Shows how much is spent per expense account.
|
||||
*
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
* @param Budget $budget
|
||||
* @param BudgetLimit|null $budgetLimit
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -368,18 +368,18 @@ class BudgetController extends Controller
|
||||
foreach ($journals as $journal) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']);
|
||||
$result[$key] = $result[$key] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
];
|
||||
$result[$key]['amount'] = bcadd($journal['amount'], $result[$key]['amount']);
|
||||
}
|
||||
|
||||
$names = $this->getAccountNames(array_keys($result));
|
||||
foreach ($result as $combinedId => $info) {
|
||||
$parts = explode('-', $combinedId);
|
||||
$opposingId = (int) $parts[0];
|
||||
$opposingId = (int)$parts[0];
|
||||
$name = $names[$opposingId] ?? 'no name';
|
||||
$title = sprintf('%s (%s)', $name, $info['currency_name']);
|
||||
$chartData[$title] = [
|
||||
@@ -429,11 +429,11 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows a budget overview chart (spent and budgeted).
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Budget $budget
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -454,14 +454,14 @@ class BudgetController extends Controller
|
||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||
$chartData = [
|
||||
[
|
||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency->name]),
|
||||
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency->name]),
|
||||
'type' => 'bar',
|
||||
'entries' => [],
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
],
|
||||
[
|
||||
'label' => (string) trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]),
|
||||
'label' => (string)trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
@@ -505,10 +505,10 @@ class BudgetController extends Controller
|
||||
/**
|
||||
* Shows a chart for transactions without a budget.
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -539,7 +539,7 @@ class BudgetController extends Controller
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);
|
||||
}
|
||||
|
||||
$data = $this->generator->singleSet((string) trans('firefly.spent'), $chartData);
|
||||
$data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);
|
||||
$cache->store($data);
|
||||
|
||||
return response()->json($data);
|
||||
|
||||
@@ -71,10 +71,10 @@ class BudgetReportController extends Controller
|
||||
/**
|
||||
* Chart that groups the expenses by budget.
|
||||
*
|
||||
* @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 JsonResponse
|
||||
*/
|
||||
@@ -88,10 +88,10 @@ class BudgetReportController extends Controller
|
||||
foreach ($currency['budgets'] as $budget) {
|
||||
$title = sprintf('%s (%s)', $budget['name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($budget['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -107,10 +107,10 @@ class BudgetReportController extends Controller
|
||||
/**
|
||||
* Chart that groups the expenses by budget.
|
||||
*
|
||||
* @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 JsonResponse
|
||||
*/
|
||||
@@ -125,10 +125,10 @@ class BudgetReportController extends Controller
|
||||
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -144,10 +144,10 @@ class BudgetReportController extends Controller
|
||||
/**
|
||||
* Chart that groups expenses by the account.
|
||||
*
|
||||
* @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 JsonResponse
|
||||
*/
|
||||
@@ -162,10 +162,10 @@ class BudgetReportController extends Controller
|
||||
foreach ($budget['transaction_journals'] as $journal) {
|
||||
$title = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -181,10 +181,10 @@ class BudgetReportController extends Controller
|
||||
/**
|
||||
* Main overview of a budget in the budget report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -199,17 +199,17 @@ class BudgetReportController extends Controller
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-spent', $currency['currency_id']);
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['budgets'] as $currentBudget) {
|
||||
foreach ($currentBudget['transaction_journals'] as $journal) {
|
||||
@@ -227,8 +227,8 @@ class BudgetReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -252,10 +252,10 @@ class BudgetReportController extends Controller
|
||||
/**
|
||||
* Chart that groups expenses by the account.
|
||||
*
|
||||
* @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 JsonResponse
|
||||
*/
|
||||
@@ -270,10 +270,10 @@ class BudgetReportController extends Controller
|
||||
foreach ($budget['transaction_journals'] as $journal) {
|
||||
$title = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
|
||||
@@ -39,6 +39,8 @@ use FireflyIII\Support\Http\Controllers\ChartGeneration;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class CategoryController.
|
||||
@@ -72,8 +74,8 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function all(Category $category): JsonResponse
|
||||
{
|
||||
@@ -286,8 +288,8 @@ class CategoryController extends Controller
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function specificPeriod(Category $category, Carbon $date): JsonResponse
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CategoryReportController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -66,10 +67,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -86,10 +87,10 @@ class CategoryReportController extends Controller
|
||||
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -102,10 +103,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -120,10 +121,10 @@ class CategoryReportController extends Controller
|
||||
foreach ($currency['categories'] as $category) {
|
||||
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($category['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -137,10 +138,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -155,10 +156,10 @@ class CategoryReportController extends Controller
|
||||
foreach ($currency['categories'] as $category) {
|
||||
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($category['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -172,10 +173,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -192,10 +193,10 @@ class CategoryReportController extends Controller
|
||||
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -208,10 +209,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -228,10 +229,10 @@ class CategoryReportController extends Controller
|
||||
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -244,10 +245,10 @@ class CategoryReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -264,17 +265,17 @@ class CategoryReportController extends Controller
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-spent', $currency['currency_id']);
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.spent_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['categories'] as $currentCategory) {
|
||||
foreach ($currentCategory['transaction_journals'] as $journal) {
|
||||
@@ -291,17 +292,17 @@ class CategoryReportController extends Controller
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-earned', $currency['currency_id']);
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.earned_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['categories'] as $currentCategory) {
|
||||
foreach ($currentCategory['transaction_journals'] as $journal) {
|
||||
@@ -321,8 +322,8 @@ class CategoryReportController extends Controller
|
||||
/**
|
||||
* TODO duplicate function
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -344,10 +345,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -364,10 +365,10 @@ class CategoryReportController extends Controller
|
||||
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -380,10 +381,10 @@ class CategoryReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -400,10 +401,10 @@ class CategoryReportController extends Controller
|
||||
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -86,10 +86,10 @@ class DoubleReportController extends Controller
|
||||
$categoryName = $journal['budget_name'] ?? trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -101,10 +101,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -121,10 +121,10 @@ class DoubleReportController extends Controller
|
||||
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -136,10 +136,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -156,10 +156,10 @@ class DoubleReportController extends Controller
|
||||
$categoryName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -171,10 +171,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Account $account
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -196,17 +196,17 @@ class DoubleReportController extends Controller
|
||||
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
|
||||
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.spent_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
@@ -222,17 +222,17 @@ class DoubleReportController extends Controller
|
||||
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
|
||||
|
||||
$chartData[$earnedKey] = $chartData[$earnedKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.earned_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['transaction_journals'] as $journal) {
|
||||
$key = $journal['date']->isoFormat($format);
|
||||
@@ -250,10 +250,10 @@ class DoubleReportController extends Controller
|
||||
/**
|
||||
* TODO duplicate function
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param null|string $iban
|
||||
* @param Collection $accounts
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param null|string $iban
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -275,8 +275,8 @@ class DoubleReportController extends Controller
|
||||
/**
|
||||
* TODO duplicate function
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -298,10 +298,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -324,10 +324,10 @@ class DoubleReportController extends Controller
|
||||
$tagName = trans('firefly.no_tags');
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -342,10 +342,10 @@ class DoubleReportController extends Controller
|
||||
$tagName = $tag['name'];
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -358,10 +358,10 @@ class DoubleReportController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $others
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -384,10 +384,10 @@ class DoubleReportController extends Controller
|
||||
$tagName = trans('firefly.no_tags');
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -402,10 +402,10 @@ class DoubleReportController extends Controller
|
||||
$tagName = $tag['name'];
|
||||
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
|
||||
@@ -73,10 +73,10 @@ class ExpenseReportController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi currency aware.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws JsonException
|
||||
@@ -106,35 +106,35 @@ class ExpenseReportController extends Controller
|
||||
|
||||
// prep chart data:
|
||||
/**
|
||||
* @var string $name
|
||||
* @var string $name
|
||||
* @var Collection $combination
|
||||
*/
|
||||
foreach ($combined as $name => $combination) {
|
||||
// first is always expense account:
|
||||
/** @var Account $exp */
|
||||
$exp = $combination->first();
|
||||
$chartData[$exp->id . '-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.income')),
|
||||
$exp = $combination->first();
|
||||
$chartData[$exp->id.'-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.income')),
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id . '-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.expenses')),
|
||||
$chartData[$exp->id.'-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.expenses')),
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
// total in, total out:
|
||||
$chartData[$exp->id . '-total-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_income')),
|
||||
$chartData[$exp->id.'-total-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_income')),
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id . '-total-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_expenses')),
|
||||
$chartData[$exp->id.'-total-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_expenses')),
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
@@ -158,10 +158,10 @@ class ExpenseReportController extends Controller
|
||||
// first is always expense account:
|
||||
/** @var Account $exp */
|
||||
$exp = $combination->first();
|
||||
$labelIn = $exp->id . '-in';
|
||||
$labelOut = $exp->id . '-out';
|
||||
$labelSumIn = $exp->id . '-total-in';
|
||||
$labelSumOut = $exp->id . '-total-out';
|
||||
$labelIn = $exp->id.'-in';
|
||||
$labelOut = $exp->id.'-out';
|
||||
$labelSumIn = $exp->id.'-total-in';
|
||||
$labelSumOut = $exp->id.'-total-out';
|
||||
$currentIncome = bcmul($income[$name] ?? '0', '-1');
|
||||
$currentExpense = $expenses[$name] ?? '0';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PiggyBankController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -23,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
@@ -31,7 +33,6 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Http\Controllers\DateCalculation;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class PiggyBankController.
|
||||
@@ -60,11 +61,11 @@ class PiggyBankController extends Controller
|
||||
*
|
||||
* TODO this chart is not multi currency aware.
|
||||
*
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param PiggyBankRepositoryInterface $repository
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function history(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
@@ -100,7 +101,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
);
|
||||
$currentSum = $filtered->sum('amount');
|
||||
$label = $oldest->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$label = $oldest->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$chartData[$label] = $currentSum;
|
||||
$oldest = app('navigation')->addPeriod($oldest, $step, 0);
|
||||
}
|
||||
@@ -110,7 +111,7 @@ class PiggyBankController extends Controller
|
||||
}
|
||||
);
|
||||
$finalSum = $finalFiltered->sum('amount');
|
||||
$finalLabel = $today->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$finalLabel = $today->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$chartData[$finalLabel] = $finalSum;
|
||||
|
||||
$data = $this->generator->singleSet($piggyBank->name, $chartData);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ReportController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -23,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
@@ -65,12 +67,12 @@ class ReportController extends Controller
|
||||
* This chart, by default, is shown on the multi-year and year report pages,
|
||||
* which means that giving it a 2 week "period" should be enough granularity.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function netWorth(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||
{
|
||||
@@ -115,10 +117,10 @@ class ReportController extends Controller
|
||||
/** @var array $netWorthItem */
|
||||
foreach ($result as $netWorthItem) {
|
||||
$currencyId = $netWorthItem['currency']->id;
|
||||
$label = $current->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
$label = $current->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
if (!array_key_exists($currencyId, $chartData)) {
|
||||
$chartData[$currencyId] = [
|
||||
'label' => 'Net worth in ' . $netWorthItem['currency']->name,
|
||||
'label' => 'Net worth in '.$netWorthItem['currency']->name,
|
||||
'type' => 'line',
|
||||
'currency_symbol' => $netWorthItem['currency']->symbol,
|
||||
'currency_code' => $netWorthItem['currency']->code,
|
||||
@@ -139,9 +141,9 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Shows income and expense, debit/credit: operations.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws JsonException
|
||||
@@ -179,13 +181,13 @@ class ReportController extends Controller
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$period = $journal['date']->format($format);
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$data[$currencyId] = $data[$currencyId] ?? [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_decimal_places' => (int) $journal['currency_decimal_places'],
|
||||
'currency_decimal_places' => (int)$journal['currency_decimal_places'],
|
||||
];
|
||||
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
|
||||
'period' => $period,
|
||||
@@ -220,7 +222,7 @@ class ReportController extends Controller
|
||||
/** @var array $currency */
|
||||
foreach ($data as $currency) {
|
||||
$income = [
|
||||
'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||
'currency_id' => $currency['currency_id'],
|
||||
@@ -229,7 +231,7 @@ class ReportController extends Controller
|
||||
'entries' => [],
|
||||
];
|
||||
$expense = [
|
||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
'currency_id' => $currency['currency_id'],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TagReportController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -67,10 +68,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -87,10 +88,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -103,10 +104,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -123,10 +124,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -139,10 +140,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -159,10 +160,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['category_name'] ?? trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -175,10 +176,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -195,10 +196,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -211,10 +212,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -231,10 +232,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -249,10 +250,10 @@ class TagReportController extends Controller
|
||||
/**
|
||||
* Generate main tag overview chart.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Tag $tag
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Tag $tag
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -269,17 +270,17 @@ class TagReportController extends Controller
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-spent', $currency['currency_id']);
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['tags'] as $currentTag) {
|
||||
foreach ($currentTag['transaction_journals'] as $journal) {
|
||||
@@ -296,17 +297,17 @@ class TagReportController extends Controller
|
||||
// add things to chart Data for each currency:
|
||||
$spentKey = sprintf('%d-earned', $currency['currency_id']);
|
||||
$chartData[$spentKey] = $chartData[$spentKey] ?? [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string) trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_id' => $currency['currency_id'],
|
||||
'entries' => $this->makeEntries($start, $end),
|
||||
];
|
||||
|
||||
foreach ($currency['tags'] as $currentTag) {
|
||||
foreach ($currentTag['transaction_journals'] as $journal) {
|
||||
@@ -326,8 +327,8 @@ class TagReportController extends Controller
|
||||
/**
|
||||
* TODO duplicate function
|
||||
*
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -349,10 +350,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -369,10 +370,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -385,10 +386,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -405,10 +406,10 @@ class TagReportController extends Controller
|
||||
$objectName = $journal['source_account_name'] ?? trans('firefly.empty');
|
||||
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
}
|
||||
@@ -421,10 +422,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -439,10 +440,10 @@ class TagReportController extends Controller
|
||||
foreach ($currency['tags'] as $tag) {
|
||||
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
@@ -455,10 +456,10 @@ class TagReportController 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 JsonResponse
|
||||
*/
|
||||
@@ -473,10 +474,10 @@ class TagReportController extends Controller
|
||||
foreach ($currency['tags'] as $tag) {
|
||||
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
|
||||
$result[$title] = $result[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
];
|
||||
foreach ($tag['transaction_journals'] as $journal) {
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);
|
||||
|
||||
@@ -32,7 +32,6 @@ use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class TransactionController
|
||||
@@ -52,8 +51,8 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -78,13 +77,13 @@ class TransactionController extends Controller
|
||||
// group by category.
|
||||
/** @var array $journal */
|
||||
foreach ($result as $journal) {
|
||||
$budget = $journal['budget_name'] ?? (string) trans('firefly.no_budget');
|
||||
$budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget');
|
||||
$title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
@@ -94,9 +93,9 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -132,13 +131,13 @@ class TransactionController extends Controller
|
||||
// group by category.
|
||||
/** @var array $journal */
|
||||
foreach ($result as $journal) {
|
||||
$category = $journal['category_name'] ?? (string) trans('firefly.no_category');
|
||||
$category = $journal['category_name'] ?? (string)trans('firefly.no_category');
|
||||
$title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
@@ -148,9 +147,9 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -189,10 +188,10 @@ class TransactionController extends Controller
|
||||
$name = $journal['destination_account_name'];
|
||||
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
@@ -202,9 +201,9 @@ class TransactionController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param string $objectType
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -243,10 +242,10 @@ class TransactionController extends Controller
|
||||
$name = $journal['source_account_name'];
|
||||
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
|
||||
$data[$title] = $data[$title] ?? [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
];
|
||||
$data[$title]['amount'] = bcadd($data[$title]['amount'], $journal['amount']);
|
||||
}
|
||||
$chart = $this->generator->multiCurrencyPieChart($data);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controller.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -96,9 +97,9 @@ abstract class Controller extends BaseController
|
||||
function ($request, $next): mixed {
|
||||
$locale = app('steam')->getLocale();
|
||||
// translations for specific strings:
|
||||
$this->monthFormat = (string) trans('config.month_js', [], $locale);
|
||||
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
||||
$this->monthFormat = (string)trans('config.month_js', [], $locale);
|
||||
$this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
|
||||
$this->dateTimeFormat = (string)trans('config.date_time_js', [], $locale);
|
||||
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CurrencyController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -36,6 +37,8 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class CurrencyController.
|
||||
@@ -56,7 +59,7 @@ class CurrencyController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.currencies'));
|
||||
app('view')->share('title', (string)trans('firefly.currencies'));
|
||||
app('view')->share('mainTitleIcon', 'fa-usd');
|
||||
$this->repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->userRepository = app(UserRepositoryInterface::class);
|
||||
@@ -69,7 +72,7 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Create a currency.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -78,13 +81,13 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
$subTitleIcon = 'fa-plus';
|
||||
$subTitle = (string) trans('firefly.create_currency');
|
||||
$subTitle = (string)trans('firefly.create_currency');
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('currencies.create.fromStore')) {
|
||||
@@ -100,14 +103,14 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Make currency the default currency.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function defaultCurrency(Request $request)
|
||||
{
|
||||
$currencyId = (int) $request->get('id');
|
||||
$currencyId = (int)$request->get('id');
|
||||
if ($currencyId > 0) {
|
||||
// valid currency?
|
||||
$currency = $this->repository->find($currencyId);
|
||||
@@ -117,7 +120,7 @@ class CurrencyController extends Controller
|
||||
Log::channel('audit')->info(sprintf('Make %s the default currency.', $currency->code));
|
||||
|
||||
$this->repository->enable($currency);
|
||||
$request->session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.new_default_currency', ['name' => $currency->name]));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
@@ -129,8 +132,8 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Deletes a currency.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -139,7 +142,7 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
@@ -147,7 +150,7 @@ class CurrencyController extends Controller
|
||||
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
$location = $this->repository->currencyInUseAt($currency);
|
||||
$message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
|
||||
$message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
|
||||
$request->session()->flash('error', $message);
|
||||
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code));
|
||||
|
||||
@@ -156,7 +159,7 @@ class CurrencyController extends Controller
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('currencies.delete.url');
|
||||
$subTitle = (string) trans('form.delete_currency', ['name' => $currency->name]);
|
||||
$subTitle = (string)trans('form.delete_currency', ['name' => $currency->name]);
|
||||
Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code));
|
||||
|
||||
return view('currencies.delete', compact('currency', 'subTitle'));
|
||||
@@ -165,8 +168,8 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Destroys a currency.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -175,21 +178,21 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_delete_currency', ['name' => e($currency->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_delete_currency', ['name' => e($currency->name)]));
|
||||
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
if ($this->repository->isFallbackCurrency($currency)) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));
|
||||
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
@@ -198,19 +201,19 @@ class CurrencyController extends Controller
|
||||
Log::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code));
|
||||
$this->repository->destroy($currency);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_currency', ['name' => $currency->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_currency', ['name' => $currency->name]));
|
||||
|
||||
return redirect($this->getPreviousUrl('currencies.delete.url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function disableCurrency(Request $request): JsonResponse
|
||||
{
|
||||
$currencyId = (int) $request->get('id');
|
||||
$currencyId = (int)$request->get('id');
|
||||
$currency = $this->repository->find($currencyId);
|
||||
|
||||
// valid currency?
|
||||
@@ -224,7 +227,7 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code));
|
||||
return response()->json([]);
|
||||
}
|
||||
@@ -232,7 +235,7 @@ class CurrencyController extends Controller
|
||||
// currency cannot be in use.
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
$location = $this->repository->currencyInUseAt($currency);
|
||||
$message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
|
||||
$message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
|
||||
|
||||
$request->session()->flash('error', $message);
|
||||
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is in use.', $currency->code));
|
||||
@@ -247,18 +250,18 @@ class CurrencyController extends Controller
|
||||
|
||||
// extra warning
|
||||
if ('EUR' === $currency->code) {
|
||||
session()->flash('warning', (string) trans('firefly.disable_EUR_side_effects'));
|
||||
session()->flash('warning', (string)trans('firefly.disable_EUR_side_effects'));
|
||||
}
|
||||
|
||||
session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
|
||||
session()->flash('success', (string)trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a currency.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Request $request
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
@@ -267,20 +270,20 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$subTitle = (string) trans('breadcrumbs.edit_currency', ['name' => $currency->name]);
|
||||
$subTitle = (string)trans('breadcrumbs.edit_currency', ['name' => $currency->name]);
|
||||
$currency->symbol = htmlentities($currency->symbol);
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'enabled' => $hasOldInput ? (bool) $request->old('enabled') : $currency->enabled,
|
||||
'enabled' => $hasOldInput ? (bool)$request->old('enabled') : $currency->enabled,
|
||||
];
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
@@ -296,12 +299,12 @@ class CurrencyController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function enableCurrency(Request $request): JsonResponse
|
||||
{
|
||||
$currencyId = (int) $request->get('id');
|
||||
$currencyId = (int)$request->get('id');
|
||||
if ($currencyId > 0) {
|
||||
// valid currency?
|
||||
$currency = $this->repository->find($currencyId);
|
||||
@@ -309,7 +312,7 @@ class CurrencyController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
$this->repository->enable($currency);
|
||||
session()->flash('success', (string) trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));
|
||||
session()->flash('success', (string)trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));
|
||||
Log::channel('audit')->info(sprintf('Enabled currency %s.', $currency->code));
|
||||
}
|
||||
}
|
||||
@@ -320,19 +323,19 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Show overview of currencies.
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->repository->getAll();
|
||||
$total = $collection->count();
|
||||
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
@@ -342,7 +345,7 @@ class CurrencyController extends Controller
|
||||
$defaultCurrency = $this->repository->getCurrencyByPreference(app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR')));
|
||||
$isOwner = true;
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('info', (string) trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));
|
||||
$request->session()->flash('info', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));
|
||||
$isOwner = false;
|
||||
}
|
||||
|
||||
@@ -352,7 +355,7 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Store new currency.
|
||||
*
|
||||
* @param CurrencyFormRequest $request
|
||||
* @param CurrencyFormRequest $request
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -362,7 +365,7 @@ class CurrencyController extends Controller
|
||||
$user = auth()->user();
|
||||
$data = $request->getCurrencyData();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
|
||||
Log::error('User '.auth()->user()->id.' is not admin, but tried to store a currency.');
|
||||
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
|
||||
|
||||
return redirect($this->getPreviousUrl('currencies.create.url'));
|
||||
@@ -374,15 +377,15 @@ class CurrencyController extends Controller
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
|
||||
$request->session()->flash('error', (string) trans('firefly.could_not_store_currency'));
|
||||
$request->session()->flash('error', (string)trans('firefly.could_not_store_currency'));
|
||||
$currency = null;
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('currencies.create.url'));
|
||||
|
||||
if (null !== $currency) {
|
||||
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.created_currency', ['name' => $currency->name]));
|
||||
Log::channel('audit')->info('Created (POST) currency.', $data);
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
$request->session()->put('currencies.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('currencies.create'))->withInput();
|
||||
@@ -395,8 +398,8 @@ class CurrencyController extends Controller
|
||||
/**
|
||||
* Updates a currency.
|
||||
*
|
||||
* @param CurrencyFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
* @param CurrencyFormRequest $request
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -410,17 +413,17 @@ class CurrencyController extends Controller
|
||||
$data['enabled'] = true;
|
||||
}
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
$request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data);
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
}
|
||||
$currency = $this->repository->update($currency, $data);
|
||||
Log::channel('audit')->info('Updated (POST) currency.', $data);
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_currency', ['name' => $currency->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_currency', ['name' => $currency->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
$request->session()->put('currencies.edit.fromUpdate', true);
|
||||
|
||||
return redirect(route('currencies.edit', [$currency->id]));
|
||||
|
||||
@@ -81,14 +81,14 @@ class DebugController extends Controller
|
||||
/**
|
||||
* Clear log and session.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function flush(Request $request)
|
||||
{
|
||||
app('preferences')->mark();
|
||||
$request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range','temp-mfa-secret','temp-mfa-codes']);
|
||||
$request->session()->forget(['start', 'end', '_previous', 'viewRange', 'range', 'is_custom_range', 'temp-mfa-secret', 'temp-mfa-codes']);
|
||||
Log::debug('Call cache:clear...');
|
||||
Artisan::call('cache:clear');
|
||||
Log::debug('Call config:clear...');
|
||||
@@ -112,7 +112,7 @@ class DebugController extends Controller
|
||||
/**
|
||||
* Show debug info.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
@@ -142,10 +142,10 @@ class DebugController extends Controller
|
||||
$logChannel = config('logging.default');
|
||||
$appLogLevel = config('logging.level');
|
||||
$displayErrors = ini_get('display_errors');
|
||||
$errorReporting = $this->errorReporting((int) ini_get('error_reporting'));
|
||||
$errorReporting = $this->errorReporting((int)ini_get('error_reporting'));
|
||||
$interface = PHP_SAPI;
|
||||
$defaultLanguage = (string) config('firefly.default_language');
|
||||
$defaultLocale = (string) config('firefly.default_locale');
|
||||
$defaultLanguage = (string)config('firefly.default_language');
|
||||
$defaultLocale = (string)config('firefly.default_locale');
|
||||
$bcscale = bcscale();
|
||||
$drivers = implode(', ', DB::availableDrivers());
|
||||
$currentDriver = DB::getDriverName();
|
||||
@@ -196,7 +196,7 @@ class DebugController extends Controller
|
||||
}
|
||||
if ('' !== $logContent) {
|
||||
// last few lines
|
||||
$logContent = 'Truncated from this point <----|' . substr($logContent, -8192);
|
||||
$logContent = 'Truncated from this point <----|'.substr($logContent, -8192);
|
||||
}
|
||||
|
||||
return view(
|
||||
@@ -247,21 +247,59 @@ class DebugController extends Controller
|
||||
public function routes(): string
|
||||
{
|
||||
$set = RouteFacade::getRoutes();
|
||||
$ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.', 'attachments.download', 'attachments.preview',
|
||||
'bills.rescan', 'budgets.income', 'currencies.def', 'error', 'flush', 'help.show',
|
||||
'login', 'logout', 'password.reset', 'profile.confirm-email-change', 'profile.undo-email-change',
|
||||
'register', 'report.options', 'routes', 'rule-groups.down', 'rule-groups.up', 'rules.up', 'rules.down',
|
||||
'rules.select', 'search.search', 'test-flash', 'transactions.link.delete', 'transactions.link.switch',
|
||||
'two-factor.lost', 'reports.options', 'debug',
|
||||
'preferences.delete-code', 'rules.test-triggers', 'piggy-banks.remove-money', 'piggy-banks.add-money',
|
||||
'accounts.reconcile.transactions', 'accounts.reconcile.overview',
|
||||
'transactions.clone', 'two-factor.index', 'api.v1', 'installer.', 'attachments.view', 'recurring.events',
|
||||
'recurring.suggest',
|
||||
$ignore = [
|
||||
'chart.',
|
||||
'javascript.',
|
||||
'json.',
|
||||
'report-data.',
|
||||
'popup.',
|
||||
'debugbar.',
|
||||
'attachments.download',
|
||||
'attachments.preview',
|
||||
'bills.rescan',
|
||||
'budgets.income',
|
||||
'currencies.def',
|
||||
'error',
|
||||
'flush',
|
||||
'help.show',
|
||||
'login',
|
||||
'logout',
|
||||
'password.reset',
|
||||
'profile.confirm-email-change',
|
||||
'profile.undo-email-change',
|
||||
'register',
|
||||
'report.options',
|
||||
'routes',
|
||||
'rule-groups.down',
|
||||
'rule-groups.up',
|
||||
'rules.up',
|
||||
'rules.down',
|
||||
'rules.select',
|
||||
'search.search',
|
||||
'test-flash',
|
||||
'transactions.link.delete',
|
||||
'transactions.link.switch',
|
||||
'two-factor.lost',
|
||||
'reports.options',
|
||||
'debug',
|
||||
'preferences.delete-code',
|
||||
'rules.test-triggers',
|
||||
'piggy-banks.remove-money',
|
||||
'piggy-banks.add-money',
|
||||
'accounts.reconcile.transactions',
|
||||
'accounts.reconcile.overview',
|
||||
'transactions.clone',
|
||||
'two-factor.index',
|
||||
'api.v1',
|
||||
'installer.',
|
||||
'attachments.view',
|
||||
'recurring.events',
|
||||
'recurring.suggest',
|
||||
];
|
||||
$return = ' ';
|
||||
/** @var Route $route */
|
||||
foreach ($set as $route) {
|
||||
$name = (string) $route->getName();
|
||||
$name = (string)$route->getName();
|
||||
if (in_array('GET', $route->methods(), true)) {
|
||||
$found = false;
|
||||
foreach ($ignore as $string) {
|
||||
@@ -271,7 +309,7 @@ class DebugController extends Controller
|
||||
}
|
||||
}
|
||||
if (false === $found) {
|
||||
$return .= 'touch ' . $route->getName() . '.md;';
|
||||
$return .= 'touch '.$route->getName().'.md;';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +320,7 @@ class DebugController extends Controller
|
||||
/**
|
||||
* Flash all types of messages.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
|
||||
@@ -53,7 +53,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-life-bouy');
|
||||
app('view')->share('title', (string) trans('firefly.export_data_title'));
|
||||
app('view')->share('title', (string)trans('firefly.export_data_title'));
|
||||
$this->journalRepository = app(JournalRepositoryInterface::class);
|
||||
$this->middleware(IsDemoUser::class)->except(['index']);
|
||||
|
||||
@@ -92,7 +92,7 @@ class IndexController extends Controller
|
||||
$response
|
||||
->header('Content-Description', 'File Transfer')
|
||||
->header('Content-Type', 'text/x-csv')
|
||||
->header('Content-Disposition', 'attachment; filename=' . $quoted)
|
||||
->header('Content-Disposition', 'attachment; filename='.$quoted)
|
||||
//->header('Content-Transfer-Encoding', 'binary')
|
||||
->header('Connection', 'Keep-Alive')
|
||||
->header('Expires', '0')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HomeController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -25,6 +26,7 @@ namespace FireflyIII\Http\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Events\RequestedVersionCheckStatus;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Middleware\Installer;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@@ -57,7 +59,7 @@ class HomeController extends Controller
|
||||
/**
|
||||
* Change index date range.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws Exception
|
||||
@@ -72,7 +74,7 @@ class HomeController extends Controller
|
||||
Log::debug('Received dateRange', ['start' => $request->get('start'), 'end' => $request->get('end'), 'label' => $request->get('label')]);
|
||||
// check if the label is "everything" or "Custom range" which will betray
|
||||
// a possible problem with the budgets.
|
||||
if ($label === (string) trans('firefly.everything') || $label === (string) trans('firefly.customRange')) {
|
||||
if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
|
||||
$isCustomRange = true;
|
||||
Log::debug('Range is now marked as "custom".');
|
||||
}
|
||||
@@ -80,7 +82,7 @@ class HomeController extends Controller
|
||||
$diff = $start->diffInDays($end) + 1;
|
||||
|
||||
if ($diff > 50) {
|
||||
$request->session()->flash('warning', (string) trans('firefly.warning_much_data', ['days' => $diff]));
|
||||
$request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => $diff]));
|
||||
}
|
||||
|
||||
$request->session()->put('is_custom_range', $isCustomRange);
|
||||
@@ -96,10 +98,10 @@ class HomeController extends Controller
|
||||
/**
|
||||
* Show index.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository): mixed
|
||||
{
|
||||
@@ -113,13 +115,13 @@ class HomeController extends Controller
|
||||
if (0 === $count) {
|
||||
return redirect(route('new-user.index'));
|
||||
}
|
||||
$subTitle = (string) trans('firefly.welcome_back');
|
||||
$subTitle = (string)trans('firefly.welcome_back');
|
||||
$transactions = [];
|
||||
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$accounts = $repository->getAccountsById($frontPage->data);
|
||||
$today = today(config('app.timezone'));
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* JavascriptController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -32,6 +33,9 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\GetConfigurationData;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use JsonException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class JavascriptController.
|
||||
@@ -43,13 +47,13 @@ class JavascriptController extends Controller
|
||||
/**
|
||||
* Show info about accounts.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
*
|
||||
* @return Response
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function accounts(AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
{
|
||||
@@ -57,14 +61,14 @@ class JavascriptController extends Controller
|
||||
[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]
|
||||
);
|
||||
$preference = app('preferences')->get('currencyPreference', config('firefly.default_currency', 'EUR'));
|
||||
$default = $currencyRepository->findByCodeNull((string) $preference->data);
|
||||
$default = $currencyRepository->findByCodeNull((string)$preference->data);
|
||||
|
||||
$data = ['accounts' => []];
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountId = $account->id;
|
||||
$currency = (int) $repository->getMetaValue($account, 'currency_id');
|
||||
$accountId = $account->id;
|
||||
$currency = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$currency = 0 === $currency ? $default->id : $currency;
|
||||
$entry = ['preferredCurrency' => $currency, 'name' => $account->name];
|
||||
$data['accounts'][$accountId] = $entry;
|
||||
@@ -78,7 +82,7 @@ class JavascriptController extends Controller
|
||||
/**
|
||||
* Get info about currencies.
|
||||
*
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@@ -101,19 +105,19 @@ class JavascriptController extends Controller
|
||||
/**
|
||||
* Show some common variables to be used in scripts.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
* @param Request $request
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
*
|
||||
* @return Response
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws JsonException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response
|
||||
{
|
||||
$account = $repository->find((int) $request->get('account'));
|
||||
$account = $repository->find((int)$request->get('account'));
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
if (null !== $account) {
|
||||
$currency = $repository->getAccountCurrency($account) ?? $currency;
|
||||
@@ -122,9 +126,9 @@ class JavascriptController extends Controller
|
||||
$accounting = app('amount')->getJsConfig();
|
||||
$accounting['frac_digits'] = $currency->decimal_places;
|
||||
$pref = app('preferences')->get('language', config('firefly.default_language', 'en_US'));
|
||||
$lang = $pref->data;
|
||||
$dateRange = $this->getDateRangeConfig();
|
||||
$uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);
|
||||
$lang = $pref->data;
|
||||
$dateRange = $this->getDateRangeConfig();
|
||||
$uid = substr(hash('sha256', sprintf('%s-%s-%s', (string)config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);
|
||||
|
||||
$data = [
|
||||
'currencyCode' => $currency->code,
|
||||
@@ -146,7 +150,7 @@ class JavascriptController extends Controller
|
||||
/**
|
||||
* Bit of a hack but OK.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AutoCompleteController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BoxController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -37,7 +38,6 @@ use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use JsonException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ class BoxController extends Controller
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
$today = today(config('app.timezone'));
|
||||
$display = 2; // see method docs.
|
||||
$boxTitle = (string) trans('firefly.spent');
|
||||
$boxTitle = (string)trans('firefly.spent');
|
||||
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
@@ -92,21 +92,21 @@ class BoxController extends Controller
|
||||
// spent in this period, in budgets, for default currency.
|
||||
// also calculate spent per day.
|
||||
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
|
||||
$spentAmount = $spent[(int) $currency->id]['sum'] ?? '0';
|
||||
$spentAmount = $spent[(int)$currency->id]['sum'] ?? '0';
|
||||
|
||||
$days = $today->between($start, $end) ? $today->diffInDays($start) + 1 : $end->diffInDays($start) + 1;
|
||||
$spentPerDay = bcdiv($spentAmount, (string) $days);
|
||||
$spentPerDay = bcdiv($spentAmount, (string)$days);
|
||||
if ($availableBudgets->count() > 0) {
|
||||
$display = 0; // assume user overspent
|
||||
$boxTitle = (string) trans('firefly.overspent');
|
||||
$totalAvailableSum = (string) $availableBudgets->sum('amount');
|
||||
$boxTitle = (string)trans('firefly.overspent');
|
||||
$totalAvailableSum = (string)$availableBudgets->sum('amount');
|
||||
// calculate with available budget.
|
||||
$leftToSpendAmount = bcadd($totalAvailableSum, $spentAmount);
|
||||
if (1 === bccomp($leftToSpendAmount, '0')) {
|
||||
$boxTitle = (string) trans('firefly.left_to_spend');
|
||||
$boxTitle = (string)trans('firefly.left_to_spend');
|
||||
$days = $today->diffInDays($end) + 1;
|
||||
$display = 1; // not overspent
|
||||
$leftPerDayAmount = bcdiv($leftToSpendAmount, (string) $days);
|
||||
$leftPerDayAmount = bcdiv($leftToSpendAmount, (string)$days);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class BoxController extends Controller
|
||||
/**
|
||||
* Current total balance.
|
||||
*
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
* @param CurrencyRepositoryInterface $repository
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ class BoxController extends Controller
|
||||
$set = $collector->getExtractedJournals();
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$amount = $journal['amount'] ?? '0';
|
||||
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));
|
||||
@@ -175,7 +175,7 @@ class BoxController extends Controller
|
||||
$set = $collector->getExtractedJournals();
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0');
|
||||
$sums[$currencyId] = $sums[$currencyId] ?? '0';
|
||||
|
||||
@@ -64,7 +64,7 @@ class BudgetController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
@@ -79,9 +79,9 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IntroController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -38,8 +39,8 @@ class IntroController extends Controller
|
||||
/**
|
||||
* Returns the introduction wizard for a page.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string|null $specificPage
|
||||
* @param string $route
|
||||
* @param string|null $specificPage
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -73,7 +74,7 @@ class IntroController extends Controller
|
||||
/**
|
||||
* Returns true if there is a general outro step.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string $route
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -98,8 +99,8 @@ class IntroController extends Controller
|
||||
/**
|
||||
* Enable the boxes for a specific page again.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string|null $specialPage
|
||||
* @param string $route
|
||||
* @param string|null $specialPage
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -108,22 +109,22 @@ class IntroController extends Controller
|
||||
{
|
||||
$specialPage = $specialPage ?? '';
|
||||
$route = str_replace('.', '_', $route);
|
||||
$key = 'shown_demo_' . $route;
|
||||
$key = 'shown_demo_'.$route;
|
||||
if ('' !== $specialPage) {
|
||||
$key .= '_' . $specialPage;
|
||||
$key .= '_'.$specialPage;
|
||||
}
|
||||
Log::debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key));
|
||||
app('preferences')->set($key, false);
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json(['message' => (string) trans('firefly.intro_boxes_after_refresh')]);
|
||||
return response()->json(['message' => (string)trans('firefly.intro_boxes_after_refresh')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set that you saw them.
|
||||
*
|
||||
* @param string $route
|
||||
* @param string|null $specialPage
|
||||
* @param string $route
|
||||
* @param string|null $specialPage
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -131,9 +132,9 @@ class IntroController extends Controller
|
||||
public function postFinished(string $route, string $specialPage = null): JsonResponse // @phpstan-ignore-line
|
||||
{
|
||||
$specialPage = $specialPage ?? '';
|
||||
$key = 'shown_demo_' . $route;
|
||||
$key = 'shown_demo_'.$route;
|
||||
if ('' !== $specialPage) {
|
||||
$key .= '_' . $specialPage;
|
||||
$key .= '_'.$specialPage;
|
||||
}
|
||||
Log::debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key));
|
||||
app('preferences')->set($key, true);
|
||||
|
||||
@@ -63,7 +63,7 @@ class ReconcileController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
@@ -76,10 +76,10 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Overview of reconciliation.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Account|null $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Account|null $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -176,10 +176,10 @@ class ReconcileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param TransactionCurrency $currency
|
||||
* @param array $journal
|
||||
* @param string $amount
|
||||
* @param Account $account
|
||||
* @param TransactionCurrency $currency
|
||||
* @param array $journal
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -218,9 +218,9 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* Returns a list of transactions in a modal.
|
||||
*
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Account $account
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
@@ -274,8 +274,8 @@ class ReconcileController extends Controller
|
||||
/**
|
||||
* "fix" amounts to make it easier on the reconciliation overview:
|
||||
*
|
||||
* @param Account $account
|
||||
* @param array $array
|
||||
* @param Account $account
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,8 @@ use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class RecurrenceController
|
||||
@@ -61,7 +63,7 @@ class RecurrenceController extends Controller
|
||||
/**
|
||||
* Shows all events for a repetition. Used in calendar.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -73,10 +75,10 @@ class RecurrenceController extends Controller
|
||||
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||
$firstDate = Carbon::createFromFormat('Y-m-d', $request->get('first_date'));
|
||||
$endDate = '' !== (string) $request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null;
|
||||
$endsAt = (string) $request->get('ends');
|
||||
$endDate = '' !== (string)$request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null;
|
||||
$endsAt = (string)$request->get('ends');
|
||||
$repetitionType = explode(',', $request->get('type'))[0];
|
||||
$repetitions = (int) $request->get('reps');
|
||||
$repetitions = (int)$request->get('reps');
|
||||
$repetitionMoment = '';
|
||||
$start->startOfDay();
|
||||
|
||||
@@ -100,8 +102,8 @@ class RecurrenceController extends Controller
|
||||
$repetition = new RecurrenceRepetition();
|
||||
$repetition->repetition_type = $repetitionType;
|
||||
$repetition->repetition_moment = $repetitionMoment;
|
||||
$repetition->repetition_skip = (int) $request->get('skip');
|
||||
$repetition->weekend = (int) $request->get('weekend');
|
||||
$repetition->repetition_skip = (int)$request->get('skip');
|
||||
$repetition->weekend = (int)$request->get('weekend');
|
||||
$actualEnd = clone $end;
|
||||
|
||||
switch ($endsAt) {
|
||||
@@ -122,7 +124,7 @@ class RecurrenceController extends Controller
|
||||
foreach ($occurrences as $current) {
|
||||
if ($current->gte($start)) {
|
||||
$event = [
|
||||
'id' => $repetitionType . $firstDate->format('Ymd'),
|
||||
'id' => $repetitionType.$firstDate->format('Ymd'),
|
||||
'title' => 'X',
|
||||
'allDay' => true,
|
||||
'start' => $current->format('Y-m-d'),
|
||||
@@ -140,43 +142,51 @@ class RecurrenceController extends Controller
|
||||
/**
|
||||
* Suggests repetition moments.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function suggest(Request $request): JsonResponse
|
||||
{
|
||||
$string = $request->get('date') ?? date('Y-m-d');
|
||||
$today = Carbon::now()->startOfDay();
|
||||
$date = Carbon::createFromFormat('Y-m-d', $string)->startOfDay();
|
||||
$preSelected = (string) $request->get('pre_select');
|
||||
$preSelected = (string)$request->get('pre_select');
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
Log::debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true)));
|
||||
Log::debug(sprintf('past = true? %s', var_export('true' === (string) $request->get('past'), true)));
|
||||
Log::debug(sprintf('past = true? %s', var_export('true' === (string)$request->get('past'), true)));
|
||||
|
||||
$result = [];
|
||||
if ($date > $today || 'true' === (string) $request->get('past')) {
|
||||
if ($date > $today || 'true' === (string)$request->get('past')) {
|
||||
Log::debug('Will fill dropdown.');
|
||||
$weekly = sprintf('weekly,%s', $date->dayOfWeekIso);
|
||||
$monthly = sprintf('monthly,%s', $date->day);
|
||||
$dayOfWeek = (string) trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
|
||||
$dayOfWeek = (string)trans(sprintf('config.dow_%s', $date->dayOfWeekIso));
|
||||
$ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso);
|
||||
$yearly = sprintf('yearly,%s', $date->format('Y-m-d'));
|
||||
$yearlyDate = $date->isoFormat((string) trans('config.month_and_day_no_year_js', [], $locale));
|
||||
$yearlyDate = $date->isoFormat((string)trans('config.month_and_day_no_year_js', [], $locale));
|
||||
$result = [
|
||||
'daily' => ['label' => (string) trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')],
|
||||
$weekly => ['label' => (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
'selected' => str_starts_with($preSelected, 'weekly')],
|
||||
$monthly => ['label' => (string) trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]),
|
||||
'selected' => str_starts_with($preSelected, 'monthly')],
|
||||
$ndom => ['label' => (string) trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),
|
||||
'selected' => str_starts_with($preSelected, 'ndom')],
|
||||
$yearly => ['label' => (string) trans('firefly.recurring_yearly', ['date' => $yearlyDate]),
|
||||
'selected' => str_starts_with($preSelected, 'yearly')],
|
||||
'daily' => ['label' => (string)trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')],
|
||||
$weekly => [
|
||||
'label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
'selected' => str_starts_with($preSelected, 'weekly'),
|
||||
],
|
||||
$monthly => [
|
||||
'label' => (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]),
|
||||
'selected' => str_starts_with($preSelected, 'monthly'),
|
||||
],
|
||||
$ndom => [
|
||||
'label' => (string)trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),
|
||||
'selected' => str_starts_with($preSelected, 'ndom'),
|
||||
],
|
||||
$yearly => [
|
||||
'label' => (string)trans('firefly.recurring_yearly', ['date' => $yearlyDate]),
|
||||
'selected' => str_starts_with($preSelected, 'yearly'),
|
||||
],
|
||||
];
|
||||
}
|
||||
Log::debug('Dropdown is', $result);
|
||||
|
||||
@@ -38,17 +38,17 @@ class RuleController extends Controller
|
||||
/**
|
||||
* Render HTML form for rule action.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function action(Request $request): JsonResponse
|
||||
{
|
||||
$count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1;
|
||||
$count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;
|
||||
$keys = array_keys(config('firefly.rule-actions'));
|
||||
$actions = [];
|
||||
foreach ($keys as $key) {
|
||||
$actions[$key] = (string) trans('firefly.rule_action_' . $key . '_choice');
|
||||
$actions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');
|
||||
}
|
||||
try {
|
||||
$view = view('rules.partials.action', compact('actions', 'count'))->render();
|
||||
@@ -64,18 +64,18 @@ class RuleController extends Controller
|
||||
/**
|
||||
* Render HTML for rule trigger.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function trigger(Request $request): JsonResponse
|
||||
{
|
||||
$count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1;
|
||||
$count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;
|
||||
$operators = config('search.operators');
|
||||
$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);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NewUserController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -66,7 +67,7 @@ class NewUserController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
app('view')->share('title', (string) trans('firefly.welcome'));
|
||||
app('view')->share('title', (string)trans('firefly.welcome'));
|
||||
app('view')->share('mainTitleIcon', 'fa-fire');
|
||||
|
||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||
@@ -84,8 +85,8 @@ class NewUserController extends Controller
|
||||
/**
|
||||
* Store his new settings.
|
||||
*
|
||||
* @param NewUserFormRequest $request
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
* @param NewUserFormRequest $request
|
||||
* @param CurrencyRepositoryInterface $currencyRepository
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
@@ -100,7 +101,7 @@ class NewUserController extends Controller
|
||||
// set language preference:
|
||||
app('preferences')->set('language', $language);
|
||||
// Store currency preference from input:
|
||||
$currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));
|
||||
$currency = $currencyRepository->find((int)$request->input('amount_currency_id_bank_balance'));
|
||||
|
||||
// if is null, set to EUR:
|
||||
if (null === $currency) {
|
||||
@@ -123,11 +124,20 @@ class NewUserController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
// set default optional fields:
|
||||
$visibleFields = ['interest_date' => true, 'book_date' => false, 'process_date' => false, 'due_date' => false, 'payment_date' => false,
|
||||
'invoice_date' => false, 'internal_reference' => false, 'notes' => true, 'attachments' => true,];
|
||||
$visibleFields = [
|
||||
'interest_date' => true,
|
||||
'book_date' => false,
|
||||
'process_date' => false,
|
||||
'due_date' => false,
|
||||
'payment_date' => false,
|
||||
'invoice_date' => false,
|
||||
'internal_reference' => false,
|
||||
'notes' => true,
|
||||
'attachments' => true,
|
||||
];
|
||||
app('preferences')->set('transaction_journal_optional_fields', $visibleFields);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));
|
||||
session()->flash('success', (string)trans('firefly.stored_new_accounts_new_user'));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect(route('index'));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PreferencesController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -34,6 +35,8 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class PreferencesController.
|
||||
@@ -51,7 +54,7 @@ class PreferencesController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.preferences'));
|
||||
app('view')->share('title', (string)trans('firefly.preferences'));
|
||||
app('view')->share('mainTitleIcon', 'fa-gear');
|
||||
|
||||
return $next($request);
|
||||
@@ -62,12 +65,12 @@ class PreferencesController extends Controller
|
||||
/**
|
||||
* Show overview of preferences.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -104,7 +107,7 @@ class PreferencesController extends Controller
|
||||
$slackUrl = app('preferences')->get('slack_webhook_url', '')->data;
|
||||
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
|
||||
$fiscalYearStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
|
||||
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
||||
$fiscalYearStart = date('Y').'-'.$fiscalYearStartStr;
|
||||
$tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||
|
||||
// notification preferences (single value for each):
|
||||
@@ -124,7 +127,7 @@ class PreferencesController extends Controller
|
||||
Log::error($e->getMessage());
|
||||
$locales = [];
|
||||
}
|
||||
$locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales;
|
||||
$locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales;
|
||||
// an important fallback is that the frontPageAccount array gets refilled automatically
|
||||
// when it turns up empty.
|
||||
if (0 === count($frontPageAccounts->data)) {
|
||||
@@ -155,12 +158,12 @@ class PreferencesController extends Controller
|
||||
/**
|
||||
* Store new preferences.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function postIndex(Request $request)
|
||||
{
|
||||
@@ -168,7 +171,7 @@ class PreferencesController extends Controller
|
||||
$frontPageAccounts = [];
|
||||
if (is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) {
|
||||
foreach ($request->get('frontPageAccounts') as $id) {
|
||||
$frontPageAccounts[] = (int) $id;
|
||||
$frontPageAccounts[] = (int)$id;
|
||||
}
|
||||
app('preferences')->set('frontPageAccounts', $frontPageAccounts);
|
||||
}
|
||||
@@ -194,7 +197,7 @@ class PreferencesController extends Controller
|
||||
|
||||
|
||||
// slack URL:
|
||||
$url = (string) $request->get('slackUrl');
|
||||
$url = (string)$request->get('slackUrl');
|
||||
if (str_starts_with($url, 'https://hooks.slack.com/services/')) {
|
||||
app('preferences')->set('slack_webhook_url', $url);
|
||||
}
|
||||
@@ -203,8 +206,8 @@ class PreferencesController extends Controller
|
||||
}
|
||||
|
||||
// custom fiscal year
|
||||
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
|
||||
$string = strtotime((string) $request->get('fiscalYearStart'));
|
||||
$customFiscalYear = 1 === (int)$request->get('customFiscalYear');
|
||||
$string = strtotime((string)$request->get('fiscalYearStart'));
|
||||
if (false !== $string) {
|
||||
$fiscalYearStart = date('m-d', $string);
|
||||
app('preferences')->set('customFiscalYear', $customFiscalYear);
|
||||
@@ -214,7 +217,7 @@ class PreferencesController extends Controller
|
||||
|
||||
// save page size:
|
||||
app('preferences')->set('listPageSize', 50);
|
||||
$listPageSize = (int) $request->get('listPageSize');
|
||||
$listPageSize = (int)$request->get('listPageSize');
|
||||
if ($listPageSize > 0 && $listPageSize < 1337) {
|
||||
app('preferences')->set('listPageSize', $listPageSize);
|
||||
}
|
||||
@@ -256,7 +259,7 @@ class PreferencesController extends Controller
|
||||
];
|
||||
app('preferences')->set('transaction_journal_optional_fields', $optionalTj);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.saved_preferences'));
|
||||
session()->flash('success', (string)trans('firefly.saved_preferences'));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect(route('preferences.index'));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ProfileController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -54,6 +55,8 @@ use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;
|
||||
use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
|
||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||
use PragmaRX\Recovery\Recovery;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ProfileController.
|
||||
@@ -79,7 +82,7 @@ class ProfileController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.profile'));
|
||||
app('view')->share('title', (string)trans('firefly.profile'));
|
||||
app('view')->share('mainTitleIcon', 'fa-user');
|
||||
|
||||
return $next($request);
|
||||
@@ -94,62 +97,17 @@ class ProfileController extends Controller
|
||||
$this->middleware(IsDemoUser::class)->except(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your email address.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function changeEmail(Request $request)
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$email = auth()->user()->email;
|
||||
$subTitle = (string) trans('firefly.change_your_email');
|
||||
$subTitleIcon = 'fa-envelope';
|
||||
|
||||
return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your password.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string) trans('firefly.change_your_password');
|
||||
$subTitleIcon = 'fa-key';
|
||||
|
||||
return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon'));
|
||||
}
|
||||
|
||||
/**
|
||||
* View that generates a 2FA code for the user.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws InvalidCharactersException
|
||||
* @throws SecretKeyTooShortException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function code(Request $request)
|
||||
{
|
||||
@@ -200,8 +158,8 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Screen to confirm email change.
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param string $token
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param string $token
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
@@ -229,7 +187,7 @@ class ProfileController extends Controller
|
||||
$repository->unblockUser($user);
|
||||
|
||||
// return to login.
|
||||
session()->flash('success', (string) trans('firefly.login_with_new_email'));
|
||||
session()->flash('success', (string)trans('firefly.login_with_new_email'));
|
||||
|
||||
return redirect(route('login'));
|
||||
}
|
||||
@@ -237,7 +195,7 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Delete your account view.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -249,7 +207,7 @@ class ProfileController extends Controller
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string) trans('firefly.delete_account');
|
||||
$subTitle = (string)trans('firefly.delete_account');
|
||||
$subTitleIcon = 'fa-trash';
|
||||
|
||||
return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon'));
|
||||
@@ -278,8 +236,8 @@ class ProfileController extends Controller
|
||||
$repository->setMFACode($user, null);
|
||||
app('preferences')->mark();
|
||||
|
||||
session()->flash('success', (string) trans('firefly.pref_two_factor_auth_disabled'));
|
||||
session()->flash('info', (string) trans('firefly.pref_two_factor_auth_remove_it'));
|
||||
session()->flash('success', (string)trans('firefly.pref_two_factor_auth_disabled'));
|
||||
session()->flash('info', (string)trans('firefly.pref_two_factor_auth_remove_it'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -308,7 +266,7 @@ class ProfileController extends Controller
|
||||
|
||||
// If FF3 already has a secret, just set the two factor auth enabled to 1,
|
||||
// and let the user continue with the existing secret.
|
||||
session()->flash('info', (string) trans('firefly.2fa_already_enabled'));
|
||||
session()->flash('info', (string)trans('firefly.2fa_already_enabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -318,8 +276,8 @@ class ProfileController extends Controller
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -337,7 +295,7 @@ class ProfileController extends Controller
|
||||
if (0 === $count) {
|
||||
/** @var ClientRepository $repository */
|
||||
$repository = app(ClientRepository::class);
|
||||
$repository->createPersonalAccessClient(null, config('app.name') . ' Personal Access Client', 'http://localhost');
|
||||
$repository->createPersonalAccessClient(null, config('app.name').' Personal Access Client', 'http://localhost');
|
||||
}
|
||||
|
||||
$accessToken = app('preferences')->get('access_token');
|
||||
@@ -358,7 +316,7 @@ class ProfileController extends Controller
|
||||
public function logoutOtherSessions()
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
session()->flash('info', (string) trans('firefly.external_auth_disabled'));
|
||||
session()->flash('info', (string)trans('firefly.external_auth_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -367,7 +325,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
@@ -398,8 +356,8 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Submit the change email form.
|
||||
*
|
||||
* @param EmailFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param EmailFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -416,7 +374,7 @@ class ProfileController extends Controller
|
||||
$newEmail = $request->convertString('email');
|
||||
$oldEmail = $user->email;
|
||||
if ($newEmail === $user->email) {
|
||||
session()->flash('error', (string) trans('firefly.email_not_changed'));
|
||||
session()->flash('error', (string)trans('firefly.email_not_changed'));
|
||||
|
||||
return redirect(route('profile.change-email'))->withInput();
|
||||
}
|
||||
@@ -426,7 +384,7 @@ class ProfileController extends Controller
|
||||
Auth::guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
|
||||
return redirect(route('index'));
|
||||
}
|
||||
@@ -439,16 +397,39 @@ class ProfileController extends Controller
|
||||
// force user logout.
|
||||
Auth::guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
|
||||
return redirect(route('index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your email address.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function changeEmail(Request $request)
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$email = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_email');
|
||||
$subTitleIcon = 'fa-envelope';
|
||||
|
||||
return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit change password form.
|
||||
*
|
||||
* @param ProfileFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param ProfileFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -474,20 +455,42 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
$repository->changePassword($user, $request->get('new_password'));
|
||||
session()->flash('success', (string) trans('firefly.password_changed'));
|
||||
session()->flash('success', (string)trans('firefly.password_changed'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your password.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
if (!$this->internalAuth || !$this->internalIdentity) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_password');
|
||||
$subTitleIcon = 'fa-key';
|
||||
|
||||
return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit 2FA for the first time.
|
||||
*
|
||||
* @param TokenFormRequest $request
|
||||
* @param TokenFormRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function postCode(TokenFormRequest $request)
|
||||
{
|
||||
@@ -508,7 +511,7 @@ class ProfileController extends Controller
|
||||
Preferences::delete('temp-mfa-secret');
|
||||
Preferences::delete('temp-mfa-codes');
|
||||
|
||||
session()->flash('success', (string) trans('firefly.saved_preferences'));
|
||||
session()->flash('success', (string)trans('firefly.saved_preferences'));
|
||||
app('preferences')->mark();
|
||||
|
||||
// also save the code so replay attack is prevented.
|
||||
@@ -532,11 +535,11 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* TODO duplicate code.
|
||||
*
|
||||
* @param string $mfaCode
|
||||
* @param string $mfaCode
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function addToMFAHistory(string $mfaCode): void
|
||||
{
|
||||
@@ -577,8 +580,8 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Submit delete account.
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param DeleteAccountFormRequest $request
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param DeleteAccountFormRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -591,7 +594,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
if (!Hash::check($request->get('password'), auth()->user()->password)) {
|
||||
session()->flash('error', (string) trans('firefly.invalid_password'));
|
||||
session()->flash('error', (string)trans('firefly.invalid_password'));
|
||||
|
||||
return redirect(route('profile.delete-account'));
|
||||
}
|
||||
@@ -607,7 +610,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
* @throws AuthenticationException
|
||||
@@ -615,7 +618,7 @@ class ProfileController extends Controller
|
||||
public function postLogoutOtherSessions(Request $request)
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
session()->flash('info', (string) trans('firefly.external_auth_disabled'));
|
||||
session()->flash('info', (string)trans('firefly.external_auth_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -625,11 +628,11 @@ class ProfileController extends Controller
|
||||
];
|
||||
if (Auth::once($creds)) {
|
||||
Auth::logoutOtherDevices($request->get('password'));
|
||||
session()->flash('info', (string) trans('firefly.other_sessions_logged_out'));
|
||||
session()->flash('info', (string)trans('firefly.other_sessions_logged_out'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
session()->flash('error', (string) trans('auth.failed'));
|
||||
session()->flash('error', (string)trans('auth.failed'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -637,7 +640,7 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Regenerate access token.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
@@ -654,7 +657,7 @@ class ProfileController extends Controller
|
||||
$user = auth()->user();
|
||||
$token = $user->generateAccessToken();
|
||||
app('preferences')->set('access_token', $token);
|
||||
session()->flash('success', (string) trans('firefly.token_regenerated'));
|
||||
session()->flash('success', (string)trans('firefly.token_regenerated'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
@@ -662,9 +665,9 @@ class ProfileController extends Controller
|
||||
/**
|
||||
* Undo change of user email address.
|
||||
*
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param string $token
|
||||
* @param string $hash
|
||||
* @param UserRepositoryInterface $repository
|
||||
* @param string $token
|
||||
* @param string $hash
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
@@ -694,7 +697,7 @@ class ProfileController extends Controller
|
||||
/** @var string $match */
|
||||
$match = null;
|
||||
foreach ($set as $entry) {
|
||||
$hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $entry->data));
|
||||
$hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $entry->data));
|
||||
if ($hashed === $hash) {
|
||||
$match = $entry->data;
|
||||
break;
|
||||
@@ -709,7 +712,7 @@ class ProfileController extends Controller
|
||||
$repository->unblockUser($user);
|
||||
|
||||
// return to login.
|
||||
session()->flash('success', (string) trans('firefly.login_with_old_email'));
|
||||
session()->flash('success', (string)trans('firefly.login_with_old_email'));
|
||||
|
||||
return redirect(route('login'));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ReportController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -39,6 +40,8 @@ use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class ReportController.
|
||||
@@ -63,7 +66,7 @@ class ReportController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.reports'));
|
||||
app('view')->share('title', (string)trans('firefly.reports'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bar-chart');
|
||||
app('view')->share('subTitleIcon', 'fa-calendar');
|
||||
$this->helper = app(ReportHelperInterface::class);
|
||||
@@ -77,9 +80,9 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show audit report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Factory|View|string
|
||||
*
|
||||
@@ -88,7 +91,7 @@ class ReportController extends Controller
|
||||
public function auditReport(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
|
||||
@@ -112,10 +115,10 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show 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|string
|
||||
*
|
||||
@@ -124,7 +127,7 @@ class ReportController extends Controller
|
||||
public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
|
||||
@@ -149,10 +152,10 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show category report.
|
||||
*
|
||||
* @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|string
|
||||
*
|
||||
@@ -161,7 +164,7 @@ class ReportController extends Controller
|
||||
public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
|
||||
@@ -186,9 +189,9 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show default report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Factory|View|string
|
||||
*
|
||||
@@ -197,7 +200,7 @@ class ReportController extends Controller
|
||||
public function defaultReport(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
|
||||
$this->repository->cleanupBudgets();
|
||||
@@ -222,10 +225,10 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show account report.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
@@ -242,8 +245,10 @@ class ReportController extends Controller
|
||||
'subTitle',
|
||||
trans(
|
||||
'firefly.report_double',
|
||||
['start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat)]
|
||||
[
|
||||
'start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -257,12 +262,12 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show index.
|
||||
*
|
||||
* @param AccountRepositoryInterface $repository
|
||||
* @param AccountRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function index(AccountRepositoryInterface $repository)
|
||||
{
|
||||
@@ -301,7 +306,7 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Show options for reports.
|
||||
*
|
||||
* @param string $reportType
|
||||
* @param string $reportType
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
@@ -322,7 +327,7 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Process the submit of report.
|
||||
*
|
||||
* @param ReportFormRequest $request
|
||||
* @param ReportFormRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
@@ -343,37 +348,37 @@ class ReportController extends Controller
|
||||
|
||||
if (0 === $request->getAccountList()->count()) {
|
||||
Log::debug('Account count is zero');
|
||||
session()->flash('error', (string) trans('firefly.select_at_least_one_account'));
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_account'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ('category' === $reportType && 0 === $request->getCategoryList()->count()) {
|
||||
session()->flash('error', (string) trans('firefly.select_at_least_one_category'));
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_category'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ('budget' === $reportType && 0 === $request->getBudgetList()->count()) {
|
||||
session()->flash('error', (string) trans('firefly.select_at_least_one_budget'));
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_budget'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ('tag' === $reportType && 0 === $request->getTagList()->count()) {
|
||||
session()->flash('error', (string) trans('firefly.select_at_least_one_tag'));
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_tag'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ('double' === $reportType && 0 === $request->getDoubleList()->count()) {
|
||||
session()->flash('error', (string) trans('firefly.select_at_least_one_expense'));
|
||||
session()->flash('error', (string)trans('firefly.select_at_least_one_expense'));
|
||||
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
if ($request->getEndDate() < $request->getStartDate()) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
|
||||
$url = match ($reportType) {
|
||||
@@ -391,10 +396,10 @@ class ReportController extends Controller
|
||||
/**
|
||||
* Get a tag report.
|
||||
*
|
||||
* @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|string
|
||||
* @throws FireflyException
|
||||
@@ -402,7 +407,7 @@ class ReportController extends Controller
|
||||
public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
return view('error')->with('message', (string) trans('firefly.end_after_start_date'));
|
||||
return view('error')->with('message', (string)trans('firefly.end_after_start_date'));
|
||||
}
|
||||
$this->repository->cleanupBudgets();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SearchController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -47,7 +48,7 @@ class SearchController extends Controller
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-search');
|
||||
app('view')->share('title', (string) trans('firefly.search'));
|
||||
app('view')->share('title', (string)trans('firefly.search'));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -57,8 +58,8 @@ class SearchController extends Controller
|
||||
/**
|
||||
* Do the search.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param SearchInterface $searcher
|
||||
* @param Request $request
|
||||
* @param SearchInterface $searcher
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -69,9 +70,9 @@ class SearchController extends Controller
|
||||
if (is_array($request->get('search'))) {
|
||||
$fullQuery = '';
|
||||
}
|
||||
$fullQuery = (string) $fullQuery;
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$ruleId = (int) $request->get('rule');
|
||||
$fullQuery = (string)$fullQuery;
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$ruleId = (int)$request->get('rule');
|
||||
$ruleChanged = false;
|
||||
|
||||
// find rule, check if query is different, offer to update.
|
||||
@@ -90,7 +91,7 @@ class SearchController extends Controller
|
||||
$query = $searcher->getWordsAsString();
|
||||
$operators = $searcher->getOperators();
|
||||
$invalidOperators = $searcher->getInvalidOperators();
|
||||
$subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]);
|
||||
$subTitle = (string)trans('breadcrumbs.search_result', ['query' => $fullQuery]);
|
||||
|
||||
return view('search.index', compact('query', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators'));
|
||||
}
|
||||
@@ -98,15 +99,15 @@ class SearchController extends Controller
|
||||
/**
|
||||
* JSON request that does the work.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param SearchInterface $searcher
|
||||
* @param Request $request
|
||||
* @param SearchInterface $searcher
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function search(Request $request, SearchInterface $searcher): JsonResponse
|
||||
{
|
||||
$fullQuery = (string) $request->get('query');
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$fullQuery = (string)$request->get('query');
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
|
||||
$searcher->parseQuery($fullQuery);
|
||||
|
||||
@@ -115,7 +116,7 @@ class SearchController extends Controller
|
||||
$hasPages = $groups->hasPages();
|
||||
$searchTime = round($searcher->searchTime(), 3); // in seconds
|
||||
$parameters = ['search' => $fullQuery];
|
||||
$url = route('search.index') . '?' . http_build_query($parameters);
|
||||
$url = route('search.index').'?'.http_build_query($parameters);
|
||||
$groups->setPath($url);
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TagController.php
|
||||
* Copyright (c) 2019 james@firefly-iii.org
|
||||
@@ -35,6 +36,8 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* Class TagController.
|
||||
@@ -56,7 +59,7 @@ class TagController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.tags'));
|
||||
app('view')->share('title', (string)trans('firefly.tags'));
|
||||
app('view')->share('mainTitleIcon', 'fa-tag');
|
||||
|
||||
$this->attachmentsHelper = app(AttachmentHelperInterface::class);
|
||||
@@ -74,7 +77,7 @@ class TagController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.new_tag');
|
||||
$subTitle = (string)trans('firefly.new_tag');
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
// location info:
|
||||
@@ -100,13 +103,13 @@ class TagController extends Controller
|
||||
/**
|
||||
* Delete a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(Tag $tag)
|
||||
{
|
||||
$subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string)trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('tags.delete.url');
|
||||
@@ -114,34 +117,16 @@ class TagController extends Controller
|
||||
return view('tags.delete', compact('tag', 'subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(Tag $tag): RedirectResponse
|
||||
{
|
||||
$tagName = $tag->tag;
|
||||
$this->repository->destroy($tag);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.deleted_tag', ['tag' => $tagName]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('tags.delete.url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Tag $tag)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
$location = $this->repository->getLocation($tag);
|
||||
@@ -170,7 +155,7 @@ class TagController extends Controller
|
||||
/**
|
||||
* Edit a tag.
|
||||
*
|
||||
* @param TagRepositoryInterface $repository
|
||||
* @param TagRepositoryInterface $repository
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -202,51 +187,72 @@ class TagController extends Controller
|
||||
{
|
||||
$tags = $request->get('tags');
|
||||
if (null === $tags || !is_array($tags)) {
|
||||
session()->flash('info', (string) trans('firefly.select_tags_to_delete'));
|
||||
session()->flash('info', (string)trans('firefly.select_tags_to_delete'));
|
||||
|
||||
return redirect(route('tags.index'));
|
||||
}
|
||||
$count = 0;
|
||||
foreach ($tags as $tagId) {
|
||||
$tagId = (int) $tagId;
|
||||
$tagId = (int)$tagId;
|
||||
$tag = $this->repository->find($tagId);
|
||||
if (null !== $tag) {
|
||||
$this->repository->destroy($tag);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
session()->flash('success', (string) trans_choice('firefly.deleted_x_tags', $count));
|
||||
session()->flash('success', (string)trans_choice('firefly.deleted_x_tags', $count));
|
||||
|
||||
return redirect(route('tags.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a tag.
|
||||
*
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(Tag $tag): RedirectResponse
|
||||
{
|
||||
$tagName = $tag->tag;
|
||||
$this->repository->destroy($tag);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('tags.delete.url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single tag.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function show(Request $request, Tag $tag, Carbon $start = null, Carbon $end = null)
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-tag';
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$start = $start ?? session('start');
|
||||
$end = $end ?? session('end');
|
||||
$location = $this->repository->getLocation($tag);
|
||||
$attachments = $this->repository->getAttachments($tag);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_tag',
|
||||
['tag' => $tag->tag, 'start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat),]
|
||||
[
|
||||
'tag' => $tag->tag,
|
||||
'start' => $start->isoFormat($this->monthAndDayFormat),
|
||||
'end' => $end->isoFormat($this->monthAndDayFormat),
|
||||
]
|
||||
);
|
||||
|
||||
$startPeriod = $this->repository->firstUseDate($tag);
|
||||
@@ -270,22 +276,22 @@ class TagController extends Controller
|
||||
/**
|
||||
* Show a single tag over all time.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
* @param Request $request
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function showAll(Request $request, Tag $tag)
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-tag';
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$periods = [];
|
||||
$subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone'));
|
||||
$end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone'));
|
||||
$attachments = $this->repository->getAttachments($tag);
|
||||
@@ -305,7 +311,7 @@ class TagController extends Controller
|
||||
/**
|
||||
* Store a tag.
|
||||
*
|
||||
* @param TagFormRequest $request
|
||||
* @param TagFormRequest $request
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -317,7 +323,7 @@ class TagController extends Controller
|
||||
$result = $this->repository->store($data);
|
||||
Log::debug('Data after storage', $result->toArray());
|
||||
|
||||
session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']]));
|
||||
session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -327,14 +333,14 @@ class TagController extends Controller
|
||||
$this->attachmentsHelper->saveAttachmentsForModel($result, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('tags.create.url'));
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
session()->put('tags.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('tags.create'))->withInput();
|
||||
@@ -346,8 +352,8 @@ class TagController extends Controller
|
||||
/**
|
||||
* Update a tag.
|
||||
*
|
||||
* @param TagFormRequest $request
|
||||
* @param Tag $tag
|
||||
* @param TagFormRequest $request
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -356,7 +362,7 @@ class TagController extends Controller
|
||||
$data = $request->collectTagData();
|
||||
$tag = $this->repository->update($tag, $data);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.updated_tag', ['tag' => $data['tag']]));
|
||||
session()->flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -366,14 +372,14 @@ class TagController extends Controller
|
||||
$this->attachmentsHelper->saveAttachmentsForModel($tag, $files);
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachmentsHelper->getMessages()->get('attachments'));
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('tags.edit.url'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
session()->put('tags.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
Reference in New Issue
Block a user