mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various PSR12 code cleanup
This commit is contained in:
parent
dbf3e76ecc
commit
6cfdc58cb1
@ -50,7 +50,7 @@ class DeleteController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
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);
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(ObjectGroup $objectGroup)
|
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();
|
$piggyBanks = $objectGroup->piggyBanks()->count();
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
@ -86,7 +86,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(ObjectGroup $objectGroup): RedirectResponse
|
public function destroy(ObjectGroup $objectGroup): RedirectResponse
|
||||||
{
|
{
|
||||||
session()->flash('success', (string) trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
|
session()->flash('success', (string)trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$this->repository->destroy($objectGroup);
|
$this->repository->destroy($objectGroup);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class EditController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
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);
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class EditController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(ObjectGroup $objectGroup)
|
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';
|
$subTitleIcon = 'fa-pencil';
|
||||||
|
|
||||||
if (true !== session('object-groups.edit.fromUpdate')) {
|
if (true !== session('object-groups.edit.fromUpdate')) {
|
||||||
@ -95,12 +95,12 @@ class EditController extends Controller
|
|||||||
$data = $request->getObjectGroupData();
|
$data = $request->getObjectGroupData();
|
||||||
$piggyBank = $this->repository->update($objectGroup, $data);
|
$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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUrl('object-groups.edit.url'));
|
$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);
|
session()->put('object-groups.edit.fromUpdate', true);
|
||||||
|
|
||||||
$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));
|
$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));
|
||||||
|
@ -53,7 +53,7 @@ class IndexController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-envelope-o');
|
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);
|
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -68,7 +68,7 @@ class IndexController extends Controller
|
|||||||
{
|
{
|
||||||
$this->repository->deleteEmpty();
|
$this->repository->deleteEmpty();
|
||||||
$this->repository->resetOrder();
|
$this->repository->resetOrder();
|
||||||
$subTitle = (string) trans('firefly.object_groups_index');
|
$subTitle = (string)trans('firefly.object_groups_index');
|
||||||
$objectGroups = $this->repository->get();
|
$objectGroups = $this->repository->get();
|
||||||
|
|
||||||
return view('object-groups.index', compact('subTitle', 'objectGroups'));
|
return view('object-groups.index', compact('subTitle', 'objectGroups'));
|
||||||
@ -83,7 +83,7 @@ class IndexController extends Controller
|
|||||||
public function setOrder(Request $request, ObjectGroup $objectGroup)
|
public function setOrder(Request $request, ObjectGroup $objectGroup)
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title));
|
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);
|
$this->repository->setOrder($objectGroup, $newOrder);
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
|
@ -54,7 +54,7 @@ class AmountController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||||
|
|
||||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
@ -130,7 +130,7 @@ class AmountController extends Controller
|
|||||||
$this->piggyRepos->addAmount($piggyBank, $amount);
|
$this->piggyRepos->addAmount($piggyBank, $amount);
|
||||||
session()->flash(
|
session()->flash(
|
||||||
'success',
|
'success',
|
||||||
(string) trans(
|
(string)trans(
|
||||||
'firefly.added_amount_to_piggy',
|
'firefly.added_amount_to_piggy',
|
||||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
||||||
)
|
)
|
||||||
@ -140,10 +140,10 @@ class AmountController extends Controller
|
|||||||
return redirect(route('piggy-banks.index'));
|
return redirect(route('piggy-banks.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::error('Cannot add ' . $amount . ' because canAddAmount returned false.');
|
Log::error('Cannot add '.$amount.' because canAddAmount returned false.');
|
||||||
session()->flash(
|
session()->flash(
|
||||||
'error',
|
'error',
|
||||||
(string) trans(
|
(string)trans(
|
||||||
'firefly.cannot_add_amount_piggy',
|
'firefly.cannot_add_amount_piggy',
|
||||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
||||||
)
|
)
|
||||||
@ -172,7 +172,7 @@ class AmountController extends Controller
|
|||||||
$this->piggyRepos->removeAmount($piggyBank, $amount);
|
$this->piggyRepos->removeAmount($piggyBank, $amount);
|
||||||
session()->flash(
|
session()->flash(
|
||||||
'success',
|
'success',
|
||||||
(string) trans(
|
(string)trans(
|
||||||
'firefly.removed_amount_from_piggy',
|
'firefly.removed_amount_from_piggy',
|
||||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => $piggyBank->name]
|
||||||
)
|
)
|
||||||
@ -181,11 +181,11 @@ class AmountController extends Controller
|
|||||||
|
|
||||||
return redirect(route('piggy-banks.index'));
|
return redirect(route('piggy-banks.index'));
|
||||||
}
|
}
|
||||||
$amount = (string) $request->get('amount');
|
$amount = (string)$request->get('amount');
|
||||||
|
|
||||||
session()->flash(
|
session()->flash(
|
||||||
'error',
|
'error',
|
||||||
(string) trans(
|
(string)trans(
|
||||||
'firefly.cannot_remove_from_piggy',
|
'firefly.cannot_remove_from_piggy',
|
||||||
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
['amount' => app('amount')->formatAnything($currency, $amount, false), 'name' => e($piggyBank->name)]
|
||||||
)
|
)
|
||||||
|
@ -53,7 +53,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||||
|
|
||||||
$this->attachments = app(AttachmentHelperInterface::class);
|
$this->attachments = app(AttachmentHelperInterface::class);
|
||||||
@ -71,7 +71,7 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.new_piggy_bank');
|
$subTitle = (string)trans('firefly.new_piggy_bank');
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "create another").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
@ -99,7 +99,7 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$piggyBank = $this->piggyRepos->store($data);
|
$piggyBank = $this->piggyRepos->store($data);
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
session()->flash('success', (string)trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
// store attachment(s):
|
// store attachment(s):
|
||||||
@ -109,7 +109,7 @@ class CreateController extends Controller
|
|||||||
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
$this->attachments->saveAttachmentsForModel($piggyBank, $files);
|
||||||
}
|
}
|
||||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
@ -117,7 +117,7 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$redirect = redirect($this->getPreviousUrl('piggy-banks.create.url'));
|
$redirect = redirect($this->getPreviousUrl('piggy-banks.create.url'));
|
||||||
|
|
||||||
if (1 === (int) $request->get('create_another')) {
|
if (1 === (int)$request->get('create_another')) {
|
||||||
session()->put('piggy-banks.create.fromStore', true);
|
session()->put('piggy-banks.create.fromStore', true);
|
||||||
|
|
||||||
$redirect = redirect(route('piggy-banks.create'))->withInput();
|
$redirect = redirect(route('piggy-banks.create'))->withInput();
|
||||||
|
@ -49,7 +49,7 @@ class DeleteController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||||
|
|
||||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
@ -68,7 +68,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(PiggyBank $piggyBank)
|
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
|
// put previous url in session
|
||||||
$this->rememberPreviousUrl('piggy-banks.delete.url');
|
$this->rememberPreviousUrl('piggy-banks.delete.url');
|
||||||
@ -85,7 +85,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(PiggyBank $piggyBank): RedirectResponse
|
public function destroy(PiggyBank $piggyBank): RedirectResponse
|
||||||
{
|
{
|
||||||
session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$this->piggyRepos->destroy($piggyBank);
|
$this->piggyRepos->destroy($piggyBank);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\PiggyBank;
|
namespace FireflyIII\Http\Controllers\PiggyBank;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
||||||
@ -35,6 +36,7 @@ use Illuminate\Contracts\View\Factory;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use JsonException;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +59,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||||
|
|
||||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
@ -75,8 +77,8 @@ class IndexController extends Controller
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
* @throws \FireflyIII\Exceptions\FireflyException
|
* @throws FireflyException
|
||||||
* @throws \JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
@ -104,7 +106,7 @@ class IndexController extends Controller
|
|||||||
/** @var PiggyBank $piggy */
|
/** @var PiggyBank $piggy */
|
||||||
foreach ($collection as $piggy) {
|
foreach ($collection as $piggy) {
|
||||||
$array = $transformer->transform($piggy);
|
$array = $transformer->transform($piggy);
|
||||||
$groupOrder = (int) $array['object_group_order'];
|
$groupOrder = (int)$array['object_group_order'];
|
||||||
// make group array if necessary:
|
// make group array if necessary:
|
||||||
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [
|
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [
|
||||||
'object_group_id' => $array['object_group_id'] ?? 0,
|
'object_group_id' => $array['object_group_id'] ?? 0,
|
||||||
@ -113,7 +115,7 @@ class IndexController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
$account = $accountTransformer->transform($piggy->account);
|
$account = $accountTransformer->transform($piggy->account);
|
||||||
$accountId = (int) $account['id'];
|
$accountId = (int)$account['id'];
|
||||||
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
|
$array['attachments'] = $this->piggyRepos->getAttachments($piggy);
|
||||||
if (!array_key_exists($accountId, $accounts)) {
|
if (!array_key_exists($accountId, $accounts)) {
|
||||||
// create new:
|
// create new:
|
||||||
@ -168,10 +170,10 @@ class IndexController extends Controller
|
|||||||
// current_amount
|
// current_amount
|
||||||
// left_to_save
|
// left_to_save
|
||||||
// save_per_month
|
// save_per_month
|
||||||
$sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);
|
$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]['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]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string)$piggy['left_to_save']);
|
||||||
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);
|
$sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string)$piggy['save_per_month']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($piggyBanks as $groupOrder => $group) {
|
foreach ($piggyBanks as $groupOrder => $group) {
|
||||||
@ -192,8 +194,8 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
||||||
{
|
{
|
||||||
$objectGroupTitle = (string) $request->get('objectGroupTitle');
|
$objectGroupTitle = (string)$request->get('objectGroupTitle');
|
||||||
$newOrder = (int) $request->get('order');
|
$newOrder = (int)$request->get('order');
|
||||||
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
||||||
if ('' !== $objectGroupTitle) {
|
if ('' !== $objectGroupTitle) {
|
||||||
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
||||||
|
@ -51,7 +51,7 @@ class ShowController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||||
|
|
||||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReportController.php
|
* ReportController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -63,8 +63,8 @@ class CreateController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));
|
||||||
|
|
||||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||||
@ -98,22 +98,22 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$request->session()->forget('recurring.create.fromStore');
|
$request->session()->forget('recurring.create.fromStore');
|
||||||
$repetitionEnds = [
|
$repetitionEnds = [
|
||||||
'forever' => (string) trans('firefly.repeat_forever'),
|
'forever' => (string)trans('firefly.repeat_forever'),
|
||||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||||
'times' => (string) trans('firefly.repeat_times'),
|
'times' => (string)trans('firefly.repeat_times'),
|
||||||
];
|
];
|
||||||
$weekendResponses = [
|
$weekendResponses = [
|
||||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||||
];
|
];
|
||||||
$hasOldInput = null !== $request->old('_token'); // flash some data
|
$hasOldInput = null !== $request->old('_token'); // flash some data
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'first_date' => $tomorrow->format('Y-m-d'),
|
'first_date' => $tomorrow->format('Y-m-d'),
|
||||||
'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
|
'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
|
||||||
'active' => $hasOldInput ? (bool) $request->old('active') : true,
|
'active' => $hasOldInput ? (bool)$request->old('active') : true,
|
||||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,
|
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,
|
||||||
];
|
];
|
||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
|
|
||||||
@ -144,15 +144,15 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
$request->session()->forget('recurring.create.fromStore');
|
$request->session()->forget('recurring.create.fromStore');
|
||||||
$repetitionEnds = [
|
$repetitionEnds = [
|
||||||
'forever' => (string) trans('firefly.repeat_forever'),
|
'forever' => (string)trans('firefly.repeat_forever'),
|
||||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||||
'times' => (string) trans('firefly.repeat_times'),
|
'times' => (string)trans('firefly.repeat_times'),
|
||||||
];
|
];
|
||||||
$weekendResponses = [
|
$weekendResponses = [
|
||||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -185,8 +185,8 @@ class CreateController extends Controller
|
|||||||
'category' => $request->old('category'),
|
'category' => $request->old('category'),
|
||||||
'budget_id' => $request->old('budget_id'),
|
'budget_id' => $request->old('budget_id'),
|
||||||
'bill_id' => $request->old('bill_id'),
|
'bill_id' => $request->old('bill_id'),
|
||||||
'active' => (bool) $request->old('active'),
|
'active' => (bool)$request->old('active'),
|
||||||
'apply_rules' => (bool) $request->old('apply_rules'),
|
'apply_rules' => (bool)$request->old('apply_rules'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (false === $hasOldInput) {
|
if (false === $hasOldInput) {
|
||||||
@ -237,7 +237,7 @@ class CreateController extends Controller
|
|||||||
return redirect(route('recurring.create'))->withInput();
|
return redirect(route('recurring.create'))->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
$request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
// store attachment(s):
|
// store attachment(s):
|
||||||
@ -247,7 +247,7 @@ class CreateController extends Controller
|
|||||||
$this->attachments->saveAttachmentsForModel($recurrence, $files);
|
$this->attachments->saveAttachmentsForModel($recurrence, $files);
|
||||||
}
|
}
|
||||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
@ -255,7 +255,7 @@ class CreateController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUrl('recurring.create.url'));
|
$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:
|
// set value so create routine will not overwrite URL:
|
||||||
$request->session()->put('recurring.create.fromStore', true);
|
$request->session()->put('recurring.create.fromStore', true);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class DeleteController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
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);
|
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(Recurrence $recurrence)
|
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
|
// put previous url in session
|
||||||
$this->rememberPreviousUrl('recurrences.delete.url');
|
$this->rememberPreviousUrl('recurrences.delete.url');
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class DeleteController extends Controller
|
|||||||
public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence)
|
public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence)
|
||||||
{
|
{
|
||||||
$repository->destroy($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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return redirect($this->getPreviousUrl('recurrences.delete.url'));
|
return redirect($this->getPreviousUrl('recurrences.delete.url'));
|
||||||
|
@ -64,8 +64,8 @@ class EditController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
app('view')->share('subTitle', (string)trans('firefly.recurrences'));
|
||||||
|
|
||||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||||
@ -107,7 +107,7 @@ class EditController extends Controller
|
|||||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||||
$currentRepType = $repetition->repetition_type;
|
$currentRepType = $repetition->repetition_type;
|
||||||
if ('' !== $repetition->repetition_moment) {
|
if ('' !== $repetition->repetition_moment) {
|
||||||
$currentRepType .= ',' . $repetition->repetition_moment;
|
$currentRepType .= ','.$repetition->repetition_moment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||||
@ -118,9 +118,9 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$repetitionEnd = 'forever';
|
$repetitionEnd = 'forever';
|
||||||
$repetitionEnds = [
|
$repetitionEnds = [
|
||||||
'forever' => (string) trans('firefly.repeat_forever'),
|
'forever' => (string)trans('firefly.repeat_forever'),
|
||||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||||
'times' => (string) trans('firefly.repeat_times'),
|
'times' => (string)trans('firefly.repeat_times'),
|
||||||
];
|
];
|
||||||
if (null !== $recurrence->repeat_until) {
|
if (null !== $recurrence->repeat_until) {
|
||||||
$repetitionEnd = 'until_date';
|
$repetitionEnd = 'until_date';
|
||||||
@ -130,22 +130,22 @@ class EditController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$weekendResponses = [
|
$weekendResponses = [
|
||||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'transaction_type' => strtolower($recurrence->transactionType->type),
|
'transaction_type' => strtolower($recurrence->transactionType->type),
|
||||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,
|
||||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,
|
||||||
'deposit_source_id' => $array['transactions'][0]['source_id'],
|
'deposit_source_id' => $array['transactions'][0]['source_id'],
|
||||||
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
|
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
|
||||||
];
|
];
|
||||||
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
|
$array['first_date'] = substr((string)$array['first_date'], 0, 10);
|
||||||
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
|
$array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);
|
||||||
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
@ -178,7 +178,7 @@ class EditController extends Controller
|
|||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$this->recurring->update($recurrence, $data);
|
$this->recurring->update($recurrence, $data);
|
||||||
|
|
||||||
$request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
$request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||||
|
|
||||||
// store new attachment(s):
|
// store new attachment(s):
|
||||||
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
$files = $request->hasFile('attachments') ? $request->file('attachments') : null;
|
||||||
@ -186,7 +186,7 @@ class EditController extends Controller
|
|||||||
$this->attachments->saveAttachmentsForModel($recurrence, $files);
|
$this->attachments->saveAttachmentsForModel($recurrence, $files);
|
||||||
}
|
}
|
||||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||||
@ -194,7 +194,7 @@ class EditController extends Controller
|
|||||||
}
|
}
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
|
$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:
|
// set value so edit routine will not overwrite URL:
|
||||||
$request->session()->put('recurrences.edit.fromUpdate', true);
|
$request->session()->put('recurrences.edit.fromUpdate', true);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexController.php
|
* IndexController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -33,6 +34,8 @@ use Illuminate\Contracts\View\Factory;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +61,7 @@ class IndexController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
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);
|
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||||
|
|
||||||
@ -75,13 +78,13 @@ class IndexController extends Controller
|
|||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||||
$collection = $this->recurringRepos->get();
|
$collection = $this->recurringRepos->get();
|
||||||
$today = today(config('app.timezone'));
|
$today = today(config('app.timezone'));
|
||||||
$year = today(config('app.timezone'));
|
$year = today(config('app.timezone'));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
/*
|
/*
|
||||||
* TriggerController.php
|
* TriggerController.php
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController.php
|
* AccountController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use JsonException;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BalanceController.php
|
* BalanceController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -29,7 +29,6 @@ use FireflyIII\Helpers\Report\ReportHelperInterface;
|
|||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use JsonException;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetController.php
|
* BudgetController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -187,8 +188,8 @@ class BudgetController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
|
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +268,7 @@ class BudgetController extends Controller
|
|||||||
$total = $sums[$currencyId]['sum'] ?? '0';
|
$total = $sums[$currencyId]['sum'] ?? '0';
|
||||||
$pct = '0';
|
$pct = '0';
|
||||||
if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {
|
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;
|
$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;
|
||||||
}
|
}
|
||||||
@ -349,7 +350,7 @@ class BudgetController extends Controller
|
|||||||
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
|
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
|
||||||
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
|
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
|
||||||
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
|
$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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +385,7 @@ class BudgetController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'], // intentional float
|
'amount_float' => (float)$journal['amount'], // intentional float
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryController.php
|
* CategoryController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -301,8 +302,8 @@ class CategoryController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float
|
$result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,8 +354,8 @@ class CategoryController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +674,7 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = (string) view('reports.partials.categories', compact('report'))->render();
|
$result = (string)view('reports.partials.categories', compact('report'))->render();
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||||
@ -702,7 +703,7 @@ class CategoryController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'],
|
'amount_float' => (float)$journal['amount'],
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
@ -752,7 +753,7 @@ class CategoryController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'],
|
'amount_float' => (float)$journal['amount'],
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DoubleController.php
|
* DoubleController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -101,8 +102,8 @@ class DoubleController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort by amount_float
|
// sort by amount_float
|
||||||
@ -153,8 +154,8 @@ class DoubleController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort by amount_float
|
// sort by amount_float
|
||||||
@ -436,7 +437,7 @@ class DoubleController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'],
|
'amount_float' => (float)$journal['amount'],
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
@ -486,7 +487,7 @@ class DoubleController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'],
|
'amount_float' => (float)$journal['amount'],
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OperationsController.php
|
* OperationsController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -28,7 +29,6 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Support\CacheProperties;
|
use FireflyIII\Support\CacheProperties;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use JsonException;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -294,8 +294,8 @@ class TagController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,8 +346,8 @@ class TagController extends Controller
|
|||||||
];
|
];
|
||||||
$result[$key]['transactions']++;
|
$result[$key]['transactions']++;
|
||||||
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);
|
||||||
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);
|
$result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);
|
||||||
$result[$key]['avg_float'] = (float) $result[$key]['avg'];
|
$result[$key]['avg_float'] = (float)$result[$key]['avg'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,7 +493,7 @@ class TagController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'],
|
'amount_float' => (float)$journal['amount'],
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
@ -543,7 +543,7 @@ class TagController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'description' => $journal['description'],
|
'description' => $journal['description'],
|
||||||
'transaction_group_id' => $journal['transaction_group_id'],
|
'transaction_group_id' => $journal['transaction_group_id'],
|
||||||
'amount_float' => (float) $journal['amount'], // intentional float.
|
'amount_float' => (float)$journal['amount'], // intentional float.
|
||||||
'amount' => $journal['amount'],
|
'amount' => $journal['amount'],
|
||||||
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
'date' => $journal['date']->isoFormat($this->monthAndDayFormat),
|
||||||
'date_sort' => $journal['date']->format('Y-m-d'),
|
'date_sort' => $journal['date']->format('Y-m-d'),
|
||||||
|
@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Rule;
|
|||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Http\Requests\RuleFormRequest;
|
use FireflyIII\Http\Requests\RuleFormRequest;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\Rule;
|
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
@ -61,7 +60,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
@ -89,7 +88,7 @@ class CreateController extends Controller
|
|||||||
$oldActions = [];
|
$oldActions = [];
|
||||||
|
|
||||||
// build triggers from query, if present.
|
// build triggers from query, if present.
|
||||||
$query = (string) $request->get('from_query');
|
$query = (string)$request->get('from_query');
|
||||||
if ('' !== $query) {
|
if ('' !== $query) {
|
||||||
$search = app(SearchInterface::class);
|
$search = app(SearchInterface::class);
|
||||||
$search->parseQuery($query);
|
$search->parseQuery($query);
|
||||||
@ -113,9 +112,9 @@ class CreateController extends Controller
|
|||||||
$subTitleIcon = 'fa-clone';
|
$subTitleIcon = 'fa-clone';
|
||||||
|
|
||||||
// title depends on whether or not there is a rule group:
|
// 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) {
|
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
|
// flash old data
|
||||||
@ -143,13 +142,13 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function createFromBill(Request $request, Bill $bill)
|
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();
|
$this->createDefaultRuleGroup();
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'strict' => true,
|
'strict' => true,
|
||||||
'title' => (string) trans('firefly.new_rule_for_bill_title', ['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]),
|
'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),
|
||||||
];
|
];
|
||||||
|
|
||||||
// make triggers and actions from the bill itself.
|
// make triggers and actions from the bill itself.
|
||||||
@ -169,7 +168,7 @@ class CreateController extends Controller
|
|||||||
$subTitleIcon = 'fa-clone';
|
$subTitleIcon = 'fa-clone';
|
||||||
|
|
||||||
// title depends on whether or not there is a rule group:
|
// title depends on whether or not there is a rule group:
|
||||||
$subTitle = (string) trans('firefly.make_new_rule_no_group');
|
$subTitle = (string)trans('firefly.make_new_rule_no_group');
|
||||||
|
|
||||||
// flash old data
|
// flash old data
|
||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
@ -194,10 +193,10 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
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';
|
$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.
|
// get triggers and actions for journal.
|
||||||
$oldTriggers = $this->getTriggersForJournal($journal);
|
$oldTriggers = $this->getTriggersForJournal($journal);
|
||||||
@ -208,8 +207,8 @@ class CreateController extends Controller
|
|||||||
// collect pre-filled information:
|
// collect pre-filled information:
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'strict' => true,
|
'strict' => true,
|
||||||
'title' => (string) trans('firefly.new_rule_for_journal_title', ['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]),
|
'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),
|
||||||
];
|
];
|
||||||
|
|
||||||
// restore actions and triggers from old input:
|
// restore actions and triggers from old input:
|
||||||
@ -242,7 +241,7 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function duplicate(Request $request): JsonResponse
|
public function duplicate(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$ruleId = (int) $request->get('id');
|
$ruleId = (int)$request->get('id');
|
||||||
$rule = $this->ruleRepos->find($ruleId);
|
$rule = $this->ruleRepos->find($ruleId);
|
||||||
if (null !== $rule) {
|
if (null !== $rule) {
|
||||||
$this->ruleRepos->duplicate($rule);
|
$this->ruleRepos->duplicate($rule);
|
||||||
@ -264,22 +263,22 @@ class CreateController extends Controller
|
|||||||
$data = $request->getRuleData();
|
$data = $request->getRuleData();
|
||||||
|
|
||||||
$rule = $this->ruleRepos->store($data);
|
$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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
// redirect to show bill.
|
// redirect to show bill.
|
||||||
if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {
|
if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {
|
||||||
return redirect(route('bills.show', [(int) $request->get('bill_id')]));
|
return redirect(route('bills.show', [(int)$request->get('bill_id')]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// redirect to new bill creation.
|
// 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'));
|
return redirect($this->getPreviousUrl('bills.create.url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUrl('rules.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);
|
session()->put('rules.create.fromStore', true);
|
||||||
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
|
$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class DeleteController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
@ -68,7 +68,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(Rule $rule)
|
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
|
// put previous url in session
|
||||||
$this->rememberPreviousUrl('rules.delete.url');
|
$this->rememberPreviousUrl('rules.delete.url');
|
||||||
@ -88,7 +88,7 @@ class DeleteController extends Controller
|
|||||||
$title = $rule->title;
|
$title = $rule->title;
|
||||||
$this->ruleRepos->destroy($rule);
|
$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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return redirect($this->getPreviousUrl('rules.delete.url'));
|
return redirect($this->getPreviousUrl('rules.delete.url'));
|
||||||
|
@ -61,7 +61,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
@ -87,7 +87,7 @@ class EditController extends Controller
|
|||||||
$oldTriggers = [];
|
$oldTriggers = [];
|
||||||
|
|
||||||
// build triggers from query, if present.
|
// build triggers from query, if present.
|
||||||
$query = (string) $request->get('from_query');
|
$query = (string)$request->get('from_query');
|
||||||
if ('' !== $query) {
|
if ('' !== $query) {
|
||||||
$search = app(SearchInterface::class);
|
$search = app(SearchInterface::class);
|
||||||
$search->parseQuery($query);
|
$search->parseQuery($query);
|
||||||
@ -117,15 +117,15 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$hasOldInput = null !== $request->old('_token');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
$preFilled = [
|
$preFilled = [
|
||||||
'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,
|
'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,
|
||||||
'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,
|
'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,
|
||||||
'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,
|
'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// get rule trigger for update / store-journal:
|
// get rule trigger for update / store-journal:
|
||||||
$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);
|
$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").
|
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||||
if (true !== session('rules.edit.fromUpdate')) {
|
if (true !== session('rules.edit.fromUpdate')) {
|
||||||
@ -151,7 +151,7 @@ class EditController extends Controller
|
|||||||
$triggers = [];
|
$triggers = [];
|
||||||
foreach ($operators as $key => $operator) {
|
foreach ($operators as $key => $operator) {
|
||||||
if ('user_action' !== $key && false === $operator['alias']) {
|
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);
|
asort($triggers);
|
||||||
@ -194,10 +194,10 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$this->ruleRepos->update($rule, $data);
|
$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();
|
app('preferences')->mark();
|
||||||
$redirect = redirect($this->getPreviousUrl('rules.edit.url'));
|
$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);
|
session()->put('rules.edit.fromUpdate', true);
|
||||||
|
|
||||||
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
|
$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IndexController.php
|
* IndexController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -54,7 +55,7 @@ class IndexController extends Controller
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
|
||||||
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
$this->ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
@ -87,8 +88,8 @@ class IndexController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse
|
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, (int) $order);
|
$this->ruleRepos->moveRule($rule, $ruleGroup, (int)$order);
|
||||||
|
|
||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class SelectController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -98,7 +98,7 @@ class SelectController extends Controller
|
|||||||
$newRuleEngine->fire();
|
$newRuleEngine->fire();
|
||||||
$resultCount = $newRuleEngine->getResults();
|
$resultCount = $newRuleEngine->getResults();
|
||||||
|
|
||||||
session()->flash('success', (string) trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
session()->flash('success', (string)trans_choice('firefly.applied_rule_selection', $resultCount, ['title' => $rule->title]));
|
||||||
|
|
||||||
return redirect()->route('rules.index');
|
return redirect()->route('rules.index');
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class SelectController extends Controller
|
|||||||
// does the user have shared accounts?
|
// does the user have shared accounts?
|
||||||
$first = session('first', Carbon::now()->subYear())->format('Y-m-d');
|
$first = session('first', Carbon::now()->subYear())->format('Y-m-d');
|
||||||
$today = Carbon::now()->format('Y-m-d');
|
$today = Carbon::now()->format('Y-m-d');
|
||||||
$subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
$subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);
|
||||||
|
|
||||||
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
|
return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ class SelectController extends Controller
|
|||||||
|
|
||||||
// warn if nothing.
|
// warn if nothing.
|
||||||
if (0 === count($textTriggers)) {
|
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) {
|
foreach ($textTriggers as $textTrigger) {
|
||||||
@ -170,7 +170,7 @@ class SelectController extends Controller
|
|||||||
// Warn the user if only a subset of transactions is returned
|
// Warn the user if only a subset of transactions is returned
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (0 === count($collection)) {
|
if (0 === count($collection)) {
|
||||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return json response
|
// Return json response
|
||||||
@ -201,7 +201,7 @@ class SelectController extends Controller
|
|||||||
$triggers = $rule->ruleTriggers;
|
$triggers = $rule->ruleTriggers;
|
||||||
|
|
||||||
if (0 === count($triggers)) {
|
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:
|
// create new rule engine:
|
||||||
$newRuleEngine = app(RuleEngineInterface::class);
|
$newRuleEngine = app(RuleEngineInterface::class);
|
||||||
@ -213,7 +213,7 @@ class SelectController extends Controller
|
|||||||
|
|
||||||
$warning = '';
|
$warning = '';
|
||||||
if (0 === count($collection)) {
|
if (0 === count($collection)) {
|
||||||
$warning = (string) trans('firefly.warning_no_matching_transactions');
|
$warning = (string)trans('firefly.warning_no_matching_transactions');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return json response
|
// Return json response
|
||||||
|
@ -50,7 +50,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||||
@ -68,7 +68,7 @@ class CreateController extends Controller
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$subTitleIcon = 'fa-clone';
|
$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").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
if (true !== session('rule-groups.create.fromStore')) {
|
if (true !== session('rule-groups.create.fromStore')) {
|
||||||
@ -91,11 +91,11 @@ class CreateController extends Controller
|
|||||||
$data = $request->getRuleGroupData();
|
$data = $request->getRuleGroupData();
|
||||||
$ruleGroup = $this->repository->store($data);
|
$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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
$redirect = redirect($this->getPreviousUrl('rule-groups.create.url'));
|
$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);
|
session()->put('rule-groups.create.fromStore', true);
|
||||||
|
|
||||||
$redirect = redirect(route('rule-groups.create'))->withInput();
|
$redirect = redirect(route('rule-groups.create'))->withInput();
|
||||||
|
@ -51,7 +51,7 @@ class DeleteController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||||
@ -70,7 +70,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(RuleGroup $ruleGroup)
|
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
|
// put previous url in session
|
||||||
$this->rememberPreviousUrl('rule-groups.delete.url');
|
$this->rememberPreviousUrl('rule-groups.delete.url');
|
||||||
@ -91,10 +91,10 @@ class DeleteController extends Controller
|
|||||||
$title = $ruleGroup->title;
|
$title = $ruleGroup->title;
|
||||||
|
|
||||||
/** @var RuleGroup $moveTo */
|
/** @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);
|
$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();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return redirect($this->getPreviousUrl('rule-groups.delete.url'));
|
return redirect($this->getPreviousUrl('rule-groups.delete.url'));
|
||||||
|
@ -52,7 +52,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->repository = app(RuleGroupRepositoryInterface::class);
|
$this->repository = app(RuleGroupRepositoryInterface::class);
|
||||||
@ -72,11 +72,11 @@ class EditController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(Request $request, RuleGroup $ruleGroup)
|
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');
|
$hasOldInput = null !== $request->old('_token');
|
||||||
$preFilled = [
|
$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").
|
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||||
if (true !== session('rule-groups.edit.fromUpdate')) {
|
if (true !== session('rule-groups.edit.fromUpdate')) {
|
||||||
@ -97,20 +97,20 @@ class EditController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function moveGroup(Request $request): JsonResponse
|
public function moveGroup(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$groupId = (int) $request->get('id');
|
$groupId = (int)$request->get('id');
|
||||||
$ruleGroup = $this->repository->find($groupId);
|
$ruleGroup = $this->repository->find($groupId);
|
||||||
if (null !== $ruleGroup) {
|
if (null !== $ruleGroup) {
|
||||||
$direction = $request->get('direction');
|
$direction = $request->get('direction');
|
||||||
if ('down' === $direction) {
|
if ('down' === $direction) {
|
||||||
$maxOrder = $this->repository->maxOrder();
|
$maxOrder = $this->repository->maxOrder();
|
||||||
$order = (int) $ruleGroup->order;
|
$order = (int)$ruleGroup->order;
|
||||||
if ($order < $maxOrder) {
|
if ($order < $maxOrder) {
|
||||||
$newOrder = $order + 1;
|
$newOrder = $order + 1;
|
||||||
$this->repository->setOrder($ruleGroup, $newOrder);
|
$this->repository->setOrder($ruleGroup, $newOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ('up' === $direction) {
|
if ('up' === $direction) {
|
||||||
$order = (int) $ruleGroup->order;
|
$order = (int)$ruleGroup->order;
|
||||||
if ($order > 1) {
|
if ($order > 1) {
|
||||||
$newOrder = $order - 1;
|
$newOrder = $order - 1;
|
||||||
$this->repository->setOrder($ruleGroup, $newOrder);
|
$this->repository->setOrder($ruleGroup, $newOrder);
|
||||||
@ -133,15 +133,15 @@ class EditController extends Controller
|
|||||||
$data = [
|
$data = [
|
||||||
'title' => $request->convertString('title'),
|
'title' => $request->convertString('title'),
|
||||||
'description' => $request->stringWithNewlines('description'),
|
'description' => $request->stringWithNewlines('description'),
|
||||||
'active' => 1 === (int) $request->input('active'),
|
'active' => 1 === (int)$request->input('active'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->repository->update($ruleGroup, $data);
|
$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();
|
app('preferences')->mark();
|
||||||
$redirect = redirect($this->getPreviousUrl('rule-groups.edit.url'));
|
$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);
|
session()->put('rule-groups.edit.fromUpdate', true);
|
||||||
|
|
||||||
$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);
|
$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);
|
||||||
|
@ -53,7 +53,7 @@ class ExecutionController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-random');
|
||||||
|
|
||||||
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
|
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
|
||||||
@ -95,7 +95,7 @@ class ExecutionController extends Controller
|
|||||||
$newRuleEngine->fire();
|
$newRuleEngine->fire();
|
||||||
|
|
||||||
// Tell the user that the job is queued
|
// 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');
|
return redirect()->route('rules.index');
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ class ExecutionController extends Controller
|
|||||||
{
|
{
|
||||||
$first = session('first')->format('Y-m-d');
|
$first = session('first')->format('Y-m-d');
|
||||||
$today = Carbon::now()->format('Y-m-d');
|
$today = Carbon::now()->format('Y-m-d');
|
||||||
$subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
|
$subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);
|
||||||
|
|
||||||
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
|
return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HealthcheckController.php
|
* HealthcheckController.php
|
||||||
* Copyright (c) 2021 https://github.com/ajgon
|
* Copyright (c) 2021 https://github.com/ajgon
|
||||||
|
@ -127,10 +127,10 @@ class InstallController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// index will set FF3 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.
|
// 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');
|
return view('install.index');
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ class InstallController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function runCommand(Request $request): JsonResponse
|
public function runCommand(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$requestIndex = (int) $request->get('index');
|
$requestIndex = (int)$request->get('index');
|
||||||
$response = [
|
$response = [
|
||||||
'hasNextCommand' => false,
|
'hasNextCommand' => false,
|
||||||
'done' => true,
|
'done' => true,
|
||||||
|
@ -57,7 +57,7 @@ class BulkController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
$this->repository = app(JournalRepositoryInterface::class);
|
$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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -76,7 +76,7 @@ class BulkController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(array $journals)
|
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');
|
$this->rememberPreviousUrl('transactions.bulk-edit.url');
|
||||||
|
|
||||||
@ -101,14 +101,14 @@ class BulkController extends Controller
|
|||||||
{
|
{
|
||||||
$journalIds = $request->get('journals');
|
$journalIds = $request->get('journals');
|
||||||
$journalIds = is_array($journalIds) ? $journalIds : [];
|
$journalIds = is_array($journalIds) ? $journalIds : [];
|
||||||
$ignoreCategory = 1 === (int) $request->get('ignore_category');
|
$ignoreCategory = 1 === (int)$request->get('ignore_category');
|
||||||
$ignoreBudget = 1 === (int) $request->get('ignore_budget');
|
$ignoreBudget = 1 === (int)$request->get('ignore_budget');
|
||||||
$tagsAction = $request->get('tags_action');
|
$tagsAction = $request->get('tags_action');
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
foreach ($journalIds as $journalId) {
|
foreach ($journalIds as $journalId) {
|
||||||
$journalId = (int) $journalId;
|
$journalId = (int)$journalId;
|
||||||
$journal = $this->repository->find($journalId);
|
$journal = $this->repository->find($journalId);
|
||||||
if (null !== $journal) {
|
if (null !== $journal) {
|
||||||
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
|
||||||
@ -128,7 +128,7 @@ class BulkController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$request->session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));
|
$request->session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||||
|
|
||||||
// redirect to previous URL:
|
// redirect to previous URL:
|
||||||
return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));
|
return redirect($this->getPreviousUrl('transactions.bulk-edit.url'));
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConvertController.php
|
* ConvertController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -70,7 +71,7 @@ class ConvertController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
$this->repository = app(JournalRepositoryInterface::class);
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -103,7 +104,7 @@ class ConvertController extends Controller
|
|||||||
|
|
||||||
$groupTitle = $group->title ?? $first->description;
|
$groupTitle = $group->title ?? $first->description;
|
||||||
$groupArray = $transformer->transformObject($group);
|
$groupArray = $transformer->transformObject($group);
|
||||||
$subTitle = (string) trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]);
|
$subTitle = (string)trans('firefly.convert_to_'.$destinationType->type, ['description' => $groupTitle]);
|
||||||
$subTitleIcon = 'fa-exchange';
|
$subTitleIcon = 'fa-exchange';
|
||||||
|
|
||||||
// get a list of asset accounts and liabilities and stuff, in various combinations:
|
// get a list of asset accounts and liabilities and stuff, in various combinations:
|
||||||
@ -119,7 +120,7 @@ class ConvertController extends Controller
|
|||||||
|
|
||||||
if ($sourceType->type === $destinationType->type) { // cannot convert to its own type.
|
if ($sourceType->type === $destinationType->type) { // cannot convert to its own type.
|
||||||
Log::debug('This is already a transaction of the expected type..');
|
Log::debug('This is already a transaction of the expected type..');
|
||||||
session()->flash('info', (string) trans('firefly.convert_is_already_type_' . $destinationType->type));
|
session()->flash('info', (string)trans('firefly.convert_is_already_type_'.$destinationType->type));
|
||||||
|
|
||||||
return redirect(route('transactions.show', [$group->id]));
|
return redirect(route('transactions.show', [$group->id]));
|
||||||
}
|
}
|
||||||
@ -156,7 +157,7 @@ class ConvertController extends Controller
|
|||||||
// group accounts:
|
// group accounts:
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accountList as $account) {
|
foreach ($accountList as $account) {
|
||||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||||
$name = $account->name;
|
$name = $account->name;
|
||||||
if ('' === $role) {
|
if ('' === $role) {
|
||||||
$role = 'no_account_type';
|
$role = 'no_account_type';
|
||||||
@ -164,7 +165,7 @@ class ConvertController extends Controller
|
|||||||
|
|
||||||
// maybe it's a liability thing:
|
// maybe it's a liability thing:
|
||||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||||
$role = 'l_' . $account->accountType->type;
|
$role = 'l_'.$account->accountType->type;
|
||||||
}
|
}
|
||||||
if (AccountType::CASH === $account->accountType->type) {
|
if (AccountType::CASH === $account->accountType->type) {
|
||||||
$role = 'cash_account';
|
$role = 'cash_account';
|
||||||
@ -174,7 +175,7 @@ class ConvertController extends Controller
|
|||||||
$role = 'revenue_account';
|
$role = 'revenue_account';
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = (string) trans('firefly.opt_group_' . $role);
|
$key = (string)trans('firefly.opt_group_'.$role);
|
||||||
$grouped[$key][$account->id] = $name;
|
$grouped[$key][$account->id] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +196,7 @@ class ConvertController extends Controller
|
|||||||
// group accounts:
|
// group accounts:
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accountList as $account) {
|
foreach ($accountList as $account) {
|
||||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||||
$name = $account->name;
|
$name = $account->name;
|
||||||
if ('' === $role) {
|
if ('' === $role) {
|
||||||
$role = 'no_account_type';
|
$role = 'no_account_type';
|
||||||
@ -203,7 +204,7 @@ class ConvertController extends Controller
|
|||||||
|
|
||||||
// maybe it's a liability thing:
|
// maybe it's a liability thing:
|
||||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||||
$role = 'l_' . $account->accountType->type;
|
$role = 'l_'.$account->accountType->type;
|
||||||
}
|
}
|
||||||
if (AccountType::CASH === $account->accountType->type) {
|
if (AccountType::CASH === $account->accountType->type) {
|
||||||
$role = 'cash_account';
|
$role = 'cash_account';
|
||||||
@ -213,7 +214,7 @@ class ConvertController extends Controller
|
|||||||
$role = 'expense_account';
|
$role = 'expense_account';
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = (string) trans('firefly.opt_group_' . $role);
|
$key = (string)trans('firefly.opt_group_'.$role);
|
||||||
$grouped[$key][$account->id] = $name;
|
$grouped[$key][$account->id] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,9 +236,9 @@ class ConvertController extends Controller
|
|||||||
foreach ($accountList as $account) {
|
foreach ($accountList as $account) {
|
||||||
$balance = app('steam')->balance($account, today());
|
$balance = app('steam')->balance($account, today());
|
||||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||||
$role = 'l_' . $account->accountType->type;
|
$role = 'l_'.$account->accountType->type;
|
||||||
$key = (string) trans('firefly.opt_group_' . $role);
|
$key = (string)trans('firefly.opt_group_'.$role);
|
||||||
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
|
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $grouped;
|
return $grouped;
|
||||||
@ -258,13 +259,13 @@ class ConvertController extends Controller
|
|||||||
foreach ($accountList as $account) {
|
foreach ($accountList as $account) {
|
||||||
$balance = app('steam')->balance($account, today());
|
$balance = app('steam')->balance($account, today());
|
||||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||||
if ('' === $role) {
|
if ('' === $role) {
|
||||||
$role = 'no_account_type';
|
$role = 'no_account_type';
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = (string) trans('firefly.opt_group_' . $role);
|
$key = (string)trans('firefly.opt_group_'.$role);
|
||||||
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
|
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $grouped;
|
return $grouped;
|
||||||
@ -301,7 +302,7 @@ class ConvertController extends Controller
|
|||||||
// correct transfers:
|
// correct transfers:
|
||||||
$group->refresh();
|
$group->refresh();
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.converted_to_' . $destinationType->type));
|
session()->flash('success', (string)trans('firefly.converted_to_'.$destinationType->type));
|
||||||
event(new UpdatedTransactionGroup($group, true, true));
|
event(new UpdatedTransactionGroup($group, true, true));
|
||||||
|
|
||||||
return redirect(route('transactions.show', [$group->id]));
|
return redirect(route('transactions.show', [$group->id]));
|
||||||
@ -328,10 +329,10 @@ class ConvertController extends Controller
|
|||||||
$destinationName = $data['destination_name'][$journal->id] ?? null;
|
$destinationName = $data['destination_name'][$journal->id] ?? null;
|
||||||
|
|
||||||
// double check its not an empty string.
|
// double check its not an empty string.
|
||||||
$sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;
|
$sourceId = '' === $sourceId || null === $sourceId ? null : (int)$sourceId;
|
||||||
$sourceName = '' === $sourceName ? null : (string) $sourceName;
|
$sourceName = '' === $sourceName ? null : (string)$sourceName;
|
||||||
$destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId;
|
$destinationId = '' === $destinationId || null === $destinationId ? null : (int)$destinationId;
|
||||||
$destinationName = '' === $destinationName ? null : (string) $destinationName;
|
$destinationName = '' === $destinationName ? null : (string)$destinationName;
|
||||||
$validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName,]);
|
$validSource = $validator->validateSource(['id' => $sourceId, 'name' => $sourceName,]);
|
||||||
$validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName,]);
|
$validDestination = $validator->validateDestination(['id' => $destinationId, 'name' => $destinationName,]);
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ use Illuminate\Contracts\View\Factory;
|
|||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use JsonException;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CreateController
|
* Class CreateController
|
||||||
@ -52,7 +55,7 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||||
|
|
||||||
@ -68,7 +71,7 @@ class CreateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function cloneGroup(Request $request): JsonResponse
|
public function cloneGroup(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$groupId = (int) $request->get('id');
|
$groupId = (int)$request->get('id');
|
||||||
if (0 !== $groupId) {
|
if (0 !== $groupId) {
|
||||||
$group = $this->repository->find($groupId);
|
$group = $this->repository->find($groupId);
|
||||||
if (null !== $group) {
|
if (null !== $group) {
|
||||||
@ -100,22 +103,22 @@ class CreateController extends Controller
|
|||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* @throws \JsonException
|
* @throws JsonException
|
||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function create(?string $objectType)
|
public function create(?string $objectType)
|
||||||
{
|
{
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
$sourceId = (int) request()->get('source');
|
$sourceId = (int)request()->get('source');
|
||||||
$destinationId = (int) request()->get('destination');
|
$destinationId = (int)request()->get('destination');
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$cash = $accountRepository->getCashAccount();
|
$cash = $accountRepository->getCashAccount();
|
||||||
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
$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';
|
$subTitleIcon = 'fa-plus';
|
||||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
use FireflyIII\Events\DestroyedTransactionGroup;
|
|
||||||
use FireflyIII\Events\UpdatedAccount;
|
use FireflyIII\Events\UpdatedAccount;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
@ -57,7 +56,7 @@ class DeleteController extends Controller
|
|||||||
// translations:
|
// translations:
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||||
@ -87,7 +86,7 @@ class DeleteController extends Controller
|
|||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$subTitle = (string) trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
|
$subTitle = (string)trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);
|
||||||
$previous = app('steam')->getSafePreviousUrl(route('index'));
|
$previous = app('steam')->getSafePreviousUrl(route('index'));
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
Log::debug('Will try to remember previous URL');
|
Log::debug('Will try to remember previous URL');
|
||||||
@ -114,7 +113,7 @@ class DeleteController extends Controller
|
|||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
$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:
|
// grab asset account(s) from group:
|
||||||
$accounts = [];
|
$accounts = [];
|
||||||
|
@ -48,7 +48,7 @@ class EditController extends Controller
|
|||||||
// some useful repositories:
|
// some useful repositories:
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
static function ($request, $next) {
|
static function ($request, $next) {
|
||||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
@ -24,7 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Transaction;
|
namespace FireflyIII\Http\Controllers\Transaction;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
@ -32,6 +32,8 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
|||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IndexController
|
* Class IndexController
|
||||||
@ -55,7 +57,7 @@ class IndexController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-exchange');
|
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);
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
@ -73,9 +75,9 @@ class IndexController extends Controller
|
|||||||
* @param Carbon|null $end
|
* @param Carbon|null $end
|
||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
* @throws \FireflyIII\Exceptions\FireflyException
|
* @throws FireflyException
|
||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
|
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
|
||||||
{
|
{
|
||||||
@ -83,10 +85,10 @@ class IndexController extends Controller
|
|||||||
$objectType = 'transfer';
|
$objectType = 'transfer';
|
||||||
}
|
}
|
||||||
|
|
||||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
|
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||||
$types = config('firefly.transactionTypesByType.' . $objectType);
|
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||||
$page = (int) $request->get('page');
|
$page = (int)$request->get('page');
|
||||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||||
if (null === $start) {
|
if (null === $start) {
|
||||||
$start = session('start');
|
$start = session('start');
|
||||||
$end = session('end');
|
$end = session('end');
|
||||||
@ -101,7 +103,7 @@ class IndexController extends Controller
|
|||||||
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||||
$startStr = $start->isoFormat($this->monthAndDayFormat);
|
$startStr = $start->isoFormat($this->monthAndDayFormat);
|
||||||
$endStr = $end->isoFormat($this->monthAndDayFormat);
|
$endStr = $end->isoFormat($this->monthAndDayFormat);
|
||||||
$subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
$subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
||||||
|
|
||||||
$firstJournal = $this->repository->firstNull();
|
$firstJournal = $this->repository->firstNull();
|
||||||
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
|
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
|
||||||
@ -132,22 +134,22 @@ class IndexController extends Controller
|
|||||||
* @param string $objectType
|
* @param string $objectType
|
||||||
*
|
*
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
* @throws \FireflyIII\Exceptions\FireflyException
|
* @throws FireflyException
|
||||||
* @throws \Psr\Container\ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function indexAll(Request $request, string $objectType)
|
public function indexAll(Request $request, string $objectType)
|
||||||
{
|
{
|
||||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
|
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||||
$types = config('firefly.transactionTypesByType.' . $objectType);
|
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||||
$page = (int) $request->get('page');
|
$page = (int)$request->get('page');
|
||||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||||
$path = route('transactions.index.all', [$objectType]);
|
$path = route('transactions.index.all', [$objectType]);
|
||||||
$first = $this->repository->firstNull();
|
$first = $this->repository->firstNull();
|
||||||
$start = null === $first ? new Carbon() : $first->date;
|
$start = null === $first ? new Carbon() : $first->date;
|
||||||
$last = $this->repository->getLast();
|
$last = $this->repository->getLast();
|
||||||
$end = $last ? $last->date : today(config('app.timezone'));
|
$end = $last ? $last->date : today(config('app.timezone'));
|
||||||
$subTitle = (string) trans('firefly.all_' . $objectType);
|
$subTitle = (string)trans('firefly.all_'.$objectType);
|
||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LinkController.php
|
* LinkController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -54,7 +55,7 @@ class LinkController extends Controller
|
|||||||
// some useful repositories:
|
// some useful repositories:
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
$this->journalRepository = app(JournalRepositoryInterface::class);
|
$this->journalRepository = app(JournalRepositoryInterface::class);
|
||||||
@ -75,7 +76,7 @@ class LinkController extends Controller
|
|||||||
public function delete(TransactionJournalLink $link)
|
public function delete(TransactionJournalLink $link)
|
||||||
{
|
{
|
||||||
$subTitleIcon = 'fa-link';
|
$subTitleIcon = 'fa-link';
|
||||||
$subTitle = (string) trans('breadcrumbs.delete_journal_link');
|
$subTitle = (string)trans('breadcrumbs.delete_journal_link');
|
||||||
$this->rememberPreviousUrl('journal_links.delete.url');
|
$this->rememberPreviousUrl('journal_links.delete.url');
|
||||||
|
|
||||||
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
|
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
|
||||||
@ -92,10 +93,10 @@ class LinkController extends Controller
|
|||||||
{
|
{
|
||||||
$this->repository->destroyLink($link);
|
$this->repository->destroyLink($link);
|
||||||
|
|
||||||
session()->flash('success', (string) trans('firefly.deleted_link'));
|
session()->flash('success', (string)trans('firefly.deleted_link'));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
return redirect((string) session('journal_links.delete.url'));
|
return redirect((string)session('journal_links.delete.url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +126,7 @@ class LinkController extends Controller
|
|||||||
Log::debug('We are here (store)');
|
Log::debug('We are here (store)');
|
||||||
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
|
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
|
||||||
if (null === $other) {
|
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]));
|
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||||
}
|
}
|
||||||
@ -133,19 +134,19 @@ class LinkController extends Controller
|
|||||||
$alreadyLinked = $this->repository->findLink($journal, $other);
|
$alreadyLinked = $this->repository->findLink($journal, $other);
|
||||||
|
|
||||||
if ($other->id === $journal->id) {
|
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]));
|
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($alreadyLinked) {
|
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]));
|
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
|
Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
|
||||||
$this->repository->storeLink($linkInfo, $other, $journal);
|
$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]));
|
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||||
}
|
}
|
||||||
@ -158,7 +159,7 @@ class LinkController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function switchLink(Request $request)
|
public function switchLink(Request $request)
|
||||||
{
|
{
|
||||||
$linkId = (int) $request->get('id');
|
$linkId = (int)$request->get('id');
|
||||||
$this->repository->switchLinkById($linkId);
|
$this->repository->switchLinkById($linkId);
|
||||||
|
|
||||||
return redirect(app('steam')->getSafePreviousUrl());
|
return redirect(app('steam')->getSafePreviousUrl());
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MassController.php
|
* MassController.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -61,7 +62,7 @@ class MassController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
$this->repository = app(JournalRepositoryInterface::class);
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ class MassController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(array $journals): IlluminateView
|
public function delete(array $journals): IlluminateView
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.mass_delete_journals');
|
$subTitle = (string)trans('firefly.mass_delete_journals');
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
$this->rememberPreviousUrl('transactions.mass-delete.url');
|
$this->rememberPreviousUrl('transactions.mass-delete.url');
|
||||||
@ -103,15 +104,15 @@ class MassController extends Controller
|
|||||||
/** @var string $journalId */
|
/** @var string $journalId */
|
||||||
foreach ($ids as $journalId) {
|
foreach ($ids as $journalId) {
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
$journal = $this->repository->find((int) $journalId);
|
$journal = $this->repository->find((int)$journalId);
|
||||||
if (null !== $journal && (int) $journalId === $journal->id) {
|
if (null !== $journal && (int)$journalId === $journal->id) {
|
||||||
$this->repository->destroyJournal($journal);
|
$this->repository->destroyJournal($journal);
|
||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
session()->flash('success', (string) trans_choice('firefly.mass_deleted_transactions_success', $count));
|
session()->flash('success', (string)trans_choice('firefly.mass_deleted_transactions_success', $count));
|
||||||
|
|
||||||
// redirect to previous URL:
|
// redirect to previous URL:
|
||||||
return redirect($this->getPreviousUrl('transactions.mass-delete.url'));
|
return redirect($this->getPreviousUrl('transactions.mass-delete.url'));
|
||||||
@ -126,7 +127,7 @@ class MassController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(array $journals): IlluminateView
|
public function edit(array $journals): IlluminateView
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.mass_edit_journals');
|
$subTitle = (string)trans('firefly.mass_edit_journals');
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
@ -173,7 +174,7 @@ class MassController extends Controller
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
/** @var string $journalId */
|
/** @var string $journalId */
|
||||||
foreach ($journalIds as $journalId) {
|
foreach ($journalIds as $journalId) {
|
||||||
$integer = (int) $journalId;
|
$integer = (int)$journalId;
|
||||||
try {
|
try {
|
||||||
$this->updateJournal($integer, $request);
|
$this->updateJournal($integer, $request);
|
||||||
$count++;
|
$count++;
|
||||||
@ -183,7 +184,7 @@ class MassController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
session()->flash('success', (string) trans_choice('firefly.mass_edited_transactions_success', $count));
|
session()->flash('success', (string)trans_choice('firefly.mass_edited_transactions_success', $count));
|
||||||
|
|
||||||
// redirect to previous URL:
|
// redirect to previous URL:
|
||||||
return redirect($this->getPreviousUrl('transactions.mass-edit.url'));
|
return redirect($this->getPreviousUrl('transactions.mass-edit.url'));
|
||||||
@ -272,7 +273,7 @@ class MassController extends Controller
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) $value[$journalId];
|
return (string)$value[$journalId];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,6 +294,6 @@ class MassController extends Controller
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) $value[$journalId];
|
return (int)$value[$journalId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
|||||||
*/
|
*/
|
||||||
class ShowController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
private TransactionGroupRepositoryInterface $repository;
|
|
||||||
private ALERepositoryInterface $ALERepository;
|
private ALERepositoryInterface $ALERepository;
|
||||||
|
private TransactionGroupRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ShowController constructor.
|
* ShowController constructor.
|
||||||
@ -57,7 +57,7 @@ class ShowController extends Controller
|
|||||||
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
$this->repository = app(TransactionGroupRepositoryInterface::class);
|
||||||
$this->ALERepository = app(ALERepositoryInterface::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');
|
app('view')->share('mainTitleIcon', 'fa-exchange');
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -92,7 +92,7 @@ class ShowController extends Controller
|
|||||||
throw new FireflyException('This transaction is broken :(.');
|
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;
|
$title = 1 === $splits ? $first->description : $transactionGroup->title;
|
||||||
$subTitle = sprintf('%s: "%s"', $type, $title);
|
$subTitle = sprintf('%s: "%s"', $type, $title);
|
||||||
|
|
||||||
@ -188,12 +188,14 @@ class ShowController extends Controller
|
|||||||
'type' => $transaction['source_type'],
|
'type' => $transaction['source_type'],
|
||||||
'id' => $transaction['source_id'],
|
'id' => $transaction['source_id'],
|
||||||
'name' => $transaction['source_name'],
|
'name' => $transaction['source_name'],
|
||||||
'iban' => $transaction['source_iban']];
|
'iban' => $transaction['source_iban'],
|
||||||
|
];
|
||||||
$accounts['destination'][] = [
|
$accounts['destination'][] = [
|
||||||
'type' => $transaction['destination_type'],
|
'type' => $transaction['destination_type'],
|
||||||
'id' => $transaction['destination_id'],
|
'id' => $transaction['destination_id'],
|
||||||
'name' => $transaction['destination_name'],
|
'name' => $transaction['destination_name'],
|
||||||
'iban' => $transaction['destination_iban']];
|
'iban' => $transaction['destination_iban'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);
|
$accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);
|
||||||
|
@ -45,8 +45,8 @@ class CreateController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-bolt');
|
app('view')->share('mainTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('subTitleIcon', 'fa-plus');
|
app('view')->share('subTitleIcon', 'fa-plus');
|
||||||
app('view')->share('title', (string) trans('firefly.webhooks'));
|
app('view')->share('title', (string)trans('firefly.webhooks'));
|
||||||
app('view')->share('subTitle', (string) trans('firefly.create_new_webhook'));
|
app('view')->share('subTitle', (string)trans('firefly.create_new_webhook'));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Http\Controllers\Webhooks;
|
|||||||
|
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Webhook;
|
use FireflyIII\Models\Webhook;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
@ -50,8 +49,8 @@ class DeleteController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-bolt');
|
app('view')->share('mainTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('subTitleIcon', 'fa-trash');
|
app('view')->share('subTitleIcon', 'fa-trash');
|
||||||
app('view')->share('title', (string) trans('firefly.webhooks'));
|
app('view')->share('title', (string)trans('firefly.webhooks'));
|
||||||
app('view')->share('subTitle', (string) trans('firefly.delete_webhook'));
|
app('view')->share('subTitle', (string)trans('firefly.delete_webhook'));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -67,7 +66,7 @@ class DeleteController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Webhook $webhook)
|
public function index(Webhook $webhook)
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->name]);
|
$subTitle = (string)trans('firefly.delete_webhook', ['title' => $webhook->name]);
|
||||||
$this->rememberPreviousUrl('webhooks.delete.url');
|
$this->rememberPreviousUrl('webhooks.delete.url');
|
||||||
|
|
||||||
return view('webhooks.delete', compact('webhook', 'subTitle'));
|
return view('webhooks.delete', compact('webhook', 'subTitle'));
|
||||||
|
@ -24,12 +24,9 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Webhooks;
|
namespace FireflyIII\Http\Controllers\Webhooks;
|
||||||
|
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\Webhook;
|
use FireflyIII\Models\Webhook;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
@ -52,7 +49,7 @@ class EditController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-bolt');
|
app('view')->share('mainTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('subTitleIcon', 'fa-pencil');
|
app('view')->share('subTitleIcon', 'fa-pencil');
|
||||||
app('view')->share('title', (string) trans('firefly.webhooks'));
|
app('view')->share('title', (string)trans('firefly.webhooks'));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -68,7 +65,7 @@ class EditController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Webhook $webhook)
|
public function index(Webhook $webhook)
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]);
|
$subTitle = (string)trans('firefly.edit_webhook', ['title' => $webhook->title]);
|
||||||
$this->rememberPreviousUrl('webhooks.delete.url');
|
$this->rememberPreviousUrl('webhooks.delete.url');
|
||||||
|
|
||||||
return view('webhooks.edit', compact('webhook', 'subTitle'));
|
return view('webhooks.edit', compact('webhook', 'subTitle'));
|
||||||
|
@ -46,12 +46,13 @@ class IndexController extends Controller
|
|||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-bolt');
|
app('view')->share('mainTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('title', (string) trans('firefly.webhooks'));
|
app('view')->share('title', (string)trans('firefly.webhooks'));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show debug info.
|
* Show debug info.
|
||||||
*
|
*
|
||||||
|
@ -24,12 +24,9 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Webhooks;
|
namespace FireflyIII\Http\Controllers\Webhooks;
|
||||||
|
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\Webhook;
|
use FireflyIII\Models\Webhook;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
@ -52,7 +49,7 @@ class ShowController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
app('view')->share('mainTitleIcon', 'fa-bolt');
|
app('view')->share('mainTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('subTitleIcon', 'fa-bolt');
|
app('view')->share('subTitleIcon', 'fa-bolt');
|
||||||
app('view')->share('title', (string) trans('firefly.webhooks'));
|
app('view')->share('title', (string)trans('firefly.webhooks'));
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -68,7 +65,7 @@ class ShowController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Webhook $webhook)
|
public function index(Webhook $webhook)
|
||||||
{
|
{
|
||||||
$subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]);
|
$subTitle = (string)trans('firefly.show_webhook', ['title' => $webhook->title]);
|
||||||
|
|
||||||
return view('webhooks.show', compact('webhook', 'subTitle'));
|
return view('webhooks.show', compact('webhook', 'subTitle'));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ namespace FireflyIII\Http\Middleware;
|
|||||||
use FireflyIII\Exceptions\BadHttpHeaderException;
|
use FireflyIII\Exceptions\BadHttpHeaderException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Log;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +49,7 @@ class AcceptHeaders
|
|||||||
if ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {
|
if ('GET' === $method && !$request->accepts(['application/json', 'application/vdn.api+json'])) {
|
||||||
throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');
|
throw new BadHttpHeaderException('Your request must accept either application/json or application/vdn.api+json.');
|
||||||
}
|
}
|
||||||
$allowed = ['application/x-www-form-urlencoded','application/json'];
|
$allowed = ['application/x-www-form-urlencoded', 'application/json'];
|
||||||
$submitted = (string)$request->header('Content-Type');
|
$submitted = (string)$request->header('Content-Type');
|
||||||
if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {
|
if (('POST' === $method || 'PUT' === $method) && !in_array($submitted, $allowed, true)) {
|
||||||
$error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));
|
$error = new BadHttpHeaderException(sprintf('Content-Type cannot be "%s"', $submitted));
|
||||||
|
@ -94,10 +94,10 @@ class Authenticate
|
|||||||
// do an extra check on user object.
|
// do an extra check on user object.
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $this->auth->authenticate();
|
$user = $this->auth->authenticate();
|
||||||
if (1 === (int) $user->blocked) {
|
if (1 === (int)$user->blocked) {
|
||||||
$message = (string) trans('firefly.block_account_logout');
|
$message = (string)trans('firefly.block_account_logout');
|
||||||
if ('email_changed' === $user->blocked_code) {
|
if ('email_changed' === $user->blocked_code) {
|
||||||
$message = (string) trans('firefly.email_changed_logout');
|
$message = (string)trans('firefly.email_changed_logout');
|
||||||
}
|
}
|
||||||
app('session')->flash('logoutMessage', $message);
|
app('session')->flash('logoutMessage', $message);
|
||||||
$this->auth->logout();
|
$this->auth->logout();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binder.php
|
* Binder.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EncryptCookies.php
|
* EncryptCookies.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -147,8 +147,8 @@ class Installer
|
|||||||
private function oldDBVersion(): bool
|
private function oldDBVersion(): bool
|
||||||
{
|
{
|
||||||
// older version in config than database?
|
// older version in config than database?
|
||||||
$configVersion = (int) config('firefly.db_version');
|
$configVersion = (int)config('firefly.db_version');
|
||||||
$dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;
|
$dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;
|
||||||
if ($configVersion > $dbVersion) {
|
if ($configVersion > $dbVersion) {
|
||||||
app('log')->warning(
|
app('log')->warning(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -174,8 +174,8 @@ class Installer
|
|||||||
private function oldVersion(): bool
|
private function oldVersion(): bool
|
||||||
{
|
{
|
||||||
// version compare thing.
|
// version compare thing.
|
||||||
$configVersion = (string) config('firefly.version');
|
$configVersion = (string)config('firefly.version');
|
||||||
$dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
|
$dbVersion = (string)app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;
|
||||||
if (1 === version_compare($configVersion, $dbVersion)) {
|
if (1 === version_compare($configVersion, $dbVersion)) {
|
||||||
app('log')->warning(
|
app('log')->warning(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
@ -106,7 +106,7 @@ class InterestingMessage
|
|||||||
|
|
||||||
// send message about newly created transaction group.
|
// send message about newly created transaction group.
|
||||||
/** @var TransactionGroup $group */
|
/** @var TransactionGroup $group */
|
||||||
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int) $transactionGroupId);
|
$group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int)$transactionGroupId);
|
||||||
|
|
||||||
if (null === $group) {
|
if (null === $group) {
|
||||||
return;
|
return;
|
||||||
@ -122,17 +122,17 @@ class InterestingMessage
|
|||||||
$title = $count > 1 ? $group->title : $journal->description;
|
$title = $count > 1 ? $group->title : $journal->description;
|
||||||
if ('created' === $message) {
|
if ('created' === $message) {
|
||||||
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
|
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
|
||||||
session()->flash('success', (string) trans('firefly.stored_journal', ['description' => $title]));
|
session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));
|
||||||
}
|
}
|
||||||
if ('updated' === $message) {
|
if ('updated' === $message) {
|
||||||
$type = strtolower($journal->transactionType->type);
|
$type = strtolower($journal->transactionType->type);
|
||||||
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
|
session()->flash('success_url', route('transactions.show', [$transactionGroupId]));
|
||||||
session()->flash('success', (string) trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
|
session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));
|
||||||
}
|
}
|
||||||
if ('no_change' === $message) {
|
if ('no_change' === $message) {
|
||||||
$type = strtolower($journal->transactionType->type);
|
$type = strtolower($journal->transactionType->type);
|
||||||
session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));
|
session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));
|
||||||
session()->flash('warning', (string) trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
|
session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,13 +166,13 @@ class InterestingMessage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('deleted' === $message) {
|
if ('deleted' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.account_deleted', ['name' => $account->name]));
|
session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));
|
||||||
}
|
}
|
||||||
if ('created' === $message) {
|
if ('created' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));
|
session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||||
}
|
}
|
||||||
if ('updated' === $message) {
|
if ('updated' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));
|
session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,19 +189,6 @@ class InterestingMessage
|
|||||||
|
|
||||||
return null !== $billId && null !== $message;
|
return null !== $billId && null !== $message;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function webhookMessage(Request $request): bool
|
|
||||||
{
|
|
||||||
// get parameters from request.
|
|
||||||
$billId = $request->get('webhook_id');
|
|
||||||
$message = $request->get('message');
|
|
||||||
|
|
||||||
return null !== $billId && null !== $message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
@ -219,13 +206,27 @@ class InterestingMessage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('deleted' === $message) {
|
if ('deleted' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $bill->name]));
|
session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));
|
||||||
}
|
}
|
||||||
if ('created' === $message) {
|
if ('created' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));
|
session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function webhookMessage(Request $request): bool
|
||||||
|
{
|
||||||
|
// get parameters from request.
|
||||||
|
$billId = $request->get('webhook_id');
|
||||||
|
$message = $request->get('message');
|
||||||
|
|
||||||
|
return null !== $billId && null !== $message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
@ -242,13 +243,13 @@ class InterestingMessage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('deleted' === $message) {
|
if ('deleted' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.deleted_webhook', ['title' => $webhook->title]));
|
session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));
|
||||||
}
|
}
|
||||||
if ('updated' === $message) {
|
if ('updated' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.updated_webhook', ['title' => $webhook->title]));
|
session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));
|
||||||
}
|
}
|
||||||
if ('created' === $message) {
|
if ('created' === $message) {
|
||||||
session()->flash('success', (string) trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
|
session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsAdmin.php
|
* IsAdmin.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IsDemoUser.php
|
* IsDemoUser.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -53,7 +54,7 @@ class IsDemoUser
|
|||||||
$repository = app(UserRepositoryInterface::class);
|
$repository = app(UserRepositoryInterface::class);
|
||||||
if ($repository->hasRole($user, 'demo')) {
|
if ($repository->hasRole($user, 'demo')) {
|
||||||
Log::info('User is a demo user.');
|
Log::info('User is a demo user.');
|
||||||
$request->session()->flash('info', (string) trans('firefly.not_available_demo_user'));
|
$request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));
|
||||||
$current = $request->url();
|
$current = $request->url();
|
||||||
$previous = $request->session()->previousUrl();
|
$previous = $request->session()->previousUrl();
|
||||||
if ($current !== $previous) {
|
if ($current !== $previous) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range.php
|
* Range.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -112,12 +113,12 @@ class Range
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save some formats:
|
// save some formats:
|
||||||
$monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
$monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
|
||||||
$dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
$dateTimeFormat = (string)trans('config.date_time_js', [], $locale);
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
|
|
||||||
// also format for moment JS:
|
// also format for moment JS:
|
||||||
$madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);
|
$madMomentJS = (string)trans('config.month_and_day_moment_js', [], $locale);
|
||||||
|
|
||||||
app('view')->share('madMomentJS', $madMomentJS);
|
app('view')->share('madMomentJS', $madMomentJS);
|
||||||
app('view')->share('monthAndDayFormat', $monthAndDayFormat);
|
app('view')->share('monthAndDayFormat', $monthAndDayFormat);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RedirectIfAuthenticated.php
|
* RedirectIfAuthenticated.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -64,8 +64,8 @@ class SecureHeaders
|
|||||||
|
|
||||||
$route = $request->route();
|
$route = $request->route();
|
||||||
$customUrl = '';
|
$customUrl = '';
|
||||||
$authGuard = (string) config('firefly.authentication_guard');
|
$authGuard = (string)config('firefly.authentication_guard');
|
||||||
$logoutUrl = (string) config('firefly.custom_logout_url');
|
$logoutUrl = (string)config('firefly.custom_logout_url');
|
||||||
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
|
if ('remote_user_guard' === $authGuard && '' !== $logoutUrl) {
|
||||||
$customUrl = $logoutUrl;
|
$customUrl = $logoutUrl;
|
||||||
}
|
}
|
||||||
@ -115,8 +115,8 @@ class SecureHeaders
|
|||||||
*/
|
*/
|
||||||
private function getTrackingScriptSource(): string
|
private function getTrackingScriptSource(): string
|
||||||
{
|
{
|
||||||
if ('' !== (string) config('firefly.tracker_site_id') && '' !== (string) config('firefly.tracker_url')) {
|
if ('' !== (string)config('firefly.tracker_site_id') && '' !== (string)config('firefly.tracker_url')) {
|
||||||
return (string) config('firefly.tracker_url');
|
return (string)config('firefly.tracker_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StartFireflySession.php
|
* StartFireflySession.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TrimStrings.php
|
* TrimStrings.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TrustProxies.php
|
* TrustProxies.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -45,6 +46,6 @@ class TrustProxies extends Middleware
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->proxies = (string) config('firefly.trusted_proxies');
|
$this->proxies = (string)config('firefly.trusted_proxies');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VerifyCsrfToken.php
|
* VerifyCsrfToken.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountFormRequest.php
|
* AccountFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -107,12 +108,12 @@ class AccountFormRequest extends FormRequest
|
|||||||
'virtual_balance' => 'numeric|nullable|max:1000000000',
|
'virtual_balance' => 'numeric|nullable|max:1000000000',
|
||||||
'currency_id' => 'exists:transaction_currencies,id',
|
'currency_id' => 'exists:transaction_currencies,id',
|
||||||
'account_number' => 'between:1,255|uniqueAccountNumberForUser|nullable',
|
'account_number' => 'between:1,255|uniqueAccountNumberForUser|nullable',
|
||||||
'account_role' => 'in:' . $accountRoles,
|
'account_role' => 'in:'.$accountRoles,
|
||||||
'active' => 'boolean',
|
'active' => 'boolean',
|
||||||
'cc_type' => 'in:' . $ccPaymentTypes,
|
'cc_type' => 'in:'.$ccPaymentTypes,
|
||||||
'amount_currency_id_opening_balance' => 'exists:transaction_currencies,id',
|
'amount_currency_id_opening_balance' => 'exists:transaction_currencies,id',
|
||||||
'amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id',
|
'amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id',
|
||||||
'what' => 'in:' . $types,
|
'what' => 'in:'.$types,
|
||||||
'interest_period' => 'in:daily,monthly,yearly',
|
'interest_period' => 'in:daily,monthly,yearly',
|
||||||
];
|
];
|
||||||
$rules = Location::requestRules($rules);
|
$rules = Location::requestRules($rules);
|
||||||
@ -122,7 +123,7 @@ class AccountFormRequest extends FormRequest
|
|||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
// add rules:
|
// add rules:
|
||||||
$rules['id'] = 'belongsToUser:accounts';
|
$rules['id'] = 'belongsToUser:accounts';
|
||||||
$rules['name'] = 'required|min:1|uniqueAccountForUser:' . $account->id;
|
$rules['name'] = 'required|min:1|uniqueAccountForUser:'.$account->id;
|
||||||
$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];
|
$rules['iban'] = ['iban', 'nullable', new UniqueIban($account, $account->accountType->type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AttachmentFormRequest.php
|
* AttachmentFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillStoreRequest.php
|
* BillStoreRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillUpdateRequest.php
|
* BillUpdateRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetFormStoreRequest.php
|
* BudgetFormStoreRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetFormRequest.php
|
* BudgetFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -69,7 +70,7 @@ class BudgetFormUpdateRequest extends FormRequest
|
|||||||
$budget = $this->route()->parameter('budget');
|
$budget = $this->route()->parameter('budget');
|
||||||
|
|
||||||
if (null !== $budget) {
|
if (null !== $budget) {
|
||||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,' . $budget->id;
|
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,'.$budget->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetIncomeRequest.php
|
* BudgetIncomeRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BulkEditJournalRequest.php
|
* BulkEditJournalRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CategoryFormRequest.php
|
* CategoryFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -60,7 +61,7 @@ class CategoryFormRequest extends FormRequest
|
|||||||
$category = $this->route()->parameter('category');
|
$category = $this->route()->parameter('category');
|
||||||
|
|
||||||
if (null !== $category) {
|
if (null !== $category) {
|
||||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,' . $category->id;
|
$nameRule = 'required|between:1,100|uniqueObjectForUser:categories,name,'.$category->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixed
|
// fixed
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConfigurationRequest.php
|
* ConfigurationRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CurrencyFormRequest.php
|
* CurrencyFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteAccountFormRequest.php
|
* DeleteAccountFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmailFormRequest.php
|
* EmailFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JournalLinkRequest.php
|
* JournalLinkRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -45,7 +46,7 @@ class JournalLinkRequest extends FormRequest
|
|||||||
$return = [];
|
$return = [];
|
||||||
$linkType = $this->get('link_type');
|
$linkType = $this->get('link_type');
|
||||||
$parts = explode('_', $linkType);
|
$parts = explode('_', $linkType);
|
||||||
$return['link_type_id'] = (int) $parts[0];
|
$return['link_type_id'] = (int)$parts[0];
|
||||||
$return['transaction_journal_id'] = $this->convertInteger('opposing');
|
$return['transaction_journal_id'] = $this->convertInteger('opposing');
|
||||||
$return['notes'] = $this->convertString('notes');
|
$return['notes'] = $this->convertString('notes');
|
||||||
$return['direction'] = $parts[1];
|
$return['direction'] = $parts[1];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LinkTypeFormRequest.php
|
* LinkTypeFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MassDeleteJournalRequest.php
|
* MassDeleteJournalRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MassEditJournalRequest.php
|
* MassEditJournalRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NewUserFormRequest.php
|
* NewUserFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ObjectGroupFormRequest.php
|
* ObjectGroupFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PiggyBankStoreRequest.php
|
* PiggyBankStoreRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PiggyBankUpdateRequest.php
|
* PiggyBankUpdateRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProfileFormRequest.php
|
* ProfileFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -191,7 +191,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
$rules = [
|
$rules = [
|
||||||
// mandatory info for recurrence.
|
// mandatory info for recurrence.
|
||||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||||
'first_date' => 'required|date|after:' . $today->format('Y-m-d'),
|
'first_date' => 'required|date|after:'.$today->format('Y-m-d'),
|
||||||
'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],
|
'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],
|
||||||
'skip' => 'required|numeric|integer|gte:0|lte:31',
|
'skip' => 'required|numeric|integer|gte:0|lte:31',
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
|
|
||||||
// if ends at date X, set another rule.
|
// if ends at date X, set another rule.
|
||||||
if ('until_date' === $this->convertString('repetition_end')) {
|
if ('until_date' === $this->convertString('repetition_end')) {
|
||||||
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
|
$rules['repeat_until'] = 'required|date|after:'.$tomorrow->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
// switch on type to expand rules for source and destination accounts:
|
// switch on type to expand rules for source and destination accounts:
|
||||||
@ -263,7 +263,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
$recurrence = $this->route()->parameter('recurrence');
|
$recurrence = $this->route()->parameter('recurrence');
|
||||||
if ($recurrence instanceof Recurrence) {
|
if ($recurrence instanceof Recurrence) {
|
||||||
$rules['id'] = 'required|numeric|exists:recurrences,id';
|
$rules['id'] = 'required|numeric|exists:recurrences,id';
|
||||||
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;
|
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,'.$recurrence->id;
|
||||||
$rules['first_date'] = 'required|date';
|
$rules['first_date'] = 'required|date';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,16 +314,16 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
default:
|
default:
|
||||||
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
|
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
|
||||||
case 'withdrawal':
|
case 'withdrawal':
|
||||||
$sourceId = (int) $data['source_id'];
|
$sourceId = (int)$data['source_id'];
|
||||||
$destinationId = (int) $data['withdrawal_destination_id'];
|
$destinationId = (int)$data['withdrawal_destination_id'];
|
||||||
break;
|
break;
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
$sourceId = (int) $data['deposit_source_id'];
|
$sourceId = (int)$data['deposit_source_id'];
|
||||||
$destinationId = (int) $data['destination_id'];
|
$destinationId = (int)$data['destination_id'];
|
||||||
break;
|
break;
|
||||||
case 'transfer':
|
case 'transfer':
|
||||||
$sourceId = (int) $data['source_id'];
|
$sourceId = (int)$data['source_id'];
|
||||||
$destinationId = (int) $data['destination_id'];
|
$destinationId = (int)$data['destination_id'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// validate source account.
|
// validate source account.
|
||||||
@ -331,7 +331,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
|
|
||||||
// do something with result:
|
// do something with result:
|
||||||
if (false === $validSource) {
|
if (false === $validSource) {
|
||||||
$message = (string) trans('validation.generic_invalid_source');
|
$message = (string)trans('validation.generic_invalid_source');
|
||||||
$validator->errors()->add('source_id', $message);
|
$validator->errors()->add('source_id', $message);
|
||||||
$validator->errors()->add('deposit_source_id', $message);
|
$validator->errors()->add('deposit_source_id', $message);
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
$validDestination = $accountValidator->validateDestination(['id' => $destinationId,]);
|
$validDestination = $accountValidator->validateDestination(['id' => $destinationId,]);
|
||||||
// do something with result:
|
// do something with result:
|
||||||
if (false === $validDestination) {
|
if (false === $validDestination) {
|
||||||
$message = (string) trans('validation.generic_invalid_destination');
|
$message = (string)trans('validation.generic_invalid_destination');
|
||||||
$validator->errors()->add('destination_id', $message);
|
$validator->errors()->add('destination_id', $message);
|
||||||
$validator->errors()->add('withdrawal_destination_id', $message);
|
$validator->errors()->add('withdrawal_destination_id', $message);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReportFormRequest.php
|
* ReportFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -55,7 +56,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
if (is_array($set)) {
|
if (is_array($set)) {
|
||||||
foreach ($set as $accountId) {
|
foreach ($set as $accountId) {
|
||||||
$account = $repository->find((int) $accountId);
|
$account = $repository->find((int)$accountId);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$collection->push($account);
|
$collection->push($account);
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
if (is_array($set)) {
|
if (is_array($set)) {
|
||||||
foreach ($set as $budgetId) {
|
foreach ($set as $budgetId) {
|
||||||
$budget = $repository->find((int) $budgetId);
|
$budget = $repository->find((int)$budgetId);
|
||||||
if (null !== $budget) {
|
if (null !== $budget) {
|
||||||
$collection->push($budget);
|
$collection->push($budget);
|
||||||
}
|
}
|
||||||
@ -101,7 +102,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
if (is_array($set)) {
|
if (is_array($set)) {
|
||||||
foreach ($set as $categoryId) {
|
foreach ($set as $categoryId) {
|
||||||
$category = $repository->find((int) $categoryId);
|
$category = $repository->find((int)$categoryId);
|
||||||
if (null !== $category) {
|
if (null !== $category) {
|
||||||
$collection->push($category);
|
$collection->push($category);
|
||||||
}
|
}
|
||||||
@ -124,7 +125,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
if (is_array($set)) {
|
if (is_array($set)) {
|
||||||
foreach ($set as $accountId) {
|
foreach ($set as $accountId) {
|
||||||
$account = $repository->find((int) $accountId);
|
$account = $repository->find((int)$accountId);
|
||||||
if (null !== $account) {
|
if (null !== $account) {
|
||||||
$collection->push($account);
|
$collection->push($account);
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
$date = today(config('app.timezone'));
|
$date = today(config('app.timezone'));
|
||||||
$range = $this->get('daterange');
|
$range = $this->get('daterange');
|
||||||
$parts = explode(' - ', (string) $range);
|
$parts = explode(' - ', (string)$range);
|
||||||
if (2 === count($parts)) {
|
if (2 === count($parts)) {
|
||||||
$string = $parts[1];
|
$string = $parts[1];
|
||||||
// validate as date
|
// validate as date
|
||||||
@ -179,7 +180,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
$date = today(config('app.timezone'));
|
$date = today(config('app.timezone'));
|
||||||
$range = $this->get('daterange');
|
$range = $this->get('daterange');
|
||||||
$parts = explode(' - ', (string) $range);
|
$parts = explode(' - ', (string)$range);
|
||||||
if (2 === count($parts)) {
|
if (2 === count($parts)) {
|
||||||
$string = $parts[0];
|
$string = $parts[0];
|
||||||
// validate as date
|
// validate as date
|
||||||
@ -223,7 +224,7 @@ class ReportFormRequest extends FormRequest
|
|||||||
$collection->push($tag);
|
$collection->push($tag);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$tag = $repository->find((int) $tagTag);
|
$tag = $repository->find((int)$tagTag);
|
||||||
if (null !== $tag) {
|
if (null !== $tag) {
|
||||||
$collection->push($tag);
|
$collection->push($tag);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RuleGroupFormRequest.php
|
* RuleGroupFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -68,7 +69,7 @@ class RuleGroupFormRequest extends FormRequest
|
|||||||
$ruleGroup = $this->route()->parameter('ruleGroup');
|
$ruleGroup = $this->route()->parameter('ruleGroup');
|
||||||
|
|
||||||
if (null !== $ruleGroup) {
|
if (null !== $ruleGroup) {
|
||||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id;
|
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SelectTransactionsRequest.php
|
* SelectTransactionsRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -49,8 +50,8 @@ class SelectTransactionsRequest extends FormRequest
|
|||||||
$today = Carbon::now()->addDay()->format('Y-m-d');
|
$today = Carbon::now()->addDay()->format('Y-m-d');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'start' => 'required|date|after:' . $first,
|
'start' => 'required|date|after:'.$first,
|
||||||
'end' => 'required|date|before:' . $today,
|
'end' => 'required|date|before:'.$today,
|
||||||
'accounts' => 'required',
|
'accounts' => 'required',
|
||||||
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
|
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
|
||||||
];
|
];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TagFormRequest.php
|
* TagFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -68,7 +69,7 @@ class TagFormRequest extends FormRequest
|
|||||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
|
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag';
|
||||||
if (null !== $tag) {
|
if (null !== $tag) {
|
||||||
$idRule = 'belongsToUser:tags';
|
$idRule = 'belongsToUser:tags';
|
||||||
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,' . $tag->id;
|
$tagRule = 'required|min:1|uniqueObjectForUser:tags,tag,'.$tag->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestRuleFormRequest.php
|
* TestRuleFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -48,7 +49,7 @@ class TestRuleFormRequest extends FormRequest
|
|||||||
$validTriggers = $this->getTriggers();
|
$validTriggers = $this->getTriggers();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers),
|
'rule-trigger.*' => 'required|min:1|in:'.implode(',', $validTriggers),
|
||||||
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
|
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TokenFormRequest.php
|
* TokenFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
/*
|
/*
|
||||||
* TriggerRecurrenceRequest.php
|
* TriggerRecurrenceRequest.php
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserFormRequest.php
|
* UserFormRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserRegistrationRequest.php
|
* UserRegistrationRequest.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -133,7 +133,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
|||||||
// find budget limit:
|
// find budget limit:
|
||||||
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
|
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
|
||||||
|
|
||||||
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {
|
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int)$autoBudget->auto_budget_type) {
|
||||||
// that's easy: create one.
|
// that's easy: create one.
|
||||||
// do nothing else.
|
// do nothing else.
|
||||||
$this->createBudgetLimit($autoBudget, $start, $end);
|
$this->createBudgetLimit($autoBudget, $start, $end);
|
||||||
@ -142,7 +142,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {
|
if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int)$autoBudget->auto_budget_type) {
|
||||||
// budget limit exists already,
|
// budget limit exists already,
|
||||||
$this->createRollover($autoBudget);
|
$this->createRollover($autoBudget);
|
||||||
Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));
|
Log::debug(sprintf('Done with auto budget #%d', $autoBudget->id));
|
||||||
@ -280,7 +280,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
|||||||
$repository = app(OperationsRepositoryInterface::class);
|
$repository = app(OperationsRepositoryInterface::class);
|
||||||
$repository->setUser($autoBudget->budget->user);
|
$repository->setUser($autoBudget->budget->user);
|
||||||
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
||||||
$currencyId = (int) $autoBudget->transaction_currency_id;
|
$currencyId = (int)$autoBudget->transaction_currency_id;
|
||||||
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
||||||
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
private Carbon $date;
|
private Carbon $date;
|
||||||
private bool $force;
|
private bool $force;
|
||||||
private TransactionGroupRepositoryInterface $groupRepository;
|
private TransactionGroupRepositoryInterface $groupRepository;
|
||||||
private JournalRepositoryInterface $journalRepository;
|
|
||||||
private RecurringRepositoryInterface $repository;
|
|
||||||
private Collection $recurrences;
|
|
||||||
private Collection $groups;
|
private Collection $groups;
|
||||||
|
private JournalRepositoryInterface $journalRepository;
|
||||||
|
private Collection $recurrences;
|
||||||
|
private RecurringRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
@ -97,6 +97,14 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
Log::debug(sprintf('Created new CreateRecurringTransactions("%s")', $this->date->format('Y-m-d')));
|
Log::debug(sprintf('Created new CreateRecurringTransactions("%s")', $this->date->format('Y-m-d')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getGroups(): Collection
|
||||||
|
{
|
||||||
|
return $this->groups;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*/
|
*/
|
||||||
@ -520,12 +528,4 @@ class CreateRecurringTransactions implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$this->recurrences = $recurrences;
|
$this->recurrences = $recurrences;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getGroups(): Collection
|
|
||||||
{
|
|
||||||
return $this->groups;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ class DownloadExchangeRates implements ShouldQueue
|
|||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
|
private array $active;
|
||||||
private Carbon $date;
|
private Carbon $date;
|
||||||
private CurrencyRepositoryInterface $repository;
|
private CurrencyRepositoryInterface $repository;
|
||||||
private array $active;
|
|
||||||
private Collection $users;
|
private Collection $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,16 +91,6 @@ class DownloadExchangeRates implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Carbon $date
|
|
||||||
*/
|
|
||||||
public function setDate(Carbon $date): void
|
|
||||||
{
|
|
||||||
$newDate = clone $date;
|
|
||||||
$newDate->startOfDay();
|
|
||||||
$this->date = $newDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $currency
|
* @param TransactionCurrency $currency
|
||||||
* @return void
|
* @return void
|
||||||
@ -108,7 +98,7 @@ class DownloadExchangeRates implements ShouldQueue
|
|||||||
private function downloadRates(TransactionCurrency $currency): void
|
private function downloadRates(TransactionCurrency $currency): void
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));
|
Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));
|
||||||
$base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);
|
$base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
$url = sprintf('%s/%s.json', $base, $currency->code);
|
$url = sprintf('%s/%s.json', $base, $currency->code);
|
||||||
$res = $client->get($url);
|
$res = $client->get($url);
|
||||||
@ -117,7 +107,7 @@ class DownloadExchangeRates implements ShouldQueue
|
|||||||
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));
|
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$body = (string) $res->getBody();
|
$body = (string)$res->getBody();
|
||||||
$json = json_decode($body, true);
|
$json = json_decode($body, true);
|
||||||
if (false === $json || null === $json) {
|
if (false === $json || null === $json) {
|
||||||
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
|
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
|
||||||
@ -185,4 +175,14 @@ class DownloadExchangeRates implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Carbon $date
|
||||||
|
*/
|
||||||
|
public function setDate(Carbon $date): void
|
||||||
|
{
|
||||||
|
$newDate = clone $date;
|
||||||
|
$newDate->startOfDay();
|
||||||
|
$this->date = $newDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job.php
|
* Job.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MailError.php
|
* MailError.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$email = (string) config('firefly.site_owner');
|
$email = (string)config('firefly.site_owner');
|
||||||
$args = $this->exception;
|
$args = $this->exception;
|
||||||
$args['loggedIn'] = $this->userData['id'] > 0;
|
$args['loggedIn'] = $this->userData['id'] > 0;
|
||||||
$args['user'] = $this->userData;
|
$args['user'] = $this->userData;
|
||||||
@ -83,12 +84,12 @@ class MailError extends Job implements ShouldQueue
|
|||||||
$args,
|
$args,
|
||||||
function (Message $message) use ($email) {
|
function (Message $message) use ($email) {
|
||||||
if ('mail@example.com' !== $email) {
|
if ('mail@example.com' !== $email) {
|
||||||
$message->to($email, $email)->subject((string) trans('email.error_subject'));
|
$message->to($email, $email)->subject((string)trans('email.error_subject'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Log::error('Exception when mailing: ' . $e->getMessage());
|
Log::error('Exception when mailing: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,6 @@ class AccessTokenCreatedMail extends Mailable
|
|||||||
{
|
{
|
||||||
return $this
|
return $this
|
||||||
->markdown('emails.token-created')
|
->markdown('emails.token-created')
|
||||||
->subject((string) trans('email.access_token_created_subject'));
|
->subject((string)trans('email.access_token_created_subject'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user