mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix various level 4 issues [skip ci]
This commit is contained in:
parent
ea9f635b1a
commit
d4942efd8e
@ -116,7 +116,7 @@ abstract class Controller extends BaseController
|
||||
if (null !== $date) {
|
||||
try {
|
||||
$obj = Carbon::parse((string) $date);
|
||||
} catch (InvalidDateException|InvalidFormatException $e) {
|
||||
} catch (InvalidFormatException $e) {
|
||||
// don't care
|
||||
app('log')->warning(
|
||||
sprintf(
|
||||
|
@ -62,7 +62,11 @@ class ConvertsDatesToUTC extends Command
|
||||
{
|
||||
$this->friendlyWarning('Please do not use this command right now.');
|
||||
|
||||
return 0;
|
||||
// this variable is ALWAYS en_US.
|
||||
// stops phpstan complaining about dead code.
|
||||
if (config('app.fallback_locale') === 'en_US') {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string $model
|
||||
@ -108,10 +112,10 @@ 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
|
||||
$item->{$timezoneField} = 'UTC'; // @phpstan-ignore-line
|
||||
$item->save();
|
||||
}
|
||||
);
|
||||
|
@ -61,12 +61,7 @@ class ReportsSums extends Command
|
||||
$sum = '' === $sum ? '0' : $sum;
|
||||
$foreign = '' === $foreign ? '0' : $foreign;
|
||||
$total = bcadd($sum, $foreign);
|
||||
if (!is_numeric($total)) {
|
||||
$message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $total);
|
||||
$this->friendlyError($message);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (0 !== bccomp($total, '0')) {
|
||||
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $total);
|
||||
$this->friendlyError($message);
|
||||
|
@ -240,7 +240,7 @@ class UpgradesVariousCurrencyInformation extends Command
|
||||
private function isMultiCurrency(Account $account): bool
|
||||
{
|
||||
$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency');
|
||||
if (false === $value || null === $value) {
|
||||
if (null === $value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -230,8 +230,8 @@ class PiggyBankFactory
|
||||
foreach ($accounts as $info) {
|
||||
if ($account->id === $info['account_id']) {
|
||||
if (array_key_exists($account->id, $accounts)) {
|
||||
$toBeLinked[$account->id] = ['current_amount' => $account->pivot?->current_amount ?? '0'];
|
||||
Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
|
||||
$toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount ?? '0'];
|
||||
Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount ?? '0'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,7 @@ class PiggyBankFactory
|
||||
}
|
||||
if (array_key_exists('current_amount', $info)) {
|
||||
$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];
|
||||
Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
|
||||
Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot->current_amount ?? '0'));
|
||||
}
|
||||
if (!array_key_exists('current_amount', $info)) {
|
||||
$toBeLinked[$account->id] ??= [];
|
||||
|
@ -39,7 +39,7 @@ class PiggyBankEventHandler
|
||||
if (null !== $event->transactionGroup) {
|
||||
$journal = $event->transactionGroup->transactionJournals()->first();
|
||||
}
|
||||
$date = $journal?->date ?? today(config('app.timezone'));
|
||||
$date = $journal->date ?? today(config('app.timezone'));
|
||||
// sanity check: event must not already exist for this journal and piggy bank.
|
||||
if (null !== $journal) {
|
||||
$exists = PiggyBankEvent::where('piggy_bank_id', $event->piggyBank->id)
|
||||
|
@ -56,7 +56,7 @@ class AccountObserver
|
||||
$account->native_virtual_balance = $converter->convert($currency, $userCurrency, today(), $account->virtual_balance);
|
||||
|
||||
}
|
||||
if ('' === (string) $account->virtual_balance || ('' !== (string) $account->virtual_balance && 0 === bccomp($account->virtual_balance, '0'))) {
|
||||
if ('' === (string) $account->virtual_balance || (0 === bccomp($account->virtual_balance, '0'))) {
|
||||
$account->virtual_balance = null;
|
||||
$account->native_virtual_balance = null;
|
||||
}
|
||||
|
@ -71,9 +71,6 @@ class PiggyBankObserver
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($group);
|
||||
if (null === $userCurrency) {
|
||||
return;
|
||||
}
|
||||
$piggyBank->native_target_amount = null;
|
||||
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
@ -121,9 +121,7 @@ class DebugController extends Controller
|
||||
echo sprintf('<h2>%s</h2>', $count);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
var_dump($return);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,6 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class AmountController extends Controller
|
||||
{
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private PiggyBankRepositoryInterface $piggyRepos;
|
||||
|
||||
/**
|
||||
@ -57,7 +56,6 @@ class AmountController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-bullseye');
|
||||
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
$this->accountRepos = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class EditController extends Controller
|
||||
{
|
||||
private AccountRepositoryInterface $accountRepository;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private PiggyBankRepositoryInterface $piggyRepos;
|
||||
|
||||
@ -59,7 +58,6 @@ class EditController extends Controller
|
||||
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
$this->piggyRepos = app(PiggyBankRepositoryInterface::class);
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
|
||||
// update recurring thing:
|
||||
$recurrence->latest_date = $date;
|
||||
$recurrence->latest_date_tz = $date?->format('e');
|
||||
$recurrence->latest_date_tz = $date->format('e');
|
||||
$recurrence->save();
|
||||
|
||||
return $group;
|
||||
@ -419,7 +419,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
$single = [
|
||||
'type' => null === $transaction?->transactionType?->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type),
|
||||
'type' => null === $transaction->transactionType->type ? strtolower($recurrence->transactionType->type) : strtolower($transaction->transactionType->type),
|
||||
'date' => $date,
|
||||
'user' => $recurrence->user_id,
|
||||
'currency_id' => $transaction->transaction_currency_id,
|
||||
|
@ -265,8 +265,8 @@ trait RecurrenceValidation
|
||||
|
||||
return;
|
||||
}
|
||||
$nthDay = (int) ($parameters[0] ?? 0.0);
|
||||
$dayOfWeek = (int) ($parameters[1] ?? 0.0);
|
||||
$nthDay = (int) $parameters[0];
|
||||
$dayOfWeek = (int) $parameters[1];
|
||||
if ($nthDay < 1 || $nthDay > 5) {
|
||||
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user