mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-03 20:14:31 +00:00
Code cleanup
This commit is contained in:
@@ -59,7 +59,7 @@ class CreateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-credit-card');
|
||||
app('view')->share('title', (string)trans('firefly.accounts'));
|
||||
app('view')->share('title', (string) trans('firefly.accounts'));
|
||||
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -78,7 +78,7 @@ class CreateController extends Controller
|
||||
{
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||
$subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
@@ -97,9 +97,9 @@ class CreateController extends Controller
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
'daily' => (string)trans('firefly.interest_calc_daily'),
|
||||
'monthly' => (string)trans('firefly.interest_calc_monthly'),
|
||||
'yearly' => (string)trans('firefly.interest_calc_yearly'),
|
||||
'daily' => (string) trans('firefly.interest_calc_daily'),
|
||||
'monthly' => (string) trans('firefly.interest_calc_monthly'),
|
||||
'yearly' => (string) trans('firefly.interest_calc_yearly'),
|
||||
];
|
||||
|
||||
// pre fill some data
|
||||
@@ -107,7 +107,7 @@ class CreateController extends Controller
|
||||
'preFilled',
|
||||
[
|
||||
'currency_id' => $defaultCurrency->id,
|
||||
'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : true,
|
||||
'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,
|
||||
]
|
||||
);
|
||||
// issue #8321
|
||||
@@ -140,7 +140,7 @@ class CreateController extends Controller
|
||||
{
|
||||
$data = $request->getAccountData();
|
||||
$account = $this->repository->store($data);
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
Log::channel('audit')->info('Stored new account.', $data);
|
||||
@@ -163,7 +163,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -172,7 +172,7 @@ class CreateController extends Controller
|
||||
|
||||
// redirect to previous URL.
|
||||
$redirect = redirect($this->getPreviousUrl('accounts.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('accounts.create.fromStore', true);
|
||||
|
||||
|
||||
@@ -52,7 +52,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);
|
||||
|
||||
@@ -73,7 +73,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]);
|
||||
@@ -98,11 +98,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'));
|
||||
|
||||
@@ -58,7 +58,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->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -82,7 +82,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();
|
||||
@@ -107,9 +107,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").
|
||||
@@ -118,7 +118,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 = '';
|
||||
}
|
||||
@@ -144,17 +144,17 @@ class EditController extends Controller
|
||||
'cc_type' => $repository->getMetaValue($account, 'cc_type'),
|
||||
'cc_monthly_payment_date' => $repository->getMetaValue($account, 'cc_monthly_payment_date'),
|
||||
'BIC' => $repository->getMetaValue($account, 'BIC'),
|
||||
'opening_balance_date' => substr((string)$openingBalanceDate, 0, 10),
|
||||
'opening_balance_date' => substr((string) $openingBalanceDate, 0, 10),
|
||||
'liability_type_id' => $account->account_type_id,
|
||||
'opening_balance' => app('steam')->bcround($openingBalanceAmount, $currency->decimal_places),
|
||||
'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),
|
||||
'virtual_balance' => app('steam')->bcround($virtualBalance, $currency->decimal_places),
|
||||
'currency_id' => $currency->id,
|
||||
'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : $includeNetWorth,
|
||||
'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : $includeNetWorth,
|
||||
'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'] = '';
|
||||
@@ -179,7 +179,7 @@ class EditController extends Controller
|
||||
$data = $request->getAccountData();
|
||||
$this->repository->update($account, $data);
|
||||
Log::channel('audit')->info(sprintf('Updated account #%d.', $account->id), $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):
|
||||
/** @var null|array $files */
|
||||
@@ -189,7 +189,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -198,7 +198,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);
|
||||
|
||||
|
||||
@@ -54,7 +54,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);
|
||||
|
||||
@@ -71,13 +71,13 @@ class IndexController extends Controller
|
||||
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);
|
||||
|
||||
@@ -100,10 +100,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,7 +124,7 @@ class IndexController extends Controller
|
||||
public function index(Request $request, string $objectType)
|
||||
{
|
||||
app('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));
|
||||
|
||||
@@ -132,8 +132,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();
|
||||
|
||||
@@ -155,7 +155,7 @@ class IndexController extends Controller
|
||||
|
||||
$accounts->each(
|
||||
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
||||
$interest = (string)$this->repository->getMetaValue($account, 'interest');
|
||||
$interest = (string) $this->repository->getMetaValue($account, 'interest');
|
||||
$interest = '' === $interest ? '0' : $interest;
|
||||
|
||||
// See reference nr. 68
|
||||
@@ -164,14 +164,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:
|
||||
|
||||
@@ -59,7 +59,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);
|
||||
|
||||
@@ -81,7 +81,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))]));
|
||||
}
|
||||
@@ -113,7 +113,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%']);
|
||||
@@ -158,7 +158,7 @@ class ReconcileController extends Controller
|
||||
|
||||
/** @var string $journalId */
|
||||
foreach ($data['journals'] as $journalId) {
|
||||
$this->repository->reconcileById((int)$journalId);
|
||||
$this->repository->reconcileById((int) $journalId);
|
||||
}
|
||||
app('log')->debug('Reconciled all transactions.');
|
||||
|
||||
@@ -175,10 +175,10 @@ class ReconcileController extends Controller
|
||||
app('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]));
|
||||
|
||||
@@ -60,7 +60,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);
|
||||
|
||||
@@ -96,19 +96,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('view.layout')) {
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
}
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
@@ -172,10 +172,10 @@ class ShowController extends Controller
|
||||
$today = today(config('app.timezone'));
|
||||
$start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
|
||||
$subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection();
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
|
||||
@@ -45,7 +45,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,7 +61,7 @@ class ConfigurationController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string)trans('firefly.instance_configuration');
|
||||
$subTitle = (string) trans('firefly.instance_configuration');
|
||||
$subTitleIcon = 'fa-wrench';
|
||||
|
||||
Log::channel('audit')->info('User visits admin config index.');
|
||||
@@ -93,7 +93,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');
|
||||
|
||||
@@ -51,7 +51,7 @@ class HomeController extends Controller
|
||||
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');
|
||||
|
||||
@@ -51,7 +51,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);
|
||||
|
||||
@@ -70,7 +70,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").
|
||||
@@ -89,17 +89,17 @@ class LinkController extends Controller
|
||||
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) {
|
||||
@@ -123,10 +123,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'));
|
||||
@@ -140,11 +140,11 @@ class LinkController extends Controller
|
||||
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));
|
||||
@@ -165,7 +165,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();
|
||||
|
||||
@@ -186,7 +186,7 @@ class LinkController extends Controller
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -211,9 +211,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);
|
||||
|
||||
@@ -232,7 +232,7 @@ class LinkController extends Controller
|
||||
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'));
|
||||
}
|
||||
@@ -246,10 +246,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);
|
||||
|
||||
|
||||
@@ -47,7 +47,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);
|
||||
@@ -63,22 +63,22 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string)trans('firefly.update_check_title');
|
||||
$subTitle = (string) trans('firefly.update_check_title');
|
||||
$subTitleIcon = 'fa-star';
|
||||
$permission = app('fireflyconfig')->get('permission_update_check', -1);
|
||||
$channel = app('fireflyconfig')->get('update_channel', 'stable');
|
||||
$selected = $permission->data;
|
||||
$channelSelected = $channel->data;
|
||||
$options = [
|
||||
-1 => (string)trans('firefly.updates_ask_me_later'),
|
||||
0 => (string)trans('firefly.updates_do_not_check'),
|
||||
1 => (string)trans('firefly.updates_enable_check'),
|
||||
-1 => (string) trans('firefly.updates_ask_me_later'),
|
||||
0 => (string) trans('firefly.updates_do_not_check'),
|
||||
1 => (string) trans('firefly.updates_enable_check'),
|
||||
];
|
||||
|
||||
$channelOptions = [
|
||||
'stable' => (string)trans('firefly.update_channel_stable'),
|
||||
'beta' => (string)trans('firefly.update_channel_beta'),
|
||||
'alpha' => (string)trans('firefly.update_channel_alpha'),
|
||||
'stable' => (string) trans('firefly.update_channel_stable'),
|
||||
'beta' => (string) trans('firefly.update_channel_beta'),
|
||||
'alpha' => (string) trans('firefly.update_channel_alpha'),
|
||||
];
|
||||
|
||||
return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions'));
|
||||
@@ -91,14 +91,14 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function post(Request $request)
|
||||
{
|
||||
$checkForUpdates = (int)$request->get('check_for_updates');
|
||||
$checkForUpdates = (int) $request->get('check_for_updates');
|
||||
$channel = $request->get('update_channel');
|
||||
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,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);
|
||||
|
||||
@@ -77,7 +77,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'));
|
||||
}
|
||||
@@ -111,7 +111,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'));
|
||||
}
|
||||
@@ -133,15 +133,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'));
|
||||
@@ -154,10 +154,10 @@ 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 = (bool)app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$singleUserMode = (bool) app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
||||
$allowInvites = false;
|
||||
if (!$this->externalIdentity && $singleUserMode) {
|
||||
// also registration enabled.
|
||||
@@ -179,7 +179,7 @@ class UserController extends Controller
|
||||
|
||||
public function invite(InviteUserFormRequest $request): RedirectResponse
|
||||
{
|
||||
$address = (string)$request->get('invited_user');
|
||||
$address = (string) $request->get('invited_user');
|
||||
$invitee = $this->repository->inviteUser(auth()->user(), $address);
|
||||
session()->flash('info', trans('firefly.user_is_invited', ['address' => $address]));
|
||||
|
||||
@@ -196,9 +196,9 @@ class UserController extends Controller
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -53,7 +53,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);
|
||||
@@ -68,7 +68,7 @@ class AttachmentController extends Controller
|
||||
*/
|
||||
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');
|
||||
@@ -87,7 +87,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'));
|
||||
@@ -117,7 +117,7 @@ class AttachmentController extends Controller
|
||||
->header('Expires', '0')
|
||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||
->header('Pragma', 'public')
|
||||
->header('Content-Length', (string)strlen($content))
|
||||
->header('Content-Length', (string) strlen($content))
|
||||
;
|
||||
|
||||
return $response;
|
||||
@@ -134,7 +134,7 @@ class AttachmentController extends Controller
|
||||
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')) {
|
||||
@@ -176,11 +176,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]);
|
||||
|
||||
@@ -79,7 +79,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
|
||||
@@ -101,7 +101,7 @@ class ForgotPasswordController extends Controller
|
||||
*/
|
||||
private function validateHost(): void
|
||||
{
|
||||
$configuredHost = parse_url((string)config('app.url'), PHP_URL_HOST);
|
||||
$configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
|
||||
if (false === $configuredHost || null === $configuredHost) {
|
||||
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
|
||||
}
|
||||
@@ -132,7 +132,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;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class LoginController extends Controller
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*/
|
||||
protected string $redirectTo = RouteServiceProvider::HOME;
|
||||
protected string $redirectTo = RouteServiceProvider::HOME;
|
||||
private UserRepositoryInterface $repository;
|
||||
|
||||
private string $username;
|
||||
@@ -225,7 +225,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'));
|
||||
|
||||
@@ -84,7 +84,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);
|
||||
|
||||
@@ -100,7 +100,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);
|
||||
|
||||
@@ -146,7 +146,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;
|
||||
@@ -178,7 +178,7 @@ class RegisterController extends Controller
|
||||
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');
|
||||
$pageTitle = (string) trans('firefly.register_page_title');
|
||||
$allowRegistration = $this->allowedToRegister();
|
||||
|
||||
if (false === $allowRegistration) {
|
||||
|
||||
@@ -130,7 +130,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;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,22 @@ class TwoFactorController extends Controller
|
||||
app('preferences')->set('mfa_history', $newHistory);
|
||||
}
|
||||
|
||||
private function addToMFAFailureCounter(): void
|
||||
{
|
||||
$preference = (int) app('preferences')->get('mfa_failure_count', 0)->data;
|
||||
++$preference;
|
||||
Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));
|
||||
app('preferences')->set('mfa_failure_count', $preference);
|
||||
}
|
||||
|
||||
private function getMFAFailureCounter(): int
|
||||
{
|
||||
$value = (int) app('preferences')->get('mfa_failure_count', 0)->data;
|
||||
Log::channel('audit')->info(sprintf('MFA failure count is %d.', $value));
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function addToMFAHistory(string $mfaCode): void
|
||||
{
|
||||
/** @var array $mfaHistory */
|
||||
@@ -177,6 +193,12 @@ class TwoFactorController extends Controller
|
||||
$this->filterMFAHistory();
|
||||
}
|
||||
|
||||
private function resetMFAFailureCounter(): void
|
||||
{
|
||||
app('preferences')->set('mfa_failure_count', 0);
|
||||
Log::channel('audit')->info('MFA failure count is set to zero.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if code is in users backup codes.
|
||||
*/
|
||||
@@ -219,26 +241,4 @@ class TwoFactorController extends Controller
|
||||
|
||||
app('preferences')->set('mfa_recovery', $newList);
|
||||
}
|
||||
|
||||
private function addToMFAFailureCounter(): void
|
||||
{
|
||||
$preference = (int) app('preferences')->get('mfa_failure_count', 0)->data;
|
||||
++$preference;
|
||||
Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));
|
||||
app('preferences')->set('mfa_failure_count', $preference);
|
||||
}
|
||||
|
||||
private function getMFAFailureCounter(): int
|
||||
{
|
||||
$value = (int) app('preferences')->get('mfa_failure_count', 0)->data;
|
||||
Log::channel('audit')->info(sprintf('MFA failure count is %d.', $value));
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function resetMFAFailureCounter(): void
|
||||
{
|
||||
app('preferences')->set('mfa_failure_count', 0);
|
||||
Log::channel('audit')->info('MFA failure count is set to zero.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,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);
|
||||
@@ -74,9 +74,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").
|
||||
@@ -101,13 +101,13 @@ class CreateController extends Controller
|
||||
$bill = $this->repository->store($billData);
|
||||
} catch (FireflyException $e) {
|
||||
app('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();
|
||||
}
|
||||
|
||||
Log::channel('audit')->info('Stored new bill.', $billData);
|
||||
$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 null|array $files */
|
||||
@@ -117,7 +117,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
|
||||
@@ -51,7 +51,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);
|
||||
|
||||
@@ -69,7 +69,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'));
|
||||
}
|
||||
@@ -84,7 +84,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'));
|
||||
|
||||
@@ -52,7 +52,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);
|
||||
@@ -75,10 +75,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')) {
|
||||
@@ -99,7 +99,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' => null !== $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '',
|
||||
];
|
||||
|
||||
@@ -119,7 +119,7 @@ class EditController extends Controller
|
||||
|
||||
Log::channel('audit')->info(sprintf('Updated bill #%d.', $bill->id), $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 null|array $files */
|
||||
@@ -129,7 +129,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
// flash messages
|
||||
@@ -138,7 +138,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]);
|
||||
|
||||
@@ -55,7 +55,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);
|
||||
|
||||
@@ -96,7 +96,7 @@ 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' => [],
|
||||
],
|
||||
];
|
||||
@@ -104,7 +104,7 @@ class IndexController extends Controller
|
||||
/** @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] ??= [
|
||||
'object_group_id' => $array['object_group_id'],
|
||||
@@ -164,8 +164,8 @@ class IndexController extends Controller
|
||||
|
||||
// only fill in avg when bill is active.
|
||||
if (null !== $bill['next_expected_match']) {
|
||||
$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:
|
||||
@@ -178,7 +178,7 @@ class IndexController extends Controller
|
||||
|
||||
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');
|
||||
|
||||
app('log')->debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name']));
|
||||
app('log')->debug(sprintf('Average is %s', $avg));
|
||||
@@ -191,8 +191,8 @@ class IndexController extends Controller
|
||||
'weekly' => '52.17',
|
||||
'daily' => '365.24',
|
||||
];
|
||||
$yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1)));
|
||||
app('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)));
|
||||
app('log')->debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1)));
|
||||
|
||||
// per period:
|
||||
$division = [
|
||||
@@ -256,8 +256,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -62,7 +62,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);
|
||||
|
||||
@@ -80,13 +80,13 @@ 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]));
|
||||
}
|
||||
$set = $this->repository->getRulesForBill($bill);
|
||||
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]));
|
||||
}
|
||||
@@ -125,8 +125,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();
|
||||
|
||||
@@ -102,13 +102,14 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Factory|View
|
||||
* @return Redirector|RedirectResponse
|
||||
*/
|
||||
public function show(BudgetLimit $budgetLimit)
|
||||
public function delete(BudgetLimit $budgetLimit)
|
||||
{
|
||||
$notes = $this->blRepository->getNoteText($budgetLimit);
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
session()->flash('success', trans('firefly.deleted_bl'));
|
||||
|
||||
return view('budgets.budget-limits.show', compact('budgetLimit', 'notes'));
|
||||
return redirect(route('budgets.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,14 +123,13 @@ class BudgetLimitController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Redirector|RedirectResponse
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function delete(BudgetLimit $budgetLimit)
|
||||
public function show(BudgetLimit $budgetLimit)
|
||||
{
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
session()->flash('success', trans('firefly.deleted_bl'));
|
||||
$notes = $this->blRepository->getNoteText($budgetLimit);
|
||||
|
||||
return redirect(route('budgets.index'));
|
||||
return view('budgets.budget-limits.show', compact('budgetLimit', 'notes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,7 +250,7 @@ class BudgetLimitController extends Controller
|
||||
if (-1 === bccomp($amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
$notes = (string)$request->get('notes');
|
||||
$notes = (string) $request->get('notes');
|
||||
if (strlen($notes) > 32768) {
|
||||
$notes = substr($notes, 0, 32768);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -73,24 +73,24 @@ 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'),
|
||||
AutoBudget::AUTO_BUDGET_ADJUSTED => (string)trans('firefly.auto_budget_adjusted'),
|
||||
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'),
|
||||
AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),
|
||||
];
|
||||
$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);
|
||||
@@ -100,7 +100,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'));
|
||||
}
|
||||
@@ -116,7 +116,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();
|
||||
|
||||
Log::channel('audit')->info('Stored new budget.', $data);
|
||||
@@ -129,7 +129,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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();
|
||||
|
||||
@@ -50,7 +50,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);
|
||||
|
||||
@@ -66,7 +66,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_budget', ['name' => $budget->name]);
|
||||
$subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('budgets.delete.url');
|
||||
@@ -83,7 +83,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'));
|
||||
|
||||
@@ -53,7 +53,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.budgets'));
|
||||
app('view')->share('title', (string) trans('firefly.budgets'));
|
||||
app('view')->share('mainTitleIcon', 'fa-pie-chart');
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -70,38 +70,38 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(Request $request, Budget $budget)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
$subTitle = (string) trans('firefly.edit_budget', ['name' => $budget->name]);
|
||||
$autoBudget = $this->repository->getAutoBudget($budget);
|
||||
|
||||
// auto budget types
|
||||
$autoBudgetTypes = [
|
||||
0 => (string)trans('firefly.auto_budget_none'),
|
||||
AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),
|
||||
AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),
|
||||
AutoBudget::AUTO_BUDGET_ADJUSTED => (string)trans('firefly.auto_budget_adjusted'),
|
||||
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'),
|
||||
AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),
|
||||
];
|
||||
$autoBudgetPeriods = [
|
||||
'daily' => (string)trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string)trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string)trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string)trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string)trans('firefly.auto_budget_period_yearly'),
|
||||
'daily' => (string) trans('firefly.auto_budget_period_daily'),
|
||||
'weekly' => (string) trans('firefly.auto_budget_period_weekly'),
|
||||
'monthly' => (string) trans('firefly.auto_budget_period_monthly'),
|
||||
'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),
|
||||
'half_year' => (string) trans('firefly.auto_budget_period_half_year'),
|
||||
'yearly' => (string) trans('firefly.auto_budget_period_yearly'),
|
||||
];
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,
|
||||
];
|
||||
if (null !== $autoBudget) {
|
||||
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
if (is_array($amount)) {
|
||||
$amount = '0';
|
||||
}
|
||||
$amount = (string)$amount;
|
||||
$amount = (string) $amount;
|
||||
$preFilled['auto_budget_amount'] = app('steam')->bcround($amount, $autoBudget->transactionCurrency->decimal_places);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class EditController extends Controller
|
||||
$data = $request->getBudgetData();
|
||||
$this->repository->update($budget, $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_budget', ['name' => $budget->name]));
|
||||
$this->repository->cleanupBudgets();
|
||||
app('preferences')->mark();
|
||||
|
||||
@@ -139,14 +139,14 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
$request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));
|
||||
}
|
||||
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
$request->session()->put('budgets.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -65,7 +65,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);
|
||||
@@ -306,7 +306,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) {
|
||||
app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
|
||||
|
||||
@@ -59,7 +59,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);
|
||||
@@ -91,8 +91,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);
|
||||
@@ -112,12 +112,12 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function noBudgetAll(Request $request)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.all_journals_without_budget');
|
||||
$subTitle = (string) trans('firefly.all_journals_without_budget');
|
||||
$first = $this->journalRepos->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$end = today(config('app.timezone'));
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
@@ -140,8 +140,8 @@ class ShowController extends Controller
|
||||
/** @var Carbon $allStart */
|
||||
$allStart = session('first', today(config('app.timezone'))->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);
|
||||
@@ -156,7 +156,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'));
|
||||
}
|
||||
@@ -174,8 +174,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);
|
||||
@@ -74,7 +74,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'));
|
||||
}
|
||||
@@ -91,7 +91,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):
|
||||
@@ -102,7 +102,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -110,7 +110,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();
|
||||
|
||||
@@ -50,7 +50,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);
|
||||
|
||||
@@ -66,7 +66,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(Category $category)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_category', ['name' => $category->name]);
|
||||
$subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('categories.delete.url');
|
||||
@@ -84,7 +84,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);
|
||||
@@ -70,7 +70,7 @@ class EditController extends Controller
|
||||
*/
|
||||
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')) {
|
||||
@@ -95,7 +95,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):
|
||||
@@ -106,7 +106,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -114,7 +114,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]));
|
||||
|
||||
@@ -50,7 +50,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);
|
||||
|
||||
@@ -66,8 +66,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->repository->getCategories();
|
||||
$total = $collection->count();
|
||||
$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
|
||||
@@ -55,7 +55,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);
|
||||
|
||||
@@ -78,8 +78,8 @@ class NoCategoryController extends Controller
|
||||
$start ??= session('start');
|
||||
// @var Carbon $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,10 +113,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;
|
||||
app('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'));
|
||||
|
||||
@@ -56,7 +56,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);
|
||||
|
||||
@@ -79,9 +79,9 @@ class ShowController extends Controller
|
||||
// @var Carbon $end
|
||||
$end ??= session('end', today(config('app.timezone'))->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) ?? today(config('app.timezone'))->startOfYear();
|
||||
$periods = $this->getCategoryPeriodOverview($category, $oldest, $end);
|
||||
$path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
@@ -116,13 +116,13 @@ class ShowController extends Controller
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$start = null;
|
||||
$end = null;
|
||||
$periods = new Collection();
|
||||
|
||||
$subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);
|
||||
$first = $this->repository->firstUseDate($category);
|
||||
|
||||
/** @var Carbon $start */
|
||||
|
||||
@@ -109,22 +109,22 @@ class AccountController extends Controller
|
||||
|
||||
// loop the end balances. This is an array for each account ($expenses)
|
||||
foreach ($endBalances as $accountId => $expenses) {
|
||||
$accountId = (int)$accountId;
|
||||
$accountId = (int) $accountId;
|
||||
// loop each expense entry (each entry can be a different currency).
|
||||
foreach ($expenses as $currencyId => $endAmount) {
|
||||
$currencyId = (int)$currencyId;
|
||||
$currencyId = (int) $currencyId;
|
||||
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string)$endAmount, $startAmount);
|
||||
$startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string) $endAmount, $startAmount);
|
||||
$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float)$diff, // intentional float
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class AccountController extends Controller
|
||||
foreach ($currencies as $currencyId => $currency) {
|
||||
$dataSet
|
||||
= [
|
||||
'label' => (string)trans('firefly.spent'),
|
||||
'label' => (string) trans('firefly.spent'),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
@@ -200,7 +200,7 @@ class AccountController extends Controller
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$budgetId = (int)$journal['budget_id'];
|
||||
$budgetId = (int) $journal['budget_id'];
|
||||
$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);
|
||||
$budgetIds[] = $budgetId;
|
||||
if (!array_key_exists($key, $result)) {
|
||||
@@ -220,7 +220,7 @@ class AccountController extends Controller
|
||||
foreach ($result as $row) {
|
||||
$budgetId = $row['budget_id'];
|
||||
$name = $names[$budgetId];
|
||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ class AccountController extends Controller
|
||||
if (!array_key_exists($key, $result)) {
|
||||
$result[$key] = [
|
||||
'total' => '0',
|
||||
'category_id' => (int)$journal['category_id'],
|
||||
'category_id' => (int) $journal['category_id'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
@@ -281,7 +281,7 @@ class AccountController extends Controller
|
||||
foreach ($result as $row) {
|
||||
$categoryId = $row['category_id'];
|
||||
$name = $names[$categoryId] ?? '(unknown)';
|
||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class AccountController extends Controller
|
||||
foreach ($result as $row) {
|
||||
$categoryId = $row['category_id'];
|
||||
$name = $names[$categoryId] ?? '(unknown)';
|
||||
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);
|
||||
$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];
|
||||
}
|
||||
$data = $this->generator->multiCurrencyPieChart($chartData);
|
||||
@@ -434,14 +434,14 @@ class AccountController extends Controller
|
||||
Log::debug(sprintf('$current date is %s', $current->format('Y-m-d')));
|
||||
if ('1D' === $step) {
|
||||
// per day the entire period, balance for every day.
|
||||
$format = (string)trans('config.month_and_day_js', [], $locale);
|
||||
$format = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$range = app('steam')->balanceInRange($account, $start, $end, $currency);
|
||||
$previous = array_values($range)[0];
|
||||
while ($end >= $current) {
|
||||
$theDate = $current->format('Y-m-d');
|
||||
$balance = $range[$theDate] ?? $previous;
|
||||
$label = $current->isoFormat($format);
|
||||
$entries[$label] = (float)$balance;
|
||||
$entries[$label] = (float) $balance;
|
||||
$previous = $balance;
|
||||
$current->addDay();
|
||||
}
|
||||
@@ -449,7 +449,7 @@ class AccountController extends Controller
|
||||
if ('1W' === $step || '1M' === $step || '1Y' === $step) {
|
||||
while ($end >= $current) {
|
||||
Log::debug(sprintf('Current is: %s', $current->format('Y-m-d')));
|
||||
$balance = (float)app('steam')->balance($account, $current, $currency);
|
||||
$balance = (float) app('steam')->balance($account, $current, $currency);
|
||||
$label = app('navigation')->periodShow($current, $step);
|
||||
$entries[$label] = $balance;
|
||||
$current = app('navigation')->addPeriod($current, $step, 0);
|
||||
@@ -510,22 +510,22 @@ class AccountController extends Controller
|
||||
|
||||
// loop the end balances. This is an array for each account ($expenses)
|
||||
foreach ($endBalances as $accountId => $expenses) {
|
||||
$accountId = (int)$accountId;
|
||||
$accountId = (int) $accountId;
|
||||
// loop each expense entry (each entry can be a different currency).
|
||||
foreach ($expenses as $currencyId => $endAmount) {
|
||||
$currencyId = (int)$currencyId;
|
||||
$currencyId = (int) $currencyId;
|
||||
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string)$endAmount, $startAmount);
|
||||
$startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');
|
||||
$diff = bcsub((string) $endAmount, $startAmount);
|
||||
$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
|
||||
if (0 !== bccomp($diff, '0')) {
|
||||
// store the values in a temporary array.
|
||||
$tempData[] = [
|
||||
'name' => $accountNames[$accountId],
|
||||
'difference' => $diff,
|
||||
'diff_float' => (float)$diff, // intentional float
|
||||
'diff_float' => (float) $diff, // intentional float
|
||||
'currency_id' => $currencyId,
|
||||
];
|
||||
}
|
||||
@@ -544,7 +544,7 @@ class AccountController extends Controller
|
||||
foreach ($currencies as $currencyId => $currency) {
|
||||
$dataSet
|
||||
= [
|
||||
'label' => (string)trans('firefly.earned'),
|
||||
'label' => (string) trans('firefly.earned'),
|
||||
'type' => 'bar',
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_code' => $currency->code,
|
||||
|
||||
@@ -72,7 +72,7 @@ class BillController extends Controller
|
||||
*/
|
||||
foreach ($paid as $info) {
|
||||
$amount = $info['sum'];
|
||||
$label = (string)trans('firefly.paid_in_currency', ['currency' => $info['name']]);
|
||||
$label = (string) trans('firefly.paid_in_currency', ['currency' => $info['name']]);
|
||||
$chartData[$label] = [
|
||||
'amount' => $amount,
|
||||
'currency_symbol' => $info['symbol'],
|
||||
@@ -85,7 +85,7 @@ class BillController extends Controller
|
||||
*/
|
||||
foreach ($unpaid as $info) {
|
||||
$amount = $info['sum'];
|
||||
$label = (string)trans('firefly.unpaid_in_currency', ['currency' => $info['name']]);
|
||||
$label = (string) trans('firefly.unpaid_in_currency', ['currency' => $info['name']]);
|
||||
$chartData[$label] = [
|
||||
'amount' => $amount,
|
||||
'currency_symbol' => $info['symbol'],
|
||||
@@ -136,21 +136,21 @@ class BillController extends Controller
|
||||
$chartData = [
|
||||
[
|
||||
'type' => 'line',
|
||||
'label' => (string)trans('firefly.min-amount'),
|
||||
'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'),
|
||||
'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'),
|
||||
'label' => (string) trans('firefly.journal-amount'),
|
||||
'currency_symbol' => $bill->transactionCurrency->symbol,
|
||||
'currency_code' => $bill->transactionCurrency->code,
|
||||
'entries' => [],
|
||||
@@ -158,7 +158,7 @@ class BillController extends Controller
|
||||
];
|
||||
$currencyId = $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
|
||||
|
||||
|
||||
@@ -172,12 +172,12 @@ class BudgetController extends Controller
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency);
|
||||
$spent = $expenses[$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;
|
||||
@@ -220,7 +220,7 @@ 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] ??= [
|
||||
'amount' => '0',
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
@@ -233,7 +233,7 @@ class BudgetController extends Controller
|
||||
$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]
|
||||
= [
|
||||
@@ -293,7 +293,7 @@ class BudgetController extends Controller
|
||||
$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'],
|
||||
@@ -353,7 +353,7 @@ class BudgetController extends Controller
|
||||
$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] = [
|
||||
@@ -422,14 +422,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,
|
||||
@@ -500,7 +500,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);
|
||||
|
||||
@@ -171,7 +171,7 @@ class BudgetReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
|
||||
(string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
|
||||
@@ -185,7 +185,7 @@ class CategoryController extends Controller
|
||||
$inKey = sprintf('%d-in', $currencyId);
|
||||
$chartData[$outKey]
|
||||
= [
|
||||
'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
@@ -193,7 +193,7 @@ class CategoryController extends Controller
|
||||
|
||||
$chartData[$inKey]
|
||||
= [
|
||||
'label' => sprintf('%s (%s)', (string)trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||
'entries' => [],
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||
|
||||
@@ -218,7 +218,7 @@ class CategoryReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),
|
||||
(string) trans('firefly.spent_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
@@ -245,7 +245,7 @@ class CategoryReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),
|
||||
(string) trans('firefly.earned_in_specific_category', ['category' => $category->name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
|
||||
@@ -164,7 +164,7 @@ class DoubleReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_double', ['account' => $name]),
|
||||
(string) trans('firefly.spent_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
@@ -190,7 +190,7 @@ class DoubleReportController extends Controller
|
||||
$chartData[$earnedKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_double', ['account' => $name]),
|
||||
(string) trans('firefly.earned_in_specific_double', ['account' => $name]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
|
||||
@@ -103,27 +103,27 @@ class ExpenseReportController extends Controller
|
||||
/** @var Account $exp */
|
||||
$exp = $combination->first();
|
||||
$chartData[$exp->id.'-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.income')),
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.income')),
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id.'-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.expenses')),
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.expenses')),
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
// total in, total out:
|
||||
$chartData[$exp->id.'-total-in'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_income')),
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_income')),
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id.'-total-out'] = [
|
||||
'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_expenses')),
|
||||
'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_expenses')),
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
|
||||
@@ -95,7 +95,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);
|
||||
}
|
||||
@@ -105,7 +105,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);
|
||||
|
||||
@@ -109,7 +109,7 @@ class ReportController extends Controller
|
||||
continue;
|
||||
}
|
||||
$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'],
|
||||
@@ -175,13 +175,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] ??= [
|
||||
'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] ??= [
|
||||
'period' => $period,
|
||||
@@ -198,8 +198,8 @@ class ReportController extends Controller
|
||||
TransactionTypeEnum::DEPOSIT->value === $journal['transaction_type_type']
|
||||
|| ((
|
||||
TransactionTypeEnum::TRANSFER->value === $journal['transaction_type_type']
|
||||
|| TransactionTypeEnum::RECONCILIATION->value === $journal['transaction_type_type']
|
||||
|| TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type']
|
||||
|| TransactionTypeEnum::RECONCILIATION->value === $journal['transaction_type_type']
|
||||
|| TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type']
|
||||
)
|
||||
&& in_array($journal['destination_account_id'], $ids, true))) {
|
||||
$key = 'earned';
|
||||
@@ -214,7 +214,7 @@ class ReportController extends Controller
|
||||
foreach ($data as $currency) {
|
||||
Log::debug(sprintf('Now processing currency "%s"', $currency['currency_name']));
|
||||
$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'],
|
||||
@@ -223,7 +223,7 @@ class ReportController extends Controller
|
||||
'entries' => [],
|
||||
];
|
||||
$expense = [
|
||||
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
|
||||
'type' => 'bar',
|
||||
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
|
||||
'currency_id' => $currency['currency_id'],
|
||||
|
||||
@@ -222,7 +222,7 @@ class TagReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
|
||||
(string) trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
@@ -249,7 +249,7 @@ class TagReportController extends Controller
|
||||
$chartData[$spentKey] ??= [
|
||||
'label' => sprintf(
|
||||
'%s (%s)',
|
||||
(string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
|
||||
(string) trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
|
||||
$currency['currency_name']
|
||||
),
|
||||
'type' => 'bar',
|
||||
|
||||
@@ -74,7 +74,7 @@ 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] ??= [
|
||||
'amount' => '0',
|
||||
@@ -124,7 +124,7 @@ 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] ??= [
|
||||
'amount' => '0',
|
||||
|
||||
@@ -29,6 +29,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Route;
|
||||
|
||||
/**
|
||||
* Class Controller.
|
||||
@@ -59,7 +60,7 @@ abstract class Controller extends BaseController
|
||||
{
|
||||
// is site a demo site?
|
||||
$isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false));
|
||||
$isDemoSite = (bool)$isDemoSiteConfig->data;
|
||||
$isDemoSite = (bool) $isDemoSiteConfig->data;
|
||||
app('view')->share('IS_DEMO_SITE', $isDemoSite);
|
||||
app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
|
||||
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));
|
||||
@@ -69,8 +70,8 @@ abstract class Controller extends BaseController
|
||||
app('view')->share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === config('firefly.allow_webhooks'));
|
||||
|
||||
// share custom auth guard info.
|
||||
$authGuard = config('firefly.authentication_guard');
|
||||
$logoutUrl = config('firefly.custom_logout_url');
|
||||
$authGuard = config('firefly.authentication_guard');
|
||||
$logoutUrl = config('firefly.custom_logout_url');
|
||||
|
||||
// overrule v2 layout back to v1.
|
||||
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
|
||||
@@ -81,18 +82,18 @@ abstract class Controller extends BaseController
|
||||
app('view')->share('logoutUrl', $logoutUrl);
|
||||
|
||||
// upload size
|
||||
$maxFileSize = app('steam')->phpBytes((string)ini_get('upload_max_filesize'));
|
||||
$maxPostSize = app('steam')->phpBytes((string)ini_get('post_max_size'));
|
||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||
$maxFileSize = app('steam')->phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = app('steam')->phpBytes((string) ini_get('post_max_size'));
|
||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||
app('view')->share('uploadSize', $uploadSize);
|
||||
|
||||
// share is alpha, is beta
|
||||
$isAlpha = false;
|
||||
$isAlpha = false;
|
||||
if (str_contains(config('firefly.version'), 'alpha')) {
|
||||
$isAlpha = true;
|
||||
}
|
||||
|
||||
$isBeta = false;
|
||||
$isBeta = false;
|
||||
if (str_contains(config('firefly.version'), 'beta')) {
|
||||
$isBeta = true;
|
||||
}
|
||||
@@ -102,11 +103,11 @@ abstract class Controller extends BaseController
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next): mixed {
|
||||
$locale = app('steam')->getLocale();
|
||||
$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);
|
||||
$darkMode = 'browser';
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
@@ -119,7 +120,7 @@ abstract class Controller extends BaseController
|
||||
app('view')->share('locale', $locale);
|
||||
app('view')->share('shownDemo', $shownDemo);
|
||||
app('view')->share('current_route_name', $page);
|
||||
app('view')->share('original_route_name', \Route::currentRouteName());
|
||||
app('view')->share('original_route_name', Route::currentRouteName());
|
||||
}
|
||||
app('view')->share('darkMode', $darkMode);
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class DebugController extends Controller
|
||||
}
|
||||
if ('' !== $logContent) {
|
||||
// last few lines
|
||||
$logContent = 'Truncated from this point <----|'.substr((string)$logContent, -16384);
|
||||
$logContent = 'Truncated from this point <----|'.substr((string) $logContent, -16384);
|
||||
}
|
||||
|
||||
return view('debug', compact('table', 'now', 'logContent'));
|
||||
@@ -152,13 +152,13 @@ class DebugController extends Controller
|
||||
$app = $this->getAppInfo();
|
||||
$user = $this->getuserInfo();
|
||||
|
||||
return (string)view('partials.debug-table', compact('system', 'docker', 'app', 'user'));
|
||||
return (string) view('partials.debug-table', compact('system', 'docker', 'app', 'user'));
|
||||
}
|
||||
|
||||
private function getSystemInformation(): array
|
||||
{
|
||||
$maxFileSize = app('steam')->phpBytes((string)ini_get('upload_max_filesize'));
|
||||
$maxPostSize = app('steam')->phpBytes((string)ini_get('post_max_size'));
|
||||
$maxFileSize = app('steam')->phpBytes((string) ini_get('upload_max_filesize'));
|
||||
$maxPostSize = app('steam')->phpBytes((string) ini_get('post_max_size'));
|
||||
$drivers = \DB::availableDrivers();
|
||||
$currentDriver = \DB::getDriverName();
|
||||
|
||||
@@ -171,7 +171,7 @@ class DebugController extends Controller
|
||||
'bits' => \PHP_INT_SIZE * 8,
|
||||
'bcscale' => bcscale(),
|
||||
'display_errors' => ini_get('display_errors'),
|
||||
'error_reporting' => $this->errorReporting((int)ini_get('error_reporting')),
|
||||
'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),
|
||||
'upload_size' => min($maxFileSize, $maxPostSize),
|
||||
'all_drivers' => $drivers,
|
||||
'current_driver' => $currentDriver,
|
||||
@@ -190,7 +190,7 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/counter-main.txt')) {
|
||||
$return['build'] = trim((string)file_get_contents('/var/www/counter-main.txt'));
|
||||
$return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
|
||||
app('log')->debug(sprintf('build is now "%s"', $return['build']));
|
||||
}
|
||||
} catch (\Exception $e) { // @phpstan-ignore-line
|
||||
@@ -200,16 +200,16 @@ class DebugController extends Controller
|
||||
|
||||
try {
|
||||
if (file_exists('/var/www/build-date-main.txt')) {
|
||||
$return['build_date'] = trim((string)file_get_contents('/var/www/build-date-main.txt'));
|
||||
$return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
|
||||
}
|
||||
} catch (\Exception $e) { // @phpstan-ignore-line
|
||||
app('log')->debug('Could not check build date, but thats ok.');
|
||||
app('log')->warning($e->getMessage());
|
||||
}
|
||||
if ('' !== (string)env('BASE_IMAGE_BUILD')) {
|
||||
if ('' !== (string) env('BASE_IMAGE_BUILD')) {
|
||||
$return['base_build'] = env('BASE_IMAGE_BUILD');
|
||||
}
|
||||
if ('' !== (string)env('BASE_IMAGE_DATE')) {
|
||||
if ('' !== (string) env('BASE_IMAGE_DATE')) {
|
||||
$return['base_build_date'] = env('BASE_IMAGE_DATE');
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ class DebugController extends Controller
|
||||
$userGuard = config('auth.defaults.guard');
|
||||
|
||||
$config = app('fireflyconfig')->get('last_rt_job', 0);
|
||||
$lastTime = (int)$config->data;
|
||||
$lastTime = (int) $config->data;
|
||||
$lastCronjob = 'never';
|
||||
$lastCronjobAgo = 'never';
|
||||
if ($lastTime > 0) {
|
||||
@@ -233,8 +233,8 @@ class DebugController extends Controller
|
||||
return [
|
||||
'debug' => var_export(config('app.debug'), true),
|
||||
'audit_log_channel' => envNonEmpty('AUDIT_LOG_CHANNEL', '(empty)'),
|
||||
'default_language' => (string)config('firefly.default_language'),
|
||||
'default_locale' => (string)config('firefly.default_locale'),
|
||||
'default_language' => (string) config('firefly.default_language'),
|
||||
'default_locale' => (string) config('firefly.default_locale'),
|
||||
'remote_header' => 'remote_user_guard' === $userGuard ? config('auth.guard_header') : 'N/A',
|
||||
'remote_mail_header' => 'remote_user_guard' === $userGuard ? config('auth.guard_email') : 'N/A',
|
||||
'stateful_domains' => implode(', ', config('sanctum.stateful')),
|
||||
@@ -265,7 +265,7 @@ class DebugController extends Controller
|
||||
$result = setlocale(LC_ALL, $code);
|
||||
$localeAttempts[$code] = $result === $code;
|
||||
}
|
||||
setlocale(LC_ALL, (string)$original);
|
||||
setlocale(LC_ALL, (string) $original);
|
||||
|
||||
return [
|
||||
'user_id' => auth()->user()->id,
|
||||
|
||||
@@ -52,7 +52,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']);
|
||||
|
||||
@@ -67,7 +67,7 @@ class IndexController extends Controller
|
||||
public function export(): LaravelResponse|RedirectResponse
|
||||
{
|
||||
if (auth()->user()->hasRole('demo')) {
|
||||
session()->flash('info', (string)trans('firefly.demo_user_export'));
|
||||
session()->flash('info', (string) trans('firefly.demo_user_export'));
|
||||
|
||||
return redirect(route('export.index'));
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class IndexController extends Controller
|
||||
->header('Expires', '0')
|
||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||
->header('Pragma', 'public')
|
||||
->header('Content-Length', (string)strlen($result['transactions']))
|
||||
->header('Content-Length', (string) strlen($result['transactions']))
|
||||
;
|
||||
|
||||
// return CSV file made from 'transactions' array.
|
||||
|
||||
@@ -55,7 +55,7 @@ class JavascriptController extends Controller
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$accountId = $account->id;
|
||||
$currency = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$currency = (int) $repository->getMetaValue($account, 'currency_id');
|
||||
$currency = 0 === $currency ? $default->id : $currency;
|
||||
$entry = ['preferredCurrency' => $currency, 'name' => $account->name];
|
||||
$data['accounts'][$accountId] = $entry;
|
||||
@@ -95,7 +95,7 @@ class JavascriptController extends Controller
|
||||
* */
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository): 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;
|
||||
@@ -106,7 +106,7 @@ class JavascriptController extends Controller
|
||||
$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);
|
||||
$uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);
|
||||
$data = [
|
||||
'currencyCode' => $currency->code,
|
||||
'currencySymbol' => $currency->symbol,
|
||||
|
||||
@@ -72,7 +72,7 @@ class BoxController extends Controller
|
||||
$end = session('end', today(config('app.timezone'))->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);
|
||||
@@ -113,24 +113,24 @@ class BoxController extends Controller
|
||||
$spentAmount = $spent[$currency->id]['sum'] ?? '0';
|
||||
app('log')->debug(sprintf('Spent for default currency for all budgets in this period: %s', $spentAmount));
|
||||
|
||||
$days = (int)($today->between($start, $end) ? $today->diffInDays($start, true) + 1 : $end->diffInDays($start, true) + 1);
|
||||
$days = (int) ($today->between($start, $end) ? $today->diffInDays($start, true) + 1 : $end->diffInDays($start, true) + 1);
|
||||
app('log')->debug(sprintf('Number of days left: %d', $days));
|
||||
$spentPerDay = bcdiv($spentAmount, (string)$days);
|
||||
$spentPerDay = bcdiv($spentAmount, (string) $days);
|
||||
app('log')->debug(sprintf('Available to spend per day: %s', $spentPerDay));
|
||||
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');
|
||||
app('log')->debug(sprintf('Total available sum is %s', $totalAvailableSum));
|
||||
// calculate with available budget.
|
||||
$leftToSpendAmount = bcadd($totalAvailableSum, $spentAmount);
|
||||
app('log')->debug(sprintf('So left to spend is %s', $leftToSpendAmount));
|
||||
if (bccomp($leftToSpendAmount, '0') >= 0) {
|
||||
app('log')->debug('Left to spend is positive or zero!');
|
||||
$boxTitle = (string)trans('firefly.left_to_spend');
|
||||
$boxTitle = (string) trans('firefly.left_to_spend');
|
||||
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
|
||||
$display = 1; // not overspent
|
||||
$leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft);
|
||||
$leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string) $activeDaysLeft);
|
||||
app('log')->debug(sprintf('Left to spend per day is %s', $leftPerDayAmount));
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ class BoxController extends Controller
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$amount = $journal['amount'] ?? '0';
|
||||
$incomes[$currencyId] ??= '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));
|
||||
@@ -203,7 +203,7 @@ class BoxController extends Controller
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = (int)$journal['currency_id'];
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$expenses[$currencyId] ??= '0';
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0');
|
||||
$sums[$currencyId] ??= '0';
|
||||
|
||||
@@ -53,7 +53,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->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
|
||||
@@ -51,7 +51,7 @@ class FrontpageController extends Controller
|
||||
// percentage!
|
||||
$pct = 0;
|
||||
if (0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$pct = (int)bcmul(bcdiv($amount, $piggyBank->target_amount), '100');
|
||||
$pct = (int) bcmul(bcdiv($amount, $piggyBank->target_amount), '100');
|
||||
}
|
||||
|
||||
$entry = [
|
||||
|
||||
@@ -103,7 +103,7 @@ class IntroController extends Controller
|
||||
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')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,7 +55,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->accountRepos = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -72,13 +72,13 @@ 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');
|
||||
$weekend = (int)$request->get('weekend');
|
||||
$repetitions = (int) $request->get('reps');
|
||||
$weekend = (int) $request->get('weekend');
|
||||
$repetitionMoment = '';
|
||||
$skip = (int)$request->get('skip');
|
||||
$skip = (int) $request->get('skip');
|
||||
$skip = $skip < 0 || $skip > 31 ? 0 : $skip;
|
||||
$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;
|
||||
|
||||
@@ -153,7 +153,7 @@ class RecurrenceController extends Controller
|
||||
*/
|
||||
public function suggest(Request $request): JsonResponse
|
||||
{
|
||||
$string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date');
|
||||
$string = '' === (string) $request->get('date') ? date('Y-m-d') : (string) $request->get('date');
|
||||
$today = today(config('app.timezone'))->startOfDay();
|
||||
|
||||
try {
|
||||
@@ -165,37 +165,37 @@ class RecurrenceController extends Controller
|
||||
return response()->json();
|
||||
}
|
||||
$date->startOfDay();
|
||||
$preSelected = (string)$request->get('pre_select');
|
||||
$preSelected = (string) $request->get('pre_select');
|
||||
$locale = app('steam')->getLocale();
|
||||
|
||||
app('log')->debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true)));
|
||||
app('log')->debug(sprintf('past = true? %s', var_export('true' === (string)$request->get('past'), true)));
|
||||
app('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')) {
|
||||
app('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')],
|
||||
'daily' => ['label' => (string) trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')],
|
||||
$weekly => [
|
||||
'label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
'label' => (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),
|
||||
'selected' => str_starts_with($preSelected, 'weekly'),
|
||||
],
|
||||
$monthly => [
|
||||
'label' => (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]),
|
||||
'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]),
|
||||
'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]),
|
||||
'label' => (string) trans('firefly.recurring_yearly', ['date' => $yearlyDate]),
|
||||
'selected' => str_starts_with($preSelected, 'yearly'),
|
||||
],
|
||||
];
|
||||
|
||||
@@ -41,11 +41,11 @@ class RuleController extends Controller
|
||||
*/
|
||||
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 {
|
||||
@@ -68,12 +68,12 @@ class RuleController extends Controller
|
||||
*/
|
||||
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);
|
||||
|
||||
@@ -66,7 +66,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');
|
||||
@@ -98,7 +98,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) {
|
||||
@@ -134,7 +134,7 @@ class NewUserController extends Controller
|
||||
];
|
||||
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'));
|
||||
|
||||
@@ -48,7 +48,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
||||
app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
|
||||
app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
|
||||
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
|
||||
@@ -64,7 +64,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(ObjectGroup $objectGroup)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);
|
||||
$subTitle = (string) trans('firefly.delete_object_group', ['title' => $objectGroup->title]);
|
||||
$piggyBanks = $objectGroup->piggyBanks()->count();
|
||||
|
||||
// put previous url in session
|
||||
@@ -78,7 +78,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function destroy(ObjectGroup $objectGroup): RedirectResponse
|
||||
{
|
||||
session()->flash('success', (string)trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
|
||||
app('preferences')->mark();
|
||||
$this->repository->destroy($objectGroup);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
||||
app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
|
||||
app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
|
||||
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
|
||||
@@ -67,7 +67,7 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(ObjectGroup $objectGroup)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.edit_object_group', ['title' => $objectGroup->title]);
|
||||
$subTitle = (string) trans('firefly.edit_object_group', ['title' => $objectGroup->title]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
|
||||
if (true !== session('object-groups.edit.fromUpdate')) {
|
||||
@@ -88,12 +88,12 @@ class EditController extends Controller
|
||||
$data = $request->getObjectGroupData();
|
||||
$piggyBank = $this->repository->update($objectGroup, $data);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.updated_object_group', ['title' => $objectGroup->title]));
|
||||
session()->flash('success', (string) trans('firefly.updated_object_group', ['title' => $objectGroup->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('object-groups.edit.url'));
|
||||
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
session()->put('object-groups.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));
|
||||
|
||||
@@ -50,7 +50,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
||||
app('view')->share('title', (string)trans('firefly.object_groups_page_title'));
|
||||
app('view')->share('title', (string) trans('firefly.object_groups_page_title'));
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -65,7 +65,7 @@ class IndexController extends Controller
|
||||
{
|
||||
$this->repository->deleteEmpty();
|
||||
$this->repository->resetOrder();
|
||||
$subTitle = (string)trans('firefly.object_groups_index');
|
||||
$subTitle = (string) trans('firefly.object_groups_index');
|
||||
$objectGroups = $this->repository->get();
|
||||
|
||||
return view('object-groups.index', compact('subTitle', 'objectGroups'));
|
||||
@@ -77,7 +77,7 @@ class IndexController extends Controller
|
||||
public function setOrder(Request $request, ObjectGroup $objectGroup)
|
||||
{
|
||||
app('log')->debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title));
|
||||
$newOrder = (int)$request->get('order');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$this->repository->setOrder($objectGroup, $newOrder);
|
||||
|
||||
return response()->json([]);
|
||||
|
||||
@@ -47,7 +47,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
@@ -64,7 +64,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(PiggyBank $piggyBank)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
|
||||
$subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('piggy-banks.delete.url');
|
||||
@@ -77,7 +77,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function destroy(PiggyBank $piggyBank): RedirectResponse
|
||||
{
|
||||
session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||
app('preferences')->mark();
|
||||
$this->piggyRepos->destroy($piggyBank);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
@@ -73,7 +73,7 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(PiggyBank $piggyBank)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
||||
$subTitle = (string) trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
$note = $piggyBank->notes()->first();
|
||||
// Flash some data to fill the form.
|
||||
@@ -116,7 +116,7 @@ class EditController extends Controller
|
||||
$data = $request->getPiggyBankData();
|
||||
$piggyBank = $this->piggyRepos->update($piggyBank, $data);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
|
||||
session()->flash('success', (string) trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -127,7 +127,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -135,7 +135,7 @@ class EditController extends Controller
|
||||
}
|
||||
$redirect = redirect($this->getPreviousUrl('piggy-banks.edit.url'));
|
||||
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
session()->put('piggy-banks.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('piggy-banks.edit', [$piggyBank->id]));
|
||||
|
||||
@@ -106,59 +106,6 @@ class IndexController extends Controller
|
||||
return view('piggy-banks.index', compact('piggyBanks', 'accounts'));
|
||||
}
|
||||
|
||||
private function makeSums(array $piggyBanks): array
|
||||
{
|
||||
$sums = [];
|
||||
foreach ($piggyBanks as $groupOrder => $group) {
|
||||
$groupId = $group['object_group_id'];
|
||||
foreach ($group['piggy_banks'] as $piggy) {
|
||||
$currencyId = $piggy['currency_id'];
|
||||
$sums[$groupId][$currencyId] ??= [
|
||||
'target' => '0',
|
||||
'saved' => '0',
|
||||
'left_to_save' => '0',
|
||||
'save_per_month' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $piggy['currency_code'],
|
||||
'currency_symbol' => $piggy['currency_symbol'],
|
||||
'currency_decimal_places' => $piggy['currency_decimal_places'],
|
||||
];
|
||||
// target_amount
|
||||
// current_amount
|
||||
// left_to_save
|
||||
// save_per_month
|
||||
$sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);
|
||||
$sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);
|
||||
$sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);
|
||||
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);
|
||||
}
|
||||
}
|
||||
foreach ($piggyBanks as $groupOrder => $group) {
|
||||
$groupId = $group['object_group_id'];
|
||||
$piggyBanks[$groupOrder]['sums'] = $sums[$groupId] ?? [];
|
||||
}
|
||||
|
||||
return $piggyBanks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the order of a piggy bank.
|
||||
*/
|
||||
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$objectGroupTitle = (string) $request->get('objectGroupTitle');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
||||
}
|
||||
if ('' === $objectGroupTitle) {
|
||||
$this->piggyRepos->removeObjectGroup($piggyBank);
|
||||
}
|
||||
|
||||
return response()->json(['data' => 'OK']);
|
||||
}
|
||||
|
||||
private function groupPiggyBanks(Collection $collection): array
|
||||
{
|
||||
/** @var PiggyBankTransformer $transformer */
|
||||
@@ -251,4 +198,57 @@ class IndexController extends Controller
|
||||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
private function makeSums(array $piggyBanks): array
|
||||
{
|
||||
$sums = [];
|
||||
foreach ($piggyBanks as $groupOrder => $group) {
|
||||
$groupId = $group['object_group_id'];
|
||||
foreach ($group['piggy_banks'] as $piggy) {
|
||||
$currencyId = $piggy['currency_id'];
|
||||
$sums[$groupId][$currencyId] ??= [
|
||||
'target' => '0',
|
||||
'saved' => '0',
|
||||
'left_to_save' => '0',
|
||||
'save_per_month' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $piggy['currency_code'],
|
||||
'currency_symbol' => $piggy['currency_symbol'],
|
||||
'currency_decimal_places' => $piggy['currency_decimal_places'],
|
||||
];
|
||||
// target_amount
|
||||
// current_amount
|
||||
// left_to_save
|
||||
// save_per_month
|
||||
$sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);
|
||||
$sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);
|
||||
$sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);
|
||||
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);
|
||||
}
|
||||
}
|
||||
foreach ($piggyBanks as $groupOrder => $group) {
|
||||
$groupId = $group['object_group_id'];
|
||||
$piggyBanks[$groupOrder]['sums'] = $sums[$groupId] ?? [];
|
||||
}
|
||||
|
||||
return $piggyBanks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the order of a piggy bank.
|
||||
*/
|
||||
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$objectGroupTitle = (string) $request->get('objectGroupTitle');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
||||
}
|
||||
if ('' === $objectGroupTitle) {
|
||||
$this->piggyRepos->removeObjectGroup($piggyBank);
|
||||
}
|
||||
|
||||
return response()->json(['data' => 'OK']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class ShowController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.piggyBanks'));
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
|
||||
@@ -80,19 +80,59 @@ class MfaController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function index(): Factory|RedirectResponse|View
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function backupCodes(Request $request): Factory|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
request()->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
if (false === $enabledMFA) {
|
||||
request()->session()->flash('info', trans('firefly.mfa_not_enabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$subTitle = (string)trans('firefly.mfa_index_title');
|
||||
$subTitleIcon = 'fa-calculator';
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
return view('profile.mfa.backup-codes-intro');
|
||||
}
|
||||
|
||||
public function backupCodesPost(ExistingTokenFormRequest $request): Redirector|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
if (false === $enabledMFA) {
|
||||
request()->session()->flash('info', trans('firefly.mfa_not_enabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
// generate recovery codes:
|
||||
$recovery = app(Recovery::class);
|
||||
$recoveryCodes = $recovery->lowercase()
|
||||
->setCount(8) // Generate 8 codes
|
||||
->setBlocks(2) // Every code must have 2 blocks
|
||||
->setChars(6) // Each block must have 6 chars
|
||||
->toArray()
|
||||
;
|
||||
$codes = implode("\r\n", $recoveryCodes);
|
||||
|
||||
app('preferences')->set('mfa_recovery', $recoveryCodes);
|
||||
app('preferences')->mark();
|
||||
|
||||
// send user notification.
|
||||
$user = auth()->user();
|
||||
Log::channel('audit')->info(sprintf('User "%s" has generated new backup codes.', $user->email));
|
||||
event(new MFANewBackupCodes($user));
|
||||
|
||||
return view('profile.mfa.backup-codes-post')->with(compact('codes'));
|
||||
|
||||
return view('profile.mfa.index')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));
|
||||
}
|
||||
|
||||
public function disableMFA(Request $request): Factory|RedirectResponse|View
|
||||
@@ -108,7 +148,7 @@ class MfaController extends Controller
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$subTitle = (string)trans('firefly.mfa_index_title');
|
||||
$subTitle = (string) trans('firefly.mfa_index_title');
|
||||
$subTitleIcon = 'fa-calculator';
|
||||
|
||||
return view('profile.mfa.disable-mfa')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));
|
||||
@@ -180,66 +220,10 @@ class MfaController extends Controller
|
||||
app('preferences')->set('temp-mfa-secret', $secret);
|
||||
|
||||
|
||||
|
||||
return view('profile.mfa.enable-mfa', compact('image', 'secret'));
|
||||
|
||||
}
|
||||
|
||||
public function backupCodesPost(ExistingTokenFormRequest $request): Redirector|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
if (false === $enabledMFA) {
|
||||
request()->session()->flash('info', trans('firefly.mfa_not_enabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
// generate recovery codes:
|
||||
$recovery = app(Recovery::class);
|
||||
$recoveryCodes = $recovery->lowercase()
|
||||
->setCount(8) // Generate 8 codes
|
||||
->setBlocks(2) // Every code must have 2 blocks
|
||||
->setChars(6) // Each block must have 6 chars
|
||||
->toArray()
|
||||
;
|
||||
$codes = implode("\r\n", $recoveryCodes);
|
||||
|
||||
app('preferences')->set('mfa_recovery', $recoveryCodes);
|
||||
app('preferences')->mark();
|
||||
|
||||
// send user notification.
|
||||
$user = auth()->user();
|
||||
Log::channel('audit')->info(sprintf('User "%s" has generated new backup codes.', $user->email));
|
||||
event(new MFANewBackupCodes($user));
|
||||
|
||||
return view('profile.mfa.backup-codes-post')->with(compact('codes'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function backupCodes(Request $request): Factory|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
$request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
if (false === $enabledMFA) {
|
||||
request()->session()->flash('info', trans('firefly.mfa_not_enabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
return view('profile.mfa.backup-codes-intro');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit 2FA for the first time.
|
||||
*
|
||||
@@ -340,4 +324,19 @@ class MfaController extends Controller
|
||||
}
|
||||
app('preferences')->set('mfa_history', $newHistory);
|
||||
}
|
||||
|
||||
public function index(): Factory|RedirectResponse|View
|
||||
{
|
||||
if (!$this->internalAuth) {
|
||||
request()->session()->flash('error', trans('firefly.external_user_mgt_disabled'));
|
||||
|
||||
return redirect(route('profile.index'));
|
||||
}
|
||||
|
||||
$subTitle = (string) trans('firefly.mfa_index_title');
|
||||
$subTitleIcon = 'fa-calculator';
|
||||
$enabledMFA = null !== auth()->user()->mfa_secret;
|
||||
|
||||
return view('profile.mfa.index')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,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);
|
||||
@@ -107,7 +107,7 @@ class ProfileController extends Controller
|
||||
$repository->unblockUser($user);
|
||||
|
||||
// return to log in.
|
||||
session()->flash('success', (string)trans('firefly.login_with_new_email'));
|
||||
session()->flash('success', (string) trans('firefly.login_with_new_email'));
|
||||
|
||||
return redirect(route('login'));
|
||||
}
|
||||
@@ -123,7 +123,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'));
|
||||
@@ -171,7 +171,7 @@ class ProfileController extends Controller
|
||||
public function logoutOtherSessions(): Factory|RedirectResponse|View
|
||||
{
|
||||
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'));
|
||||
}
|
||||
@@ -195,7 +195,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();
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class ProfileController extends Controller
|
||||
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
|
||||
return redirect(route('index'));
|
||||
}
|
||||
@@ -218,7 +218,7 @@ class ProfileController extends Controller
|
||||
// force user logout.
|
||||
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
|
||||
$request->session()->invalidate();
|
||||
session()->flash('success', (string)trans('firefly.email_changed'));
|
||||
session()->flash('success', (string) trans('firefly.email_changed'));
|
||||
|
||||
return redirect(route('index'));
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class ProfileController extends Controller
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$email = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_email');
|
||||
$subTitle = (string) trans('firefly.change_your_email');
|
||||
$subTitleIcon = 'fa-envelope';
|
||||
|
||||
return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email'));
|
||||
@@ -271,7 +271,7 @@ 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'));
|
||||
}
|
||||
@@ -290,7 +290,7 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
$title = auth()->user()->email;
|
||||
$subTitle = (string)trans('firefly.change_your_password');
|
||||
$subTitle = (string) trans('firefly.change_your_password');
|
||||
$subTitleIcon = 'fa-key';
|
||||
|
||||
return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon'));
|
||||
@@ -310,7 +310,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'));
|
||||
}
|
||||
@@ -334,7 +334,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'));
|
||||
}
|
||||
@@ -344,11 +344,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'));
|
||||
}
|
||||
@@ -372,7 +372,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'));
|
||||
}
|
||||
@@ -410,7 +410,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;
|
||||
|
||||
@@ -426,7 +426,7 @@ class ProfileController extends Controller
|
||||
$repository->unblockUser($user);
|
||||
|
||||
// return to login page.
|
||||
session()->flash('success', (string)trans('firefly.login_with_old_email'));
|
||||
session()->flash('success', (string) trans('firefly.login_with_old_email'));
|
||||
|
||||
return redirect(route('login'));
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ class CreateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
@@ -95,22 +95,22 @@ class CreateController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurring.create.fromStore');
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
$hasOldInput = null !== $request->old('_token'); // flash some data
|
||||
$preFilled = [
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : true,
|
||||
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : true,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,
|
||||
];
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
@@ -140,15 +140,15 @@ class CreateController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurring.create.fromStore');
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
|
||||
// fill prefilled with journal info
|
||||
@@ -181,8 +181,8 @@ class CreateController extends Controller
|
||||
'category' => $request->old('category'),
|
||||
'budget_id' => $request->old('budget_id'),
|
||||
'bill_id' => $request->old('bill_id'),
|
||||
'active' => (bool)$request->old('active'),
|
||||
'apply_rules' => (bool)$request->old('apply_rules'),
|
||||
'active' => (bool) $request->old('active'),
|
||||
'apply_rules' => (bool) $request->old('apply_rules'),
|
||||
];
|
||||
}
|
||||
if (false === $hasOldInput) {
|
||||
@@ -234,7 +234,7 @@ class CreateController extends Controller
|
||||
}
|
||||
Log::channel('audit')->info('Stored new recurrence.', $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -245,7 +245,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -253,7 +253,7 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('recurring.create.url'));
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('recurring.create.fromStore', true);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -68,7 +68,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(Recurrence $recurrence)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_recurring', ['title' => $recurrence->title]);
|
||||
$subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]);
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('recurrences.delete.url');
|
||||
|
||||
@@ -85,7 +85,7 @@ class DeleteController extends Controller
|
||||
public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence)
|
||||
{
|
||||
$repository->destroy($recurrence);
|
||||
$request->session()->flash('success', (string)trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('recurrences.delete.url'));
|
||||
|
||||
@@ -63,8 +63,8 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
@@ -114,9 +114,9 @@ class EditController extends Controller
|
||||
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
if (null !== $recurrence->repeat_until) {
|
||||
$repetitionEnd = 'until_date';
|
||||
@@ -126,22 +126,22 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'transaction_type' => strtolower($recurrence->transactionType->type),
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
||||
'deposit_source_id' => $array['transactions'][0]['source_id'],
|
||||
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
|
||||
];
|
||||
$array['first_date'] = substr((string)$array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);
|
||||
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
|
||||
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
||||
|
||||
return view(
|
||||
@@ -172,7 +172,7 @@ class EditController extends Controller
|
||||
$data = $request->getAll();
|
||||
$this->recurring->update($recurrence, $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||
Log::channel('audit')->info(sprintf('Updated recurrence #%d.', $recurrence->id), $data);
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -183,7 +183,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -191,7 +191,7 @@ class EditController extends Controller
|
||||
}
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('recurrences.edit.fromUpdate', true);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -75,8 +75,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->recurringRepos->get();
|
||||
$today = today(config('app.timezone'));
|
||||
$year = today(config('app.timezone'));
|
||||
|
||||
@@ -60,7 +60,7 @@ class ShowController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -125,7 +125,7 @@ class ShowController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$subTitle = (string)trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
||||
$subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
||||
|
||||
return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today'));
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ class TriggerController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
if (0 === $groups->count()) {
|
||||
$request->session()->flash('info', (string)trans('firefly.no_new_transaction_in_recurrence'));
|
||||
$request->session()->flash('info', (string) trans('firefly.no_new_transaction_in_recurrence'));
|
||||
}
|
||||
if (1 === $groups->count()) {
|
||||
$first = $groups->first();
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_journal_no_descr'));
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_journal_no_descr'));
|
||||
$request->session()->flash('success_url', route('transactions.show', [$first->id]));
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ class BudgetController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ class BudgetController extends Controller
|
||||
$total = $sums[$currencyId]['sum'] ?? '0';
|
||||
$pct = '0';
|
||||
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
||||
$pct = round((float)bcmul(bcdiv($sum, $total), '100')); // intentional float
|
||||
$pct = round((float) bcmul(bcdiv($sum, $total), '100')); // intentional float
|
||||
}
|
||||
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ class BudgetController extends Controller
|
||||
$report[$key]['entries'][$dateKey] ??= '0';
|
||||
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key]['entries'][$dateKey]);
|
||||
$report[$key]['sum'] = bcadd($report[$key]['sum'], $journal['amount']);
|
||||
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods));
|
||||
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string) count($periods));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ class BudgetController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'], // intentional float
|
||||
'amount_float' => (float) $journal['amount'], // intentional float
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
|
||||
@@ -283,8 +283,8 @@ class CategoryController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,8 +333,8 @@ class CategoryController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -664,7 +664,7 @@ class CategoryController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
@@ -712,7 +712,7 @@ class CategoryController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
|
||||
@@ -91,8 +91,8 @@ class DoubleController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
@@ -141,8 +141,8 @@ class DoubleController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
// sort by amount_float
|
||||
@@ -407,7 +407,7 @@ class DoubleController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
@@ -455,7 +455,7 @@ class DoubleController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
|
||||
@@ -280,8 +280,8 @@ class TagController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,8 +330,8 @@ class TagController extends Controller
|
||||
];
|
||||
++$result[$key]['transactions'];
|
||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,7 +467,7 @@ class TagController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'],
|
||||
'amount_float' => (float) $journal['amount'],
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
@@ -515,7 +515,7 @@ class TagController extends Controller
|
||||
$result[] = [
|
||||
'description' => $journal['description'],
|
||||
'transaction_group_id' => $journal['transaction_group_id'],
|
||||
'amount_float' => (float)$journal['amount'], // intentional float.
|
||||
'amount_float' => (float) $journal['amount'], // intentional float.
|
||||
'amount' => $journal['amount'],
|
||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||
|
||||
@@ -59,7 +59,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);
|
||||
@@ -80,7 +80,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();
|
||||
|
||||
@@ -111,7 +111,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();
|
||||
|
||||
@@ -143,7 +143,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();
|
||||
|
||||
@@ -175,7 +175,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();
|
||||
@@ -250,8 +250,8 @@ class ReportController extends Controller
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$type = $account->accountType->type;
|
||||
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
|
||||
$type = $account->accountType->type;
|
||||
$role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));
|
||||
|
||||
if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {
|
||||
$role = sprintf('opt_group_l_%s', $type);
|
||||
@@ -260,7 +260,7 @@ class ReportController extends Controller
|
||||
if ('opt_group_' === $role) {
|
||||
$role = 'opt_group_defaultAsset';
|
||||
}
|
||||
$groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account;
|
||||
$groupedAccounts[(string) trans(sprintf('firefly.%s', $role))][$account->id] = $account;
|
||||
}
|
||||
ksort($groupedAccounts);
|
||||
|
||||
@@ -309,37 +309,37 @@ class ReportController extends Controller
|
||||
|
||||
if (0 === $request->getAccountList()->count()) {
|
||||
app('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) {
|
||||
@@ -364,7 +364,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();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -87,7 +87,7 @@ class CreateController extends Controller
|
||||
$oldActions = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string)$request->get('from_query');
|
||||
$query = (string) $request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
@@ -115,9 +115,9 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether or not there is a rule group:
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
if (null !== $ruleGroup) {
|
||||
$subTitle = (string)trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
$subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||
}
|
||||
|
||||
// flash old data
|
||||
@@ -144,13 +144,13 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function createFromBill(Request $request, Bill $bill)
|
||||
{
|
||||
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
|
||||
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));
|
||||
|
||||
$this->createDefaultRuleGroup();
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
|
||||
'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||
'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),
|
||||
'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||
];
|
||||
|
||||
// make triggers and actions from the bill itself.
|
||||
@@ -170,7 +170,7 @@ class CreateController extends Controller
|
||||
$subTitleIcon = 'fa-clone';
|
||||
|
||||
// title depends on whether there is a rule group:
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// flash old data
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
@@ -194,10 +194,10 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
||||
{
|
||||
$request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
|
||||
$request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));
|
||||
|
||||
$subTitleIcon = 'fa-clone';
|
||||
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
||||
|
||||
// get triggers and actions for journal.
|
||||
$oldTriggers = $this->getTriggersForJournal($journal);
|
||||
@@ -208,8 +208,8 @@ class CreateController extends Controller
|
||||
// collect pre-filled information:
|
||||
$preFilled = [
|
||||
'strict' => true,
|
||||
'title' => (string)trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
|
||||
'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||
'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),
|
||||
'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||
];
|
||||
|
||||
// restore actions and triggers from old input:
|
||||
@@ -238,7 +238,7 @@ class CreateController extends Controller
|
||||
|
||||
public function duplicate(Request $request): JsonResponse
|
||||
{
|
||||
$ruleId = (int)$request->get('id');
|
||||
$ruleId = (int) $request->get('id');
|
||||
$rule = $this->ruleRepos->find($ruleId);
|
||||
if (null !== $rule) {
|
||||
$this->ruleRepos->duplicate($rule);
|
||||
@@ -257,22 +257,22 @@ class CreateController extends Controller
|
||||
$data = $request->getRuleData();
|
||||
|
||||
$rule = $this->ruleRepos->store($data);
|
||||
session()->flash('success', (string)trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// redirect to show bill.
|
||||
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
|
||||
return redirect(route('bills.show', [(int)$request->get('bill_id')]));
|
||||
if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {
|
||||
return redirect(route('bills.show', [(int) $request->get('bill_id')]));
|
||||
}
|
||||
|
||||
// redirect to new bill creation.
|
||||
if ((int)$request->get('bill_id') > 0) {
|
||||
if ((int) $request->get('bill_id') > 0) {
|
||||
return redirect($this->getPreviousUrl('bills.create.url'));
|
||||
}
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('rules.create.url'));
|
||||
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
session()->put('rules.create.fromStore', true);
|
||||
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -65,7 +65,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(Rule $rule)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_rule', ['title' => $rule->title]);
|
||||
$subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('rules.delete.url');
|
||||
@@ -81,7 +81,7 @@ class DeleteController extends Controller
|
||||
$title = $rule->title;
|
||||
$this->ruleRepos->destroy($rule);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_rule', ['title' => $title]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_rule', ['title' => $title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('rules.delete.url'));
|
||||
|
||||
@@ -58,7 +58,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -83,7 +83,7 @@ class EditController extends Controller
|
||||
$oldTriggers = [];
|
||||
|
||||
// build triggers from query, if present.
|
||||
$query = (string)$request->get('from_query');
|
||||
$query = (string) $request->get('from_query');
|
||||
if ('' !== $query) {
|
||||
$search = app(SearchInterface::class);
|
||||
$search->parseQuery($query);
|
||||
@@ -113,14 +113,14 @@ class EditController extends Controller
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,
|
||||
'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,
|
||||
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,
|
||||
];
|
||||
|
||||
// get rule trigger for update / store-journal:
|
||||
$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);
|
||||
$subTitle = (string)trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
$subTitle = (string) trans('firefly.edit_rule', ['title' => $rule->title]);
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('rules.edit.fromUpdate')) {
|
||||
@@ -144,7 +144,7 @@ class EditController extends Controller
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
$triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
@@ -186,10 +186,10 @@ class EditController extends Controller
|
||||
|
||||
$this->ruleRepos->update($rule, $data);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('rules.edit.url'));
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
session()->put('rules.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -53,7 +53,7 @@ class IndexController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||
@@ -79,7 +79,7 @@ class IndexController extends Controller
|
||||
|
||||
public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse
|
||||
{
|
||||
$order = (int)$request->get('order');
|
||||
$order = (int) $request->get('order');
|
||||
$this->ruleRepos->moveRule($rule, $ruleGroup, $order);
|
||||
|
||||
return response()->json([]);
|
||||
|
||||
@@ -56,7 +56,7 @@ class SelectController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
static function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
return $next($request);
|
||||
@@ -108,7 +108,7 @@ class SelectController extends Controller
|
||||
// does the user have shared accounts?
|
||||
$first = session('first', today(config('app.timezone'))->subYear())->format('Y-m-d');
|
||||
$today = today(config('app.timezone'))->format('Y-m-d');
|
||||
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||
$subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||
|
||||
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class SelectController extends Controller
|
||||
|
||||
// warn if nothing.
|
||||
if (0 === count($textTriggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
|
||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
|
||||
foreach ($textTriggers as $textTrigger) {
|
||||
@@ -166,7 +166,7 @@ class SelectController extends Controller
|
||||
// Warn the user if only a subset of transactions is returned
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
@@ -196,7 +196,7 @@ class SelectController extends Controller
|
||||
$triggers = $rule->ruleTriggers;
|
||||
|
||||
if (0 === count($triggers)) {
|
||||
return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);
|
||||
return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);
|
||||
}
|
||||
// create new rule engine:
|
||||
$newRuleEngine = app(RuleEngineInterface::class);
|
||||
@@ -208,7 +208,7 @@ class SelectController extends Controller
|
||||
|
||||
$warning = '';
|
||||
if (0 === count($collection)) {
|
||||
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
||||
}
|
||||
|
||||
// Return json response
|
||||
|
||||
@@ -49,7 +49,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||
@@ -67,7 +67,7 @@ class CreateController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$subTitleIcon = 'fa-clone';
|
||||
$subTitle = (string)trans('firefly.make_new_rule_group');
|
||||
$subTitle = (string) trans('firefly.make_new_rule_group');
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('rule-groups.create.fromStore')) {
|
||||
@@ -88,11 +88,11 @@ class CreateController extends Controller
|
||||
$data = $request->getRuleGroupData();
|
||||
$ruleGroup = $this->repository->store($data);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
|
||||
session()->flash('success', (string) trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('rule-groups.create.url'));
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
session()->put('rule-groups.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('rule-groups.create'))->withInput();
|
||||
|
||||
@@ -50,7 +50,7 @@ class DeleteController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||
@@ -67,7 +67,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(RuleGroup $ruleGroup)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
|
||||
$subTitle = (string) trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('rule-groups.delete.url');
|
||||
@@ -85,10 +85,10 @@ class DeleteController extends Controller
|
||||
$title = $ruleGroup->title;
|
||||
|
||||
/** @var RuleGroup $moveTo */
|
||||
$moveTo = $this->repository->find((int)$request->get('move_rules_before_delete'));
|
||||
$moveTo = $this->repository->find((int) $request->get('move_rules_before_delete'));
|
||||
$this->repository->destroy($ruleGroup, $moveTo);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_rule_group', ['title' => $title]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_rule_group', ['title' => $title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('rule-groups.delete.url'));
|
||||
|
||||
@@ -51,7 +51,7 @@ class EditController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||
@@ -68,11 +68,11 @@ class EditController extends Controller
|
||||
*/
|
||||
public function edit(Request $request, RuleGroup $ruleGroup)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
|
||||
$subTitle = (string) trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : $ruleGroup->active,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $ruleGroup->active,
|
||||
];
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('rule-groups.edit.fromUpdate')) {
|
||||
@@ -89,7 +89,7 @@ class EditController extends Controller
|
||||
*/
|
||||
public function moveGroup(Request $request): JsonResponse
|
||||
{
|
||||
$groupId = (int)$request->get('id');
|
||||
$groupId = (int) $request->get('id');
|
||||
$ruleGroup = $this->repository->find($groupId);
|
||||
if (null !== $ruleGroup) {
|
||||
$direction = $request->get('direction');
|
||||
@@ -123,15 +123,15 @@ class EditController extends Controller
|
||||
$data = [
|
||||
'title' => $request->convertString('title'),
|
||||
'description' => $request->stringWithNewlines('description'),
|
||||
'active' => 1 === (int)$request->input('active'),
|
||||
'active' => 1 === (int) $request->input('active'),
|
||||
];
|
||||
|
||||
$this->repository->update($ruleGroup, $data);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
|
||||
session()->flash('success', (string) trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('rule-groups.edit.url'));
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
session()->put('rule-groups.edit.fromUpdate', true);
|
||||
|
||||
$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);
|
||||
|
||||
@@ -51,7 +51,7 @@ class ExecutionController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.rules'));
|
||||
app('view')->share('title', (string) trans('firefly.rules'));
|
||||
app('view')->share('mainTitleIcon', 'fa-random');
|
||||
|
||||
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
|
||||
@@ -89,7 +89,7 @@ class ExecutionController extends Controller
|
||||
$newRuleEngine->fire();
|
||||
|
||||
// Tell the user that the job is queued
|
||||
session()->flash('success', (string)trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));
|
||||
session()->flash('success', (string) trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));
|
||||
|
||||
return redirect()->route('rules.index');
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class ExecutionController extends Controller
|
||||
{
|
||||
$first = session('first')->format('Y-m-d');
|
||||
$today = today(config('app.timezone'))->format('Y-m-d');
|
||||
$subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
|
||||
$subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
|
||||
|
||||
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,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);
|
||||
}
|
||||
@@ -65,9 +65,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.
|
||||
@@ -86,7 +86,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'));
|
||||
}
|
||||
@@ -102,8 +102,8 @@ class SearchController extends Controller
|
||||
if (!is_scalar($entry)) {
|
||||
$entry = '';
|
||||
}
|
||||
$fullQuery = (string)$entry;
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$fullQuery = (string) $entry;
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
|
||||
$searcher->parseQuery($fullQuery);
|
||||
|
||||
|
||||
@@ -80,17 +80,17 @@ class InstallController extends Controller
|
||||
{
|
||||
app('view')->share('FF_VERSION', config('firefly.version'));
|
||||
// index will set FF3 version.
|
||||
app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));
|
||||
app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));
|
||||
|
||||
// set new DB version.
|
||||
app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));
|
||||
app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));
|
||||
|
||||
return view('install.index');
|
||||
}
|
||||
|
||||
public function runCommand(Request $request): JsonResponse
|
||||
{
|
||||
$requestIndex = (int)$request->get('index');
|
||||
$requestIndex = (int) $request->get('index');
|
||||
$response = [
|
||||
'hasNextCommand' => false,
|
||||
'done' => true,
|
||||
@@ -171,7 +171,7 @@ class InstallController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
file_put_contents($publicKey, (string)$key->getPublicKey());
|
||||
file_put_contents($publicKey, (string) $key->getPublicKey());
|
||||
file_put_contents($privateKey, $key->toString('PKCS1'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,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);
|
||||
@@ -75,7 +75,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:
|
||||
@@ -105,7 +105,7 @@ class TagController extends Controller
|
||||
*/
|
||||
public function delete(Tag $tag)
|
||||
{
|
||||
$subTitle = (string)trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('tags.delete.url');
|
||||
@@ -120,7 +120,7 @@ class TagController extends Controller
|
||||
*/
|
||||
public function edit(Tag $tag)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
$location = $this->repository->getLocation($tag);
|
||||
@@ -176,13 +176,13 @@ 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);
|
||||
@@ -202,7 +202,7 @@ class TagController extends Controller
|
||||
$tagName = $tag->tag;
|
||||
$this->repository->destroy($tag);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_tag', ['tag' => $tagName]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('tags.delete.url'));
|
||||
@@ -219,8 +219,8 @@ class TagController extends Controller
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-tag';
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$start ??= session('start');
|
||||
$end ??= session('end');
|
||||
$location = $this->repository->getLocation($tag);
|
||||
@@ -262,10 +262,10 @@ class TagController extends Controller
|
||||
{
|
||||
// default values:
|
||||
$subTitleIcon = 'fa-tag';
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$periods = [];
|
||||
$subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
|
||||
$start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone'));
|
||||
$end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone'));
|
||||
$attachments = $this->repository->getAttachments($tag);
|
||||
@@ -295,7 +295,7 @@ class TagController extends Controller
|
||||
$result = $this->repository->store($data);
|
||||
app('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):
|
||||
@@ -306,7 +306,7 @@ class TagController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -316,7 +316,7 @@ class TagController extends Controller
|
||||
$request->session()->flash('error', $this->attachmentsHelper->getErrors()->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();
|
||||
@@ -333,7 +333,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):
|
||||
@@ -344,7 +344,7 @@ class TagController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
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) {
|
||||
@@ -354,7 +354,7 @@ class TagController extends Controller
|
||||
$request->session()->flash('error', $this->attachmentsHelper->getErrors()->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]);
|
||||
|
||||
@@ -55,7 +55,7 @@ class BulkController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
return $next($request);
|
||||
@@ -72,7 +72,7 @@ class BulkController extends Controller
|
||||
*/
|
||||
public function edit(array $journals)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.mass_bulk_journals');
|
||||
$subTitle = (string) trans('firefly.mass_bulk_journals');
|
||||
|
||||
$this->rememberPreviousUrl('transactions.bulk-edit.url');
|
||||
|
||||
@@ -95,14 +95,14 @@ class BulkController extends Controller
|
||||
{
|
||||
$journalIds = $request->get('journals');
|
||||
$journalIds = is_array($journalIds) ? $journalIds : [];
|
||||
$ignoreCategory = 1 === (int)$request->get('ignore_category');
|
||||
$ignoreBudget = 1 === (int)$request->get('ignore_budget');
|
||||
$ignoreCategory = 1 === (int) $request->get('ignore_category');
|
||||
$ignoreBudget = 1 === (int) $request->get('ignore_budget');
|
||||
$tagsAction = $request->get('tags_action');
|
||||
$collection = new Collection();
|
||||
$count = 0;
|
||||
|
||||
foreach ($journalIds as $journalId) {
|
||||
$journalId = (int)$journalId;
|
||||
$journalId = (int) $journalId;
|
||||
$journal = $this->repository->find($journalId);
|
||||
if (null !== $journal) {
|
||||
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
||||
|
||||
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Transaction;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Events\UpdatedTransactionGroup;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
|
||||
@@ -51,7 +51,7 @@ class CreateController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||
|
||||
@@ -62,7 +62,7 @@ class CreateController extends Controller
|
||||
|
||||
public function cloneGroup(Request $request): JsonResponse
|
||||
{
|
||||
$groupId = (int)$request->get('id');
|
||||
$groupId = (int) $request->get('id');
|
||||
if (0 !== $groupId) {
|
||||
$group = $this->repository->find($groupId);
|
||||
if (null !== $group) {
|
||||
@@ -102,14 +102,14 @@ class CreateController extends Controller
|
||||
{
|
||||
app('preferences')->mark();
|
||||
|
||||
$sourceId = (int)request()->get('source');
|
||||
$destinationId = (int)request()->get('destination');
|
||||
$sourceId = (int) request()->get('source');
|
||||
$destinationId = (int) request()->get('destination');
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$cash = $accountRepository->getCashAccount();
|
||||
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
||||
$subTitle = (string)trans(sprintf('breadcrumbs.create_%s', strtolower((string)$objectType)));
|
||||
$subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
|
||||
$subTitleIcon = 'fa-plus';
|
||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||
|
||||
@@ -54,7 +54,7 @@ class DeleteController extends Controller
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||
@@ -82,7 +82,7 @@ class DeleteController extends Controller
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||
$subTitle = (string)trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);
|
||||
$subTitle = (string) trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);
|
||||
$previous = app('steam')->getSafePreviousUrl();
|
||||
// put previous url in session
|
||||
app('log')->debug('Will try to remember previous URL');
|
||||
@@ -106,7 +106,7 @@ class DeleteController extends Controller
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||
session()->flash('success', (string)trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
||||
session()->flash('success', (string) trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
||||
|
||||
// grab asset account(s) from group:
|
||||
$accounts = [];
|
||||
|
||||
@@ -52,7 +52,7 @@ class EditController extends Controller
|
||||
// translations:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
@@ -80,7 +80,7 @@ class EditController extends Controller
|
||||
$expectedSourceTypes = config('firefly.expected_source_types');
|
||||
$allowedSourceDests = config('firefly.source_dests');
|
||||
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
|
||||
$subTitle = (string)trans('firefly.edit_transaction_title', ['description' => $title]);
|
||||
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
|
||||
$subTitleIcon = 'fa-plus';
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$cash = $repository->getCashAccount();
|
||||
|
||||
@@ -54,7 +54,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
@@ -78,8 +78,8 @@ class IndexController extends Controller
|
||||
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
|
||||
if (null === $start) {
|
||||
$start = session('start');
|
||||
@@ -94,7 +94,7 @@ class IndexController extends Controller
|
||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||
$startStr = $start->isoFormat($this->monthAndDayFormat);
|
||||
$endStr = $end->isoFormat($this->monthAndDayFormat);
|
||||
$subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
||||
$subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
||||
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||
$firstJournal = $this->repository->firstNull();
|
||||
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
|
||||
@@ -128,14 +128,14 @@ class IndexController extends Controller
|
||||
{
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$path = route('transactions.index.all', [$objectType]);
|
||||
$first = $this->repository->firstNull();
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$last = $this->repository->getLast();
|
||||
$end = null !== $last ? $last->date : today(config('app.timezone'));
|
||||
$subTitle = (string)trans('firefly.all_'.$objectType);
|
||||
$subTitle = (string) trans('firefly.all_'.$objectType);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
@@ -52,7 +52,7 @@ class LinkController extends Controller
|
||||
// some useful repositories:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
$this->journalRepository = app(JournalRepositoryInterface::class);
|
||||
@@ -71,7 +71,7 @@ class LinkController extends Controller
|
||||
public function delete(TransactionJournalLink $link)
|
||||
{
|
||||
$subTitleIcon = 'fa-link';
|
||||
$subTitle = (string)trans('breadcrumbs.delete_journal_link');
|
||||
$subTitle = (string) trans('breadcrumbs.delete_journal_link');
|
||||
$this->rememberPreviousUrl('journal_links.delete.url');
|
||||
|
||||
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
|
||||
@@ -86,10 +86,10 @@ class LinkController extends Controller
|
||||
{
|
||||
$this->repository->destroyLink($link);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_link'));
|
||||
session()->flash('success', (string) trans('firefly.deleted_link'));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect((string)session('journal_links.delete.url'));
|
||||
return redirect((string) session('journal_links.delete.url'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ class LinkController extends Controller
|
||||
app('log')->debug('We are here (store)');
|
||||
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
|
||||
if (null === $other) {
|
||||
session()->flash('error', (string)trans('firefly.invalid_link_selection'));
|
||||
session()->flash('error', (string) trans('firefly.invalid_link_selection'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
@@ -122,19 +122,19 @@ class LinkController extends Controller
|
||||
$alreadyLinked = $this->repository->findLink($journal, $other);
|
||||
|
||||
if ($other->id === $journal->id) {
|
||||
session()->flash('error', (string)trans('firefly.journals_link_to_self'));
|
||||
session()->flash('error', (string) trans('firefly.journals_link_to_self'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
|
||||
if ($alreadyLinked) {
|
||||
session()->flash('error', (string)trans('firefly.journals_error_linked'));
|
||||
session()->flash('error', (string) trans('firefly.journals_error_linked'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
app('log')->debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
|
||||
$this->repository->storeLink($linkInfo, $other, $journal);
|
||||
session()->flash('success', (string)trans('firefly.journals_linked'));
|
||||
session()->flash('success', (string) trans('firefly.journals_linked'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class LinkController extends Controller
|
||||
*/
|
||||
public function switchLink(Request $request)
|
||||
{
|
||||
$linkId = (int)$request->get('id');
|
||||
$linkId = (int) $request->get('id');
|
||||
$this->repository->switchLinkById($linkId);
|
||||
|
||||
return redirect(app('steam')->getSafePreviousUrl());
|
||||
|
||||
@@ -58,7 +58,7 @@ class MassController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
|
||||
@@ -72,7 +72,7 @@ class MassController extends Controller
|
||||
*/
|
||||
public function delete(array $journals): IlluminateView
|
||||
{
|
||||
$subTitle = (string)trans('firefly.mass_delete_journals');
|
||||
$subTitle = (string) trans('firefly.mass_delete_journals');
|
||||
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('transactions.mass-delete.url');
|
||||
@@ -98,8 +98,8 @@ class MassController extends Controller
|
||||
app('log')->debug(sprintf('Searching for ID #%d', $journalId));
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = $this->repository->find((int)$journalId);
|
||||
if (null !== $journal && (int)$journalId === $journal->id) {
|
||||
$journal = $this->repository->find((int) $journalId);
|
||||
if (null !== $journal && (int) $journalId === $journal->id) {
|
||||
$this->repository->destroyJournal($journal);
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Deleted transaction journal #%d', $journalId));
|
||||
@@ -121,7 +121,7 @@ class MassController extends Controller
|
||||
*/
|
||||
public function edit(array $journals): IlluminateView
|
||||
{
|
||||
$subTitle = (string)trans('firefly.mass_edit_journals');
|
||||
$subTitle = (string) trans('firefly.mass_edit_journals');
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
@@ -168,7 +168,7 @@ class MassController extends Controller
|
||||
|
||||
/** @var string $journalId */
|
||||
foreach ($journalIds as $journalId) {
|
||||
$integer = (int)$journalId;
|
||||
$integer = (int) $journalId;
|
||||
|
||||
try {
|
||||
$this->updateJournal($integer, $request);
|
||||
@@ -251,7 +251,7 @@ class MassController extends Controller
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)$value[$journalId];
|
||||
return (string) $value[$journalId];
|
||||
}
|
||||
|
||||
private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
|
||||
@@ -264,6 +264,6 @@ class MassController extends Controller
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int)$value[$journalId];
|
||||
return (int) $value[$journalId];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ShowController extends Controller
|
||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||
$this->aleRepository = app(ALERepositoryInterface::class);
|
||||
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||
|
||||
return $next($request);
|
||||
@@ -88,7 +88,7 @@ class ShowController extends Controller
|
||||
throw new FireflyException('This transaction is broken :(.');
|
||||
}
|
||||
|
||||
$type = (string)trans(sprintf('firefly.%s', $first->transactionType->type));
|
||||
$type = (string) trans(sprintf('firefly.%s', $first->transactionType->type));
|
||||
$title = 1 === $splits ? $first->description : $transactionGroup->title;
|
||||
$subTitle = sprintf('%s: "%s"', $type, $title);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class CreateController 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);
|
||||
@@ -74,13 +74,13 @@ class CreateController 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')) {
|
||||
@@ -117,15 +117,15 @@ class CreateController extends Controller
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::channel('audit')->warning('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();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user