mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code reordering and reformatting. I should really start employing style CI.
This commit is contained in:
parent
9b9d52e99f
commit
4003cea759
@ -88,8 +88,9 @@ class CurrencyController extends Controller
|
||||
* https://api-docs.firefly-iii.org/#/autocomplete/getCurrenciesCodeAC
|
||||
*
|
||||
* @param AutocompleteRequest $request
|
||||
* @deprecated
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @deprecated
|
||||
*/
|
||||
public function currenciesWithCode(AutocompleteRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ class ObjectGroupController extends Controller
|
||||
/**
|
||||
* Documentation for this endpoint is at:
|
||||
* https://api-docs.firefly-iii.org/#/autocomplete/getObjectGroupsAC
|
||||
*
|
||||
* @param AutocompleteRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
|
@ -105,9 +105,9 @@ class AccountController extends Controller
|
||||
foreach ($accounts as $account) {
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = $default;
|
||||
$currency = $default;
|
||||
}
|
||||
$currentSet = [
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
'currency_id' => (string)$currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
|
@ -46,8 +46,8 @@ abstract class Controller extends BaseController
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
protected const CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected ParameterBag $parameters;
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@ -92,7 +92,7 @@ abstract class Controller extends BaseController
|
||||
if (null !== $date) {
|
||||
try {
|
||||
$obj = Carbon::parse($date);
|
||||
} catch (InvalidDateException|InvalidFormatException $e) {
|
||||
} catch (InvalidDateException | InvalidFormatException $e) {
|
||||
// don't care
|
||||
Log::error(sprintf('Invalid date exception in API controller: %s', $e->getMessage()));
|
||||
}
|
||||
|
@ -58,10 +58,11 @@ class AccountController extends Controller
|
||||
|
||||
/**
|
||||
* This endpoint is deprecated and not documented.
|
||||
* @deprecated
|
||||
*
|
||||
* @param MoveTransactionsRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @deprecated
|
||||
*/
|
||||
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
|
||||
{
|
||||
|
@ -78,9 +78,9 @@ class ExportController extends Controller
|
||||
*/
|
||||
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);
|
||||
$data = $this->exporter->export();
|
||||
$data = $this->exporter->export();
|
||||
|
||||
/** @var LaravelResponse $response */
|
||||
$response = response($data[$key]);
|
||||
|
@ -71,6 +71,7 @@ class AccountController extends Controller
|
||||
$end = $request->getEnd();
|
||||
$assetAccounts = $request->getAssetAccounts();
|
||||
$transfers = $this->opsRepository->sumTransfers($start, $end, $assetAccounts);
|
||||
|
||||
return response()->json($transfers);
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class ShowController extends Controller
|
||||
$this->parameters->set('type', $type);
|
||||
|
||||
// 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;
|
||||
|
||||
// get list of accounts. Count it and split it.
|
||||
@ -95,7 +95,7 @@ class ShowController extends Controller
|
||||
// continue sort:
|
||||
|
||||
|
||||
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
|
||||
|
@ -74,10 +74,10 @@ class UpdateController extends Controller
|
||||
public function update(UpdateRequest $request, Account $account): JsonResponse
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$data = $request->getUpdateData();
|
||||
$data = $request->getUpdateData();
|
||||
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
|
||||
$account = $this->repository->update($account, $data);
|
||||
$manager = $this->getManager();
|
||||
$account = $this->repository->update($account, $data);
|
||||
$manager = $this->getManager();
|
||||
$account->refresh();
|
||||
Preferences::mark();
|
||||
|
||||
|
@ -49,7 +49,7 @@ class DestroyController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
@ -52,7 +52,7 @@ class UpdateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->repository = app(AttachmentRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
@ -47,7 +47,7 @@ class DestroyController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
|
||||
$this->abRepository->setUser($user);
|
||||
|
||||
|
@ -69,8 +69,8 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->store($data);
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->store($data);
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var BillTransformer $transformer */
|
||||
|
@ -66,8 +66,8 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Bill $bill): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->update($bill, $data);
|
||||
$data = $request->getAll();
|
||||
$bill = $this->repository->update($bill, $data);
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var BillTransformer $transformer */
|
||||
|
@ -53,7 +53,7 @@ class ShowController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||
$this->repository->setUser(auth()->user());
|
||||
$this->blRepository->setUser(auth()->user());
|
||||
|
@ -66,9 +66,9 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Category $category): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$data = $request->getAll();
|
||||
$category = $this->repository->update($category, $data);
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var CategoryTransformer $transformer */
|
||||
$transformer = app(CategoryTransformer::class);
|
||||
|
@ -47,7 +47,7 @@ class DestroyController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ListController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
@ -50,7 +50,7 @@ class UpdateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$user = auth()->user();
|
||||
$this->repository = app(ObjectGroupRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$data = $request->getAll();
|
||||
$piggyBank = $this->repository->update($piggyBank, $data);
|
||||
|
||||
if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) {
|
||||
|
@ -66,9 +66,9 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$data = $request->getAll();
|
||||
$recurrence = $this->repository->store($data);
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
$transformer = app(RecurrenceTransformer::class);
|
||||
|
@ -66,9 +66,9 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$data = $request->getAll();
|
||||
$recurrence = $this->repository->update($recurrence, $data);
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
$transformer = app(RecurrenceTransformer::class);
|
||||
|
@ -68,7 +68,7 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$rule = $this->ruleRepository->store($request->getAll());
|
||||
$rule = $this->ruleRepository->store($request->getAll());
|
||||
$manager = $this->getManager();
|
||||
/** @var RuleTransformer $transformer */
|
||||
$transformer = app(RuleTransformer::class);
|
||||
|
@ -70,8 +70,8 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Rule $rule): JsonResponse
|
||||
{
|
||||
$data = $request->getAll();
|
||||
$rule = $this->ruleRepository->update($rule, $data);
|
||||
$data = $request->getAll();
|
||||
$rule = $this->ruleRepository->update($rule, $data);
|
||||
$manager = $this->getManager();
|
||||
|
||||
/** @var RuleTransformer $transformer */
|
||||
|
@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
|
||||
class StoreController extends Controller
|
||||
{
|
||||
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private RuleGroupRepositoryInterface $ruleGroupRepository;
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Controllers\Models\RuleGroup;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TestRequest;
|
||||
use FireflyIII\Api\V1\Requests\Models\RuleGroup\TriggerRequest;
|
||||
@ -36,7 +37,6 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection as FractalCollection;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class TriggerController
|
||||
|
@ -68,7 +68,7 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$rule = $this->repository->store($request->getAll());
|
||||
$rule = $this->repository->store($request->getAll());
|
||||
$manager = $this->getManager();
|
||||
/** @var TagTransformer $transformer */
|
||||
$transformer = app(TagTransformer::class);
|
||||
|
@ -70,7 +70,7 @@ class UpdateController extends Controller
|
||||
*/
|
||||
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();
|
||||
/** @var TagTransformer $transformer */
|
||||
$transformer = app(TagTransformer::class);
|
||||
|
@ -94,16 +94,16 @@ class StoreController extends Controller
|
||||
$validator = Validator::make(
|
||||
['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction]
|
||||
);
|
||||
throw new ValidationException($validator,0, $e);
|
||||
throw new ValidationException($validator, 0, $e);
|
||||
} catch (FireflyException $e) {
|
||||
Log::warning('Caught an exception. Return error message.');
|
||||
Log::error($e->getMessage());
|
||||
$message = sprintf('Internal exception: %s', $e->getMessage());
|
||||
$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();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
|
@ -80,7 +80,7 @@ class UpdateController extends Controller
|
||||
$manager = $this->getManager();
|
||||
|
||||
app('preferences')->mark();
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
@ -98,7 +98,7 @@ class UpdateController extends Controller
|
||||
|
||||
$selectedGroup = $collector->getGroups()->first();
|
||||
if (null === $selectedGroup) {
|
||||
throw new NotFoundHttpException();
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
/** @var TransactionGroupTransformer $transformer */
|
||||
$transformer = app(TransactionGroupTransformer::class);
|
||||
|
@ -50,7 +50,7 @@ class DestroyController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->repository = app(CurrencyRepositoryInterface::class);
|
||||
$this->userRepository = app(UserRepositoryInterface::class);
|
||||
$this->repository->setUser(auth()->user());
|
||||
|
||||
@ -75,13 +75,13 @@ class DestroyController extends Controller
|
||||
|
||||
if (!$this->userRepository->hasRole($admin, 'owner')) {
|
||||
// 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)) {
|
||||
throw new FireflyException('200006: Currency in use.');
|
||||
throw new FireflyException('200006: Currency in use.');
|
||||
}
|
||||
if ($this->repository->isFallbackCurrency($currency)) {
|
||||
throw new FireflyException('200026: Currency is fallback.');
|
||||
throw new FireflyException('200026: Currency is fallback.');
|
||||
}
|
||||
|
||||
$this->repository->destroy($currency);
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
|
||||
|
||||
use FireflyIII\Api\V1\Controllers\Controller;
|
||||
use FireflyIII\Api\V1\Requests\Models\TransactionCurrency\UpdateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
@ -33,6 +34,7 @@ use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Transformers\CurrencyTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use JsonException;
|
||||
use League\Fractal\Resource\Item;
|
||||
|
||||
/**
|
||||
@ -126,7 +128,7 @@ class UpdateController extends Controller
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function makeDefault(TransactionCurrency $currency): JsonResponse
|
||||
@ -157,8 +159,8 @@ class UpdateController extends Controller
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return JsonResponse
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws FireflyException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse
|
||||
{
|
||||
|
@ -84,8 +84,8 @@ class ShowController extends Controller
|
||||
$linkType = $this->repository->findByName($name);
|
||||
|
||||
// get list of transaction links. Count it and split it.
|
||||
$collection = $this->repository->getJournalLinks($linkType);
|
||||
$count = $collection->count();
|
||||
$collection = $this->repository->getJournalLinks($linkType);
|
||||
$count = $collection->count();
|
||||
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
// make paginator:
|
||||
|
@ -80,7 +80,7 @@ class StoreController extends Controller
|
||||
$admin = auth()->user();
|
||||
|
||||
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();
|
||||
// if currency ID is 0, find the currency by the code:
|
||||
|
@ -86,7 +86,7 @@ class UpdateController extends Controller
|
||||
$admin = auth()->user();
|
||||
|
||||
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();
|
||||
|
@ -162,7 +162,7 @@ class ConfigurationController extends Controller
|
||||
public function update(UpdateRequest $request, string $name): JsonResponse
|
||||
{
|
||||
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();
|
||||
$shortName = str_replace('configuration.', '', $name);
|
||||
|
@ -83,7 +83,7 @@ class UserController extends Controller
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
throw new FireflyException('200025: No access to function.');
|
||||
throw new FireflyException('200025: No access to function.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,11 +67,11 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$manager = $this->getManager();
|
||||
$manager = $this->getManager();
|
||||
$collection = $this->repository->all();
|
||||
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
$count = $collection->count();
|
||||
$webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
$count = $collection->count();
|
||||
$webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
// make paginator:
|
||||
$paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));
|
||||
|
@ -61,7 +61,7 @@ class StoreController extends Controller
|
||||
*/
|
||||
public function store(CreateRequest $request): JsonResponse
|
||||
{
|
||||
$data = $request->getData();
|
||||
$data = $request->getData();
|
||||
$webhook = $this->repository->store($data);
|
||||
$manager = $this->getManager();
|
||||
/** @var WebhookTransformer $transformer */
|
||||
|
@ -71,7 +71,7 @@ class UpdateRequest extends FormRequest
|
||||
'currency_id' => ['currency_id', 'integer'],
|
||||
'currency_code' => ['currency_code', 'string'],
|
||||
'liability_direction' => ['liability_direction', 'string'],
|
||||
'liability_amount' => ['liability_amount', 'string'],
|
||||
'liability_amount' => ['liability_amount', 'string'],
|
||||
'liability_start_date' => ['liability_start_date', 'date'],
|
||||
];
|
||||
/** @var Account $account */
|
||||
|
@ -78,6 +78,7 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$budget = $this->route()->parameter('budget');
|
||||
|
||||
return [
|
||||
'name' => sprintf('between:1,100|uniqueObjectForUser:budgets,name,%d', $budget->id),
|
||||
'active' => [new IsBoolean],
|
||||
|
@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest
|
||||
* Configure the validator instance with special rules for after the basic validation rules.
|
||||
*
|
||||
* @param Validator $validator
|
||||
* See reference nr. 72
|
||||
* See reference nr. 72
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ class UpdateRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$tag = $this->route()->parameter('tagOrId');
|
||||
// See reference nr. 73
|
||||
// See reference nr. 73
|
||||
$rules = [
|
||||
'tag' => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id,
|
||||
'description' => 'min:1|nullable',
|
||||
|
@ -53,6 +53,7 @@ class StoreRequest extends FormRequest
|
||||
public function getAll(): array
|
||||
{
|
||||
Log::debug('get all data in TransactionStoreRequest');
|
||||
|
||||
return [
|
||||
'group_title' => $this->string('group_title'),
|
||||
'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),
|
||||
'transactions' => $this->getTransactionData(),
|
||||
];
|
||||
// See reference nr. 71
|
||||
// See reference nr. 71
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ class UpdateRequest extends FormRequest
|
||||
];
|
||||
|
||||
return $this->getAllData($fields);
|
||||
// return $return;
|
||||
// return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ class UpdateRequest extends FormRequest
|
||||
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'];
|
||||
return ['value' => 'required'];
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class CorrectDatabase extends Command
|
||||
'firefly-iii:fix-recurring-transactions',
|
||||
'firefly-iii:restore-oauth-keys',
|
||||
'firefly-iii:fix-transaction-types',
|
||||
'firefly-iii:fix-frontpage-accounts'
|
||||
'firefly-iii:fix-frontpage-accounts',
|
||||
];
|
||||
foreach ($commands as $command) {
|
||||
$this->line(sprintf('Now executing %s', $command));
|
||||
|
@ -106,7 +106,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
private function deleteFromOrphanedAccounts(): void
|
||||
{
|
||||
$set
|
||||
= Transaction
|
||||
= Transaction
|
||||
::leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
|
||||
->whereNotNull('accounts.deleted_at')
|
||||
->get(['transactions.*']);
|
||||
|
@ -53,9 +53,9 @@ class DeleteZeroAmount extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$start = microtime(true);
|
||||
$set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$set = array_unique($set);
|
||||
$start = microtime(true);
|
||||
$set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$set = array_unique($set);
|
||||
$journals = TransactionJournal::whereIn('id', $set)->get();
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($journals as $journal) {
|
||||
|
@ -85,8 +85,8 @@ class EnableCurrencies extends Command
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
$found = array_values(array_unique($found));
|
||||
$found = array_values(
|
||||
array_filter(
|
||||
$found, function (int $currencyId) {
|
||||
return $currencyId !== 0;
|
||||
|
@ -57,7 +57,7 @@ class FixPiggies extends Command
|
||||
{
|
||||
$count = 0;
|
||||
$start = microtime(true);
|
||||
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
|
||||
$set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal', 'TransactionJournal.TransactionType'])->get();
|
||||
|
||||
/** @var PiggyBankEvent $event */
|
||||
foreach ($set as $event) {
|
||||
|
@ -125,7 +125,7 @@ class FixPostgresSequences extends Command
|
||||
|
||||
$highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->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));
|
||||
continue;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class FixUnevenAmount extends Command
|
||||
// one of the transactions is bad.
|
||||
$journal = TransactionJournal::find($param);
|
||||
if (!$journal) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
/** @var Transaction $source */
|
||||
$source = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
@ -36,7 +36,6 @@ use FireflyIII\Support\Export\ExportDataGenerator;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use InvalidArgumentException;
|
||||
use League\Csv\CannotInsertRecord;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
use JsonException;
|
||||
|
||||
/**
|
||||
* Class BudgetLimitCurrency
|
||||
@ -51,7 +52,7 @@ class BudgetLimitCurrency extends Command
|
||||
*
|
||||
* @return int
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
@ -106,7 +107,7 @@ class BudgetLimitCurrency extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +104,7 @@ class CCLiabilities extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ class MigrateAttachments extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ class MigrateJournalNotes extends Command
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$set = TransactionJournalMeta::whereName('notes')->get();
|
||||
$set = TransactionJournalMeta::whereName('notes')->get();
|
||||
/** @var TransactionJournalMeta $meta */
|
||||
foreach ($set as $meta) {
|
||||
$journal = $meta->transactionJournal;
|
||||
@ -114,7 +114,7 @@ class MigrateJournalNotes extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ class MigrateRecurrenceMeta extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@ class MigrateRecurrenceType extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ class MigrateTagLocations extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function migrateTagLocations(): void
|
||||
|
@ -137,7 +137,7 @@ class MigrateToGroups extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +128,7 @@ class MigrateToRules extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ class OtherCurrenciesCorrections extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,10 +248,10 @@ class OtherCurrenciesCorrections extends Command
|
||||
{
|
||||
$accountId = $account->id;
|
||||
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) {
|
||||
return $this->accountCurrencies[$accountId];
|
||||
return $this->accountCurrencies[$accountId];
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
|
@ -107,7 +107,7 @@ class RenameAccountMeta extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,6 +191,7 @@ class TransactionIdentifier extends Command
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $opposing;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Console\Commands\Upgrade;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@ -132,7 +133,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
private function isExecuted(): bool
|
||||
{
|
||||
@ -141,7 +142,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
return (bool)$configVar->data;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -271,10 +272,10 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
$accountId = $account->id;
|
||||
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) {
|
||||
return $this->accountCurrencies[$accountId];
|
||||
return $this->accountCurrencies[$accountId];
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
|
@ -106,7 +106,7 @@ class UpgradeDatabase extends Command
|
||||
|
||||
// instructions
|
||||
'firefly:instructions update',
|
||||
'firefly-iii:verify-security-alerts'
|
||||
'firefly-iii:verify-security-alerts',
|
||||
];
|
||||
$args = [];
|
||||
if ($this->option('force')) {
|
||||
|
@ -92,59 +92,6 @@ class UpgradeLiabilities extends Command
|
||||
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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,14 +25,21 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Storage;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Log;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
* Class VerifySecurityAlerts
|
||||
*/
|
||||
class VerifySecurityAlerts extends Command
|
||||
{
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Verify security alerts';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
@ -40,18 +47,11 @@ class VerifySecurityAlerts extends Command
|
||||
*/
|
||||
protected $signature = 'firefly-iii:verify-security-alerts';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Verify security alerts';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
@ -64,6 +64,7 @@ class VerifySecurityAlerts extends Command
|
||||
$disk = Storage::disk('resources');
|
||||
if (!$disk->has('alerts.json')) {
|
||||
Log::debug('No alerts.json file present.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
$content = $disk->get('alerts.json');
|
||||
@ -81,6 +82,7 @@ class VerifySecurityAlerts extends Command
|
||||
if ('info' === $array['level']) {
|
||||
Log::debug('INFO level alert');
|
||||
$this->info($array['message']);
|
||||
|
||||
return 0;
|
||||
}
|
||||
if ('warning' === $array['level']) {
|
||||
@ -88,6 +90,7 @@ class VerifySecurityAlerts extends Command
|
||||
$this->warn('------------------------ :o');
|
||||
$this->warn($array['message']);
|
||||
$this->warn('------------------------ :o');
|
||||
|
||||
return 0;
|
||||
}
|
||||
if ('danger' === $array['level']) {
|
||||
@ -95,6 +98,7 @@ class VerifySecurityAlerts extends Command
|
||||
$this->error('------------------------ :-(');
|
||||
$this->error($array['message']);
|
||||
$this->error('------------------------ :-(');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ class AdminRequestedTestMessage extends Event
|
||||
public $ipAddress;
|
||||
/** @var User The user */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
|
@ -37,6 +37,7 @@ class DestroyedTransactionGroup extends Event
|
||||
use SerializesModels;
|
||||
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
|
@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
@ -40,6 +40,7 @@ class RegisteredUser extends Event
|
||||
public $ipAddress;
|
||||
/** @var User The user */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a new user registers.
|
||||
*
|
||||
|
@ -42,6 +42,7 @@ class RequestedNewPassword extends Event
|
||||
public $token;
|
||||
/** @var User The user */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when a users tries to reset his or her password.
|
||||
*
|
||||
|
@ -44,6 +44,7 @@ class RequestedReportOnJournals
|
||||
public $groups;
|
||||
/** @var int The ID of the user. */
|
||||
public $userId;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RequestedSendWebhookMessages extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Events;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class RequestedVersionCheckStatus
|
||||
*
|
||||
@ -37,6 +38,7 @@ class RequestedVersionCheckStatus extends Event
|
||||
|
||||
/** @var User The user */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance. This event is triggered when Firefly III wants to know
|
||||
* what the deal is with the version checker.
|
||||
|
@ -44,6 +44,7 @@ class UserChangedEmail extends Event
|
||||
public $oldEmail;
|
||||
/** @var User The user itself */
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* UserChangedEmail constructor.
|
||||
*
|
||||
|
@ -166,7 +166,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response
|
||||
|
@ -49,8 +49,8 @@ class AccountFactory
|
||||
protected array $validAssetFields;
|
||||
protected array $validCCFields;
|
||||
protected array $validFields;
|
||||
private array $canHaveVirtual;
|
||||
private array $canHaveOpeningBalance;
|
||||
private array $canHaveVirtual;
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class AccountMetaFactory
|
||||
try {
|
||||
$entry->delete();
|
||||
} 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;
|
||||
|
@ -54,7 +54,7 @@ class AttachmentFactory
|
||||
/** @var Transaction $transaction */
|
||||
$transaction = $this->user->transactions()->find((int)$data['attachable_id']);
|
||||
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;
|
||||
$model = TransactionJournal::class;
|
||||
|
@ -141,14 +141,6 @@ class RecurrenceFactory
|
||||
return $recurrence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MessageBag
|
||||
*/
|
||||
@ -157,5 +149,13 @@ class RecurrenceFactory
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class TransactionJournalMetaFactory
|
||||
try {
|
||||
$entry->delete();
|
||||
} 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;
|
||||
@ -68,7 +68,7 @@ class TransactionJournalMetaFactory
|
||||
try {
|
||||
$entry->delete();
|
||||
} 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use JsonException;
|
||||
use Log;
|
||||
use Throwable;
|
||||
|
||||
@ -195,7 +196,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
#[ArrayShape(['journals' => "array", 'currency' => "mixed", 'exists' => "bool", 'end' => "string", 'endBalance' => "mixed", 'dayBefore' => "string",
|
||||
'dayBeforeBalance' => "mixed"])] public function getAuditReport(Account $account, Carbon $date): array
|
||||
|
@ -34,7 +34,7 @@ use Throwable;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
* See reference nr. 19
|
||||
* See reference nr. 19
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ use Throwable;
|
||||
|
||||
/**
|
||||
* Class MonthReportGenerator.
|
||||
* See reference nr. 18
|
||||
* See reference nr. 18
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ class AutomationHandler
|
||||
$sendReport = config('firefly.send_report_journals');
|
||||
|
||||
if (false === $sendReport) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::debug('In reportJournals.');
|
||||
|
@ -77,6 +77,18 @@ class StoredGroupEventHandler
|
||||
$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)
|
||||
*
|
||||
@ -108,16 +120,4 @@ class StoredGroupEventHandler
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,6 +77,18 @@ class UpdatedGroupEventHandler
|
||||
$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
|
||||
*/
|
||||
@ -100,18 +112,6 @@ class UpdatedGroupEventHandler
|
||||
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.
|
||||
*
|
||||
|
@ -108,6 +108,34 @@ class UserEventHandler
|
||||
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.
|
||||
*
|
||||
@ -251,34 +279,6 @@ class UserEventHandler
|
||||
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 message is only sent when the configuration of Firefly III says so.
|
||||
|
@ -61,7 +61,7 @@ class VersionCheckEventHandler
|
||||
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $event->user;
|
||||
$user = $event->user;
|
||||
if (!$repository->hasRole($user, 'owner')) {
|
||||
Log::debug('User is not admin, done.');
|
||||
|
||||
@ -88,13 +88,14 @@ class VersionCheckEventHandler
|
||||
|
||||
/**
|
||||
* @param RequestedVersionCheckStatus $event
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
protected function warnToCheckForUpdates(RequestedVersionCheckStatus $event): void
|
||||
{
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$user = $event->user;
|
||||
$user = $event->user;
|
||||
if (!$repository->hasRole($user, 'owner')) {
|
||||
Log::debug('User is not admin, done.');
|
||||
|
||||
|
@ -216,9 +216,9 @@ trait AccountCollection
|
||||
$this->query->leftJoin('account_types as dest_account_type', 'dest_account_type.id', '=', 'dest_account.account_type_id');
|
||||
|
||||
// and add fields:
|
||||
$this->fields[] = 'dest_account.name as destination_account_name';
|
||||
$this->fields[] = 'dest_account.iban as destination_account_iban';
|
||||
$this->fields[] = 'dest_account_type.type as destination_account_type';
|
||||
$this->fields[] = 'dest_account.name as destination_account_name';
|
||||
$this->fields[] = 'dest_account.iban as destination_account_iban';
|
||||
$this->fields[] = 'dest_account_type.type as destination_account_type';
|
||||
$this->hasAccountInfo = true;
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,16 @@ class GroupCollector implements GroupCollectorInterface
|
||||
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.
|
||||
*
|
||||
@ -767,14 +777,4 @@ class GroupCollector implements GroupCollectorInterface
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function findNothing(): GroupCollectorInterface
|
||||
{
|
||||
$this->query->where('transaction_groups.id', -1);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -57,13 +57,6 @@ interface 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.
|
||||
*
|
||||
@ -118,6 +111,13 @@ interface 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.
|
||||
*
|
||||
@ -478,6 +478,13 @@ interface GroupCollectorInterface
|
||||
*/
|
||||
public function withAttachmentInformation(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Limit results to transactions without a bill..
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function withBill(): GroupCollectorInterface;
|
||||
|
||||
/**
|
||||
* Include bill name + ID.
|
||||
*
|
||||
@ -527,13 +534,6 @@ interface 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.
|
||||
*
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Helpers\Fiscal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -67,7 +68,7 @@ class FiscalHelper implements FiscalHelperInterface
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return Carbon date object
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function startOfFiscalYear(Carbon $date): Carbon
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ class Help implements HelpInterface
|
||||
if ('' !== $content) {
|
||||
Log::debug('Content is longer than zero. Expect something.');
|
||||
$converter = new CommonMarkConverter();
|
||||
$content = (string) $converter->convertToHtml($content);
|
||||
$content = (string)$converter->convertToHtml($content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
@ -30,6 +30,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@ -62,7 +63,7 @@ class NetWorth implements NetWorthInterface
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return array
|
||||
* @throws \JsonException
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array
|
||||
{
|
||||
@ -73,7 +74,7 @@ class NetWorth implements NetWorthInterface
|
||||
$cache->addProperty('net-worth-by-currency');
|
||||
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$netWorth = [];
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user