mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix phpstan level 3!
This commit is contained in:
parent
cd296aa9ac
commit
2baac1a6d7
@ -16,6 +16,8 @@ parameters:
|
||||
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
|
||||
- identifier: varTag.nativeType
|
||||
- identifier: varTag.type
|
||||
|
||||
# phpstan can't handle this so we ignore them.
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::before#'
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::after#'
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::withTrashed#'
|
||||
|
@ -55,23 +55,9 @@ class ConvertsDatesToUTC extends Command
|
||||
{
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Convert stored dates to UTC.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'correction:convert-to-utc';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$this->friendlyWarning('Please do not use this command right now.');
|
||||
|
@ -67,7 +67,7 @@ class CorrectsOpeningBalanceCurrencies extends Command
|
||||
|
||||
private function getJournals(): Collection
|
||||
{
|
||||
// @var Collection
|
||||
/** @var Collection */
|
||||
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)->get(['transaction_journals.*'])
|
||||
|
@ -81,18 +81,7 @@ class CorrectsTimezoneInformation extends Command
|
||||
TransactionJournal::class => ['date'],
|
||||
];
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Make sure all dates have a timezone.';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'correction:timezones';
|
||||
|
||||
/**
|
||||
|
@ -138,11 +138,13 @@ class UpgradesLiabilities extends Command
|
||||
|
||||
private function getSourceTransaction(TransactionJournal $journal): ?Transaction
|
||||
{
|
||||
/** @var Transaction|null */
|
||||
return $journal->transactions()->where('amount', '<', 0)->first();
|
||||
}
|
||||
|
||||
private function getDestinationTransaction(TransactionJournal $journal): ?Transaction
|
||||
{
|
||||
/** @var Transaction|null */
|
||||
return $journal->transactions()->where('amount', '>', 0)->first();
|
||||
}
|
||||
|
||||
|
@ -208,6 +208,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
|
||||
private function getSourceTransaction(TransactionJournal $transfer): ?Transaction
|
||||
{
|
||||
/** @var Transaction|null */
|
||||
return $transfer->transactions()->where('amount', '<', 0)->first();
|
||||
}
|
||||
|
||||
@ -243,6 +244,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
|
||||
private function getDestinationTransaction(TransactionJournal $transfer): ?Transaction
|
||||
{
|
||||
/** @var Transaction|null */
|
||||
return $transfer->transactions()->where('amount', '>', 0)->first();
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
*/
|
||||
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
|
||||
{
|
||||
/** @var Transaction $lead */
|
||||
/** @var Transaction|null $lead */
|
||||
$lead = null;
|
||||
|
||||
switch ($journal->transactionType->type) {
|
||||
@ -214,7 +214,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var Transaction|null */
|
||||
return $lead;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class AccountFactory
|
||||
app('log')->debug(sprintf('Now in AccountFactory::find("%s", "%s")', $accountName, $accountType));
|
||||
$type = AccountType::whereType($accountType)->first();
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $this->user->accounts()->where('account_type_id', $type->id)->where('name', $accountName)->first();
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ class BillFactory
|
||||
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
/** @var Bill|null */
|
||||
return $this->user->bills()->whereLike('name', sprintf('%%%s%%', $name))->first();
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ class BudgetFactory
|
||||
|
||||
public function findByName(string $name): ?Budget
|
||||
{
|
||||
/** @var Budget|null */
|
||||
return $this->user->budgets()->where('name', $name)->first();
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ class CategoryFactory
|
||||
|
||||
public function findByName(string $name): ?Category
|
||||
{
|
||||
/** @var Category|null */
|
||||
return $this->user->categories()->where('name', $name)->first();
|
||||
}
|
||||
|
||||
|
@ -41,14 +41,7 @@ class PiggyBankFactory
|
||||
{
|
||||
use CreatesObjectGroups;
|
||||
|
||||
public User $user {
|
||||
set(User $value) {
|
||||
$this->user = $value;
|
||||
$this->currencyRepository->setUser($value);
|
||||
$this->accountRepository->setUser($value);
|
||||
$this->piggyBankRepository->setUser($value);
|
||||
}
|
||||
}
|
||||
public User $user;
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private PiggyBankRepositoryInterface $piggyBankRepository;
|
||||
@ -60,13 +53,21 @@ class PiggyBankFactory
|
||||
$this->piggyBankRepository = app(PiggyBankRepositoryInterface::class);
|
||||
}
|
||||
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->currencyRepository->setUser($user);
|
||||
$this->accountRepository->setUser($user);
|
||||
$this->piggyBankRepository->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a piggy bank or come back with an exception.
|
||||
*/
|
||||
public function store(array $data): PiggyBank
|
||||
{
|
||||
|
||||
$piggyBankData = $data;
|
||||
$piggyBankData = $data;
|
||||
|
||||
// unset some fields
|
||||
unset($piggyBankData['object_group_title'], $piggyBankData['transaction_currency_code'], $piggyBankData['transaction_currency_id'], $piggyBankData['accounts'], $piggyBankData['object_group_id'], $piggyBankData['notes']);
|
||||
@ -90,11 +91,11 @@ class PiggyBankFactory
|
||||
|
||||
throw new FireflyException('400005: Could not store new piggy bank.', 0, $e);
|
||||
}
|
||||
$piggyBank = $this->setOrder($piggyBank, $data);
|
||||
$piggyBank = $this->setOrder($piggyBank, $data);
|
||||
$this->linkToAccountIds($piggyBank, $data['accounts']);
|
||||
$this->piggyBankRepository->updateNote($piggyBank, $data['notes']);
|
||||
|
||||
$objectGroupTitle = $data['object_group_title'] ?? '';
|
||||
$objectGroupTitle = $data['object_group_title'] ?? '';
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
|
||||
if (null !== $objectGroup) {
|
||||
@ -102,7 +103,7 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
// try also with ID
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
if (0 !== $objectGroupId) {
|
||||
$objectGroup = $this->findObjectGroupById($objectGroupId);
|
||||
if (null !== $objectGroup) {
|
||||
@ -110,7 +111,7 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
Log::debug('Touch piggy bank');
|
||||
$piggyBank->encrypted = false;
|
||||
$piggyBank->encrypted = false;
|
||||
$piggyBank->save();
|
||||
$piggyBank->touch();
|
||||
|
||||
@ -143,11 +144,10 @@ class PiggyBankFactory
|
||||
// first find by ID:
|
||||
if ($piggyBankId > 0) {
|
||||
$piggyBank = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.id', $piggyBankId)
|
||||
->first(['piggy_banks.*'])
|
||||
;
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.id', $piggyBankId)
|
||||
->first(['piggy_banks.*']);
|
||||
if (null !== $piggyBank) {
|
||||
return $piggyBank;
|
||||
}
|
||||
@ -168,17 +168,16 @@ class PiggyBankFactory
|
||||
public function findByName(string $name): ?PiggyBank
|
||||
{
|
||||
return PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.name', $name)
|
||||
->first(['piggy_banks.*'])
|
||||
;
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.name', $name)
|
||||
->first(['piggy_banks.*']);
|
||||
}
|
||||
|
||||
private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank
|
||||
{
|
||||
$this->resetOrder();
|
||||
$order = $this->getMaxOrder() + 1;
|
||||
$order = $this->getMaxOrder() + 1;
|
||||
if (array_key_exists('order', $data)) {
|
||||
$order = $data['order'];
|
||||
}
|
||||
@ -193,15 +192,14 @@ class PiggyBankFactory
|
||||
{
|
||||
// TODO duplicate code
|
||||
$set = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->with(
|
||||
[
|
||||
'objectGroups',
|
||||
]
|
||||
)
|
||||
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])
|
||||
;
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->with(
|
||||
[
|
||||
'objectGroups',
|
||||
]
|
||||
)
|
||||
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);
|
||||
$current = 1;
|
||||
foreach ($set as $piggyBank) {
|
||||
if ($piggyBank->order !== $current) {
|
||||
|
@ -132,7 +132,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
|
||||
return;
|
||||
|
||||
case TransactionGroup::class:
|
||||
// @var TransactionGroup $model
|
||||
/** @var TransactionGroup $model */
|
||||
$basicMessage['user_id'] = $model->user->id;
|
||||
|
||||
break;
|
||||
|
@ -85,11 +85,13 @@ class ShowController extends Controller
|
||||
return $this->redirectAccountToAccount($account);
|
||||
}
|
||||
|
||||
// @var Carbon $start
|
||||
$start ??= session('start');
|
||||
// @var Carbon $end
|
||||
$end ??= session('end');
|
||||
|
||||
/** @var Carbon $start */
|
||||
/** @var Carbon $end */
|
||||
|
||||
|
||||
if ($end->lt($start)) {
|
||||
[$start, $end] = [$end, $start];
|
||||
}
|
||||
|
@ -79,10 +79,12 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function noBudget(Request $request, ?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
// @var Carbon $start
|
||||
$start ??= session('start');
|
||||
// @var Carbon $end
|
||||
$end ??= session('end');
|
||||
|
||||
/** @var Carbon $start */
|
||||
/** @var Carbon $end */
|
||||
|
||||
$subTitle = trans(
|
||||
'firefly.without_budget_between',
|
||||
['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]
|
||||
|
@ -75,10 +75,12 @@ class NoCategoryController extends Controller
|
||||
public function show(Request $request, ?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
app('log')->debug('Start of noCategory()');
|
||||
// @var Carbon $start
|
||||
$start ??= session('start');
|
||||
// @var Carbon $end
|
||||
$end ??= session('end');
|
||||
|
||||
/** @var Carbon $start */
|
||||
/** @var Carbon $end */
|
||||
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$subTitle = trans(
|
||||
|
@ -74,10 +74,12 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function show(Request $request, Category $category, ?Carbon $start = null, ?Carbon $end = null)
|
||||
{
|
||||
// @var Carbon $start
|
||||
$start ??= session('start', today(config('app.timezone'))->startOfMonth());
|
||||
// @var Carbon $end
|
||||
$end ??= session('end', today(config('app.timezone'))->endOfMonth());
|
||||
|
||||
/** @var Carbon $start */
|
||||
/** @var Carbon $end */
|
||||
|
||||
$subTitleIcon = 'fa-bookmark';
|
||||
$page = (int) $request->get('page');
|
||||
$attachments = $this->repository->getAttachments($category);
|
||||
|
@ -67,6 +67,7 @@ class DebugController extends Controller
|
||||
if (!auth()->user()->hasRole('owner')) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
/** @var iterable $routes */
|
||||
$routes = Route::getRoutes();
|
||||
$return = [];
|
||||
|
||||
|
@ -179,8 +179,9 @@ class IndexController extends Controller
|
||||
|
||||
private function mergeAccountsAndPiggies(array $piggyBanks, array $accounts): array
|
||||
{
|
||||
// @var array $piggyBank
|
||||
/** @var array $group */
|
||||
foreach ($piggyBanks as $group) {
|
||||
/** @var array $piggyBank */
|
||||
foreach ($group['piggy_banks'] as $piggyBank) {
|
||||
// loop all accounts in this piggy bank subtract the current amount from "left to save" in the $accounts array.
|
||||
/** @var array $piggyAccount */
|
||||
|
@ -203,6 +203,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
||||
)
|
||||
);
|
||||
|
||||
/** @var BudgetLimit|null */
|
||||
return $budget->budgetlimits()
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first()
|
||||
|
@ -40,8 +40,6 @@ class AccountMeta extends Model
|
||||
];
|
||||
|
||||
protected $fillable = ['account_id', 'name', 'data'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'account_meta';
|
||||
|
||||
public function account(): BelongsTo
|
||||
|
@ -41,7 +41,6 @@ class Configuration extends Model
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'configuration';
|
||||
|
||||
/**
|
||||
|
@ -79,6 +79,7 @@ class Preference extends Model
|
||||
$preference = $user->preferences()->where('id', (int) $value)->first();
|
||||
}
|
||||
if (null !== $preference) {
|
||||
/** @var Preference $preference */
|
||||
return $preference;
|
||||
}
|
||||
$default = config('firefly.default_preferences');
|
||||
@ -89,7 +90,6 @@ class Preference extends Model
|
||||
$preference->user_id = (int) $user->id;
|
||||
$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;
|
||||
$preference->save();
|
||||
|
||||
return $preference;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ class Recurrence extends Model
|
||||
protected $fillable
|
||||
= ['user_id', 'transaction_type_id', 'title', 'description', 'first_date', 'first_date_tz', 'repeat_until', 'repeat_until_tz', 'latest_date', 'latest_date_tz', 'repetitions', 'apply_rules', 'active'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences';
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,6 @@ class RecurrenceMeta extends Model
|
||||
|
||||
protected $fillable = ['recurrence_id', 'name', 'value'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_meta';
|
||||
|
||||
public function recurrence(): BelongsTo
|
||||
|
@ -62,7 +62,6 @@ class RecurrenceRepetition extends Model
|
||||
|
||||
protected $fillable = ['recurrence_id', 'weekend', 'repetition_type', 'repetition_moment', 'repetition_skip'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_repetitions';
|
||||
|
||||
public function recurrence(): BelongsTo
|
||||
|
@ -60,7 +60,6 @@ class RecurrenceTransaction extends Model
|
||||
'description',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'recurrences_transactions';
|
||||
|
||||
public function destinationAccount(): BelongsTo
|
||||
|
@ -48,7 +48,6 @@ class RecurrenceTransactionMeta extends Model
|
||||
|
||||
protected $fillable = ['rt_id', 'name', 'value'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'rt_meta';
|
||||
|
||||
public function recurrenceTransaction(): BelongsTo
|
||||
|
@ -42,7 +42,6 @@ class TransactionJournalLink extends Model
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'journal_links';
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,6 @@ class TransactionJournalMeta extends Model
|
||||
|
||||
protected $fillable = ['transaction_journal_id', 'name', 'data', 'hash'];
|
||||
|
||||
/** @var string The table to store the data in */
|
||||
protected $table = 'journal_meta';
|
||||
|
||||
/**
|
||||
|
@ -42,8 +42,6 @@ class AccountPolicy
|
||||
|
||||
/**
|
||||
* Everybody can do this, but selection should limit to user.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
@ -54,8 +52,6 @@ class AccountPolicy
|
||||
|
||||
/**
|
||||
* Everybody can do this, but selection should limit to user.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public function viewUser(User $user, Account $account): bool
|
||||
{
|
||||
|
@ -39,8 +39,6 @@ class BalancePolicy
|
||||
|
||||
/**
|
||||
* Everybody can do this, but selection should limit to user.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ class CurrencyServiceProvider extends ServiceProvider
|
||||
$this->app->bind(
|
||||
ExchangeRateRepositoryInterface::class,
|
||||
static function (Application $app) {
|
||||
// @var ExchangeRateRepository $repository
|
||||
/** @var ExchangeRateRepository */
|
||||
return app(ExchangeRateRepository::class);
|
||||
}
|
||||
);
|
||||
|
@ -120,7 +120,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $dbQuery->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
public function getLocation(Account $account): ?Location
|
||||
{
|
||||
// @var Location|null
|
||||
/** @var Location|null */
|
||||
return $account->locations()->first();
|
||||
}
|
||||
|
||||
@ -428,6 +428,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
public function find(int $accountId): ?Account
|
||||
{
|
||||
/** @var Account|null */
|
||||
return $this->user->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function find(int $billId): ?Bill
|
||||
{
|
||||
/** @var Bill|null */
|
||||
return $this->user->bills()->find($billId);
|
||||
}
|
||||
|
||||
@ -150,6 +151,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Bill
|
||||
{
|
||||
/** @var Bill|null */
|
||||
return $this->user->bills()->where('name', $name)->first(['bills.*']);
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
*/
|
||||
public function find(TransactionCurrency $currency, Carbon $start, Carbon $end): ?AvailableBudget
|
||||
{
|
||||
/** @var AvailableBudget|null */
|
||||
return $this->user->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
@ -194,6 +195,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
|
||||
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
|
||||
{
|
||||
/** @var AvailableBudget|null */
|
||||
return $this->user
|
||||
->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
@ -207,6 +209,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
*/
|
||||
public function setAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end, string $amount): AvailableBudget
|
||||
{
|
||||
/** @var AvailableBudget */
|
||||
$availableBudget = $this->user->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
@ -223,7 +226,6 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
}
|
||||
$availableBudget->amount = $amount;
|
||||
$availableBudget->save();
|
||||
|
||||
return $availableBudget;
|
||||
}
|
||||
|
||||
|
@ -324,6 +324,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
|
||||
public function find(Budget $budget, TransactionCurrency $currency, Carbon $start, Carbon $end): ?BudgetLimit
|
||||
{
|
||||
/** @var BudgetLimit|null */
|
||||
return $budget->budgetlimits()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
|
@ -384,6 +384,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
|
||||
public function getAutoBudget(Budget $budget): ?AutoBudget
|
||||
{
|
||||
/** @var AutoBudget|null */
|
||||
return $budget->autoBudgets()->first();
|
||||
}
|
||||
|
||||
@ -442,6 +443,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
*/
|
||||
public function find(?int $budgetId = null): ?Budget
|
||||
{
|
||||
/** @var Budget|null */
|
||||
return $this->user->budgets()->find($budgetId);
|
||||
}
|
||||
|
||||
@ -513,7 +515,7 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return null;
|
||||
}
|
||||
$query = sprintf('%%%s%%', $name);
|
||||
|
||||
/** @var Budget|null */
|
||||
return $this->user->budgets()->whereLike('name', $query)->first();
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function find(int $categoryId): ?Category
|
||||
{
|
||||
/** @var Category|null */
|
||||
return $this->user->categories()->find($categoryId);
|
||||
}
|
||||
|
||||
@ -137,6 +138,7 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
*/
|
||||
public function findByName(string $name): ?Category
|
||||
{
|
||||
/** @var Category|null */
|
||||
return $this->user->categories()->where('name', $name)->first(['categories.*']);
|
||||
}
|
||||
|
||||
|
@ -185,6 +185,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
*/
|
||||
public function find(int $journalId): ?TransactionJournal
|
||||
{
|
||||
/** @var TransactionJournal|null */
|
||||
return $this->user->transactionJournals()->find($journalId);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ trait CreatesObjectGroups
|
||||
{
|
||||
protected function findObjectGroupById(int $groupId): ?ObjectGroup
|
||||
{
|
||||
/** @var ObjectGroup|null */
|
||||
return $this->user->objectGroups()->where('id', $groupId)->first();
|
||||
}
|
||||
|
||||
@ -66,6 +67,7 @@ trait CreatesObjectGroups
|
||||
|
||||
protected function findObjectGroup(string $title): ?ObjectGroup
|
||||
{
|
||||
/** @var ObjectGroup|null */
|
||||
return $this->user->objectGroups()->where('title', $title)->first();
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
throw new FireflyException('[b] Piggy bank repetitions are EOL.');
|
||||
}
|
||||
Log::warning('Piggy bank repetitions are EOL.');
|
||||
|
||||
/** @var PiggyBankRepetition|null */
|
||||
return $piggyBank->piggyBankRepetitions()->first();
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function getFirstRuleGroup(): RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->first();
|
||||
}
|
||||
|
||||
@ -276,6 +277,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
|
||||
public function find(int $ruleId): ?Rule
|
||||
{
|
||||
/** @var Rule|null */
|
||||
return $this->user->rules()->find($ruleId);
|
||||
}
|
||||
|
||||
|
@ -208,11 +208,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
|
||||
public function find(int $ruleGroupId): ?RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->find($ruleGroupId);
|
||||
}
|
||||
|
||||
public function findByTitle(string $title): ?RuleGroup
|
||||
{
|
||||
/** @var RuleGroup|null */
|
||||
return $this->user->ruleGroups()->where('title', $title)->first();
|
||||
}
|
||||
|
||||
|
@ -101,18 +101,19 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function find(int $tagId): ?Tag
|
||||
{
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->find($tagId);
|
||||
}
|
||||
|
||||
public function findByTag(string $tag): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->where('tag', $tag)->first();
|
||||
}
|
||||
|
||||
public function firstUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
// @var Carbon|null
|
||||
/** @var Carbon|null */
|
||||
return $tag->transactionJournals()->orderBy('date', 'ASC')->first()?->date;
|
||||
}
|
||||
|
||||
@ -180,7 +181,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function lastUseDate(Tag $tag): ?Carbon
|
||||
{
|
||||
// @var Carbon|null
|
||||
/** @var Carbon|null */
|
||||
return $tag->transactionJournals()->orderBy('date', 'DESC')->first()?->date;
|
||||
}
|
||||
|
||||
@ -189,13 +190,13 @@ class TagRepository implements TagRepositoryInterface
|
||||
*/
|
||||
public function newestTag(): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'DESC')->first();
|
||||
}
|
||||
|
||||
public function oldestTag(): ?Tag
|
||||
{
|
||||
// @var Tag|null
|
||||
/** @var Tag|null */
|
||||
return $this->user->tags()->whereNotNull('date')->orderBy('date', 'ASC')->first();
|
||||
}
|
||||
|
||||
@ -380,7 +381,7 @@ class TagRepository implements TagRepositoryInterface
|
||||
|
||||
public function getLocation(Tag $tag): ?Location
|
||||
{
|
||||
// @var Location|null
|
||||
/** @var Location|null */
|
||||
return $tag->locations()->first();
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
*/
|
||||
public function find(int $groupId): ?TransactionGroup
|
||||
{
|
||||
/** @var TransactionGroup|null */
|
||||
return $this->user->transactionGroups()->find($groupId);
|
||||
}
|
||||
|
||||
@ -290,6 +291,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user->transactionJournals()->find($journalId);
|
||||
|
||||
/** @var Location|null */
|
||||
return $journal->locations()->first();
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $dbQuery->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
// @var Account|null
|
||||
/** @var Account|null */
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
if (null === $account) {
|
||||
$account = $this->userGroup->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
/** @var Account|null */
|
||||
return $account;
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
|
||||
return $current;
|
||||
});
|
||||
|
||||
/** @var Collection */
|
||||
return $all;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
|
||||
#[\Override]
|
||||
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
|
||||
{
|
||||
/** @var CurrencyExchangeRate|null */
|
||||
return
|
||||
$this->userGroup->currencyExchangeRates()
|
||||
->where('from_currency_id', $from->id)
|
||||
|
@ -39,9 +39,10 @@ class IsUniqueAccount implements ValidationRule, DataAwareRule
|
||||
protected \Closure $fail;
|
||||
|
||||
#[\Override]
|
||||
public function setData(array $data): void
|
||||
public function setData(array $data): self // @phpstan-ignore-line
|
||||
{
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
|
@ -250,6 +250,7 @@ class BillUpdateService
|
||||
|
||||
private function getRuleTrigger(Rule $rule, string $key): ?RuleTrigger
|
||||
{
|
||||
/** @var RuleTrigger|null */
|
||||
return $rule->ruleTriggers()->where('trigger_type', $key)->first();
|
||||
}
|
||||
}
|
||||
|
@ -238,11 +238,9 @@ class JournalUpdateService
|
||||
private function getSourceTransaction(): Transaction
|
||||
{
|
||||
if (null === $this->sourceTransaction) {
|
||||
$this->sourceTransaction = $this->transactionJournal->transactions()->with(['account'])->where(
|
||||
'amount',
|
||||
'<',
|
||||
0
|
||||
)->first();
|
||||
/** @var Transaction|null $result */
|
||||
$result = $this->transactionJournal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
$this->sourceTransaction = $result;
|
||||
}
|
||||
Log::debug(sprintf('getSourceTransaction: %s', $this->sourceTransaction->amount));
|
||||
|
||||
@ -321,7 +319,9 @@ class JournalUpdateService
|
||||
private function getDestinationTransaction(): Transaction
|
||||
{
|
||||
if (null === $this->destinationTransaction) {
|
||||
$this->destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
|
||||
/** @var Transaction|null $result */
|
||||
$result = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
|
||||
$this->destinationTransaction = $result;
|
||||
}
|
||||
|
||||
return $this->destinationTransaction;
|
||||
|
Loading…
Reference in New Issue
Block a user