mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix for level 2
This commit is contained in:
parent
3898c0c0ef
commit
6cd60951ba
@ -1,7 +1,6 @@
|
||||
parameters:
|
||||
scanFiles:
|
||||
- ../_ide_helper_models.php
|
||||
- ../_ide_helper.php
|
||||
- ../_ide_helper
|
||||
paths:
|
||||
- ../app
|
||||
- ../database
|
||||
@ -17,6 +16,11 @@ parameters:
|
||||
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
|
||||
- identifier: varTag.nativeType
|
||||
- identifier: varTag.type
|
||||
- '#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#'
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\HasMany::accountTypeIn#'
|
||||
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\Relations\\BelongsTo::withTrashed#'
|
||||
# - '#Control structures using switch should not be used.#' # switch is fine in some cases.
|
||||
# - '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved.
|
||||
# - '#has no value type specified in iterable type array#' # remove this rule when all other issues are solved.
|
||||
|
@ -45,7 +45,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
* Class Controller.
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
|
||||
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
||||
* @SuppressWarnings("PHPMD.NumberOfChildren")
|
||||
*/
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
* Class Controller
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
|
||||
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
||||
* @SuppressWarnings("PHPMD.NumberOfChildren")
|
||||
*/
|
||||
class Controller extends BaseController
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ class RemovesEmptyGroups extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @throws Exception;
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
@ -70,7 +70,6 @@ class RepairsAccountBalances extends Command
|
||||
|
||||
private function correctBalanceAmounts(): void
|
||||
{
|
||||
return;
|
||||
AccountBalanceCalculator::recalculateAll(true);
|
||||
AccountBalanceCalculator::recalculateAll(false);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
|
||||
private function isMultiCurrency(Account $account): bool
|
||||
{
|
||||
$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency', false);
|
||||
$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency');
|
||||
if (false === $value || null === $value) {
|
||||
return false;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class AccountBalance
|
||||
{
|
||||
$balance = new self();
|
||||
$balance->id = (string) random_int(1, 1000);
|
||||
$balance->name = (string) random_int(1, 1000);
|
||||
// $balance->name = (string) random_int(1, 1000);
|
||||
$balance->amount = (string) random_int(1, 1000);
|
||||
$balance->currencyId = '1';
|
||||
|
||||
|
@ -39,7 +39,7 @@ use Route;
|
||||
* Class Controller.
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.CouplingBetweenObjects")
|
||||
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
||||
* @SuppressWarnings("PHPMD.NumberOfChildren")
|
||||
*/
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\Webhook;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
@ -140,8 +141,10 @@ class InterestingMessage
|
||||
$accountId = $request->get('account_id');
|
||||
$message = $request->get('message');
|
||||
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
/** @var null|Account $account */
|
||||
$account = auth()->user()->accounts()->withTrashed()->find($accountId);
|
||||
$account = $user->accounts()->withTrashed()->find($accountId);
|
||||
|
||||
if (null === $account) {
|
||||
return;
|
||||
|
@ -192,7 +192,7 @@ class TransactionJournal extends Model
|
||||
/**
|
||||
* Checks if tables are joined.
|
||||
*/
|
||||
public static function isJoined(Builder $query, string $table): bool
|
||||
public static function isJoined(EloquentBuilder $query, string $table): bool
|
||||
{
|
||||
$joins = $query->getQuery()->joins;
|
||||
foreach ($joins as $join) {
|
||||
|
@ -285,6 +285,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
$currency->save();
|
||||
|
||||
// find the budget:
|
||||
/** @var Budget|null $budget */
|
||||
$budget = $this->user->budgets()->find((int) $data['budget_id']);
|
||||
if (null === $budget) {
|
||||
throw new FireflyException('200004: Budget does not exist.');
|
||||
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -89,7 +90,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface
|
||||
$events = $journal->piggyBankEvents()->get();
|
||||
$events->each(
|
||||
static function (PiggyBankEvent $event): void {
|
||||
$event->piggyBank = $event->piggyBank()->withTrashed()->first();
|
||||
$event->piggyBank = PiggyBank::withTrashed()->find($event->piggy_bank_id);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Journal;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
@ -57,7 +58,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
if (null !== $budget) {
|
||||
return $budget->id;
|
||||
}
|
||||
$budget = $journal->transactions()->first()->budgets()->first();
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = $journal->transactions()->first();
|
||||
$budget = $transaction?->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
return $budget->id;
|
||||
}
|
||||
@ -74,7 +77,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
|
||||
if (null !== $category) {
|
||||
return $category->id;
|
||||
}
|
||||
$category = $journal->transactions()->first()->categories()->first();
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = $journal->transactions()->first();
|
||||
$category = $transaction?->categories()->first();
|
||||
if (null !== $category) {
|
||||
return $category->id;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\UserGroups\Currency;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@ -33,6 +34,8 @@ interface CurrencyRepositoryInterface
|
||||
{
|
||||
public function currencyInUse(TransactionCurrency $currency): bool;
|
||||
|
||||
public function getUserGroup(): UserGroup;
|
||||
|
||||
/**
|
||||
* Currency is in use where exactly.
|
||||
*/
|
||||
|
@ -103,4 +103,12 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
#[\Override] public function getAll(): Collection
|
||||
{
|
||||
return $this->userGroup->currencyExchangeRates()->get();
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ interface ExchangeRateRepositoryInterface
|
||||
{
|
||||
public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection;
|
||||
|
||||
public function getAll(): Collection;
|
||||
|
||||
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate;
|
||||
|
||||
public function deleteRate(CurrencyExchangeRate $rate): void;
|
||||
|
Loading…
Reference in New Issue
Block a user