mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
run phpcs
This commit is contained in:
parent
0f69e0d672
commit
c3ffd39450
6
.github/workflows/sonarcloud.yml
vendored
6
.github/workflows/sonarcloud.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
- develop
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
APP_KEY: UfpBqqeXx7zpNodsC6yjYQcRfDdm4Bxh
|
||||
APP_KEY: TestTestTestTestTestTestTestTest
|
||||
jobs:
|
||||
sonarcloud:
|
||||
name: SonarCloud
|
||||
@ -46,7 +46,9 @@ jobs:
|
||||
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
|
||||
|
||||
- name: "Create database file"
|
||||
run: touch storage/database/database.sqlite
|
||||
run: |
|
||||
touch storage/database/database.sqlite
|
||||
wget -q https://github.com/firefly-iii/test-fixtures/raw/refs/heads/main/test-database.sqlite -O storage/database/database.sqlite
|
||||
|
||||
- name: "Upgrades the database to the latest version"
|
||||
run: php artisan firefly-iii:upgrade-database
|
||||
|
@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidDateException;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
|
@ -64,7 +64,7 @@ class ConvertsDatesToUTC extends Command
|
||||
|
||||
// this variable is ALWAYS en_US.
|
||||
// stops phpstan complaining about dead code.
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ class ConvertsDatesToUTC extends Command
|
||||
$items->each(
|
||||
function ($item) use ($field, $timezoneField): void {
|
||||
/** @var Carbon $date */
|
||||
$date = Carbon::parse($item->{$field}, $item->{$timezoneField}); // @phpstan-ignore-line
|
||||
$date = Carbon::parse($item->{$field}, $item->{$timezoneField}); // @phpstan-ignore-line
|
||||
$date->setTimezone('UTC');
|
||||
$item->{$field} = $date->format('Y-m-d H:i:s'); // @phpstan-ignore-line
|
||||
$item->{$timezoneField} = 'UTC'; // @phpstan-ignore-line
|
||||
|
@ -111,6 +111,7 @@ class CorrectsAccountTypes extends Command
|
||||
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
|
||||
foreach ($resultSet as $entry) {
|
||||
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
if (null !== $journal) {
|
||||
|
@ -236,7 +236,7 @@ class CorrectsNativeAmounts extends Command
|
||||
TransactionObserver::$recalculate = false;
|
||||
foreach ($set as $item) {
|
||||
// here we are.
|
||||
/** @var Transaction|null $transaction */
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->touch();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class RemovesEmptyJournals extends Command
|
||||
|
||||
protected $description = 'Delete empty and uneven transaction journals.';
|
||||
|
||||
protected $signature = 'correction:empty-journals';
|
||||
protected $signature = 'correction:empty-journals';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@ -55,8 +55,8 @@ class RemovesEmptyJournals extends Command
|
||||
private function deleteUnevenJournals(): void
|
||||
{
|
||||
$set = Transaction::whereNull('deleted_at')
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
|
||||
;
|
||||
$total = 0;
|
||||
|
||||
@ -66,7 +66,7 @@ class RemovesEmptyJournals extends Command
|
||||
if (1 === $count % 2) {
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($row->transaction_journal_id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
@ -87,13 +87,14 @@ class RemovesEmptyJournals extends Command
|
||||
{
|
||||
$count = 0;
|
||||
$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->whereNull('transactions.transaction_journal_id')
|
||||
->get(['transaction_journals.id']);
|
||||
->groupBy('transaction_journals.id')
|
||||
->whereNull('transactions.transaction_journal_id')
|
||||
->get(['transaction_journals.id'])
|
||||
;
|
||||
|
||||
foreach ($set as $entry) {
|
||||
try {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
|
@ -69,7 +69,7 @@ class RemovesOrphanedTransactions extends Command
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));
|
||||
foreach ($set as $entry) {
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::withTrashed()->find($entry->id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
@ -131,7 +131,7 @@ class RemovesOrphanedTransactions extends Command
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
// delete journals
|
||||
/** @var TransactionJournal|null $journal */
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
|
@ -256,15 +256,16 @@ class ForcesDecimalSize extends Command
|
||||
foreach ($result as $account) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $account->{$field};
|
||||
$value = $account->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));
|
||||
/** @var Account|null $updateAccount */
|
||||
|
||||
/** @var null|Account $updateAccount */
|
||||
$updateAccount = Account::find($account->id);
|
||||
$updateAccount?->update([$field => $correct]);
|
||||
}
|
||||
@ -315,8 +316,9 @@ class ForcesDecimalSize extends Command
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
|
||||
/** @var Model|null $model */
|
||||
$model = $class::find($item->id);
|
||||
|
||||
/** @var null|Model $model */
|
||||
$model = $class::find($item->id);
|
||||
$model?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
@ -369,8 +371,9 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
/** @var PiggyBankEvent|null $event */
|
||||
$event = PiggyBankEvent::find($item->id);
|
||||
|
||||
/** @var null|PiggyBankEvent $event */
|
||||
$event = PiggyBankEvent::find($item->id);
|
||||
$event?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
@ -414,17 +417,18 @@ class ForcesDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
/** @var PiggyBankRepetition|null $repetition */
|
||||
|
||||
/** @var null|PiggyBankRepetition $repetition */
|
||||
$repetition = PiggyBankRepetition::find($item->id);
|
||||
$repetition->update([$field => $correct]);
|
||||
}
|
||||
@ -467,15 +471,16 @@ class ForcesDecimalSize extends Command
|
||||
foreach ($result as $item) {
|
||||
/** @var string $field */
|
||||
foreach ($fields as $field) {
|
||||
$value = $item->{$field};
|
||||
$value = $item->{$field};
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));
|
||||
/** @var PiggyBank|null $piggyBank */
|
||||
|
||||
/** @var null|PiggyBank $piggyBank */
|
||||
$piggyBank = PiggyBank::find($item->id);
|
||||
$piggyBank?->update([$field => $correct]);
|
||||
}
|
||||
@ -502,15 +507,16 @@ class ForcesDecimalSize extends Command
|
||||
|
||||
/** @var Transaction $item */
|
||||
foreach ($result as $item) {
|
||||
$value = $item->amount;
|
||||
$value = $item->amount;
|
||||
if ('' === $value) {
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
|
||||
/** @var Transaction|null $transaction */
|
||||
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['amount' => $correct]);
|
||||
}
|
||||
@ -532,17 +538,18 @@ class ForcesDecimalSize extends Command
|
||||
|
||||
/** @var Transaction $item */
|
||||
foreach ($result as $item) {
|
||||
$value = $item->foreign_amount;
|
||||
$value = $item->foreign_amount;
|
||||
if (null === $value) {
|
||||
continue;
|
||||
}
|
||||
// fix $field by rounding it down correctly.
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(
|
||||
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)
|
||||
);
|
||||
/** @var Transaction|null $transaction */
|
||||
|
||||
/** @var null|Transaction $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['foreign_amount' => $correct]);
|
||||
}
|
||||
|
@ -53,11 +53,13 @@ class BudgetLimitHandler
|
||||
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));
|
||||
/** @var Budget|null $budget */
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = Budget::find($budgetLimit->budget_id);
|
||||
if (null === $budget) {
|
||||
Log::warning('Budget is null, probably deleted, find deleted version.');
|
||||
/** @var Budget|null $budget */
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = Budget::withTrashed()->find($budgetLimit->budget_id);
|
||||
}
|
||||
if (null === $budget) {
|
||||
|
@ -251,10 +251,11 @@ trait AccountCollection
|
||||
if (0 === $accountId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// in theory, this could lead to finding other users accounts.
|
||||
/** @var Account|null $account */
|
||||
$account = Account::find($accountId);
|
||||
if(null === $account) {
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
continue;
|
||||
}
|
||||
$balance = Steam::finalAccountBalance($account, $transaction['date']);
|
||||
|
@ -121,6 +121,7 @@ class DebugController extends Controller
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -55,7 +54,7 @@ class AmountController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Http\Requests\PiggyBankUpdateRequest;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -56,8 +55,8 @@ class EditController extends Controller
|
||||
app('view')->share('title', (string) trans('firefly.piggyBanks'));
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class CreateController extends Controller
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return view('administrations.create') // @phpstan-ignore-line
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'));
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ class EditController extends Controller
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return view('administrations.edit') // @phpstan-ignore-line
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'));
|
||||
->with(compact('title', 'subTitle', 'mainTitleIcon'))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ class UserRegistration extends Notification
|
||||
|
||||
private User $user;
|
||||
|
||||
public function __construct( User $user)
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,13 +34,13 @@ class UserPolicy
|
||||
public function view(User $user, User $user1): bool
|
||||
{
|
||||
return true;
|
||||
// return auth()->check() && $user->id === $account->user_id;
|
||||
// return auth()->check() && $user->id === $account->user_id;
|
||||
}
|
||||
|
||||
public function viewAccounts(User $user): bool
|
||||
{
|
||||
return true;
|
||||
// return auth()->check();
|
||||
// return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,6 +51,6 @@ class UserPolicy
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return true;
|
||||
// return auth()->check();
|
||||
// return auth()->check();
|
||||
}
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->first(['transaction_journals.id'])
|
||||
;
|
||||
if (null !== $first) {
|
||||
/** @var TransactionJournal|null */
|
||||
/** @var null|TransactionJournal */
|
||||
return TransactionJournal::find($first->id);
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ trait ModifiesPiggyBanks
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
$pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $pivot->current_amount);
|
||||
}
|
||||
@ -91,9 +91,9 @@ trait ModifiesPiggyBanks
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);
|
||||
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
$pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $userCurrency, today(), $pivot->current_amount);
|
||||
}
|
||||
@ -125,8 +125,8 @@ trait ModifiesPiggyBanks
|
||||
Log::debug(sprintf('Maximum amount: %s', $maxAmount));
|
||||
}
|
||||
|
||||
$compare = bccomp($amount, $maxAmount);
|
||||
$result = $compare <= 0;
|
||||
$compare = bccomp($amount, $maxAmount);
|
||||
$result = $compare <= 0;
|
||||
|
||||
Log::debug(sprintf('Compare <= 0? %d, so canAddAmount is %s', $compare, var_export($result, true)));
|
||||
|
||||
@ -160,11 +160,11 @@ trait ModifiesPiggyBanks
|
||||
|
||||
public function setCurrentAmount(PiggyBank $piggyBank, string $amount): PiggyBank
|
||||
{
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
$repetition = $this->getRepetition($piggyBank);
|
||||
if (null === $repetition) {
|
||||
return $piggyBank;
|
||||
}
|
||||
$max = $piggyBank->target_amount;
|
||||
$max = $piggyBank->target_amount;
|
||||
if (1 === bccomp($amount, $max) && 0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||
$amount = $max;
|
||||
}
|
||||
@ -207,14 +207,14 @@ trait ModifiesPiggyBanks
|
||||
|
||||
public function update(PiggyBank $piggyBank, array $data): PiggyBank
|
||||
{
|
||||
$piggyBank = $this->updateProperties($piggyBank, $data);
|
||||
$piggyBank = $this->updateProperties($piggyBank, $data);
|
||||
if (array_key_exists('notes', $data)) {
|
||||
$this->updateNote($piggyBank, (string) $data['notes']);
|
||||
}
|
||||
|
||||
// update the order of the piggy bank:
|
||||
$oldOrder = $piggyBank->order;
|
||||
$newOrder = (int) ($data['order'] ?? $oldOrder);
|
||||
$oldOrder = $piggyBank->order;
|
||||
$newOrder = (int) ($data['order'] ?? $oldOrder);
|
||||
if ($oldOrder !== $newOrder) {
|
||||
$this->setOrder($piggyBank, $newOrder);
|
||||
}
|
||||
@ -306,7 +306,7 @@ trait ModifiesPiggyBanks
|
||||
|
||||
return;
|
||||
}
|
||||
$dbNote = $piggyBank->notes()->first();
|
||||
$dbNote = $piggyBank->notes()->first();
|
||||
if (null === $dbNote) {
|
||||
$dbNote = new Note();
|
||||
$dbNote->noteable()->associate($piggyBank);
|
||||
@ -317,15 +317,16 @@ trait ModifiesPiggyBanks
|
||||
|
||||
public function setOrder(PiggyBank $piggyBank, int $newOrder): bool
|
||||
{
|
||||
$oldOrder = $piggyBank->order;
|
||||
$oldOrder = $piggyBank->order;
|
||||
// Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
if ($newOrder > $oldOrder) {
|
||||
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.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->decrement('piggy_banks.order');
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->decrement('piggy_banks.order')
|
||||
;
|
||||
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
@ -334,11 +335,12 @@ trait ModifiesPiggyBanks
|
||||
return true;
|
||||
}
|
||||
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.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->increment('piggy_banks.order');
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('accounts.user_id', $this->user->id)
|
||||
->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)
|
||||
->where('piggy_banks.id', '!=', $piggyBank->id)
|
||||
->distinct()->increment('piggy_banks.order')
|
||||
;
|
||||
|
||||
$piggyBank->order = $newOrder;
|
||||
Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
@ -359,7 +361,7 @@ trait ModifiesPiggyBanks
|
||||
}
|
||||
// if this account contains less than the amount, remove the current amount, update the amount and continue.
|
||||
$this->removeAmount($piggyBank, $account, $current);
|
||||
$amount = bcsub($amount, $current);
|
||||
$amount = bcsub($amount, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
|
||||
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
|
||||
{
|
||||
if(!($user instanceof User)) {
|
||||
if (!$user instanceof User) {
|
||||
throw new FireflyException('User is not a User object.');
|
||||
}
|
||||
$now = today(config('app.timezone'));
|
||||
|
@ -91,7 +91,8 @@ class AccountDestroyService
|
||||
$transaction->delete();
|
||||
$ibAccount->delete();
|
||||
}
|
||||
/** @var TransactionJournal|null $journal */
|
||||
|
||||
/** @var null|TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($journalId);
|
||||
if (null !== $journal) {
|
||||
/** @var JournalDestroyService $service */
|
||||
|
@ -177,7 +177,7 @@ class Amount
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
/** @var TransactionCurrency|null $default */
|
||||
/** @var null|TransactionCurrency $default */
|
||||
$default = $userGroup->currencies()->where('group_default', true)->first();
|
||||
if (null === $default) {
|
||||
$default = $this->getSystemCurrency();
|
||||
|
@ -50,6 +50,7 @@ class CurrencyForm
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @phpstan-param view-string $view
|
||||
*/
|
||||
protected function currencyField(string $name, string $view, mixed $value = null, ?array $options = null): string
|
||||
|
@ -40,9 +40,9 @@ use Illuminate\Support\Facades\Log;
|
||||
class ExchangeRateConverter
|
||||
{
|
||||
// use ConvertsExchangeRates;
|
||||
private bool $ignoreSettings = false;
|
||||
private array $prepared = [];
|
||||
private int $queryCount = 0;
|
||||
private bool $ignoreSettings = false;
|
||||
private array $prepared = [];
|
||||
private int $queryCount = 0;
|
||||
|
||||
private UserGroup $userGroup;
|
||||
|
||||
|
@ -156,7 +156,7 @@ class AccountBalanceCalculator
|
||||
* @var array $currencies
|
||||
*/
|
||||
foreach ($balances as $accountId => $currencies) {
|
||||
/** @var Account|null $account */
|
||||
/** @var null|Account $account */
|
||||
$account = Account::find($accountId);
|
||||
if (null === $account) {
|
||||
Log::error(sprintf('Could not find account #%d, will not save account balance.', $accountId));
|
||||
@ -169,7 +169,7 @@ class AccountBalanceCalculator
|
||||
* @var array $balance
|
||||
*/
|
||||
foreach ($currencies as $currencyId => $balance) {
|
||||
/** @var TransactionCurrency|null $currency */
|
||||
/** @var null|TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::find($currencyId);
|
||||
if (null === $currency) {
|
||||
Log::error(sprintf('Could not find currency #%d, will not save account balance.', $currencyId));
|
||||
@ -207,5 +207,4 @@ class AccountBalanceCalculator
|
||||
}
|
||||
$object->optimizedCalculation($accounts, $transactionJournal->date);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -129,6 +129,7 @@ class Steam
|
||||
|
||||
// find currency of this entry.
|
||||
$currencies[$entry->transaction_currency_id] ??= TransactionCurrency::find($entry->transaction_currency_id);
|
||||
|
||||
/** @var TransactionCurrency $entryCurrency */
|
||||
$entryCurrency = $currencies[$entry->transaction_currency_id];
|
||||
|
||||
|
@ -174,7 +174,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
|
||||
private function getBalanceDifference(Collection $accounts, Carbon $start, Carbon $end): void
|
||||
{
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
throw new FireflyException('Used deprecated method, rethink this.');
|
||||
}
|
||||
// collect balances, start and end for both native and converted.
|
||||
|
@ -115,7 +115,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
|
||||
// grab repetitions (for current amount):
|
||||
$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
if ('en_US' === config('app.fallback_locale')) {
|
||||
throw new FireflyException('[d] Piggy bank repetitions are EOL.');
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class FireflyValidator extends Validator
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
|
||||
*/
|
||||
public function validateBic(mixed $attribute,mixed $value): bool
|
||||
public function validateBic(mixed $attribute, mixed $value): bool
|
||||
{
|
||||
$regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';
|
||||
$result = preg_match($regex, $value);
|
||||
|
Loading…
Reference in New Issue
Block a user