Code reordering and reformatting. I should really start employing style CI.

This commit is contained in:
James Cole
2021-09-18 10:26:12 +02:00
parent 9b9d52e99f
commit 4003cea759
344 changed files with 2776 additions and 2605 deletions

View File

@@ -88,8 +88,9 @@ class CurrencyController extends Controller
* https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesCodeAC * https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesCodeAC
* *
* @param AutocompleteRequest $request * @param AutocompleteRequest $request
* @deprecated *
* @return JsonResponse * @return JsonResponse
* @deprecated
*/ */
public function currenciesWithCode(AutocompleteRequest $request): JsonResponse public function currenciesWithCode(AutocompleteRequest $request): JsonResponse
{ {

View File

@@ -58,6 +58,7 @@ class ObjectGroupController extends Controller
/** /**
* Documentation for this endpoint is at: * Documentation for this endpoint is at:
* https://api-docs.firefly-iii.org/#/autocomplete/getObjectGroupsAC * https://api-docs.firefly-iii.org/#/autocomplete/getObjectGroupsAC
*
* @param AutocompleteRequest $request * @param AutocompleteRequest $request
* *
* @return JsonResponse * @return JsonResponse

View File

@@ -105,9 +105,9 @@ class AccountController extends Controller
foreach ($accounts as $account) { foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account);
if (null === $currency) { if (null === $currency) {
$currency = $default; $currency = $default;
} }
$currentSet = [ $currentSet = [
'label' => $account->name, 'label' => $account->name,
'currency_id' => (string)$currency->id, 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code, 'currency_code' => $currency->code,

View File

@@ -46,8 +46,8 @@ abstract class Controller extends BaseController
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
protected const CONTENT_TYPE = 'application/vnd.api+json'; protected const CONTENT_TYPE = 'application/vnd.api+json';
protected ParameterBag $parameters;
protected array $allowedSort; protected array $allowedSort;
protected ParameterBag $parameters;
/** /**
* Controller constructor. * Controller constructor.
@@ -92,7 +92,7 @@ abstract class Controller extends BaseController
if (null !== $date) { if (null !== $date) {
try { try {
$obj = Carbon::parse($date); $obj = Carbon::parse($date);
} catch (InvalidDateException|InvalidFormatException $e) { } catch (InvalidDateException | InvalidFormatException $e) {
// don't care // don't care
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage())); Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
} }

View File

@@ -58,10 +58,11 @@ class AccountController extends Controller
/** /**
* This endpoint is deprecated and not documented. * This endpoint is deprecated and not documented.
* @deprecated *
* @param MoveTransactionsRequest $request * @param MoveTransactionsRequest $request
* *
* @return JsonResponse * @return JsonResponse
* @deprecated
*/ */
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
{ {

View File

@@ -78,9 +78,9 @@ class ExportController extends Controller
*/ */
private function returnExport(string $key): LaravelResponse private function returnExport(string $key): LaravelResponse
{ {
$date = date('Y-m-d-H-i-s'); $date = date('Y-m-d-H-i-s');
$fileName = sprintf('%s-export-%s.csv', $date, $key); $fileName = sprintf('%s-export-%s.csv', $date, $key);
$data = $this->exporter->export(); $data = $this->exporter->export();
/** @var LaravelResponse $response */ /** @var LaravelResponse $response */
$response = response($data[$key]); $response = response($data[$key]);

View File

@@ -71,6 +71,7 @@ class AccountController extends Controller
$end = $request->getEnd(); $end = $request->getEnd();
$assetAccounts = $request->getAssetAccounts(); $assetAccounts = $request->getAssetAccounts();
$transfers = $this->opsRepository->sumTransfers($start, $end, $assetAccounts); $transfers = $this->opsRepository->sumTransfers($start, $end, $assetAccounts);
return response()->json($transfers); return response()->json($transfers);
} }
} }

View File

@@ -84,7 +84,7 @@ class ShowController extends Controller
$this->parameters->set('type', $type); $this->parameters->set('type', $type);
// types to get, page size: // types to get, page size:
$types = $this->mapAccountTypes($this->parameters->get('type')); $types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it. // get list of accounts. Count it and split it.
@@ -95,7 +95,7 @@ class ShowController extends Controller
// continue sort: // continue sort:
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator: // make paginator:
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page')); $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));

View File

@@ -74,10 +74,10 @@ class UpdateController extends Controller
public function update(UpdateRequest $request, Account $account): JsonResponse public function update(UpdateRequest $request, Account $account): JsonResponse
{ {
Log::debug(sprintf('Now in %s', __METHOD__)); Log::debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData(); $data = $request->getUpdateData();
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type); $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$account = $this->repository->update($account, $data); $account = $this->repository->update($account, $data);
$manager = $this->getManager(); $manager = $this->getManager();
$account->refresh(); $account->refresh();
Preferences::mark(); Preferences::mark();

View File

@@ -49,7 +49,7 @@ class DestroyController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class); $this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -52,7 +52,7 @@ class UpdateController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class); $this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -47,7 +47,7 @@ class DestroyController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class); $this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user); $this->abRepository->setUser($user);

View File

@@ -69,8 +69,8 @@ class StoreController extends Controller
*/ */
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$bill = $this->repository->store($data); $bill = $this->repository->store($data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var BillTransformer $transformer */ /** @var BillTransformer $transformer */

View File

@@ -66,8 +66,8 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, Bill $bill): JsonResponse public function update(UpdateRequest $request, Bill $bill): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$bill = $this->repository->update($bill, $data); $bill = $this->repository->update($bill, $data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var BillTransformer $transformer */ /** @var BillTransformer $transformer */

View File

@@ -53,7 +53,7 @@ class ShowController extends Controller
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class); $this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user()); $this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user()); $this->blRepository->setUser(auth()->user());

View File

@@ -66,9 +66,9 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, Category $category): JsonResponse public function update(UpdateRequest $request, Category $category): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$category = $this->repository->update($category, $data); $category = $this->repository->update($category, $data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var CategoryTransformer $transformer */ /** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class); $transformer = app(CategoryTransformer::class);

View File

@@ -47,7 +47,7 @@ class DestroyController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class); $this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -53,7 +53,7 @@ class ListController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class); $this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -50,7 +50,7 @@ class UpdateController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class); $this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user); $this->repository->setUser($user);

View File

@@ -66,7 +66,7 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$piggyBank = $this->repository->update($piggyBank, $data); $piggyBank = $this->repository->update($piggyBank, $data);
if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) { if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) {

View File

@@ -66,9 +66,9 @@ class StoreController extends Controller
*/ */
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$recurrence = $this->repository->store($data); $recurrence = $this->repository->store($data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var RecurrenceTransformer $transformer */ /** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class); $transformer = app(RecurrenceTransformer::class);

View File

@@ -66,9 +66,9 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$recurrence = $this->repository->update($recurrence, $data); $recurrence = $this->repository->update($recurrence, $data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var RecurrenceTransformer $transformer */ /** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class); $transformer = app(RecurrenceTransformer::class);

View File

@@ -68,7 +68,7 @@ class StoreController extends Controller
*/ */
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$rule = $this->ruleRepository->store($request->getAll()); $rule = $this->ruleRepository->store($request->getAll());
$manager = $this->getManager(); $manager = $this->getManager();
/** @var RuleTransformer $transformer */ /** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class); $transformer = app(RuleTransformer::class);

View File

@@ -70,8 +70,8 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, Rule $rule): JsonResponse public function update(UpdateRequest $request, Rule $rule): JsonResponse
{ {
$data = $request->getAll(); $data = $request->getAll();
$rule = $this->ruleRepository->update($rule, $data); $rule = $this->ruleRepository->update($rule, $data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var RuleTransformer $transformer */ /** @var RuleTransformer $transformer */

View File

@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
class StoreController extends Controller class StoreController extends Controller
{ {
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private RuleGroupRepositoryInterface $ruleGroupRepository; private RuleGroupRepositoryInterface $ruleGroupRepository;
/** /**

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup; namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup;
use Exception;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TestRequest; use FireflyIII\Api\V1\Requests\Models\RuleGroup\TestRequest;
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TriggerRequest; use FireflyIII\Api\V1\Requests\Models\RuleGroup\TriggerRequest;
@@ -36,7 +37,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;
use Exception;
/** /**
* Class TriggerController * Class TriggerController

View File

@@ -68,7 +68,7 @@ class StoreController extends Controller
*/ */
public function store(StoreRequest $request): JsonResponse public function store(StoreRequest $request): JsonResponse
{ {
$rule = $this->repository->store($request->getAll()); $rule = $this->repository->store($request->getAll());
$manager = $this->getManager(); $manager = $this->getManager();
/** @var TagTransformer $transformer */ /** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class); $transformer = app(TagTransformer::class);

View File

@@ -70,7 +70,7 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, Tag $tag): JsonResponse public function update(UpdateRequest $request, Tag $tag): JsonResponse
{ {
$rule = $this->repository->update($tag, $request->getAll()); $rule = $this->repository->update($tag, $request->getAll());
$manager = $this->getManager(); $manager = $this->getManager();
/** @var TagTransformer $transformer */ /** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class); $transformer = app(TagTransformer::class);

View File

@@ -94,16 +94,16 @@ class StoreController extends Controller
$validator = Validator::make( $validator = Validator::make(
['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction] ['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction]
); );
throw new ValidationException($validator,0, $e); throw new ValidationException($validator, 0, $e);
} catch (FireflyException $e) { } catch (FireflyException $e) {
Log::warning('Caught an exception. Return error message.'); Log::warning('Caught an exception. Return error message.');
Log::error($e->getMessage()); Log::error($e->getMessage());
$message = sprintf('Internal exception: %s', $e->getMessage()); $message = sprintf('Internal exception: %s', $e->getMessage());
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction]); $validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction]);
throw new ValidationException($validator,0, $e); throw new ValidationException($validator, 0, $e);
} }
app('preferences')->mark(); app('preferences')->mark();
$applyRules = $data['apply_rules'] ?? true; $applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true; $fireWebhooks = $data['fire_webhooks'] ?? true;
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks)); event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));

View File

@@ -80,7 +80,7 @@ class UpdateController extends Controller
$manager = $this->getManager(); $manager = $this->getManager();
app('preferences')->mark(); app('preferences')->mark();
$applyRules = $data['apply_rules'] ?? true; $applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true; $fireWebhooks = $data['fire_webhooks'] ?? true;
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks)); event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
@@ -98,7 +98,7 @@ class UpdateController extends Controller
$selectedGroup = $collector->getGroups()->first(); $selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) { if (null === $selectedGroup) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
/** @var TransactionGroupTransformer $transformer */ /** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class); $transformer = app(TransactionGroupTransformer::class);

View File

@@ -50,7 +50,7 @@ class DestroyController extends Controller
parent::__construct(); parent::__construct();
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class); $this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class); $this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user()); $this->repository->setUser(auth()->user());
@@ -75,13 +75,13 @@ class DestroyController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) { if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied: // access denied:
throw new FireflyException('200005: You need the "owner" role to do this.'); throw new FireflyException('200005: You need the "owner" role to do this.');
} }
if ($this->repository->currencyInUse($currency)) { if ($this->repository->currencyInUse($currency)) {
throw new FireflyException('200006: Currency in use.'); throw new FireflyException('200006: Currency in use.');
} }
if ($this->repository->isFallbackCurrency($currency)) { if ($this->repository->isFallbackCurrency($currency)) {
throw new FireflyException('200026: Currency is fallback.'); throw new FireflyException('200026: Currency is fallback.');
} }
$this->repository->destroy($currency); $this->repository->destroy($currency);

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\UpdateRequest; use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\UpdateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -33,6 +34,7 @@ use FireflyIII\Support\Http\Api\AccountFilter;
use FireflyIII\Support\Http\Api\TransactionFilter; use FireflyIII\Support\Http\Api\TransactionFilter;
use FireflyIII\Transformers\CurrencyTransformer; use FireflyIII\Transformers\CurrencyTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use JsonException;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
/** /**
@@ -126,7 +128,7 @@ class UpdateController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return JsonResponse * @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function makeDefault(TransactionCurrency $currency): JsonResponse public function makeDefault(TransactionCurrency $currency): JsonResponse
@@ -157,8 +159,8 @@ class UpdateController extends Controller
* @param TransactionCurrency $currency * @param TransactionCurrency $currency
* *
* @return JsonResponse * @return JsonResponse
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
* @throws \JsonException * @throws JsonException
*/ */
public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse
{ {

View File

@@ -84,8 +84,8 @@ class ShowController extends Controller
$linkType = $this->repository->findByName($name); $linkType = $this->repository->findByName($name);
// get list of transaction links. Count it and split it. // get list of transaction links. Count it and split it.
$collection = $this->repository->getJournalLinks($linkType); $collection = $this->repository->getJournalLinks($linkType);
$count = $collection->count(); $count = $collection->count();
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator: // make paginator:

View File

@@ -80,7 +80,7 @@ class StoreController extends Controller
$admin = auth()->user(); $admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) { if (!$this->userRepository->hasRole($admin, 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); throw new FireflyException('200005: You need the "owner" role to do this.');
} }
$data = $request->getAll(); $data = $request->getAll();
// if currency ID is 0, find the currency by the code: // if currency ID is 0, find the currency by the code:

View File

@@ -86,7 +86,7 @@ class UpdateController extends Controller
$admin = auth()->user(); $admin = auth()->user();
if (!$this->userRepository->hasRole($admin, 'owner')) { if (!$this->userRepository->hasRole($admin, 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); throw new FireflyException('200005: You need the "owner" role to do this.');
} }
$data = $request->getAll(); $data = $request->getAll();

View File

@@ -162,7 +162,7 @@ class ConfigurationController extends Controller
public function update(UpdateRequest $request, string $name): JsonResponse public function update(UpdateRequest $request, string $name): JsonResponse
{ {
if (!$this->repository->hasRole(auth()->user(), 'owner')) { if (!$this->repository->hasRole(auth()->user(), 'owner')) {
throw new FireflyException('200005: You need the "owner" role to do this.'); throw new FireflyException('200005: You need the "owner" role to do this.');
} }
$data = $request->getAll(); $data = $request->getAll();
$shortName = str_replace('configuration.', '', $name); $shortName = str_replace('configuration.', '', $name);

View File

@@ -83,7 +83,7 @@ class UserController extends Controller
return response()->json([], 204); return response()->json([], 204);
} }
throw new FireflyException('200025: No access to function.'); throw new FireflyException('200025: No access to function.');
} }
/** /**

View File

@@ -67,11 +67,11 @@ class ShowController extends Controller
*/ */
public function index(): JsonResponse public function index(): JsonResponse
{ {
$manager = $this->getManager(); $manager = $this->getManager();
$collection = $this->repository->all(); $collection = $this->repository->all();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data; $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$count = $collection->count(); $count = $collection->count();
$webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator: // make paginator:
$paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page')); $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));

View File

@@ -61,7 +61,7 @@ class StoreController extends Controller
*/ */
public function store(CreateRequest $request): JsonResponse public function store(CreateRequest $request): JsonResponse
{ {
$data = $request->getData(); $data = $request->getData();
$webhook = $this->repository->store($data); $webhook = $this->repository->store($data);
$manager = $this->getManager(); $manager = $this->getManager();
/** @var WebhookTransformer $transformer */ /** @var WebhookTransformer $transformer */

View File

@@ -71,7 +71,7 @@ class UpdateRequest extends FormRequest
'currency_id' => ['currency_id', 'integer'], 'currency_id' => ['currency_id', 'integer'],
'currency_code' => ['currency_code', 'string'], 'currency_code' => ['currency_code', 'string'],
'liability_direction' => ['liability_direction', 'string'], 'liability_direction' => ['liability_direction', 'string'],
'liability_amount' => ['liability_amount', 'string'], 'liability_amount' => ['liability_amount', 'string'],
'liability_start_date' => ['liability_start_date', 'date'], 'liability_start_date' => ['liability_start_date', 'date'],
]; ];
/** @var Account $account */ /** @var Account $account */

View File

@@ -78,6 +78,7 @@ class UpdateRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
$budget = $this->route()->parameter('budget'); $budget = $this->route()->parameter('budget');
return [ return [
'name' => sprintf('between:1,100|uniqueObjectForUser:budgets,name,%d', $budget->id), 'name' => sprintf('between:1,100|uniqueObjectForUser:budgets,name,%d', $budget->id),
'active' => [new IsBoolean], 'active' => [new IsBoolean],

View File

@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest
* Configure the validator instance with special rules for after the basic validation rules. * Configure the validator instance with special rules for after the basic validation rules.
* *
* @param Validator $validator * @param Validator $validator
* See reference nr. 72 * See reference nr. 72
* *
* @return void * @return void
*/ */

View File

@@ -65,7 +65,7 @@ class UpdateRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
$tag = $this->route()->parameter('tagOrId'); $tag = $this->route()->parameter('tagOrId');
// See reference nr. 73 // See reference nr. 73
$rules = [ $rules = [
'tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id, 'tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id,
'description' => 'min:1|nullable', 'description' => 'min:1|nullable',

View File

@@ -53,6 +53,7 @@ class StoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
Log::debug('get all data in TransactionStoreRequest'); Log::debug('get all data in TransactionStoreRequest');
return [ return [
'group_title' => $this->string('group_title'), 'group_title' => $this->string('group_title'),
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'), 'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
@@ -60,7 +61,7 @@ class StoreRequest extends FormRequest
'fire_webhooks' => $this->boolean('fire_webhooks', true), 'fire_webhooks' => $this->boolean('fire_webhooks', true),
'transactions' => $this->getTransactionData(), 'transactions' => $this->getTransactionData(),
]; ];
// See reference nr. 71 // See reference nr. 71
} }
/** /**

View File

@@ -55,7 +55,7 @@ class UpdateRequest extends FormRequest
]; ];
return $this->getAllData($fields); return $this->getAllData($fields);
// return $return; // return $return;
} }
/** /**

View File

@@ -57,7 +57,7 @@ class UpdateRequest extends FormRequest
return ['value' => $this->integer('value')]; return ['value' => $this->integer('value')];
} }
return ['value' => $this->string('value')]; return ['value' => $this->string('value')];
} }
/** /**
@@ -80,6 +80,6 @@ class UpdateRequest extends FormRequest
return ['value' => 'required|numeric|min:464272080']; return ['value' => 'required|numeric|min:464272080'];
} }
return ['value' => 'required']; return ['value' => 'required'];
} }
} }

View File

@@ -76,7 +76,7 @@ class CorrectDatabase extends Command
'firefly-iii:fix-recurring-transactions', 'firefly-iii:fix-recurring-transactions',
'firefly-iii:restore-oauth-keys', 'firefly-iii:restore-oauth-keys',
'firefly-iii:fix-transaction-types', 'firefly-iii:fix-transaction-types',
'firefly-iii:fix-frontpage-accounts' 'firefly-iii:fix-frontpage-accounts',
]; ];
foreach ($commands as $command) { foreach ($commands as $command) {
$this->line(sprintf('Now executing %s', $command)); $this->line(sprintf('Now executing %s', $command));

View File

@@ -106,7 +106,7 @@ class DeleteOrphanedTransactions extends Command
private function deleteFromOrphanedAccounts(): void private function deleteFromOrphanedAccounts(): void
{ {
$set $set
= Transaction = Transaction
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id') ::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
->whereNotNull('accounts.deleted_at') ->whereNotNull('accounts.deleted_at')
->get(['transactions.*']); ->get(['transactions.*']);

View File

@@ -53,9 +53,9 @@ class DeleteZeroAmount extends Command
*/ */
public function handle(): int public function handle(): int
{ {
$start = microtime(true); $start = microtime(true);
$set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); $set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
$set = array_unique($set); $set = array_unique($set);
$journals = TransactionJournal::whereIn('id', $set)->get(); $journals = TransactionJournal::whereIn('id', $set)->get();
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {

View File

@@ -85,8 +85,8 @@ class EnableCurrencies extends Command
$found[] = (int)$entry->transaction_currency_id; $found[] = (int)$entry->transaction_currency_id;
} }
$found = array_values(array_unique($found)); $found = array_values(array_unique($found));
$found = array_values( $found = array_values(
array_filter( array_filter(
$found, function (int $currencyId) { $found, function (int $currencyId) {
return $currencyId !== 0; return $currencyId !== 0;

View File

@@ -57,7 +57,7 @@ class FixPiggies extends Command
{ {
$count = 0; $count = 0;
$start = microtime(true); $start = microtime(true);
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get(); $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
/** @var PiggyBankEvent $event */ /** @var PiggyBankEvent $event */
foreach ($set as $event) { foreach ($set as $event) {

View File

@@ -125,7 +125,7 @@ class FixPostgresSequences extends Command
$highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first(); $highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first();
$nextId = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); $nextId = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first();
if(null === $nextId) { if (null === $nextId) {
$this->line(sprintf('nextval is NULL for table "%s", go to next table.', $tableToCheck)); $this->line(sprintf('nextval is NULL for table "%s", go to next table.', $tableToCheck));
continue; continue;
} }

View File

@@ -91,7 +91,7 @@ class FixUnevenAmount extends Command
// one of the transactions is bad. // one of the transactions is bad.
$journal = TransactionJournal::find($param); $journal = TransactionJournal::find($param);
if (!$journal) { if (!$journal) {
return; return;
} }
/** @var Transaction $source */ /** @var Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first(); $source = $journal->transactions()->where('amount', '<', 0)->first();

View File

@@ -36,7 +36,6 @@ use FireflyIII\Support\Export\ExportDataGenerator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use InvalidArgumentException; use InvalidArgumentException;
use League\Csv\CannotInsertRecord;
use Log; use Log;
/** /**

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use JsonException;
/** /**
* Class BudgetLimitCurrency * Class BudgetLimitCurrency
@@ -51,7 +52,7 @@ class BudgetLimitCurrency extends Command
* *
* @return int * @return int
* @throws FireflyException * @throws FireflyException
* @throws \JsonException * @throws JsonException
*/ */
public function handle(): int public function handle(): int
{ {
@@ -106,7 +107,7 @@ class BudgetLimitCurrency extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -104,7 +104,7 @@ class CCLiabilities extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -116,7 +116,7 @@ class MigrateAttachments extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -66,7 +66,7 @@ class MigrateJournalNotes extends Command
} }
$count = 0; $count = 0;
$set = TransactionJournalMeta::whereName('notes')->get(); $set = TransactionJournalMeta::whereName('notes')->get();
/** @var TransactionJournalMeta $meta */ /** @var TransactionJournalMeta $meta */
foreach ($set as $meta) { foreach ($set as $meta) {
$journal = $meta->transactionJournal; $journal = $meta->transactionJournal;
@@ -114,7 +114,7 @@ class MigrateJournalNotes extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -92,7 +92,7 @@ class MigrateRecurrenceMeta extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -85,7 +85,7 @@ class MigrateRecurrenceType extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -83,7 +83,7 @@ class MigrateTagLocations extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
private function migrateTagLocations(): void private function migrateTagLocations(): void

View File

@@ -137,7 +137,7 @@ class MigrateToGroups extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -128,7 +128,7 @@ class MigrateToRules extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -123,7 +123,7 @@ class OtherCurrenciesCorrections extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**
@@ -248,10 +248,10 @@ class OtherCurrenciesCorrections extends Command
{ {
$accountId = $account->id; $accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null; return null;
} }
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId]; return $this->accountCurrencies[$accountId];
} }
$currency = $this->accountRepos->getAccountCurrency($account); $currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) { if (null === $currency) {

View File

@@ -107,7 +107,7 @@ class RenameAccountMeta extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**

View File

@@ -191,6 +191,7 @@ class TransactionIdentifier extends Command
return null; return null;
} }
return $opposing; return $opposing;
} }

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade; namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
@@ -132,7 +133,7 @@ class TransferCurrenciesCorrections extends Command
/** /**
* @return bool * @return bool
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
private function isExecuted(): bool private function isExecuted(): bool
{ {
@@ -141,7 +142,7 @@ class TransferCurrenciesCorrections extends Command
return (bool)$configVar->data; return (bool)$configVar->data;
} }
return false; return false;
} }
/** /**
@@ -271,10 +272,10 @@ class TransferCurrenciesCorrections extends Command
{ {
$accountId = $account->id; $accountId = $account->id;
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) { if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
return null; return null;
} }
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) { if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
return $this->accountCurrencies[$accountId]; return $this->accountCurrencies[$accountId];
} }
$currency = $this->accountRepos->getAccountCurrency($account); $currency = $this->accountRepos->getAccountCurrency($account);
if (null === $currency) { if (null === $currency) {

View File

@@ -106,7 +106,7 @@ class UpgradeDatabase extends Command
// instructions // instructions
'firefly:instructions update', 'firefly:instructions update',
'firefly-iii:verify-security-alerts' 'firefly-iii:verify-security-alerts',
]; ];
$args = []; $args = [];
if ($this->option('force')) { if ($this->option('force')) {

View File

@@ -92,59 +92,6 @@ class UpgradeLiabilities extends Command
return false; return false;
} }
/**
* @param Account $account
* @param TransactionJournal $openingBalance
*/
private function correctOpeningBalance(Account $account, TransactionJournal $openingBalance): void
{
$source = $this->getSourceTransaction($openingBalance);
$destination = $this->getDestinationTransaction($openingBalance);
if (null === $source || null === $destination) {
return;
}
// source MUST be the liability.
if ((int)$destination->account_id === (int)$account->id) {
Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));
// so if not, switch things around:
$sourceAccountId = (int)$source->account_id;
$source->account_id = $destination->account_id;
$destination->account_id = $sourceAccountId;
$source->save();
$destination->save();
Log::debug(sprintf('Source transaction #%d now has account #%d', $source->id, $source->account_id));
Log::debug(sprintf('Dest transaction #%d now has account #%d', $destination->id, $destination->account_id));
}
}
/**
* @param TransactionJournal $journal
*
* @return Transaction|null
*/
private function getSourceTransaction(TransactionJournal $journal): ?Transaction
{
return $journal->transactions()->where('amount', '<', 0)->first();
}
/**
* @param TransactionJournal $journal
*
* @return Transaction|null
*/
private function getDestinationTransaction(TransactionJournal $journal): ?Transaction
{
return $journal->transactions()->where('amount', '>', 0)->first();
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
/** /**
* *
*/ */
@@ -200,4 +147,57 @@ class UpgradeLiabilities extends Command
$factory->crud($account, 'liability_direction', 'debit'); $factory->crud($account, 'liability_direction', 'debit');
} }
/**
* @param Account $account
* @param TransactionJournal $openingBalance
*/
private function correctOpeningBalance(Account $account, TransactionJournal $openingBalance): void
{
$source = $this->getSourceTransaction($openingBalance);
$destination = $this->getDestinationTransaction($openingBalance);
if (null === $source || null === $destination) {
return;
}
// source MUST be the liability.
if ((int)$destination->account_id === (int)$account->id) {
Log::debug(sprintf('Must switch around, because account #%d is the destination.', $destination->account_id));
// so if not, switch things around:
$sourceAccountId = (int)$source->account_id;
$source->account_id = $destination->account_id;
$destination->account_id = $sourceAccountId;
$source->save();
$destination->save();
Log::debug(sprintf('Source transaction #%d now has account #%d', $source->id, $source->account_id));
Log::debug(sprintf('Dest transaction #%d now has account #%d', $destination->id, $destination->account_id));
}
}
/**
* @param TransactionJournal $journal
*
* @return Transaction|null
*/
private function getSourceTransaction(TransactionJournal $journal): ?Transaction
{
return $journal->transactions()->where('amount', '<', 0)->first();
}
/**
* @param TransactionJournal $journal
*
* @return Transaction|null
*/
private function getDestinationTransaction(TransactionJournal $journal): ?Transaction
{
return $journal->transactions()->where('amount', '>', 0)->first();
}
/**
*
*/
private function markAsExecuted(): void
{
app('fireflyconfig')->set(self::CONFIG_NAME, true);
}
} }

View File

@@ -25,14 +25,21 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Storage; use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Log; use Log;
use Storage;
/** /**
* Class VerifySecurityAlerts * Class VerifySecurityAlerts
*/ */
class VerifySecurityAlerts extends Command class VerifySecurityAlerts extends Command
{ {
/**
* The console command description.
*
* @var string
*/
protected $description = 'Verify security alerts';
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *
@@ -40,18 +47,11 @@ class VerifySecurityAlerts extends Command
*/ */
protected $signature = 'firefly-iii:verify-security-alerts'; protected $signature = 'firefly-iii:verify-security-alerts';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Verify security alerts';
/** /**
* Execute the console command. * Execute the console command.
* *
* @return int * @return int
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException * @throws FileNotFoundException
*/ */
public function handle(): int public function handle(): int
{ {
@@ -64,6 +64,7 @@ class VerifySecurityAlerts extends Command
$disk = Storage::disk('resources'); $disk = Storage::disk('resources');
if (!$disk->has('alerts.json')) { if (!$disk->has('alerts.json')) {
Log::debug('No alerts.json file present.'); Log::debug('No alerts.json file present.');
return 0; return 0;
} }
$content = $disk->get('alerts.json'); $content = $disk->get('alerts.json');
@@ -81,6 +82,7 @@ class VerifySecurityAlerts extends Command
if ('info' === $array['level']) { if ('info' === $array['level']) {
Log::debug('INFO level alert'); Log::debug('INFO level alert');
$this->info($array['message']); $this->info($array['message']);
return 0; return 0;
} }
if ('warning' === $array['level']) { if ('warning' === $array['level']) {
@@ -88,6 +90,7 @@ class VerifySecurityAlerts extends Command
$this->warn('------------------------ :o'); $this->warn('------------------------ :o');
$this->warn($array['message']); $this->warn($array['message']);
$this->warn('------------------------ :o'); $this->warn('------------------------ :o');
return 0; return 0;
} }
if ('danger' === $array['level']) { if ('danger' === $array['level']) {
@@ -95,6 +98,7 @@ class VerifySecurityAlerts extends Command
$this->error('------------------------ :-('); $this->error('------------------------ :-(');
$this->error($array['message']); $this->error($array['message']);
$this->error('------------------------ :-('); $this->error('------------------------ :-(');
return 0; return 0;
} }

View File

@@ -41,6 +41,7 @@ class AdminRequestedTestMessage extends Event
public $ipAddress; public $ipAddress;
/** @var User The user */ /** @var User The user */
public $user; public $user;
/** /**
* Create a new event instance. * Create a new event instance.
* *

View File

@@ -37,6 +37,7 @@ class DestroyedTransactionGroup extends Event
use SerializesModels; use SerializesModels;
public TransactionGroup $transactionGroup; public TransactionGroup $transactionGroup;
/** /**
* Create a new event instance. * Create a new event instance.
* *

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
use FireflyIII\Models\TransactionJournalLink; use FireflyIII\Models\TransactionJournalLink;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;

View File

@@ -40,6 +40,7 @@ class RegisteredUser extends Event
public $ipAddress; public $ipAddress;
/** @var User The user */ /** @var User The user */
public $user; public $user;
/** /**
* Create a new event instance. This event is triggered when a new user registers. * Create a new event instance. This event is triggered when a new user registers.
* *

View File

@@ -42,6 +42,7 @@ class RequestedNewPassword extends Event
public $token; public $token;
/** @var User The user */ /** @var User The user */
public $user; public $user;
/** /**
* Create a new event instance. This event is triggered when a users tries to reset his or her password. * Create a new event instance. This event is triggered when a users tries to reset his or her password.
* *

View File

@@ -44,6 +44,7 @@ class RequestedReportOnJournals
public $groups; public $groups;
/** @var int The ID of the user. */ /** @var int The ID of the user. */
public $userId; public $userId;
/** /**
* Create a new event instance. * Create a new event instance.
* *

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Events; namespace FireflyIII\Events;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
class RequestedSendWebhookMessages extends Event class RequestedSendWebhookMessages extends Event
{ {
use SerializesModels; use SerializesModels;

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Events;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
/** /**
* Class RequestedVersionCheckStatus * Class RequestedVersionCheckStatus
* *
@@ -37,6 +38,7 @@ class RequestedVersionCheckStatus extends Event
/** @var User The user */ /** @var User The user */
public $user; public $user;
/** /**
* Create a new event instance. This event is triggered when Firefly III wants to know * Create a new event instance. This event is triggered when Firefly III wants to know
* what the deal is with the version checker. * what the deal is with the version checker.

View File

@@ -44,6 +44,7 @@ class UserChangedEmail extends Event
public $oldEmail; public $oldEmail;
/** @var User The user itself */ /** @var User The user itself */
public $user; public $user;
/** /**
* UserChangedEmail constructor. * UserChangedEmail constructor.
* *

View File

@@ -166,7 +166,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
} }
/** /**
* @param Request $request * @param Request $request
* @param Throwable $exception * @param Throwable $exception
* *
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response * @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response

View File

@@ -49,8 +49,8 @@ class AccountFactory
protected array $validAssetFields; protected array $validAssetFields;
protected array $validCCFields; protected array $validCCFields;
protected array $validFields; protected array $validFields;
private array $canHaveVirtual;
private array $canHaveOpeningBalance; private array $canHaveOpeningBalance;
private array $canHaveVirtual;
private User $user; private User $user;
/** /**

View File

@@ -68,7 +68,7 @@ class AccountMetaFactory
try { try {
$entry->delete(); $entry->delete();
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));
} }
return null; return null;

View File

@@ -54,7 +54,7 @@ class AttachmentFactory
/** @var Transaction $transaction */ /** @var Transaction $transaction */
$transaction = $this->user->transactions()->find((int)$data['attachable_id']); $transaction = $this->user->transactions()->find((int)$data['attachable_id']);
if (null === $transaction) { if (null === $transaction) {
throw new FireflyException('Unexpectedly could not find transaction'); throw new FireflyException('Unexpectedly could not find transaction');
} }
$data['attachable_id'] = $transaction->transaction_journal_id; $data['attachable_id'] = $transaction->transaction_journal_id;
$model = TransactionJournal::class; $model = TransactionJournal::class;

View File

@@ -141,14 +141,6 @@ class RecurrenceFactory
return $recurrence; return $recurrence;
} }
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
/** /**
* @return MessageBag * @return MessageBag
*/ */
@@ -157,5 +149,13 @@ class RecurrenceFactory
return $this->errors; return $this->errors;
} }
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
} }

View File

@@ -50,7 +50,7 @@ class TransactionJournalMetaFactory
try { try {
$entry->delete(); $entry->delete();
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
} }
return null; return null;
@@ -68,7 +68,7 @@ class TransactionJournalMetaFactory
try { try {
$entry->delete(); $entry->delete();
} catch (Exception $e) { // @phpstan-ignore-line } catch (Exception $e) { // @phpstan-ignore-line
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage()));
} }
} }

View File

@@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
use JsonException;
use Log; use Log;
use Throwable; use Throwable;
@@ -195,7 +196,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
* *
* @return array * @return array
* @throws FireflyException * @throws FireflyException
* @throws \JsonException * @throws JsonException
*/ */
#[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string", #[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string",
'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): array 'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): array

View File

@@ -34,7 +34,7 @@ use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
* See reference nr. 19 * See reference nr. 19
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@@ -35,7 +35,7 @@ use Throwable;
/** /**
* Class MonthReportGenerator. * Class MonthReportGenerator.
* See reference nr. 18 * See reference nr. 18
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@@ -50,7 +50,7 @@ class AutomationHandler
$sendReport = config('firefly.send_report_journals'); $sendReport = config('firefly.send_report_journals');
if (false === $sendReport) { if (false === $sendReport) {
return true; return true;
} }
Log::debug('In reportJournals.'); Log::debug('In reportJournals.');

View File

@@ -77,6 +77,18 @@ class StoredGroupEventHandler
$newRuleEngine->fire(); $newRuleEngine->fire();
} }
/**
* @param StoredTransactionGroup $event
*/
public function recalculateCredit(StoredTransactionGroup $event): void
{
$group = $event->transactionGroup;
/** @var CreditRecalculateService $object */
$object = app(CreditRecalculateService::class);
$object->setGroup($group);
$object->recalculate();
}
/** /**
* This method processes all webhooks that respond to the "stored transaction group" trigger (100) * This method processes all webhooks that respond to the "stored transaction group" trigger (100)
* *
@@ -108,16 +120,4 @@ class StoredGroupEventHandler
event(new RequestedSendWebhookMessages); event(new RequestedSendWebhookMessages);
} }
/**
* @param StoredTransactionGroup $event
*/
public function recalculateCredit(StoredTransactionGroup $event): void
{
$group = $event->transactionGroup;
/** @var CreditRecalculateService $object */
$object = app(CreditRecalculateService::class);
$object->setGroup($group);
$object->recalculate();
}
} }

View File

@@ -77,6 +77,18 @@ class UpdatedGroupEventHandler
$newRuleEngine->fire(); $newRuleEngine->fire();
} }
/**
* @param UpdatedTransactionGroup $event
*/
public function recalculateCredit(UpdatedTransactionGroup $event): void
{
$group = $event->transactionGroup;
/** @var CreditRecalculateService $object */
$object = app(CreditRecalculateService::class);
$object->setGroup($group);
$object->recalculate();
}
/** /**
* @param UpdatedTransactionGroup $updatedGroupEvent * @param UpdatedTransactionGroup $updatedGroupEvent
*/ */
@@ -100,18 +112,6 @@ class UpdatedGroupEventHandler
event(new RequestedSendWebhookMessages); event(new RequestedSendWebhookMessages);
} }
/**
* @param UpdatedTransactionGroup $event
*/
public function recalculateCredit(UpdatedTransactionGroup $event): void
{
$group = $event->transactionGroup;
/** @var CreditRecalculateService $object */
$object = app(CreditRecalculateService::class);
$object->setGroup($group);
$object->recalculate();
}
/** /**
* This method will make sure all source / destination accounts are the same. * This method will make sure all source / destination accounts are the same.
* *

View File

@@ -108,6 +108,34 @@ class UserEventHandler
return true; return true;
} }
/**
* @param RegisteredUser $event
*
* @return bool
* @throws FireflyException
*/
public function createGroupMembership(RegisteredUser $event): bool
{
$user = $event->user;
// create a new group.
$group = UserGroup::create(['title' => $user->email]);
$role = UserRole::where('title', UserRole::OWNER)->first();
if (null === $role) {
throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');
}
GroupMembership::create(
[
'user_id' => $user->id,
'user_group_id' => $group->id,
'user_role_id' => $role->id,
]
);
$user->user_group_id = $group->id;
$user->save();
return true;
}
/** /**
* Set the demo user back to English. * Set the demo user back to English.
* *
@@ -251,34 +279,6 @@ class UserEventHandler
return true; return true;
} }
/**
* @param RegisteredUser $event
*
* @return bool
* @throws FireflyException
*/
public function createGroupMembership(RegisteredUser $event): bool
{
$user = $event->user;
// create a new group.
$group = UserGroup::create(['title' => $user->email]);
$role = UserRole::where('title', UserRole::OWNER)->first();
if (null === $role) {
throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?');
}
GroupMembership::create(
[
'user_id' => $user->id,
'user_group_id' => $group->id,
'user_role_id' => $role->id,
]
);
$user->user_group_id = $group->id;
$user->save();
return true;
}
/** /**
* This method will send the user a registration mail, welcoming him or her to Firefly III. * This method will send the user a registration mail, welcoming him or her to Firefly III.
* This message is only sent when the configuration of Firefly III says so. * This message is only sent when the configuration of Firefly III says so.

View File

@@ -61,7 +61,7 @@ class VersionCheckEventHandler
/** @var UserRepositoryInterface $repository */ /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
$user = $event->user; $user = $event->user;
if (!$repository->hasRole($user, 'owner')) { if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.'); Log::debug('User is not admin, done.');
@@ -88,13 +88,14 @@ class VersionCheckEventHandler
/** /**
* @param RequestedVersionCheckStatus $event * @param RequestedVersionCheckStatus $event
*
* @throws FireflyException * @throws FireflyException
*/ */
protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void
{ {
/** @var UserRepositoryInterface $repository */ /** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class); $repository = app(UserRepositoryInterface::class);
$user = $event->user; $user = $event->user;
if (!$repository->hasRole($user, 'owner')) { if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.'); Log::debug('User is not admin, done.');

View File

@@ -216,9 +216,9 @@ trait AccountCollection
$this->query->leftJoin('account_types as dest_account_type', 'dest_account_type.id', '=', 'dest_account.account_type_id'); $this->query->leftJoin('account_types as dest_account_type', 'dest_account_type.id', '=', 'dest_account.account_type_id');
// and add fields: // and add fields:
$this->fields[] = 'dest_account.name as destination_account_name'; $this->fields[] = 'dest_account.name as destination_account_name';
$this->fields[] = 'dest_account.iban as destination_account_iban'; $this->fields[] = 'dest_account.iban as destination_account_iban';
$this->fields[] = 'dest_account_type.type as destination_account_type'; $this->fields[] = 'dest_account_type.type as destination_account_type';
$this->hasAccountInfo = true; $this->hasAccountInfo = true;
} }

View File

@@ -198,6 +198,16 @@ class GroupCollector implements GroupCollectorInterface
return $this; return $this;
} }
/**
* @inheritDoc
*/
public function findNothing(): GroupCollectorInterface
{
$this->query->where('transaction_groups.id', -1);
return $this;
}
/** /**
* Return the transaction journals without group information. Is useful in some instances. * Return the transaction journals without group information. Is useful in some instances.
* *
@@ -767,14 +777,4 @@ class GroupCollector implements GroupCollectorInterface
return $groups; return $groups;
} }
/**
* @inheritDoc
*/
public function findNothing(): GroupCollectorInterface
{
$this->query->where('transaction_groups.id', -1);
return $this;
}
} }

View File

@@ -57,13 +57,6 @@ interface GroupCollectorInterface
*/ */
public function amountLess(string $amount): GroupCollectorInterface; public function amountLess(string $amount): GroupCollectorInterface;
/**
* Ensure the search will find nothing at all, zero results.
*
* @return GroupCollectorInterface
*/
public function findNothing(): GroupCollectorInterface;
/** /**
* Get transactions where the amount is more than. * Get transactions where the amount is more than.
* *
@@ -118,6 +111,13 @@ interface GroupCollectorInterface
*/ */
public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface; public function excludeSourceAccounts(Collection $accounts): GroupCollectorInterface;
/**
* Ensure the search will find nothing at all, zero results.
*
* @return GroupCollectorInterface
*/
public function findNothing(): GroupCollectorInterface;
/** /**
* Return the transaction journals without group information. Is useful in some instances. * Return the transaction journals without group information. Is useful in some instances.
* *
@@ -478,6 +478,13 @@ interface GroupCollectorInterface
*/ */
public function withAttachmentInformation(): GroupCollectorInterface; public function withAttachmentInformation(): GroupCollectorInterface;
/**
* Limit results to transactions without a bill..
*
* @return GroupCollectorInterface
*/
public function withBill(): GroupCollectorInterface;
/** /**
* Include bill name + ID. * Include bill name + ID.
* *
@@ -527,13 +534,6 @@ interface GroupCollectorInterface
*/ */
public function withTagInformation(): GroupCollectorInterface; public function withTagInformation(): GroupCollectorInterface;
/**
* Limit results to transactions without a bill..
*
* @return GroupCollectorInterface
*/
public function withBill(): GroupCollectorInterface;
/** /**
* Limit results to a transactions without a bill. * Limit results to a transactions without a bill.
* *

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Fiscal; namespace FireflyIII\Helpers\Fiscal;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use Log; use Log;
/** /**
@@ -67,7 +68,7 @@ class FiscalHelper implements FiscalHelperInterface
* @param Carbon $date * @param Carbon $date
* *
* @return Carbon date object * @return Carbon date object
* @throws \FireflyIII\Exceptions\FireflyException * @throws FireflyException
*/ */
public function startOfFiscalYear(Carbon $date): Carbon public function startOfFiscalYear(Carbon $date): Carbon
{ {

View File

@@ -96,7 +96,7 @@ class Help implements HelpInterface
if ('' !== $content) { if ('' !== $content) {
Log::debug('Content is longer than zero. Expect something.'); Log::debug('Content is longer than zero. Expect something.');
$converter = new CommonMarkConverter(); $converter = new CommonMarkConverter();
$content = (string) $converter->convertToHtml($content); $content = (string)$converter->convertToHtml($content);
} }
return $content; return $content;

View File

@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use JsonException;
use Log; use Log;
/** /**
@@ -62,7 +63,7 @@ class NetWorth implements NetWorthInterface
* @param Carbon $date * @param Carbon $date
* *
* @return array * @return array
* @throws \JsonException * @throws JsonException
*/ */
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array
{ {
@@ -73,7 +74,7 @@ class NetWorth implements NetWorthInterface
$cache->addProperty('net-worth-by-currency'); $cache->addProperty('net-worth-by-currency');
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray())); $cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
if ($cache->has()) { if ($cache->has()) {
return $cache->get(); return $cache->get();
} }
$netWorth = []; $netWorth = [];

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