mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Throw some exceptions so I can spot deprecated code.
This commit is contained in:
parent
0b220f3288
commit
62bba0d33b
@ -79,7 +79,7 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function accounts(AutocompleteRequest $request): JsonResponse
|
||||
{
|
||||
die('uses old administration ID check, needs to be updated. 1');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated. 1');
|
||||
$data = $request->getData();
|
||||
$types = $data['types'];
|
||||
$query = $data['query'];
|
||||
|
@ -55,7 +55,7 @@ class AccountController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->repository = app(AccountRepositoryInterface::class);
|
||||
die('uses old administration ID check, needs to be updated.2');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.2');
|
||||
$this->repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class BudgetController extends Controller
|
||||
*/
|
||||
public function dashboard(DateRequest $request): JsonResponse
|
||||
{
|
||||
die('uses old administration ID check, needs to be updated.3');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.3');
|
||||
// get user.
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
@ -53,7 +53,7 @@ class CategoryController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
die('uses old administration ID check, needs to be updated.4');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.4');
|
||||
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$this->accountRepos->setAdministrationId(auth()->user()->user_group_id);
|
||||
|
@ -26,6 +26,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V2\Controllers\Model\Bill;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Transformers\V2\AccountTransformer;
|
||||
@ -46,7 +47,7 @@ class ShowController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
die('uses old administration ID check, needs to be updated.5');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.5');
|
||||
$this->repository = app(BillRepositoryInterface::class);
|
||||
$this->repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
return $next($request);
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Model\Bill;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@ -63,7 +64,7 @@ class SumController extends Controller
|
||||
*/
|
||||
public function paid(DateRequest $request): JsonResponse
|
||||
{
|
||||
die('uses old administration ID check, needs to be updated.6');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.6');
|
||||
$this->repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
$result = $this->repository->sumPaidInRange($this->parameters->get('start'), $this->parameters->get('end'));
|
||||
|
||||
@ -83,7 +84,7 @@ class SumController extends Controller
|
||||
*/
|
||||
public function unpaid(DateRequest $request): JsonResponse
|
||||
{
|
||||
die('uses old administration ID check, needs to be updated.7');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.7');
|
||||
$this->repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
$result = $this->repository->sumUnpaidInRange($this->parameters->get('start'), $this->parameters->get('end'));
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@ -60,7 +61,7 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function budgeted(DateRequest $request, Budget $budget): JsonResponse
|
||||
{
|
||||
die('deprecated use of thing.');
|
||||
throw new FireflyException('deprecated use of thing.');
|
||||
$data = $request->getAll();
|
||||
$result = $this->repository->budgetedInPeriodForBudget($budget, $data['start'], $data['end']);
|
||||
$converted = $this->cerSum(array_values($result));
|
||||
@ -75,7 +76,7 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function spent(DateRequest $request, Budget $budget): JsonResponse
|
||||
{
|
||||
die('deprecated use of thing.');
|
||||
throw new FireflyException('deprecated use of thing.');
|
||||
$data = $request->getAll();
|
||||
$result = $this->repository->spentInPeriodForBudget($budget, $data['start'], $data['end']);
|
||||
$converted = $this->cerSum(array_values($result));
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Model\Budget;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\DateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@ -61,7 +62,7 @@ class SumController extends Controller
|
||||
*/
|
||||
public function budgeted(DateRequest $request): JsonResponse
|
||||
{
|
||||
die('deprecated use of thing.');
|
||||
throw new FireflyException('deprecated use of thing.');
|
||||
$data = $request->getAll();
|
||||
$result = $this->repository->budgetedInPeriod($data['start'], $data['end']);
|
||||
$converted = $this->cerSum(array_values($result));
|
||||
@ -79,7 +80,7 @@ class SumController extends Controller
|
||||
*/
|
||||
public function spent(DateRequest $request): JsonResponse
|
||||
{
|
||||
die('deprecated use of thing.');
|
||||
throw new FireflyException('deprecated use of thing.');
|
||||
$data = $request->getAll();
|
||||
$result = $this->repository->spentInPeriod($data['start'], $data['end']);
|
||||
$converted = $this->cerSum(array_values($result));
|
||||
|
@ -26,6 +26,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V2\Controllers\Model\PiggyBank;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Transformers\V2\PiggyBankTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@ -44,7 +45,7 @@ class ShowController extends Controller
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
die('uses old administration ID check, needs to be updated.8');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.8');
|
||||
$this->repository = app(PiggyBankRepositoryInterface::class);
|
||||
$this->repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
return $next($request);
|
||||
|
@ -77,7 +77,7 @@ class BasicController extends Controller
|
||||
$this->currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
$this->opsRepository = app(OperationsRepositoryInterface::class);
|
||||
|
||||
die('uses old administration ID check, needs to be updated.9');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.9');
|
||||
|
||||
$this->abRepository->setAdministrationId($user->user_group_id);
|
||||
$this->accountRepository->setAdministrationId($user->user_group_id);
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Summary;
|
||||
|
||||
use FireflyIII\Api\V2\Controllers\Controller;
|
||||
use FireflyIII\Api\V2\Request\Generic\SingleDateRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@ -62,7 +63,7 @@ class NetWorthController extends Controller
|
||||
*/
|
||||
public function get(SingleDateRequest $request): JsonResponse
|
||||
{
|
||||
die('deprecated use of thing.');
|
||||
throw new FireflyException('deprecated use of thing.');
|
||||
$date = $request->getDate();
|
||||
$result = $this->netWorth->sumNetWorthByCurrency($date);
|
||||
$converted = $this->cerSum($result);
|
||||
|
@ -245,7 +245,7 @@ class NetWorth implements NetWorthInterface
|
||||
{
|
||||
$this->userGroup = $userGroup;
|
||||
$this->adminAccountRepository = app(AdminAccountRepositoryInterface::class);
|
||||
die('uses old administration ID check, needs to be updated.A');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.A');
|
||||
$this->adminAccountRepository->setAdministrationId($userGroup->id);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class RuleGroup extends Model
|
||||
];
|
||||
|
||||
/** @var array Fields that can be filled */
|
||||
protected $fillable = ['user_id', 'stop_processing', 'order', 'title', 'description', 'active'];
|
||||
protected $fillable = ['user_id', 'user_group_id', 'stop_processing', 'order', 'title', 'description', 'active'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
|
@ -84,7 +84,7 @@ class TransactionGroup extends Model
|
||||
];
|
||||
|
||||
/** @var array Fields that can be filled */
|
||||
protected $fillable = ['user_id', 'title'];
|
||||
protected $fillable = ['user_id', 'user_group_id', 'title'];
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
@ -116,6 +116,14 @@ class TransactionGroup extends Model
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
@ -124,14 +132,6 @@ class TransactionGroup extends Model
|
||||
return $this->hasMany(TransactionJournal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Providers;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\Budget\AvailableBudgetRepository;
|
||||
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\UserGroups\Budget\AvailableBudgetRepository as AdminAbRepository;
|
||||
@ -78,7 +79,7 @@ class BudgetServiceProvider extends ServiceProvider
|
||||
$repository = app(AdminBudgetRepository::class);
|
||||
if ($app->auth->check()) { // @phpstan-ignore-line
|
||||
$repository->setUser(auth()->user());
|
||||
die('uses old administration ID check, needs to be updated.C');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.C');
|
||||
$repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
}
|
||||
|
||||
@ -108,7 +109,7 @@ class BudgetServiceProvider extends ServiceProvider
|
||||
$repository = app(AdminAbRepository::class);
|
||||
if ($app->auth->check()) { // @phpstan-ignore-line
|
||||
$repository->setUser(auth()->user());
|
||||
die('uses old administration ID check, needs to be updated.D');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.D');
|
||||
$repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
}
|
||||
|
||||
@ -164,7 +165,7 @@ class BudgetServiceProvider extends ServiceProvider
|
||||
$repository = app(AdminOperationsRepository::class);
|
||||
if ($app->auth->check()) { // @phpstan-ignore-line
|
||||
$repository->setUser(auth()->user());
|
||||
die('uses old administration ID check, needs to be updated.E');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.E');
|
||||
$repository->setAdministrationId(auth()->user()->user_group_id);
|
||||
}
|
||||
|
||||
|
@ -463,6 +463,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$newRuleGroup = new RuleGroup(
|
||||
[
|
||||
'user_id' => $this->user->id,
|
||||
'user_group_id' => $this->user->user_group_id,
|
||||
'title' => $data['title'],
|
||||
'description' => $data['description'],
|
||||
'order' => 31337,
|
||||
|
@ -132,7 +132,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
{
|
||||
/** @var BudgetRepositoryInterface $repos */
|
||||
$repos = app(BudgetRepositoryInterface::class);
|
||||
die('uses old administration ID check, needs to be updated.F');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.F');
|
||||
$repos->setAdministrationId($this->getAdministrationId());
|
||||
|
||||
return $repos->getActiveBudgets();
|
||||
|
@ -62,11 +62,11 @@ class BelongsUserGroup implements ValidationRule
|
||||
{
|
||||
$attribute = $this->parseAttribute($attribute);
|
||||
if (!auth()->check()) {
|
||||
$fail('validation.belongs_user')->translate();
|
||||
$fail('validation.belongs_user_or_user_group')->translate();
|
||||
return;
|
||||
}
|
||||
$attribute = (string)$attribute;
|
||||
Log::debug(sprintf('Going to validate %s', $attribute));
|
||||
Log::debug(sprintf('Group: Going to validate "%s"', $attribute));
|
||||
|
||||
$result = match ($attribute) {
|
||||
'piggy_bank_id' => $this->validatePiggyBankId((int)$value),
|
||||
@ -252,7 +252,7 @@ class BelongsUserGroup implements ValidationRule
|
||||
private function validateAccountId(int $value): bool
|
||||
{
|
||||
if (0 === $value) {
|
||||
// its ok to submit 0. other checks will fail.
|
||||
// it's ok to submit 0. other checks will fail.
|
||||
return true;
|
||||
}
|
||||
$count = Account::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count();
|
||||
|
@ -115,7 +115,7 @@ trait ConvertsExchangeRates
|
||||
*/
|
||||
public function cerSum(array $entries): array
|
||||
{
|
||||
die('do not use me, needs refactor');
|
||||
throw new FireflyException('do not use me, needs refactor');
|
||||
if (null === $this->enabled) {
|
||||
$this->getPreference();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Support\Request;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -171,7 +172,7 @@ trait ConvertsDataTypes
|
||||
// set administration ID
|
||||
// group ID
|
||||
$administrationId = auth()->user()->getAdministrationId();
|
||||
die('uses old administration ID check, needs to be updated.G');
|
||||
throw new FireflyException('uses old administration ID check, needs to be updated.G');
|
||||
$repository->setAdministrationId($administrationId);
|
||||
|
||||
$set = $this->get('accounts');
|
||||
|
@ -48,7 +48,7 @@ trait ValidatesAdministrationAccess
|
||||
*/
|
||||
protected function validateAdministration(Validator $validator, array $allowedRoles): void
|
||||
{
|
||||
die('deprecated method, must be done through user.');
|
||||
throw new FireflyException('deprecated method, must be done through user.');
|
||||
Log::debug('Now in validateAdministration()');
|
||||
if (!auth()->check()) {
|
||||
Log::error('User is not authenticated.');
|
||||
|
@ -49,8 +49,8 @@ return [
|
||||
'transaction_types_equal' => 'All splits must be of the same type.',
|
||||
'invalid_transaction_type' => 'Invalid transaction type.',
|
||||
'invalid_selection' => 'Your selection is invalid.',
|
||||
'belongs_user' => 'This value is invalid for this field.',
|
||||
'belongs_user_or_user_group' => 'This value is invalid for this field.',
|
||||
'belongs_user' => 'This value is linked to an object that does not belong to you.',
|
||||
'belongs_user_or_user_group' => 'This value is linked to an object that does not belong to your current financial administration.',
|
||||
'at_least_one_transaction' => 'Need at least one transaction.',
|
||||
'recurring_transaction_id' => 'Need at least one transaction.',
|
||||
'need_id_to_match' => 'You need to submit this entry with an ID for the API to be able to match it.',
|
||||
|
Loading…
Reference in New Issue
Block a user