mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-16 09:51:16 +00:00
Final nestor and phpstan fixes.
This commit is contained in:
@@ -133,9 +133,9 @@ class BudgetController extends Controller
|
||||
$row['pc_left'] = '0';
|
||||
$row['pc_overspent'] = '0';
|
||||
|
||||
if (null !== $limit) {
|
||||
if ($limit instanceof BudgetLimit) {
|
||||
$row['budgeted'] = $limit->amount;
|
||||
$row['left'] = bcsub($row['budgeted'], bcmul($row['spent'], '-1'));
|
||||
$row['left'] = bcsub((string) $row['budgeted'], bcmul((string) $row['spent'], '-1'));
|
||||
$row['overspent'] = bcmul($row['left'], '-1');
|
||||
$row['left'] = 1 === bccomp($row['left'], '0') ? $row['left'] : '0';
|
||||
$row['overspent'] = 1 === bccomp($row['overspent'], '0') ? $row['overspent'] : '0';
|
||||
|
@@ -70,7 +70,7 @@ class StoreController extends Controller
|
||||
foreach ($data as $date => $rate) {
|
||||
$date = Carbon::createFromFormat('Y-m-d', $date);
|
||||
$existing = $this->repository->getSpecificRateOnDate($from, $to, $date);
|
||||
if (null !== $existing) {
|
||||
if ($existing instanceof CurrencyExchangeRate) {
|
||||
// update existing rate.
|
||||
$existing = $this->repository->updateExchangeRate($existing, $rate);
|
||||
$collection->push($existing);
|
||||
@@ -101,7 +101,7 @@ class StoreController extends Controller
|
||||
foreach ($data['rates'] as $key => $rate) {
|
||||
$to = Amount::getTransactionCurrencyByCode($key);
|
||||
$existing = $this->repository->getSpecificRateOnDate($from, $to, $date);
|
||||
if (null !== $existing) {
|
||||
if ($existing instanceof CurrencyExchangeRate) {
|
||||
// update existing rate.
|
||||
$existing = $this->repository->updateExchangeRate($existing, $rate);
|
||||
$collection->push($existing);
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Models\Account;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Rules\IsValidSortInstruction;
|
||||
@@ -30,7 +31,6 @@ use FireflyIII\Support\Facades\Preferences;
|
||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
|
@@ -24,13 +24,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreByDateRequest extends FormRequest
|
||||
{
|
||||
|
@@ -24,8 +24,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Api\V1\Requests\Models\PiggyBank;
|
||||
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Rules\IsValidZeroOrMoreAmount;
|
||||
@@ -97,7 +97,7 @@ class StoreRequest extends FormRequest
|
||||
// validate start before end only if both are there.
|
||||
$data = $validator->getData();
|
||||
$currency = $this->getCurrencyFromData($validator, $data);
|
||||
if (null === $currency) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
return;
|
||||
}
|
||||
$targetAmount = (string) ($data['target_amount'] ?? '0');
|
||||
|
@@ -32,7 +32,6 @@ use FireflyIII\Notifications\Admin\UserInvitation;
|
||||
use FireflyIII\Notifications\Admin\VersionCheckResult;
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\Test\OwnerTestNotificationEmail;
|
||||
use FireflyIII\Notifications\Test\OwnerTestNotificationNtfy;
|
||||
use FireflyIII\Notifications\Test\OwnerTestNotificationPushover;
|
||||
use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
@@ -44,7 +44,6 @@ use FireflyIII\Models\UserRole;
|
||||
use FireflyIII\Notifications\Admin\UserRegistration as AdminRegistrationNotification;
|
||||
use FireflyIII\Notifications\Security\UserFailedLoginAttempt;
|
||||
use FireflyIII\Notifications\Test\UserTestNotificationEmail;
|
||||
use FireflyIII\Notifications\Test\UserTestNotificationNtfy;
|
||||
use FireflyIII\Notifications\Test\UserTestNotificationPushover;
|
||||
use FireflyIII\Notifications\Test\UserTestNotificationSlack;
|
||||
use FireflyIII\Notifications\User\UserLogin;
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -32,7 +33,6 @@ use FireflyIII\Support\Request\ChecksLogin;
|
||||
use FireflyIII\Support\Request\ConvertsDataTypes;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
/**
|
||||
* Class PiggyBankStoreRequest.
|
||||
|
@@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Requests;
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class UnknownUserLoginAttempt extends Notification
|
||||
{
|
||||
|
@@ -27,7 +27,6 @@ namespace FireflyIII\Notifications\Admin;
|
||||
use FireflyIII\Models\InvitedUser;
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -36,7 +35,6 @@ use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class UserInvitation
|
||||
|
@@ -26,7 +26,6 @@ namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -36,7 +35,6 @@ use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class UserRegistration
|
||||
|
@@ -26,14 +26,12 @@ namespace FireflyIII\Notifications\Admin;
|
||||
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class VersionCheckResult
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class DisabledMFANotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class EnabledMFANotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class MFABackupFewLeftNotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class MFABackupNoLeftNotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class MFAManyFailedAttemptsNotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class MFAUsedBackupCodeNotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class NewBackupCodesNotification extends Notification
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Security;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
@@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
class UserFailedLoginAttempt extends Notification
|
||||
{
|
||||
|
@@ -25,11 +25,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\Test;
|
||||
|
||||
use FireflyIII\Notifications\Notifiables\OwnerNotifiable;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Ntfy\Message;
|
||||
use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel;
|
||||
|
||||
// use Illuminate\Notifications\Slack\SlackMessage;
|
||||
|
||||
|
@@ -24,12 +24,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Notifications\Test;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Ntfy\Message;
|
||||
use Wijourdil\NtfyNotificationChannel\Channels\NtfyChannel;
|
||||
|
||||
// use Illuminate\Notifications\Slack\SlackMessage;
|
||||
|
||||
|
@@ -26,14 +26,12 @@ namespace FireflyIII\Notifications\User;
|
||||
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class BillReminder
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\User;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\FireflyConfig;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
@@ -35,7 +34,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class NewAccessToken
|
||||
|
@@ -25,13 +25,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\User;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class RuleActionFailed
|
||||
|
@@ -27,7 +27,6 @@ namespace FireflyIII\Notifications\User;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
@@ -63,9 +62,7 @@ class SubscriptionsOverdueReminder extends Notification
|
||||
'bill' => $item['bill'],
|
||||
];
|
||||
$current['pay_dates'] = array_map(
|
||||
static function (string $date): string {
|
||||
return new Carbon($date)->isoFormat((string)trans('config.month_and_day_moment_js'));
|
||||
},
|
||||
static fn(string $date): string => new Carbon($date)->isoFormat((string)trans('config.month_and_day_moment_js')),
|
||||
$item['dates']['pay_dates']
|
||||
);
|
||||
$info[] = $current;
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\User;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class UserLogin
|
||||
|
@@ -25,7 +25,6 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Notifications\User;
|
||||
|
||||
use FireflyIII\Notifications\ReturnsAvailableChannels;
|
||||
use FireflyIII\Notifications\ReturnsSettings;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@@ -34,7 +33,6 @@ use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use NotificationChannels\Pushover\PushoverMessage;
|
||||
use Ntfy\Message;
|
||||
|
||||
/**
|
||||
* Class UserNewPassword
|
||||
|
@@ -294,9 +294,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$summarizer->setConvertToPrimary($convertToPrimary);
|
||||
|
||||
// filter $journals by range AND currency if it is present.
|
||||
$expenses = array_filter($expenses, static function (array $expense) use ($start, $end, $transactionCurrency): bool {
|
||||
return $expense['date']->between($start, $end) && $expense['currency_id'] === $transactionCurrency->id;
|
||||
});
|
||||
$expenses = array_filter($expenses, static fn(array $expense): bool => $expense['date']->between($start, $end) && $expense['currency_id'] === $transactionCurrency->id);
|
||||
|
||||
return $summarizer->groupByCurrencyId($expenses, 'negative', false);
|
||||
}
|
||||
@@ -308,9 +306,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
||||
$summarizer->setConvertToPrimary($convertToPrimary);
|
||||
|
||||
// filter $journals by range AND currency if it is present.
|
||||
$expenses = array_filter($expenses, static function (array $expense) use ($budget): bool {
|
||||
return $expense['budget_id'] === $budget->id;
|
||||
});
|
||||
$expenses = array_filter($expenses, static fn(array $expense): bool => $expense['budget_id'] === $budget->id);
|
||||
|
||||
return $summarizer->groupByCurrencyId($expenses, 'negative', false);
|
||||
}
|
||||
|
@@ -28,11 +28,8 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class IsValidSortInstruction implements ValidationRule
|
||||
{
|
||||
private string $class;
|
||||
|
||||
public function __construct(string $class)
|
||||
public function __construct(private readonly string $class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
|
@@ -221,13 +221,7 @@ class JournalUpdateService
|
||||
|
||||
private function hasFields(array $fields): bool
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
if (array_key_exists($field, $this->data)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return array_any($fields, fn($field) => array_key_exists($field, $this->data));
|
||||
}
|
||||
|
||||
private function getOriginalSourceAccount(): Account
|
||||
|
@@ -60,7 +60,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
private array $currencies = [];
|
||||
private array $locations = [];
|
||||
private array $meta = [];
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
private array $notes = [];
|
||||
private array $openingBalances = [];
|
||||
private User $user;
|
||||
@@ -69,7 +69,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
private ?Carbon $date = null;
|
||||
private ?Carbon $start = null;
|
||||
private ?Carbon $end = null;
|
||||
private bool $convertToPrimary;
|
||||
private readonly bool $convertToPrimary;
|
||||
private array $balances = [];
|
||||
private array $startBalances = [];
|
||||
private array $endBalances = [];
|
||||
@@ -365,7 +365,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
private function collectBalances(): void
|
||||
{
|
||||
$this->balances = Steam::accountsBalancesOptimized($this->collection, $this->getDate(), $this->primaryCurrency, $this->convertToPrimary);
|
||||
if (null !== $this->start && null !== $this->end) {
|
||||
if ($this->start instanceof Carbon && $this->end instanceof Carbon) {
|
||||
$this->startBalances = Steam::accountsBalancesOptimized($this->collection, $this->start, $this->primaryCurrency, $this->convertToPrimary);
|
||||
$this->endBalances = Steam::accountsBalancesOptimized($this->collection, $this->end, $this->primaryCurrency, $this->convertToPrimary);
|
||||
}
|
||||
@@ -395,7 +395,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
public function setDate(?Carbon $date): void
|
||||
{
|
||||
if (null !== $date) {
|
||||
if ($date instanceof Carbon) {
|
||||
$date->endOfDay();
|
||||
Log::debug(sprintf('Date is now %s', $date->toW3cString()));
|
||||
}
|
||||
@@ -404,7 +404,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
public function getDate(): Carbon
|
||||
{
|
||||
if (null === $this->date) {
|
||||
if (!$this->date instanceof Carbon) {
|
||||
return now();
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
private function getBalanceDifference(int $id, TransactionCurrency $currency): ?string
|
||||
{
|
||||
if (null === $this->start || null === $this->end) {
|
||||
if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) {
|
||||
return null;
|
||||
}
|
||||
$startBalance = $this->startBalances[$id] ?? [];
|
||||
@@ -458,9 +458,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
case 'current_balance':
|
||||
case 'pc_current_balance':
|
||||
$this->collection = $this->collection->sortBy(static function (Account $account) use ($parameter) {
|
||||
return $account->meta['balances'][$parameter[0]] ?? '0';
|
||||
}, SORT_NUMERIC, 'desc' === $parameter[1]);
|
||||
$this->collection = $this->collection->sortBy(static fn(Account $account) => $account->meta['balances'][$parameter[0]] ?? '0', SORT_NUMERIC, 'desc' === $parameter[1]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface
|
||||
{
|
||||
private User $user; // @phpstan-ignore-line
|
||||
private UserGroup $userGroup; // @phpstan-ignore-line
|
||||
private bool $convertToPrimary;
|
||||
private readonly bool $convertToPrimary;
|
||||
private array $ids = [];
|
||||
private array $currencyIds = [];
|
||||
private array $currencies = [];
|
||||
|
@@ -161,7 +161,7 @@ class BudgetEnrichment implements EnrichmentInterface
|
||||
|
||||
private function collectExpenses(): void
|
||||
{
|
||||
if (null !== $this->start && null !== $this->end) {
|
||||
if ($this->start instanceof Carbon && $this->end instanceof Carbon) {
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$opsRepository->setUser($this->user);
|
||||
|
@@ -53,7 +53,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
||||
private array $currencyIds = [];
|
||||
private array $currencies = [];
|
||||
private bool $convertToPrimary = true;
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -181,27 +181,21 @@ class BudgetLimitEnrichment implements EnrichmentInterface
|
||||
|
||||
private function stringifyIds(): void
|
||||
{
|
||||
$this->expenses = array_map(function ($first) {
|
||||
return array_map(function ($second) {
|
||||
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||
$this->expenses = array_map(fn($first) => array_map(function ($second) {
|
||||
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||
|
||||
return $second;
|
||||
}, $first);
|
||||
}, $this->expenses);
|
||||
return $second;
|
||||
}, $first), $this->expenses);
|
||||
|
||||
$this->pcExpenses = array_map(function ($first) {
|
||||
return array_map(function ($second) {
|
||||
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||
$this->pcExpenses = array_map(fn($first) => array_map(function ($second) {
|
||||
$second['currency_id'] = (string)($second['currency_id'] ?? 0);
|
||||
|
||||
return $second;
|
||||
}, $first);
|
||||
}, $this->expenses);
|
||||
return $second;
|
||||
}, $first), $this->expenses);
|
||||
}
|
||||
|
||||
private function filterToBudget(array $expenses, int $budget): array
|
||||
{
|
||||
return array_filter($expenses, function (array $item) use ($budget) {
|
||||
return (int)$item['budget_id'] === $budget;
|
||||
});
|
||||
return array_filter($expenses, fn(array $item) => (int)$item['budget_id'] === $budget);
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
||||
// private array $accountCurrencies = [];
|
||||
private array $notes = [];
|
||||
private array $mappedObjects = [];
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
private array $amounts = [];
|
||||
private array $accounts = [];
|
||||
private array $objectGroups = [];
|
||||
@@ -271,7 +271,7 @@ class PiggyBankEnrichment implements EnrichmentInterface
|
||||
*/
|
||||
private function getSuggestedMonthlyAmount(?Carbon $startDate, ?Carbon $targetDate, ?string $targetAmount, string $currentAmount): string
|
||||
{
|
||||
if (null === $targetAmount || null === $targetDate || null === $startDate) {
|
||||
if (null === $targetAmount || !$targetDate instanceof Carbon || !$startDate instanceof Carbon) {
|
||||
return '0';
|
||||
}
|
||||
$savePerMonth = '0';
|
||||
|
@@ -27,7 +27,6 @@ namespace FireflyIII\Support\JsonApi\Enrichments;
|
||||
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\PiggyBankEvent;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
|
@@ -49,7 +49,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
private User $user;
|
||||
private UserGroup $userGroup; // @phpstan-ignore-line
|
||||
private Collection $collection;
|
||||
private bool $convertToPrimary;
|
||||
private readonly bool $convertToPrimary;
|
||||
private ?Carbon $start = null;
|
||||
private ?Carbon $end = null;
|
||||
private array $subscriptionIds = [];
|
||||
@@ -58,7 +58,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
private array $paidDates = [];
|
||||
private array $notes = [];
|
||||
private array $payDates = [];
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
private BillDateCalculator $calculator;
|
||||
|
||||
public function __construct()
|
||||
@@ -210,7 +210,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
{
|
||||
$this->paidDates = [];
|
||||
Log::debug('Now in collectPaidDates for bills');
|
||||
if (null === $this->start || null === $this->end) {
|
||||
if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) {
|
||||
Log::debug('Parameters are NULL, set empty array');
|
||||
|
||||
return;
|
||||
@@ -274,9 +274,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
// At this point the "next match" is exactly after the last time the bill was paid.
|
||||
$result = [];
|
||||
$filtered = $set->filter(function (TransactionJournal $journal) use ($subscription) {
|
||||
return (int)$journal->bill_id === (int)$subscription->id;
|
||||
});
|
||||
$filtered = $set->filter(fn(TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id);
|
||||
foreach ($filtered as $entry) {
|
||||
$array = [
|
||||
'transaction_group_id' => (string)$entry->transaction_group_id,
|
||||
@@ -346,9 +344,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
*/
|
||||
protected function lastPaidDate(Bill $subscription, Collection $dates, Carbon $default): Carbon
|
||||
{
|
||||
$filtered = $dates->filter(function (TransactionJournal $journal) use ($subscription) {
|
||||
return (int)$journal->bill_id === (int)$subscription->id;
|
||||
});
|
||||
$filtered = $dates->filter(fn(TransactionJournal $journal) => (int)$journal->bill_id === (int)$subscription->id);
|
||||
Log::debug(sprintf('Filtered down from %d to %d entries for bill #%d.', $dates->count(), $filtered->count(), $subscription->id));
|
||||
if (0 === $filtered->count()) {
|
||||
return $default;
|
||||
@@ -392,7 +388,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
private function collectPayDates(): void
|
||||
{
|
||||
if (null === $this->start || null === $this->end) {
|
||||
if (!$this->start instanceof Carbon || !$this->end instanceof Carbon) {
|
||||
Log::debug('Parameters are NULL, set empty array');
|
||||
|
||||
return;
|
||||
@@ -440,8 +436,8 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
// nullify again when it's outside the current view range.
|
||||
if (
|
||||
(null !== $this->start && $nemDate->lt($this->start))
|
||||
|| (null !== $this->end && $nemDate->gt($this->end))
|
||||
($this->start instanceof Carbon && $nemDate->lt($this->start))
|
||||
|| ($this->end instanceof Carbon && $nemDate->gt($this->end))
|
||||
) {
|
||||
$nem = null;
|
||||
$nemDate = null;
|
||||
@@ -454,7 +450,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
|
||||
private function getNextExpectedMatchDiff(?Carbon $nem, array $payDates): string
|
||||
{
|
||||
if (null === $nem) {
|
||||
if (!$nem instanceof Carbon) {
|
||||
return trans('firefly.not_expected_period');
|
||||
}
|
||||
$nemDiff = trans('firefly.not_expected_period');
|
||||
|
@@ -72,7 +72,7 @@ trait UserGroupTrait
|
||||
|
||||
return;
|
||||
}
|
||||
$class = null === $user ? 'NULL' : $user::class;
|
||||
$class = $user instanceof Authenticatable ? $user::class : 'NULL';
|
||||
|
||||
throw new FireflyException(sprintf('Object is %s, not User.', $class));
|
||||
}
|
||||
|
@@ -25,10 +25,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Request;
|
||||
|
||||
use Illuminate\Validation\Validator;
|
||||
use FireflyIII\Enums\WebhookTrigger;
|
||||
use FireflyIII\Models\Webhook;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
trait ValidatesWebhooks
|
||||
{
|
||||
|
@@ -348,9 +348,7 @@ class Steam
|
||||
$currency = $currencies[$account->id];
|
||||
|
||||
// second array
|
||||
$accountSum = array_filter($arrayOfSums, function ($entry) use ($account) {
|
||||
return $entry['account_id'] === $account->id;
|
||||
});
|
||||
$accountSum = array_filter($arrayOfSums, fn($entry) => $entry['account_id'] === $account->id);
|
||||
if (0 === count($accountSum)) {
|
||||
$result[$account->id] = $return;
|
||||
|
||||
|
@@ -34,7 +34,7 @@ use FireflyIII\Support\Facades\Amount;
|
||||
*/
|
||||
class PiggyBankTransformer extends AbstractTransformer
|
||||
{
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private readonly TransactionCurrency $primaryCurrency;
|
||||
|
||||
/**
|
||||
* PiggyBankTransformer constructor.
|
||||
@@ -53,8 +53,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
{
|
||||
// Amounts, depending on 0.0 state of target amount
|
||||
$percentage = null;
|
||||
if (null !== $piggyBank->meta['target_amount'] && 0 !== bccomp($piggyBank->meta['current_amount'], '0')) { // target amount is not 0.00
|
||||
$percentage = (int)bcmul(bcdiv($piggyBank->meta['current_amount'], $piggyBank->meta['target_amount']), '100');
|
||||
if (null !== $piggyBank->meta['target_amount'] && 0 !== bccomp((string) $piggyBank->meta['current_amount'], '0')) { // target amount is not 0.00
|
||||
$percentage = (int)bcmul(bcdiv((string) $piggyBank->meta['current_amount'], $piggyBank->meta['target_amount']), '100');
|
||||
}
|
||||
$startDate = $piggyBank->start_date?->toAtomString();
|
||||
$targetDate = $piggyBank->target_date?->toAtomString();
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\integration\Api\Chart;
|
||||
|
||||
use Override;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\integration\TestCase;
|
||||
|
||||
@@ -39,7 +40,7 @@ final class AccountControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\integration\Api\Chart;
|
||||
|
||||
use Override;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\integration\TestCase;
|
||||
|
||||
@@ -39,7 +40,7 @@ final class BalanceControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\integration\Api\Chart;
|
||||
|
||||
use Override;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\integration\TestCase;
|
||||
|
||||
@@ -39,7 +40,7 @@ final class BudgetControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\integration\Api\Chart;
|
||||
|
||||
use Override;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\integration\TestCase;
|
||||
|
||||
@@ -39,7 +40,7 @@ final class CategoryControllerTest extends TestCase
|
||||
private $user;
|
||||
|
||||
#[Override]
|
||||
#[\Override]
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
Reference in New Issue
Block a user