Skip to content

Firefly III: a personal finances manager

Replace missing methods.

James Colecd08c16dee50
diff --git a/app/Api/V2/Controllers/Autocomplete/AccountController.php b/app/Api/V2/Controllers/Autocomplete/AccountController.php
index 231ff1504b..ab52c9bddc 100644
--- a/app/Api/V2/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V2/Controllers/Autocomplete/AccountController.php
@@ -69,7 +69,7 @@ class AccountController extends Controller
public function accounts(AutocompleteRequest $request): JsonResponse
{
$params = $request->getParameters();
- $result = $this->repository->searchAccount($params['query'], $params['account_types'], $params['page'], $params['size']);
+ $result = $this->repository->searchAccount($params['query'], $params['account_types'], $params['size']);
$return = [];
/** @var Account $account */
diff --git a/app/Api/V2/Controllers/Autocomplete/TagController.php b/app/Api/V2/Controllers/Autocomplete/TagController.php
index 0e06240793..de80a16b92 100644
--- a/app/Api/V2/Controllers/Autocomplete/TagController.php
+++ b/app/Api/V2/Controllers/Autocomplete/TagController.php
@@ -59,7 +59,7 @@ class TagController extends Controller
public function tags(AutocompleteRequest $request): JsonResponse
{
$queryParameters = $request->getParameters();
- $result = $this->repository->searchTag($queryParameters['query'], $queryParameters['size']);
+ $result = $this->repository->searchTag($queryParameters['query']);
$filtered = $result->map(
static function (Tag $item) {
return [
diff --git a/app/Api/V2/Controllers/Model/Account/IndexController.php b/app/Api/V2/Controllers/Model/Account/IndexController.php
index 4f09b12828..5ee6adfc02 100644
--- a/app/Api/V2/Controllers/Model/Account/IndexController.php
+++ b/app/Api/V2/Controllers/Model/Account/IndexController.php
@@ -67,7 +67,7 @@ class IndexController extends Controller
$types = $request->getAccountTypes();
$sorting = $request->getSortInstructions('accounts');
$filters = $request->getFilterInstructions('accounts');
- $accounts = $this->repository->getAccountsByType($types, $sorting, $filters);
+ $accounts = $this->repository->getAccountsByType($types, $sorting);
$pageSize = $this->parameters->get('limit');
$count = $accounts->count();
diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
index fdd809887f..94855811d3 100644
--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php
+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php
@@ -122,8 +122,7 @@ class CorrectsUnevenAmount extends Command
$journals = DB::table('transactions')
->groupBy('transaction_journal_id')
->whereNull('deleted_at')
- ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]) // @phpstan-ignore-line
- ;
+ ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var \stdClass $entry */
foreach ($journals as $entry) {
diff --git a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
index 3034ab9b97..f86a4424e6 100644
--- a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
+++ b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php
@@ -27,6 +27,7 @@ use Illuminate\Console\Command;
class ValidatesEnvironmentVariables extends Command
{
use ShowsFriendlyMessages;
+
/**
* The name and signature of the console command.
*
@@ -37,7 +38,7 @@ class ValidatesEnvironmentVariables extends Command
/**
* The console command description.
*
- * @var string
+ * @var string|null
*/
protected $description = 'Makes sure you use the correct variables.';
@@ -54,17 +55,18 @@ class ValidatesEnvironmentVariables extends Command
private function validateLanguage(): void
{
- $language = env('DEFAULT_LANGUAGE', 'en_US');
- $locale = env('DEFAULT_LOCALE', 'equal');
+ $language = config('firefly.default_language');
+ $locale = config('firefly.default_locale');
$options = array_keys(config('firefly.languages'));
- if (!in_array($language, $options)) {
+
+ if (!in_array($language, $options, true)) {
$this->friendlyError(sprintf('DEFAULT_LANGUAGE "%s" is not a valid language for Firefly III.', $language));
$this->friendlyError('Please check your .env file and make sure you use a valid setting.');
$this->friendlyError(sprintf('Valid languages are: %s', implode(', ', $options)));
exit(1);
}
$options[] = 'equal';
- if (!in_array($locale, $options)) {
+ if (!in_array($locale, $options, true)) {
$this->friendlyError(sprintf('DEFAULT_LOCALE "%s" is not a valid local for Firefly III.', $locale));
$this->friendlyError('Please check your .env file and make sure you use a valid setting.');
$this->friendlyError(sprintf('Valid locales are: %s', implode(', ', $options)));
@@ -72,9 +74,10 @@ class ValidatesEnvironmentVariables extends Command
}
}
- private function validateGuard(): void {
- $guard = env('AUTHENTICATION_GUARD','web');
- if('web' !== $guard && 'remote_user_guard' !== $guard) {
+ private function validateGuard(): void
+ {
+ $guard = env('AUTHENTICATION_GUARD', 'web');
+ if ('web' !== $guard && 'remote_user_guard' !== $guard) {
$this->friendlyError(sprintf('AUTHENTICATION_GUARD "%s" is not a valid guard for Firefly III.', $guard));
$this->friendlyError('Please check your .env file and make sure you use a valid setting.');
$this->friendlyError('Valid guards are: web, remote_user_guard');
@@ -82,9 +85,10 @@ class ValidatesEnvironmentVariables extends Command
}
}
- private function validateStaticToken(): void {
- $token = (string) env('STATIC_CRON_TOKEN','');
- if(0 !== strlen($token) && 32 !== strlen($token)) {
+ private function validateStaticToken(): void
+ {
+ $token = (string) env('STATIC_CRON_TOKEN', '');
+ if (0 !== strlen($token) && 32 !== strlen($token)) {
$this->friendlyError('STATIC_CRON_TOKEN must be empty or a 32-character string.');
$this->friendlyError('Please check your .env file and make sure you use a valid setting.');
exit(1);
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 0309b66f95..eda47f0eec 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -65,6 +65,12 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return true;
}
+ #[\Override]
+ public function getAccountBalances(Account $account): Collection
+ {
+ return $account->accountBalances;
+ }
+
/**
* Find account with same name OR same IBAN or both, but not the same type or ID.
*/
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 548f8a6cef..463f0853c0 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -52,6 +52,7 @@ interface AccountRepositoryInterface
* Moved here from account CRUD.
*/
public function count(array $types): int;
+ public function getAccountBalances(Account $account): Collection;
/**
* Moved here from account CRUD.
diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.php
index 9f7b67f39a..87e2e69f43 100644
--- a/app/Validation/Account/DepositValidation.php
+++ b/app/Validation/Account/DepositValidation.php
@@ -126,7 +126,7 @@ trait DepositValidation
// if the user submits an ID, but that ID is not of the correct type,
// return false.
if (null !== $accountId) {
- $search = $this->getRepository()->find($accountId);
+ $search = $this->accountRepository->find($accountId);
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
app('log')->debug(sprintf('User submitted an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type));
app('log')->debug(sprintf('Firefly III accepts ID #%d as valid account data.', $accountId));
@@ -140,7 +140,7 @@ trait DepositValidation
// if user submits an IBAN:
if (null !== $accountIban) {
- $search = $this->getRepository()->findByIbanNull($accountIban, $validTypes);
+ $search = $this->accountRepository->findByIbanNull($accountIban, $validTypes);
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
app('log')->debug(sprintf('User submitted IBAN ("%s"), which is a "%s", so this is not a valid source.', $accountIban, $search->accountType->type));
$result = false;
@@ -154,7 +154,7 @@ trait DepositValidation
// if user submits a number:
if (null !== $accountNumber && '' !== $accountNumber) {
- $search = $this->getRepository()->findByAccountNumber($accountNumber, $validTypes);
+ $search = $this->accountRepository->findByAccountNumber($accountNumber, $validTypes);
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
app('log')->debug(
sprintf('User submitted number ("%s"), which is a "%s", so this is not a valid source.', $accountNumber, $search->accountType->type)
diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.php
index dcc174c4c7..a3f32afeb0 100644
--- a/app/Validation/Account/OBValidation.php
+++ b/app/Validation/Account/OBValidation.php
@@ -101,7 +101,7 @@ trait OBValidation
// return false.
if (null !== $accountId && null === $accountName) {
app('log')->debug('Source ID is not null, but name is null.');
- $search = $this->getRepository()->find($accountId);
+ $search = $this->accountRepository->find($accountId);
// the source resulted in an account, but it's not of a valid type.
if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) {
diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.php
index 649f795f86..9456e4ecf9 100644
--- a/app/Validation/Account/WithdrawalValidation.php
+++ b/app/Validation/Account/WithdrawalValidation.php
@@ -87,7 +87,7 @@ trait WithdrawalValidation
// if there's an ID it must be of the "validTypes".
if (null !== $accountId && 0 !== $accountId) {
- $found = $this->getRepository()->find($accountId);
+ $found = $this->accountRepository->find($accountId);
if (null !== $found) {
$type = $found->accountType->type;
if (in_array($type, $validTypes, true)) {