Auto commit for release 'develop' on 2025-03-14

This commit is contained in:
github-actions
2025-03-14 17:45:16 +01:00
parent f6642c075d
commit fc98d66ef4
90 changed files with 1933 additions and 1840 deletions

View File

@@ -406,16 +406,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.70.2",
"version": "v3.72.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "1ca468270efbb75ce0c7566a79cca8ea2888584d"
"reference": "900389362c43d116fee1ffc51f7878145fa61b57"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/1ca468270efbb75ce0c7566a79cca8ea2888584d",
"reference": "1ca468270efbb75ce0c7566a79cca8ea2888584d",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/900389362c43d116fee1ffc51f7878145fa61b57",
"reference": "900389362c43d116fee1ffc51f7878145fa61b57",
"shasum": ""
},
"require": {
@@ -445,18 +445,18 @@
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
},
"require-dev": {
"facile-it/paraunit": "^1.3.1 || ^2.5",
"infection/infection": "^0.29.10",
"justinrainbow/json-schema": "^5.3 || ^6.0",
"facile-it/paraunit": "^1.3.1 || ^2.6",
"infection/infection": "^0.29.14",
"justinrainbow/json-schema": "^5.3 || ^6.2",
"keradus/cli-executor": "^2.1",
"mikey179/vfsstream": "^1.6.12",
"php-coveralls/php-coveralls": "^2.7",
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6",
"phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.7",
"symfony/var-dumper": "^5.4.48 || ^6.4.18 || ^7.2.0",
"symfony/yaml": "^5.4.45 || ^6.4.18 || ^7.2.0"
"phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.12",
"symfony/var-dumper": "^5.4.48 || ^6.4.18 || ^7.2.3",
"symfony/yaml": "^5.4.45 || ^6.4.18 || ^7.2.3"
},
"suggest": {
"ext-dom": "For handling output formats in XML",
@@ -497,7 +497,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.70.2"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.72.0"
},
"funding": [
{
@@ -505,7 +505,7 @@
"type": "github"
}
],
"time": "2025-03-03T21:07:23+00:00"
"time": "2025-03-13T11:25:37+00:00"
},
{
"name": "psr/container",

View File

@@ -82,7 +82,7 @@ class UpdateRequest extends FormRequest
'accounts' => 'required',
'accounts.*' => 'array|required',
'accounts.*.account_id' => ['required', 'numeric', 'belongsToUser:accounts,id'],
'accounts.*.current_amount' => ['numeric','nullable', new IsValidZeroOrMoreAmount(true)],
'accounts.*.current_amount' => ['numeric', 'nullable', new IsValidZeroOrMoreAmount(true)],
'object_group_id' => 'numeric|belongsToUser:object_groups,id',
'object_group_title' => ['min:1', 'max:255'],
'transaction_currency_id' => 'exists:transaction_currencies,id|nullable',

View File

@@ -122,7 +122,8 @@ 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')]);
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')])
;
/** @var \stdClass $entry */
foreach ($journals as $entry) {

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
/*
* ValidatesEnvironmentVariables.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -38,7 +40,7 @@ class ValidatesEnvironmentVariables extends Command
/**
* The console command description.
*
* @var string|null
* @var null|string
*/
protected $description = 'Makes sure you use the correct variables.';
@@ -50,6 +52,7 @@ class ValidatesEnvironmentVariables extends Command
$this->validateLanguage();
$this->validateGuard();
$this->validateStaticToken();
return Command::SUCCESS;
}
@@ -63,6 +66,7 @@ class ValidatesEnvironmentVariables extends Command
$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';
@@ -70,6 +74,7 @@ class ValidatesEnvironmentVariables extends Command
$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)));
exit(1);
}
}
@@ -81,6 +86,7 @@ class ValidatesEnvironmentVariables extends Command
$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');
exit(1);
}
}
@@ -88,9 +94,10 @@ class ValidatesEnvironmentVariables extends Command
private function validateStaticToken(): void
{
$token = (string) config('firefly.static_cron_token');
if (0 !== strlen($token) && 32 !== strlen($token)) {
if ('' !== $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);
}
}

View File

@@ -55,8 +55,8 @@ class BillFactory
$skip = array_key_exists('skip', $data) ? $data['skip'] : 0;
$active = array_key_exists('active', $data) ? $data['active'] : 0;
$data['extension_date'] = $data['extension_date'] ?? null;
$data['end_date'] = $data['end_date'] ?? null;
$data['extension_date'] ??= null;
$data['end_date'] ??= null;
/** @var Bill $bill */
$bill = Bill::create(

View File

@@ -147,7 +147,8 @@ class PiggyBankFactory
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id)
->where('piggy_banks.id', $piggyBankId)
->first(['piggy_banks.*']);
->first(['piggy_banks.*'])
;
if (null !== $piggyBank) {
return $piggyBank;
}
@@ -171,7 +172,8 @@ class PiggyBankFactory
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id)
->where('piggy_banks.name', $name)
->first(['piggy_banks.*']);
->first(['piggy_banks.*'])
;
}
private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank
@@ -199,7 +201,8 @@ class PiggyBankFactory
'objectGroups',
]
)
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])
;
$current = 1;
foreach ($set as $piggyBank) {
if ($piggyBank->order !== $current) {

View File

@@ -115,7 +115,7 @@ class NetWorth implements NetWorthInterface
return $netWorth;
}
public function setUser(null | Authenticatable | User $user): void
public function setUser(null|Authenticatable|User $user): void
{
if (!$user instanceof User) {
return;

View File

@@ -130,6 +130,7 @@ class ShowController extends Controller
}
Log::debug('Collect transactions');
Timer::start('collection');
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector
@@ -137,7 +138,8 @@ class ShowController extends Controller
->setLimit($pageSize)
->setPage($page)
->withAPIInformation()
->setRange($start, $end);
->setRange($start, $end)
;
// this search will not include transaction groups where this asset account (or liability)
// is just part of ONE of the journals. To force this:
$collector->setExpandGroupSearch(true);
@@ -149,9 +151,9 @@ class ShowController extends Controller
// enrich data in arrays.
// enrich
// $enrichment = new TransactionGroupEnrichment();
// $enrichment->setUser(auth()->user());
// $groups->setCollection($enrichment->enrich($groups->getCollection()));
// $enrichment = new TransactionGroupEnrichment();
// $enrichment->setUser(auth()->user());
// $groups->setCollection($enrichment->enrich($groups->getCollection()));
$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));
@@ -207,7 +209,7 @@ class ShowController extends Controller
$today = today(config('app.timezone'));
$accountCurrency = $this->repository->getAccountCurrency($account);
$start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;

View File

@@ -53,7 +53,7 @@ class AcceptHeaders
// some routes are exempt from this.
$exempt = [
'api.v1.data.bulk.transactions'
'api.v1.data.bulk.transactions',
];
if (('POST' === $method || 'PUT' === $method) && !$request->hasHeader('Content-Type') && !in_array($request->route()->getName(), $exempt, true)) {

View File

@@ -45,7 +45,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use Override;
/**
* Class AccountRepository.
@@ -76,7 +75,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
/** @var Account $account */
foreach ($accounts as $account) {
$byName = $this->user->accounts()->where('name', $account->name)
->where('id', '!=', $account->id)->first();
->where('id', '!=', $account->id)->first()
;
if (null !== $byName) {
$result->push($account);
$result->push($byName);
@@ -85,7 +85,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
}
if (null !== $account->iban) {
$byIban = $this->user->accounts()->where('iban', $account->iban)
->where('id', '!=', $account->id)->first();
->where('id', '!=', $account->id)->first()
;
if (null !== $byIban) {
$result->push($account);
$result->push($byIban);
@@ -111,7 +112,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
}
);
)
;
if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
@@ -160,7 +162,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return $account;
}
#[Override]
#[\Override]
public function getAccountBalances(Account $account): Collection
{
return $account->accountBalances;
@@ -247,7 +249,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionTypeEnum::LIABILITY_CREDIT->value])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
return $journal?->transactionGroup;
}
@@ -294,7 +297,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
$journal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionTypeEnum::OPENING_BALANCE->value, TransactionTypeEnum::LIABILITY_CREDIT->value])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
if (null === $journal) {
return null;
}
@@ -317,7 +321,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionTypeEnum::OPENING_BALANCE->value, TransactionTypeEnum::LIABILITY_CREDIT->value])
->first(['transaction_journals.*'])?->date->format('Y-m-d H:i:s');
->first(['transaction_journals.*'])?->date->format('Y-m-d H:i:s')
;
}
public function getOpeningBalanceGroup(Account $account): ?TransactionGroup
@@ -332,7 +337,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transactions.account_id', $account->id)
->transactionTypes([TransactionTypeEnum::OPENING_BALANCE->value])
->first(['transaction_journals.*']);
->first(['transaction_journals.*'])
;
}
public function getPiggyBanks(Account $account): Collection
@@ -357,7 +363,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
/** @var null|Account $current */
$current = $this->user->accounts()->where('account_type_id', $type->id)
->where('name', $name)
->first();
->first()
;
if (null !== $current) {
return $current;
@@ -518,7 +525,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
->orderBy('transaction_journals.order', 'DESC')
->where('transaction_journals.user_id', $this->user->id)
->orderBy('transaction_journals.id', 'ASC')
->first(['transaction_journals.id']);
->first(['transaction_journals.id'])
;
if (null !== $first) {
/** @var null|TransactionJournal */
return TransactionJournal::find($first->id);
@@ -557,7 +565,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
$all = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value];
$this->user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereNotIn('account_types.type', $all)
->update(['order' => 0]);
->update(['order' => 0])
;
}
/**
@@ -578,7 +587,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
->with(['accountType']);
->with(['accountType'])
;
if ('' !== $query) {
// split query on spaces just in case:
$parts = explode(' ', $query);
@@ -603,7 +613,8 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
->with(['accountType', 'accountMeta']);
->with(['accountType', 'accountMeta'])
;
if ('' !== $query) {
// split query on spaces just in case:
$parts = explode(' ', $query);
@@ -642,15 +653,16 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return $factory->create($data);
}
#[\Override] public function periodCollection(Account $account, Carbon $start, Carbon $end): array
#[\Override]
public function periodCollection(Account $account, Carbon $start, Carbon $end): array
{
return $account->transactions()
->leftJoin('transaction_journals','transaction_journals.id','=','transactions.transaction_journal_id')
->leftJoin('transaction_types','transaction_types.id','=','transaction_journals.transaction_type_id')
->leftJoin('transaction_currencies','transaction_currencies.id','=','transactions.transaction_currency_id')
->leftJoin('transaction_currencies as foreign_currencies','foreign_currencies.id','=','transactions.foreign_currency_id')
->where('transaction_journals.date','>=',$start)
->where('transaction_journals.date','<=',$end)
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
->leftJoin('transaction_currencies as foreign_currencies', 'foreign_currencies.id', '=', 'transactions.foreign_currency_id')
->where('transaction_journals.date', '>=', $start)
->where('transaction_journals.date', '<=', $end)
->get([
// currencies
'transaction_currencies.id as currency_id',

View File

@@ -123,8 +123,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::WITHDRAWAL->value, $start, $end, $accounts, $expense, $currency);
return $this->groupByCurrency($journals, 'negative');
@@ -141,8 +140,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $opposing = null,
?TransactionCurrency $currency = null
): array
{
): array {
$start->startOfDay();
$end->endOfDay();
@@ -182,7 +180,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([$type])->withAccountInformation()
->setForeignCurrency($currency);
->setForeignCurrency($currency)
;
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
if (null !== $accounts) {
$collector->setSourceAccounts($accounts);
@@ -225,8 +224,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::WITHDRAWAL->value, $start, $end, $accounts, $expense, $currency);
return $this->groupByDirection($journals, 'destination', 'negative');
@@ -248,8 +246,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $expense = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::WITHDRAWAL->value, $start, $end, $accounts, $expense, $currency);
return $this->groupByDirection($journals, 'source', 'negative');
@@ -264,8 +261,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::DEPOSIT->value, $start, $end, $accounts, $revenue, $currency);
return $this->groupByCurrency($journals, 'positive');
@@ -280,8 +276,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::DEPOSIT->value, $start, $end, $accounts, $revenue, $currency);
return $this->groupByDirection($journals, 'destination', 'positive');
@@ -296,8 +291,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $revenue = null,
?TransactionCurrency $currency = null
): array
{
): array {
$journals = $this->getTransactionsForSum(TransactionTypeEnum::DEPOSIT->value, $start, $end, $accounts, $revenue, $currency);
return $this->groupByDirection($journals, 'source', 'positive');

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Attachment;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AttachmentFactory;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
@@ -36,7 +35,6 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\UnableToDeleteFile;
use LogicException;
/**
* Class AttachmentRepository.
@@ -46,7 +44,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface, UserGroupIn
use UserGroupTrait;
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(Attachment $attachment): bool
{
@@ -160,7 +158,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface, UserGroupIn
if (null !== $dbNote) {
try {
$dbNote->delete();
} catch (LogicException $e) {
} catch (\LogicException $e) {
app('log')->error($e->getMessage());
}
}

View File

@@ -62,7 +62,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$search->whereLike('name', sprintf('%%%s', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true);
->where('active', true)
;
return $search->take($limit)->get();
}
@@ -74,7 +75,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$search->whereLike('name', sprintf('%s%%', $query));
}
$search->orderBy('name', 'ASC')
->where('active', true);
->where('active', true)
;
return $search->take($limit)->get();
}
@@ -178,7 +180,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
return $this->user->bills()
->orderBy('order', 'ASC')
->orderBy('active', 'DESC')
->orderBy('name', 'ASC')->get();
->orderBy('name', 'ASC')->get()
;
}
public function getBillsForAccounts(Collection $accounts): Collection
@@ -219,7 +222,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
->orderBy('bills.active', 'DESC')
->orderBy('bills.name', 'ASC')
->groupBy($fields)
->get($fields);
->get($fields)
;
}
/**
@@ -293,7 +297,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
{
return $this->user->bills()
->orderBy('active', 'DESC')
->orderBy('name', 'ASC')->paginate($size);
->orderBy('name', 'ASC')->paginate($size)
;
}
/**
@@ -312,7 +317,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
'transaction_journals.date',
'transaction_journals.transaction_group_id',
]
);
)
;
}
/**
@@ -324,7 +330,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
->leftJoin('rule_actions', 'rule_actions.rule_id', '=', 'rules.id')
->where('rule_actions.action_type', 'link_to_bill')
->where('rule_actions.action_value', $bill->name)
->get(['rules.*']);
->get(['rules.*'])
;
}
/**
@@ -338,7 +345,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$rules = $this->user->rules()
->leftJoin('rule_actions', 'rule_actions.rule_id', '=', 'rules.id')
->where('rule_actions.action_type', 'link_to_bill')
->get(['rules.id', 'rules.title', 'rule_actions.action_value', 'rules.active']);
->get(['rules.id', 'rules.title', 'rule_actions.action_value', 'rules.active'])
;
$array = [];
/** @var Rule $rule */
@@ -364,9 +372,10 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$result = [];
$journals = $bill->transactionJournals()
->where('date', '>=', $date->year . '-01-01 00:00:00')
->where('date', '<=', $date->year . '-12-31 23:59:59')
->get();
->where('date', '>=', $date->year.'-01-01 00:00:00')
->where('date', '<=', $date->year.'-12-31 23:59:59')
->get()
;
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
@@ -437,12 +446,12 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
// find the most recent date for this bill NOT in the future. Cache this date:
$start = clone $bill->date;
$start->startOfDay();
app('log')->debug('nextExpectedMatch: Start is ' . $start->format('Y-m-d'));
app('log')->debug('nextExpectedMatch: Start is '.$start->format('Y-m-d'));
while ($start < $date) {
app('log')->debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d H:i:s'), $date->format('Y-m-d H:i:s')));
$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
app('log')->debug('Start is now ' . $start->format('Y-m-d H:i:s'));
app('log')->debug('Start is now '.$start->format('Y-m-d H:i:s'));
}
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
@@ -457,8 +466,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$start = clone $end;
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip);
}
app('log')->debug('nextExpectedMatch: Final start is ' . $start->format('Y-m-d'));
app('log')->debug('nextExpectedMatch: Matching end is ' . $end->format('Y-m-d'));
app('log')->debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d'));
app('log')->debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d'));
$cache->store($start);

View File

@@ -108,7 +108,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))
->first();
->first()
;
}
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string
@@ -119,7 +120,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
$availableBudget = $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first();
->where('end_date', $end->format('Y-m-d'))->first()
;
if (null !== $availableBudget) {
$amount = $availableBudget->amount;
}
@@ -133,7 +135,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
$return = [];
$availableBudgets = $this->user->availableBudgets()
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get();
->where('end_date', $end->format('Y-m-d'))->get()
;
Log::debug(sprintf('Found %d available budgets', $availableBudgets->count()));
@@ -186,7 +189,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
return $this->user->availableBudgets()
->where('start_date', '=', $start->format('Y-m-d'))
->where('end_date', '=', $end->format('Y-m-d'))
->get();
->get()
;
}
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
@@ -196,7 +200,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first();
->where('end_date', $end->format('Y-m-d'))->first()
;
}
/**
@@ -208,7 +213,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
$availableBudget = $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first();
->where('end_date', $end->format('Y-m-d'))->first()
;
if (null === $availableBudget) {
$availableBudget = new AvailableBudget();
$availableBudget->user()->associate($this->user);

View File

@@ -36,7 +36,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Override;
/**
* Class BudgetLimitRepository
@@ -69,7 +68,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
);
)
;
}
)
->orWhere(
@@ -78,13 +78,15 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));
}
);
)
;
}
)
->where('budget_limits.transaction_currency_id', $currency->id)
->whereNull('budgets.deleted_at')
->where('budgets.active', true)
->where('budgets.user_id', $this->user->id);
->where('budgets.user_id', $this->user->id)
;
if (null !== $budgets && $budgets->count() > 0) {
$query->whereIn('budget_limits.budget_id', $budgets->pluck('id')->toArray());
}
@@ -139,14 +141,16 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
->with(['budget'])
->where('budgets.user_id', $this->user->id)
->whereNull('budgets.deleted_at')
->get(['budget_limits.*']);
->get(['budget_limits.*'])
;
}
// one of the two is NULL.
if (null === $start xor null === $end) {
$query = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')
->with(['budget'])
->whereNull('budgets.deleted_at')
->where('budgets.user_id', $this->user->id);
->where('budgets.user_id', $this->user->id)
;
if (null !== $end) {
// end date must be before $end.
$query->where('end_date', '<=', $end->format('Y-m-d 00:00:00'));
@@ -179,7 +183,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
);
)
;
}
)
->orWhere(
@@ -188,9 +193,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));
}
);
)
;
}
)->get(['budget_limits.*']);
)->get(['budget_limits.*'])
;
}
public function getBudgetLimits(Budget $budget, ?Carbon $start = null, ?Carbon $end = null): Collection
@@ -232,7 +239,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d 00:00:00'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d 23:59:59'));
}
);
)
;
}
)
->orWhere(
@@ -241,12 +249,14 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d 23:59:59'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d 00:00:00'));
}
);
)
;
}
)->orderBy('budget_limits.start_date', 'DESC')->get(['budget_limits.*']);
)->orderBy('budget_limits.start_date', 'DESC')->get(['budget_limits.*'])
;
}
#[Override]
#[\Override]
public function getNoteText(BudgetLimit $budgetLimit): string
{
return (string) $budgetLimit->notes()->first()?->text;
@@ -279,7 +289,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
->where('budget_limits.start_date', $data['start_date']->format('Y-m-d'))
->where('budget_limits.end_date', $data['end_date']->format('Y-m-d'))
->where('budget_limits.transaction_currency_id', $currency->id)
->first(['budget_limits.*']);
->first(['budget_limits.*'])
;
if (null !== $limit) {
throw new FireflyException('200027: Budget limit already exists.');
}
@@ -310,10 +321,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
return $budget->budgetlimits()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first();
->where('end_date', $end->format('Y-m-d'))->first()
;
}
#[Override]
#[\Override]
public function setNoteText(BudgetLimit $budgetLimit, string $text): void
{
$dbNote = $budgetLimit->notes()->first();
@@ -380,7 +392,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$limits = $budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
->count('budget_limits.*');
->count('budget_limits.*')
;
app('log')->debug(sprintf('Found %d budget limits.', $limits));
// there might be a budget limit for these dates:
@@ -388,7 +401,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$limit = $budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
->first(['budget_limits.*']);
->first(['budget_limits.*'])
;
// if more than 1 limit found, delete the others:
if ($limits > 1 && null !== $limit) {
@@ -396,7 +410,8 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface, UserGroup
$budget->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d 00:00:00'))
->where('budget_limits.end_date', $end->format('Y-m-d 00:00:00'))
->where('budget_limits.id', '!=', $limit->id)->delete();
->where('budget_limits.id', '!=', $limit->id)->delete()
;
}
// delete if amount is zero.

View File

@@ -63,7 +63,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$search->whereLike('name', sprintf('%%%s', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true);
->orderBy('name', 'ASC')->where('active', true)
;
return $search->take($limit)->get();
}
@@ -75,7 +76,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$search->whereLike('name', sprintf('%s%%', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true);
->orderBy('name', 'ASC')->where('active', true)
;
return $search->take($limit)->get();
}
@@ -159,7 +161,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
return $this->user->budgets()->where('active', true)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
->get()
;
}
/**
@@ -324,7 +327,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
->where('rules.user_id', $this->user->id)
->whereIn('rule_actions.action_type', $types)
->where('rule_actions.action_value', $oldName)
->get(['rule_actions.*']);
->get(['rule_actions.*'])
;
app('log')->debug(sprintf('Found %d actions to update.', $actions->count()));
/** @var RuleAction $action */
@@ -342,7 +346,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
->where('rules.user_id', $this->user->id)
->whereIn('rule_triggers.trigger_type', $types)
->where('rule_triggers.trigger_value', $oldName)
->get(['rule_triggers.*']);
->get(['rule_triggers.*'])
;
app('log')->debug(sprintf('Found %d triggers to update.', $triggers->count()));
/** @var RuleTrigger $trigger */
@@ -466,7 +471,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
public function getBudgets(): Collection
{
return $this->user->budgets()->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->get();
->orderBy('name', 'ASC')->get()
;
}
public function destroyAutoBudget(Budget $budget): void
@@ -551,7 +557,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
{
return $this->user->budgets()
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', 0)->get();
->orderBy('name', 'ASC')->where('active', 0)->get()
;
}
public function getNoteText(Budget $budget): ?string
@@ -571,7 +578,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$search->whereLike('name', sprintf('%%%s%%', $query));
}
$search->orderBy('order', 'ASC')
->orderBy('name', 'ASC')->where('active', true);
->orderBy('name', 'ASC')->where('active', true)
;
return $search->take($limit)->get();
}
@@ -608,7 +616,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
->setRange($start, $end)
->excludeDestinationAccounts($selection)
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
->setBudgets($this->getActiveBudgets());
->setBudgets($this->getActiveBudgets())
;
$journals = $collector->getExtractedJournals();
$array = [];
@@ -669,7 +678,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
->setRange($start, $end)
->excludeDestinationAccounts($selection)
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
->setBudget($budget);
->setBudget($budget)
;
$journals = $collector->getExtractedJournals();
$array = [];

View File

@@ -42,7 +42,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface BudgetRepositoryInterface
{

View File

@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface NoBudgetRepositoryInterface
{

View File

@@ -202,8 +202,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
?Collection $accounts = null,
?Collection $budgets = null,
?TransactionCurrency $currency = null
): array
{
): array {
Log::debug(sprintf('Start of %s.', __METHOD__));
// this collector excludes all transfers TO liabilities (which are also withdrawals)
// because those expenses only become expenses once they move from the liability to the friend.
@@ -226,7 +225,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
$collector->setUser($this->user)
->setRange($start, $end)
// ->excludeDestinationAccounts($selection)
->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
;
if (null !== $accounts) {
$collector->setAccounts($accounts);

View File

@@ -42,7 +42,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface OperationsRepositoryInterface
{

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Category;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\Attachment;
@@ -225,7 +224,8 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf
// check transactions:
$query = $category->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'ASC');
->orderBy('transaction_journals.date', 'ASC')
;
$lastTransaction = $query->first(['transaction_journals.*']);
if (null !== $lastTransaction) {
@@ -271,7 +271,7 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf
}
/**
* @throws Exception
* @throws \Exception
*/
public function lastUseDate(Category $category, Collection $accounts): ?Carbon
{
@@ -314,14 +314,15 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf
}
/**
* @throws Exception
* @throws \Exception
*/
private function getLastTransactionDate(Category $category, Collection $accounts): ?Carbon
{
// check transactions:
$query = $category->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'DESC');
->orderBy('transaction_journals.date', 'DESC')
;
if ($accounts->count() > 0) {
// filter journals:
$query->whereIn('transactions.account_id', $accounts->pluck('id')->toArray());
@@ -346,7 +347,7 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf
}
/**
* @throws Exception
* @throws \Exception
*/
public function update(Category $category, array $data): Category
{

View File

@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface CategoryRepositoryInterface
{

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface NoCategoryRepositoryInterface
{

View File

@@ -193,7 +193,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])
->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts);
->setDestinationAccounts($accounts)->excludeSourceAccounts($accounts)
;
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
@@ -255,7 +256,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::TRANSFER->value])
->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts);
->setSourceAccounts($accounts)->excludeDestinationAccounts($accounts)
;
if (null !== $categories && $categories->count() > 0) {
$collector->setCategories($categories);
}
@@ -343,7 +345,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)
->setTypes([TransactionTypeEnum::DEPOSIT->value]);
->setTypes([TransactionTypeEnum::DEPOSIT->value])
;
if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts);
@@ -411,7 +414,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setUser($this->user)->setRange($start, $end)
->setTypes([TransactionTypeEnum::TRANSFER->value]);
->setTypes([TransactionTypeEnum::TRANSFER->value])
;
if (null !== $accounts && $accounts->count() > 0) {
$collector->setAccounts($accounts);

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface OperationsRepositoryInterface
{

View File

@@ -42,7 +42,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Override;
/**
* Class CurrencyRepository.
@@ -118,7 +117,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at')
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count();
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
;
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -275,7 +275,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
return $result;
}
#[Override]
#[\Override]
public function find(int $currencyId): ?TransactionCurrency
{
return TransactionCurrency::find($currencyId);
@@ -322,7 +322,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
$rate = $this->user->currencyExchangeRates()
->where('from_currency_id', $fromCurrency->id)
->where('to_currency_id', $toCurrency->id)
->where('date', $date->format('Y-m-d'))->first();
->where('date', $date->format('Y-m-d'))->first()
;
if (null !== $rate) {
app('log')->debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));

View File

@@ -42,7 +42,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface CurrencyRepositoryInterface
{

View File

@@ -1,4 +1,5 @@
<?php
/*
* ExchangeRateRepository.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -30,25 +31,24 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Override;
class ExchangeRateRepository implements ExchangeRateRepositoryInterface, UserGroupInterface
{
use UserGroupTrait;
#[Override]
#[\Override]
public function deleteRate(CurrencyExchangeRate $rate): void
{
$this->userGroup->currencyExchangeRates()->where('id', $rate->id)->delete();
}
#[Override]
#[\Override]
public function getAll(): Collection
{
return $this->userGroup->currencyExchangeRates()->orderBy('date', 'ASC')->get();
}
#[Override]
#[\Override]
public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection
{
// orderBy('date', 'DESC')->toRawSql();
@@ -57,18 +57,21 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface, UserGro
->where(function (Builder $q1) use ($from, $to): void {
$q1->where(function (Builder $q) use ($from, $to): void {
$q->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id);
->where('to_currency_id', $to->id)
;
})->orWhere(function (Builder $q) use ($from, $to): void {
$q->where('from_currency_id', $to->id)
->where('to_currency_id', $from->id);
->where('to_currency_id', $from->id)
;
});
})
->orderBy('date', 'DESC')
->get(['currency_exchange_rates.*']);
->get(['currency_exchange_rates.*'])
;
}
#[Override]
#[\Override]
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
{
/** @var null|CurrencyExchangeRate */
@@ -77,10 +80,11 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface, UserGro
->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id)
->where('date', $date->format('Y-m-d'))
->first();
->first()
;
}
#[Override]
#[\Override]
public function storeExchangeRate(TransactionCurrency $from, TransactionCurrency $to, string $rate, Carbon $date): CurrencyExchangeRate
{
$object = new CurrencyExchangeRate();
@@ -96,7 +100,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface, UserGro
return $object;
}
#[Override]
#[\Override]
public function updateExchangeRate(CurrencyExchangeRate $object, string $rate, ?Carbon $date = null): CurrencyExchangeRate
{
$object->rate = $rate;
@@ -107,5 +111,4 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface, UserGro
return $object;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* ExchangeRateRepositoryInterface.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -32,7 +33,6 @@ use FireflyIII\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Collection;
/**
* Interface ExchangeRateRepositoryInterface
*

View File

@@ -49,7 +49,8 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface, UserGroupIn
return Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->where('transaction_journals.user_id', $this->user->id)
->where('transactions.id', $transactionId)
->first(['transactions.*']);
->first(['transactions.*'])
;
}
/**

View File

@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface JournalAPIRepositoryInterface
{

View File

@@ -32,7 +32,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use stdClass;
/**
* Class JournalCLIRepository
@@ -49,7 +48,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->whereIn('transaction_types.type', $types)
->with(['user', 'transactionType', 'transactionCurrency', 'transactions', 'transactions.account'])
->get(['transaction_journals.*']);
->get(['transaction_journals.*'])
;
}
/**
@@ -179,11 +179,12 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
public function getSplitJournals(): Collection
{
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->groupBy('transaction_journals.id');
->groupBy('transaction_journals.id')
;
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]); // @phpstan-ignore-line
$journalIds = [];
/** @var stdClass $row */
/** @var \stdClass $row */
foreach ($result as $row) {
if ((int) $row->transaction_count > 2) {
$journalIds[] = (int) $row->id;
@@ -192,7 +193,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn
$journalIds = array_unique($journalIds);
return TransactionJournal::with(['transactions'])
->whereIn('id', $journalIds)->get();
->whereIn('id', $journalIds)->get()
;
}
/**

View File

@@ -67,7 +67,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
->transactionJournals()
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->whereIn('transaction_types.type', $types)
->get(['transaction_journals.*']);
->get(['transaction_journals.*'])
;
}
/**
@@ -150,7 +151,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
return new Carbon($cache->get());
}
$entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)
->where('name', $field)->first();
->where('name', $field)->first()
;
if (null === $entry) {
return null;
}
@@ -193,7 +195,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
public function searchJournalDescriptions(string $search, int $limit): Collection
{
$query = $this->user->transactionJournals()
->orderBy('date', 'DESC');
->orderBy('date', 'DESC')
;
if ('' !== $search) {
$query->whereLike('description', sprintf('%%%s%%', $search));
}

View File

@@ -44,7 +44,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface JournalRepositoryInterface
{

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\LinkType;
use Exception;
use FireflyIII\Events\DestroyedTransactionLink;
use FireflyIII\Models\LinkType;
use FireflyIII\Models\Note;
@@ -72,7 +71,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
}
/**
* @throws Exception
* @throws \Exception
*/
public function destroyLink(TransactionJournalLink $link): bool
{
@@ -122,7 +121,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
->where('source_journals.user_id', $this->user->id)
->where('dest_journals.user_id', $this->user->id)
->whereNull('source_journals.deleted_at')
->whereNull('dest_journals.deleted_at');
->whereNull('dest_journals.deleted_at')
;
if (null !== $linkType) {
$query->where('journal_links.link_type_id', $linkType->id);
@@ -172,7 +172,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
/**
* Store link between two journals.
*
* @throws Exception
* @throws \Exception
*/
public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink
{
@@ -234,11 +234,12 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
{
return TransactionJournalLink::where('link_type_id', $linkType->id)
->where('source_id', $inward->id)
->where('destination_id', $outward->id)->first();
->where('destination_id', $outward->id)->first()
;
}
/**
* @throws Exception
* @throws \Exception
*/
private function setNoteText(TransactionJournalLink $link, string $text): void
{
@@ -280,7 +281,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf
/**
* Update an existing transaction journal link.
*
* @throws Exception
* @throws \Exception
*/
public function updateLink(TransactionJournalLink $journalLink, array $data): TransactionJournalLink
{

View File

@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface LinkTypeRepositoryInterface
{

View File

@@ -55,7 +55,8 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGroup
return $this->user->objectGroups()
->with(['piggyBanks', 'bills'])
->orderBy('order', 'ASC')
->orderBy('title', 'ASC')->get();
->orderBy('title', 'ASC')->get()
;
}
public function deleteEmpty(): void
@@ -149,7 +150,8 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGroup
if ($newOrder > $oldOrder) {
$this->user->objectGroups()->where('object_groups.order', '<=', $newOrder)->where('object_groups.order', '>', $oldOrder)
->where('object_groups.id', '!=', $objectGroup->id)
->decrement('object_groups.order');
->decrement('object_groups.order')
;
$objectGroup->order = $newOrder;
$objectGroup->save();
@@ -157,7 +159,8 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGroup
if ($newOrder < $oldOrder) {
$this->user->objectGroups()->where('object_groups.order', '>=', $newOrder)->where('object_groups.order', '<', $oldOrder)
->where('object_groups.id', '!=', $objectGroup->id)
->increment('object_groups.order');
->increment('object_groups.order')
;
$objectGroup->order = $newOrder;
$objectGroup->save();

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface ObjectGroupRepositoryInterface
{

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\PiggyBank;
use Exception;
use FireflyIII\Events\Model\PiggyBank\ChangedAmount;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\PiggyBankFactory;
@@ -142,7 +141,7 @@ trait ModifiesPiggyBanks
}
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(PiggyBank $piggyBank): bool
{
@@ -327,7 +326,8 @@ trait ModifiesPiggyBanks
->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');
->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));
@@ -340,7 +340,8 @@ trait ModifiesPiggyBanks
->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');
->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));

View File

@@ -41,7 +41,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Override;
/**
* Class PiggyBankRepository.
@@ -59,7 +58,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
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)
->delete();
->delete()
;
}
public function findPiggyBank(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank
@@ -92,7 +92,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
return 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.id', $piggyBankId)->first(['piggy_banks.*']);
->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*'])
;
}
/**
@@ -103,7 +104,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
return 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.name', $name)->first(['piggy_banks.*']);
->where('piggy_banks.name', $name)->first(['piggy_banks.*'])
;
}
public function getAttachments(PiggyBank $piggyBank): Collection
@@ -306,20 +308,23 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
public function getPiggyBanks(): Collection
{
$query = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id');
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
;
if (null === $this->user) {
$query->where('accounts.user_group_id', $this->userGroup->id);
}
if (null !== $this->user) {
$query->where('accounts.user_id', $this->user->id);
}
return $query
->with(
[
'objectGroups',
]
)
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*']);
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*'])
;
}
public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition
@@ -385,7 +390,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
return $balance;
}
#[Override]
#[\Override]
public function purgeAll(): void
{
PiggyBank::withTrashed()
@@ -398,10 +403,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
'objectGroups',
]
)
->delete();
->delete()
;
}
#[Override]
#[\Override]
public function resetOrder(): void
{
$factory = new PiggyBankFactory();
@@ -419,12 +425,14 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
'objectGroups',
]
)
->orderBy('piggy_banks.order', 'ASC')->distinct();
->orderBy('piggy_banks.order', 'ASC')->distinct()
;
if ('' !== $query) {
$search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));
}
$search->orderBy('piggy_banks.order', 'ASC')
->orderBy('piggy_banks.name', 'ASC');
->orderBy('piggy_banks.name', 'ASC')
;
return $search->take($limit)->get(['piggy_banks.*']);
}

View File

@@ -44,7 +44,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface PiggyBankRepositoryInterface
{

View File

@@ -80,7 +80,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
$q2->where('data', json_encode($string));
})
->where('transaction_journal_id', $journalMeta->transaction_journal_id)
->count();
->count()
;
if ($count > 0) {
app('log')->debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id));
@@ -101,7 +102,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->orderBy('active', 'DESC')
->orderBy('transaction_type_id', 'ASC')
->orderBy('title', 'ASC')
->get();
->get()
;
}
/**
@@ -129,7 +131,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions'])
->orderBy('active', 'DESC')
->orderBy('title', 'ASC')
->get();
->get()
;
}
public function getBillId(RecurrenceTransaction $recTransaction): ?int
@@ -207,7 +210,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->where('transaction_journals.user_id', $recurrence->user_id)
->whereNull('transaction_journals.deleted_at')
->where('journal_meta.name', 'recurrence_id')
->where('journal_meta.data', '"' . $recurrence->id . '"');
->where('journal_meta.data', '"'.$recurrence->id.'"')
;
if (null !== $start) {
$query->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'));
}
@@ -229,7 +233,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->where('transaction_journals.user_id', $this->user->id)
->where('journal_meta.name', '=', 'recurrence_id')
->where('journal_meta.data', '=', json_encode((string) $recurrence->id))
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray()
;
}
/**
@@ -281,7 +286,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray();
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
foreach ($journalMeta as $journalId) {
$search[] = (int) $journalId;
@@ -292,7 +298,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
$collector->setUser($recurrence->user);
$collector->withCategoryInformation()->withBudgetInformation()->setLimit($pageSize)->setPage($page)
->withAccountInformation();
->withAccountInformation()
;
$collector->setJournalIds($search);
return $collector->getPaginatedGroups();
@@ -305,7 +312,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id')
->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray();
->get()->pluck('transaction_journal_id')->toArray()
;
$search = [];
foreach ($journalMeta as $journalId) {
@@ -488,7 +496,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
$search->whereLike('recurrences.title', sprintf('%%%s%%', $query));
}
$search
->orderBy('recurrences.title', 'ASC');
->orderBy('recurrences.title', 'ASC')
;
return $search->take($limit)->get(['id', 'title', 'description']);
}

View File

@@ -45,7 +45,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface RecurringRepositoryInterface
{

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Rule;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleAction;
@@ -43,7 +42,7 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
use UserGroupTrait;
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(Rule $rule): bool
{
@@ -112,7 +111,7 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
{
$count = $rule->ruleTriggers()->count();
if (0 === $count) {
throw new FireflyException('Rules should have more than zero triggers, rule #' . $rule->id . ' has none!');
throw new FireflyException('Rules should have more than zero triggers, rule #'.$rule->id.' has none!');
}
return $rule->ruleTriggers()->where('trigger_type', 'user_action')->first()->trigger_value;
@@ -167,7 +166,8 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
->orderBy('rule_groups.order', 'ASC')
->orderBy('rules.order', 'ASC')
->orderBy('rules.id', 'ASC')
->with(['ruleGroup', 'ruleTriggers'])->get(['rules.*']);
->with(['ruleGroup', 'ruleTriggers'])->get(['rules.*'])
;
$filtered = new Collection();
/** @var Rule $rule */
@@ -192,7 +192,8 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
->orderBy('rule_groups.order', 'ASC')
->orderBy('rules.order', 'ASC')
->orderBy('rules.id', 'ASC')
->with(['ruleGroup', 'ruleTriggers'])->get();
->with(['ruleGroup', 'ruleTriggers'])->get()
;
$filtered = new Collection();
/** @var Rule $rule */
@@ -215,7 +216,8 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
$search->whereLike('rules.title', sprintf('%%%s%%', $query));
}
$search->orderBy('rules.order', 'ASC')
->orderBy('rules.title', 'ASC');
->orderBy('rules.title', 'ASC')
;
return $search->take($limit)->get(['id', 'title', 'description']);
}
@@ -323,7 +325,8 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
->where('rules.order', '<=', $newOrder)
->where('rules.order', '>', $oldOrder)
->where('rules.id', '!=', $rule->id)
->decrement('rules.order');
->decrement('rules.order')
;
$rule->order = $newOrder;
app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
$rule->save();
@@ -336,7 +339,8 @@ class RuleRepository implements RuleRepositoryInterface, UserGroupInterface
->where('rules.order', '>=', $newOrder)
->where('rules.order', '<', $oldOrder)
->where('rules.id', '!=', $rule->id)
->increment('rules.order');
->increment('rules.order')
;
$rule->order = $newOrder;
app('log')->debug(sprintf('Order of rule #%d ("%s") is now %d', $rule->id, $rule->title, $newOrder));
$rule->save();

View File

@@ -42,7 +42,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface RuleRepositoryInterface
{

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\RuleGroup;
use Exception;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleGroup;
@@ -48,7 +47,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->orderBy('order', 'ASC')
->orderBy('active', 'DESC')
->orderBy('title', 'ASC')
->get(['rule_groups.id']);
->get(['rule_groups.id'])
;
$index = 1;
/** @var RuleGroup $ruleGroup */
@@ -72,7 +72,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
}
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(RuleGroup $ruleGroup, ?RuleGroup $moveTo): bool
{
@@ -105,7 +105,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->whereNull('deleted_at')
->orderBy('order', 'ASC')
->orderBy('title', 'DESC')
->get();
->get()
;
$count = 1;
/** @var RuleGroup $entry */
@@ -130,7 +131,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->orderBy('order', 'ASC')
->orderBy('title', 'DESC')
->orderBy('updated_at', 'DESC')
->get(['rules.*']);
->get(['rules.*'])
;
$count = 1;
/** @var Rule $entry */
@@ -155,7 +157,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->orderBy('order', 'ASC')
->orderBy('active', 'DESC')
->orderBy('action_type', 'ASC')
->get();
->get()
;
$index = 1;
/** @var RuleAction $action */
@@ -175,7 +178,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->orderBy('order', 'ASC')
->orderBy('active', 'DESC')
->orderBy('trigger_type', 'ASC')
->get();
->get()
;
$index = 1;
/** @var RuleTrigger $trigger */
@@ -223,7 +227,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
{
return $group->rules()
->where('rules.active', true)
->get(['rules.*']);
->get(['rules.*'])
;
}
public function getActiveStoreRules(RuleGroup $group): Collection
@@ -233,7 +238,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'store-journal')
->where('rules.active', true)
->get(['rules.*']);
->get(['rules.*'])
;
}
public function getActiveUpdateRules(RuleGroup $group): Collection
@@ -243,7 +249,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'update-journal')
->where('rules.active', true)
->get(['rules.*']);
->get(['rules.*'])
;
}
public function getAllRuleGroupsWithRules(?string $filter): Collection
@@ -262,7 +269,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
$query->orderBy('order', 'ASC');
},
]
)->get();
)->get()
;
if (null === $filter) {
return $groups;
}
@@ -317,7 +325,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
$query->orderBy('order', 'ASC');
},
]
)->get();
)->get()
;
if (null === $filter) {
return $groups;
}
@@ -351,7 +360,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
public function getRules(RuleGroup $group): Collection
{
return $group->rules()
->get(['rules.*']);
->get(['rules.*'])
;
}
public function maxOrder(): int
@@ -366,7 +376,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
$search->whereLike('rule_groups.title', sprintf('%%%s%%', $query));
}
$search->orderBy('rule_groups.order', 'ASC')
->orderBy('rule_groups.title', 'ASC');
->orderBy('rule_groups.title', 'ASC')
;
return $search->take($limit)->get(['id', 'title', 'description']);
}
@@ -399,7 +410,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
if ($newOrder > $oldOrder) {
$this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder)
->where('rule_groups.id', '!=', $ruleGroup->id)
->decrement('order');
->decrement('order')
;
$ruleGroup->order = $newOrder;
app('log')->debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
$ruleGroup->save();
@@ -409,7 +421,8 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface, UserGroupInte
$this->user->ruleGroups()->where('rule_groups.order', '>=', $newOrder)->where('rule_groups.order', '<', $oldOrder)
->where('rule_groups.id', '!=', $ruleGroup->id)
->increment('order');
->increment('order')
;
$ruleGroup->order = $newOrder;
app('log')->debug(sprintf('Order of group #%d ("%s") is now %d', $ruleGroup->id, $ruleGroup->title, $newOrder));
$ruleGroup->save();

View File

@@ -39,7 +39,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface RuleGroupRepositoryInterface
{

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface OperationsRepositoryInterface
{

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Tag;
use Carbon\Carbon;
use Exception;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Factory\TagFactory;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -52,7 +51,7 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface
}
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(Tag $tag): bool
{
@@ -141,7 +140,7 @@ class TagRepository implements TagRepositoryInterface, UserGroupInterface
if (null !== $year) {
app('log')->debug(sprintf('Get tags with year %s.', $year));
$tagQuery->where('tags.date', '>=', $year . '-01-01 00:00:00')->where('tags.date', '<=', $year . '-12-31 23:59:59');
$tagQuery->where('tags.date', '>=', $year.'-01-01 00:00:00')->where('tags.date', '<=', $year.'-12-31 23:59:59');
}
$collection = $tagQuery->get();
$return = [];

View File

@@ -41,7 +41,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface TagRepositoryInterface
{

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\TransactionGroup;
use Carbon\Carbon;
use Exception;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
@@ -145,7 +144,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$set = Attachment::whereIn('attachable_id', $journals)
->where('attachable_type', TransactionJournal::class)
->where('uploaded', true)
->whereNull('deleted_at')->get();
->whereNull('deleted_at')->get()
;
$result = [];
@@ -172,7 +172,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
/** @var null|Note $note */
$note = Note::where('noteable_id', $journalId)
->where('noteable_type', TransactionJournal::class)
->first();
->first()
;
if (null === $note) {
return null;
}
@@ -195,7 +196,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
)
->with(['source', 'destination', 'source.transactions'])
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable']);
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable'])
;
/** @var TransactionJournalLink $entry */
foreach ($set as $entry) {
@@ -289,7 +291,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
/**
* Return object with all found meta field things as Carbon objects.
*
* @throws Exception
* @throws \Exception
*/
public function getMetaDateFields(int $journalId, array $fields): NullArrayObject
{
@@ -297,7 +299,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
->where('transaction_journal_id', $journalId)
->whereIn('name', $fields)
->whereNull('deleted_at')
->get(['name', 'data']);
->get(['name', 'data'])
;
$return = [];
foreach ($query as $row) {
@@ -316,7 +319,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
->where('transaction_journal_id', $journalId)
->whereIn('name', $fields)
->whereNull('deleted_at')
->get(['name', 'data']);
->get(['name', 'data'])
;
$return = [];
foreach ($query as $row) {
@@ -338,7 +342,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
->with('piggyBank', 'piggyBank.account')
->get(['piggy_bank_events.*']);
->get(['piggy_bank_events.*'])
;
/** @var PiggyBankEvent $row */
foreach ($data as $row) {
@@ -348,7 +353,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
// get currency preference.
$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
->where('name', 'currency_id')
->first();
->first()
;
if (null !== $currencyPreference) {
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
}
@@ -382,7 +388,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
->where('tag_transaction_journal.transaction_journal_id', $journalId)
->orderBy('tags.tag', 'ASC')
->get(['tags.tag']);
->get(['tags.tag'])
;
return $result->pluck('tag')->toArray();
}

View File

@@ -44,7 +44,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface TransactionGroupRepositoryInterface
{

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface TransactionTypeRepositoryInterface
{

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\User;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\GroupMembership;
@@ -35,7 +34,6 @@ use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\QueryException;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Override;
/**
* Class UserRepository.
@@ -46,7 +44,7 @@ class UserRepository implements UserRepositoryInterface
* This updates the users email address and records some things so it can be confirmed or undone later.
* The user is blocked until the change is confirmed.
*
* @throws Exception
* @throws \Exception
*
* @see updateEmail
*/
@@ -56,7 +54,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref
app('preferences')->setForUser($user, 'previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
app('preferences')->setForUser($user, 'previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
// set undo and confirm token:
app('preferences')->setForUser($user, 'email_change_undo_token', bin2hex(random_bytes(16)));
@@ -101,7 +99,7 @@ class UserRepository implements UserRepositoryInterface
}
/**
* @throws Exception
* @throws \Exception
*/
public function destroy(User $user): bool
{
@@ -219,7 +217,8 @@ class UserRepository implements UserRepositoryInterface
->where('amount', '>', 0)
->whereNull('budgets.deleted_at')
->where('budgets.user_id', $user->id)
->count('budget_limits.budget_id');
->count('budget_limits.budget_id')
;
$return['rule_groups'] = $user->ruleGroups()->count();
$return['rules'] = $user->rules()->count();
$return['tags'] = $user->tags()->count();
@@ -227,7 +226,7 @@ class UserRepository implements UserRepositoryInterface
return $return;
}
public function hasRole(null | Authenticatable | User $user, string $role): bool
public function hasRole(null|Authenticatable|User $user, string $role): bool
{
if (null === $user) {
return false;
@@ -244,7 +243,7 @@ class UserRepository implements UserRepositoryInterface
return false;
}
#[Override]
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
@@ -268,7 +267,7 @@ class UserRepository implements UserRepositoryInterface
return $collection;
}
public function inviteUser(null | Authenticatable | User $user, string $email): InvitedUser
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
{
if (!$user instanceof User) {
throw new FireflyException('User is not a User object.');
@@ -390,7 +389,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref
app('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'admin_previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
app('preferences')->setForUser($user, 'admin_previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
$user->email = $newEmail;
$user->save();

View File

@@ -40,7 +40,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface UserRepositoryInterface
{
@@ -106,9 +105,9 @@ interface UserRepositoryInterface
public function getUserGroups(User $user): Collection;
public function hasRole(null | Authenticatable | User $user, string $role): bool;
public function hasRole(null|Authenticatable|User $user, string $role): bool;
public function inviteUser(null | Authenticatable | User $user, string $email): InvitedUser;
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser;
public function redeemCode(string $code): void;

View File

@@ -35,8 +35,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupInterface;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Override;
use ValueError;
/**
* Class UserGroupRepository
@@ -142,7 +140,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
}
if (null !== $existingGroup) {
// group already exists
$groupName = sprintf('%s-%s', $user->email, substr(sha1(rand(1000, 9999) . microtime()), 0, 4));
$groupName = sprintf('%s-%s', $user->email, substr(sha1(rand(1000, 9999).microtime()), 0, 4));
}
++$loop;
}
@@ -178,13 +176,13 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
return UserGroup::all();
}
#[Override]
#[\Override]
public function getById(int $id): ?UserGroup
{
return UserGroup::find($id);
}
#[Override]
#[\Override]
public function getMembershipsFromGroupId(int $groupId): Collection
{
return $this->user->groupMemberships()->where('user_group_id', $groupId)->get();
@@ -267,7 +265,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
// group has multiple members. How many are owner, except the user we're editing now?
$ownerCount = $userGroup->groupMemberships()
->where('user_role_id', $owner->id)
->where('user_id', '!=', $user->id)->count();
->where('user_id', '!=', $user->id)->count()
;
// if there are no other owners and the current users does not get or keep the owner role, refuse.
if (
0 === $ownerCount
@@ -287,7 +286,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
foreach ($rolesSimplified as $role) {
try {
$enum = UserRoleEnum::from($role);
} catch (ValueError $e) {
} catch (\ValueError $e) {
// TODO error message
continue;
}
@@ -314,7 +313,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
return $roles;
}
#[Override]
#[\Override]
public function useUserGroup(UserGroup $userGroup): void
{
$this->user->user_group_id = $userGroup->id;

View File

@@ -39,7 +39,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface UserGroupRepositoryInterface
{

View File

@@ -37,8 +37,6 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Override;
use stdClass;
/**
* Class AccountRepository
@@ -49,7 +47,7 @@ class AccountRepository implements AccountRepositoryInterface
{
use UserGroupTrait;
#[Override]
#[\Override]
public function countAccounts(array $types): int
{
$query = $this->userGroup->accounts();
@@ -72,7 +70,8 @@ class AccountRepository implements AccountRepositoryInterface
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
}
);
)
;
if (0 !== count($types)) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
@@ -121,7 +120,7 @@ class AccountRepository implements AccountRepositoryInterface
return $account;
}
#[Override]
#[\Override]
public function getAccountBalances(Account $account): Collection
{
return $account->accountBalances;
@@ -175,12 +174,13 @@ class AccountRepository implements AccountRepositoryInterface
return $account;
}
#[Override]
#[\Override]
public function getAccountTypes(Collection $accounts): Collection
{
return AccountType::leftJoin('accounts', 'accounts.account_type_id', '=', 'account_types.id')
->whereIn('accounts.id', $accounts->pluck('id')->toArray())
->get(['accounts.id', 'account_types.type']);
->get(['accounts.id', 'account_types.type'])
;
}
public function getAccountsById(array $accountIds): Collection
@@ -197,7 +197,7 @@ class AccountRepository implements AccountRepositoryInterface
return $query->get(['accounts.*']);
}
#[Override]
#[\Override]
public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection
{
$query = $this->userGroup->accounts();
@@ -237,7 +237,7 @@ class AccountRepository implements AccountRepositoryInterface
return $query->get(['accounts.*']);
}
#[Override]
#[\Override]
public function getLastActivity(Collection $accounts): array
{
return Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())
@@ -247,7 +247,7 @@ class AccountRepository implements AccountRepositoryInterface
;
}
#[Override]
#[\Override]
public function getMetaValues(Collection $accounts, array $fields): Collection
{
$query = AccountMeta::whereIn('account_id', $accounts->pluck('id')->toArray());
@@ -258,22 +258,23 @@ class AccountRepository implements AccountRepositoryInterface
return $query->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);
}
#[Override]
#[\Override]
public function getObjectGroups(Collection $accounts): array
{
$groupIds = [];
$return = [];
$set = DB::table('object_groupables')->where('object_groupable_type', Account::class)
->whereIn('object_groupable_id', $accounts->pluck('id')->toArray())->get();
->whereIn('object_groupable_id', $accounts->pluck('id')->toArray())->get()
;
/** @var stdClass $row */
/** @var \stdClass $row */
foreach ($set as $row) {
$groupIds[] = $row->object_group_id;
}
$groupIds = array_unique($groupIds);
$groups = ObjectGroup::whereIn('id', $groupIds)->get();
/** @var stdClass $row */
/** @var \stdClass $row */
foreach ($set as $row) {
if (!array_key_exists($row->object_groupable_id, $return)) {
/** @var null|ObjectGroup $group */
@@ -314,7 +315,8 @@ class AccountRepository implements AccountRepositoryInterface
$all = [AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::MORTGAGE->value];
$this->user->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->whereNotIn('account_types.type', $all)
->update(['order' => 0]);
->update(['order' => 0])
;
}
public function getAccountsByType(array $types, ?array $sort = [], ?array $filters = []): Collection
@@ -368,7 +370,7 @@ class AccountRepository implements AccountRepositoryInterface
return $query->get(['accounts.*']);
}
#[Override]
#[\Override]
public function update(Account $account, array $data): Account
{
/** @var AccountUpdateService $service */
@@ -386,7 +388,8 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
->with(['accountType']);
->with(['accountType'])
;
// split query on spaces just in case:
if ('' !== trim($query)) {

View File

@@ -73,7 +73,6 @@ interface AccountRepositoryInterface
public function getObjectGroups(Collection $accounts): array;
/**
* Reset order types of the mentioned accounts.
*/

View File

@@ -63,7 +63,8 @@ class BillRepository implements BillRepositoryInterface
{
return $this->userGroup->bills()
->orderBy('bills.name', 'ASC')
->get(['bills.*']);
->get(['bills.*'])
;
}
public function sumPaidInRange(Carbon $start, Carbon $end): array
@@ -131,7 +132,8 @@ class BillRepository implements BillRepositoryInterface
return $this->userGroup->bills()
->where('active', true)
->orderBy('bills.name', 'ASC')
->get(['bills.*']);
->get(['bills.*'])
;
}
public function sumUnpaidInRange(Carbon $start, Carbon $end): array

View File

@@ -47,7 +47,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
$default = app('amount')->getNativeCurrency();
$availableBudgets = $this->userGroup->availableBudgets()
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get();
->where('end_date', $end->format('Y-m-d'))->get()
;
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {

View File

@@ -41,7 +41,8 @@ class BudgetRepository implements BudgetRepositoryInterface
return $this->userGroup->budgets()->where('active', true)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
->get()
;
}
public function getBudgets(): Collection
@@ -49,6 +50,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $this->userGroup->budgets()
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
->get()
;
}
}

View File

@@ -117,7 +117,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at')
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count();
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
;
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Override;
/**
* Class ExchangeRateRepository
@@ -41,19 +40,19 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
{
use UserGroupTrait;
#[Override]
#[\Override]
public function deleteRate(CurrencyExchangeRate $rate): void
{
$this->userGroup->currencyExchangeRates()->where('id', $rate->id)->delete();
}
#[Override]
#[\Override]
public function getAll(): Collection
{
return $this->userGroup->currencyExchangeRates()->orderBy('date', 'ASC')->get();
}
#[Override]
#[\Override]
public function getRates(TransactionCurrency $from, TransactionCurrency $to): Collection
{
// orderBy('date', 'DESC')->toRawSql();
@@ -62,18 +61,21 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
->where(function (Builder $q1) use ($from, $to): void {
$q1->where(function (Builder $q) use ($from, $to): void {
$q->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id);
->where('to_currency_id', $to->id)
;
})->orWhere(function (Builder $q) use ($from, $to): void {
$q->where('from_currency_id', $to->id)
->where('to_currency_id', $from->id);
->where('to_currency_id', $from->id)
;
});
})
->orderBy('date', 'DESC')
->get(['currency_exchange_rates.*']);
->get(['currency_exchange_rates.*'])
;
}
#[Override]
#[\Override]
public function getSpecificRateOnDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): ?CurrencyExchangeRate
{
/** @var null|CurrencyExchangeRate */
@@ -82,10 +84,11 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
->where('from_currency_id', $from->id)
->where('to_currency_id', $to->id)
->where('date', $date->format('Y-m-d'))
->first();
->first()
;
}
#[Override]
#[\Override]
public function storeExchangeRate(TransactionCurrency $from, TransactionCurrency $to, string $rate, Carbon $date): CurrencyExchangeRate
{
$object = new CurrencyExchangeRate();
@@ -101,7 +104,7 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
return $object;
}
#[Override]
#[\Override]
public function updateExchangeRate(CurrencyExchangeRate $object, string $rate, ?Carbon $date = null): CurrencyExchangeRate
{
$object->rate = $rate;

View File

@@ -40,7 +40,8 @@ class JournalRepository implements JournalRepositoryInterface
public function searchJournalDescriptions(array $query, int $limit): Collection
{
$search = $this->userGroup->transactionJournals()
->orderBy('date', 'DESC');
->orderBy('date', 'DESC')
;
if (count($query) > 0) {
// split query on spaces just in case:
$search->where(function (EloquentBuilder $q) use ($query): void {

View File

@@ -47,6 +47,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
'objectGroups',
]
)
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*']);
->orderBy('piggy_banks.order', 'ASC')->distinct()->get(['piggy_banks.*'])
;
}
}

View File

@@ -68,7 +68,8 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac
{
return $webhook->webhookMessages()
->orderBy('created_at', 'DESC')
->get(['webhook_messages.*']);
->get(['webhook_messages.*'])
;
}
public function getReadyMessages(Webhook $webhook): Collection
@@ -81,7 +82,8 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac
static function (WebhookMessage $message) { // @phpstan-ignore-line
return $message->webhookAttempts()->count() <= 2;
}
)->splice(0, 3);
)->splice(0, 3)
;
}
public function store(array $data): Webhook

View File

@@ -42,7 +42,6 @@ use Illuminate\Support\Collection;
* @method checkUserGroupAccess(UserRoleEnum $role)
* @method setUser(null|Authenticatable|User $user)
* @method setUserGroupById(int $userGroupId)
*
*/
interface WebhookRepositoryInterface
{

View File

@@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Log;
class IsValidZeroOrMoreAmount implements ValidationRule
{
use ValidatesAmountsTrait;
private bool $nullable = false;
public function __construct(bool $nullable = false)
@@ -38,9 +39,6 @@ class IsValidZeroOrMoreAmount implements ValidationRule
$this->nullable = $nullable;
}
use ValidatesAmountsTrait;
/**
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/

View File

@@ -1,4 +1,5 @@
<?php
/*
* Timer.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -42,5 +43,4 @@ class Timer
unset(self::$times[$title]);
Log::debug(sprintf('Timer "%s" took %f seconds', $title, $diff));
}
}

View File

@@ -36,7 +36,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Debug\Timer;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
/**
* Trait PeriodOverview.
@@ -106,8 +105,8 @@ trait PeriodOverview
$title = app('navigation')->periodShow($currentDate['start'], $currentDate['period']);
[$transactions, $spent] = $this->filterTransactionsByType(TransactionTypeEnum::WITHDRAWAL, $transactions, $currentDate['start'], $currentDate['end']);
[$transactions, $earned] = $this->filterTransactionsByType(TransactionTypeEnum::DEPOSIT, $transactions, $currentDate['start'], $currentDate['end']);
[$transactions, $transferredAway] = $this->filterTransfers('away',$transactions, $currentDate['start'], $currentDate['end']);
[$transactions, $transferredIn] = $this->filterTransfers('in',$transactions, $currentDate['start'], $currentDate['end']);
[$transactions, $transferredAway] = $this->filterTransfers('away', $transactions, $currentDate['start'], $currentDate['end']);
[$transactions, $transferredIn] = $this->filterTransfers('in', $transactions, $currentDate['start'], $currentDate['end']);
$entries[]
= [
'title' => $title,
@@ -124,9 +123,11 @@ trait PeriodOverview
return $entries;
}
private function filterTransfers(string $direction, array $transactions, Carbon $start, Carbon $end): array
{
$result = [];
/**
* @var int $index
* @var array $item
@@ -134,29 +135,31 @@ trait PeriodOverview
foreach ($transactions as $index => $item) {
$date = Carbon::parse($item['date']);
if ($date >= $start && $date <= $end) {
if ($direction === 'away' && bccomp($item['amount'], '0') === -1) {
if ('away' === $direction && -1 === bccomp($item['amount'], '0')) {
$result[] = $item;
unset($transactions[$index]);
}
if ($direction === 'in' && bccomp($item['amount'], '0') === 1) {
if ('in' === $direction && 1 === bccomp($item['amount'], '0')) {
$result[] = $item;
unset($transactions[$index]);
}
}
}
return [$transactions, $result];
}
private function filterTransactionsByType(TransactionTypeEnum $type, array $transactions, Carbon $start, Carbon $end): array
{
$result = [];
/**
* @var int $index
* @var array $item
*/
foreach ($transactions as $index => $item) {
$date = Carbon::parse($item['date']);
if($item['type'] === $type->value && $date >= $start && $date <= $end) {
if ($item['type'] === $type->value && $date >= $start && $date <= $end) {
$result[] = $item;
unset($transactions[$index]);
}

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Support\JsonApi\Enrichments;
use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -49,7 +48,6 @@ use Illuminate\Support\Facades\Log;
*/
class AccountEnrichment implements EnrichmentInterface
{
private Collection $collection;
private User $user;

View File

@@ -72,7 +72,7 @@ class Preferences
public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
{
//Log::debug(sprintf('getForUser(#%d, "%s")', $user->id, $name));
// Log::debug(sprintf('getForUser(#%d, "%s")', $user->id, $name));
// don't care about user group ID, except for some specific preferences.
$userGroupId = $this->getUserGroupId($user, $name);
$query = Preference::where('user_id', $user->id)->where('name', $name);
@@ -90,7 +90,7 @@ class Preferences
}
if (null !== $preference) {
//Log::debug(sprintf('Found preference #%d for user #%d: %s', $preference->id, $user->id, $name));
// Log::debug(sprintf('Found preference #%d for user #%d: %s', $preference->id, $user->id, $name));
return $preference;
}

View File

@@ -401,13 +401,13 @@ trait ConvertsDataTypes
continue;
}
$amount = null;
if(array_key_exists('current_amount',$entry)) {
if (array_key_exists('current_amount', $entry)) {
$amount = $this->clearString((string) ($entry['current_amount'] ?? '0'));
if(null === $entry['current_amount']) {
if (null === $entry['current_amount']) {
$amount = null;
}
}
if(!array_key_exists('current_amount',$entry)) {
if (!array_key_exists('current_amount', $entry)) {
$amount = null;
}
$return[] = [

View File

@@ -33,13 +33,13 @@ trait ValidatesBulkTransactionQuery
{
$data = $validator->getData();
// assumption is all validation has already taken place and the query key exists.
$query =$data['query'] ?? '[]';
$query = $data['query'] ?? '[]';
$json = json_decode($query, true, 8, JSON_THROW_ON_ERROR);
if (
array_key_exists('where', $json) &&
array_key_exists('update', $json) &&
array_key_exists('account_id', $json['where']) && array_key_exists('account_id', $json['update'])
array_key_exists('where', $json)
&& array_key_exists('update', $json)
&& array_key_exists('account_id', $json['where']) && array_key_exists('account_id', $json['update'])
) {
// find both accounts, must be same type.
// already validated: belongs to this user.

16
composer.lock generated
View File

@@ -1878,16 +1878,16 @@
},
{
"name": "laravel/framework",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "0883d4175f4e2b5c299e7087ad3c74f2ce195c6d"
"reference": "f85216c82cbd38b66d67ebd20ea762cb3751a4b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/0883d4175f4e2b5c299e7087ad3c74f2ce195c6d",
"reference": "0883d4175f4e2b5c299e7087ad3c74f2ce195c6d",
"url": "https://api.github.com/repos/laravel/framework/zipball/f85216c82cbd38b66d67ebd20ea762cb3751a4b4",
"reference": "f85216c82cbd38b66d67ebd20ea762cb3751a4b4",
"shasum": ""
},
"require": {
@@ -2089,7 +2089,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-03-05T15:34:10+00:00"
"time": "2025-03-12T14:34:30+00:00"
},
{
"name": "laravel/passport",
@@ -12876,7 +12876,7 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
@@ -12897,6 +12897,6 @@
"ext-xml": "*",
"ext-xmlwriter": "*"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

View File

@@ -81,7 +81,7 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2025-03-05',
'version' => 'develop/2025-03-14',
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 25,

566
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -80,18 +80,18 @@
"profile_oauth_create_new_client": "Vytvo\u0159it nov\u00e9ho klienta",
"profile_oauth_create_client": "Vytvo\u0159it klienta",
"profile_oauth_edit_client": "Upravit klienta",
"profile_oauth_name_help": "Something your users will recognize and trust.",
"profile_oauth_name_help": "N\u011bco \u010demu va\u0161i u\u017eivatel\u00e9 budou d\u016fv\u011b\u0159ovat.",
"profile_oauth_redirect_url": "P\u0159esm\u011brovat URL adresu",
"profile_oauth_clients_external_auth": "If you're using an external authentication provider like Authelia, OAuth Clients will not work. You can use Personal Access Tokens only.",
"profile_oauth_redirect_url_help": "Your application's authorization callback URL.",
"profile_oauth_clients_external_auth": "Pokud pro ov\u011b\u0159ov\u00e1n\u00ed pou\u017e\u00edv\u00e1te extern\u00ed slu\u017ebu, nap\u0159\u00edklad Authelia, OAuth klienti nemus\u00ed fungovat spr\u00e1vn\u011b. M\u00edsto toho m\u016f\u017eete pou\u017e\u00edt Personal Access Token.",
"profile_oauth_redirect_url_help": "Callback URL va\u0161\u00ed aplikace.",
"profile_authorized_apps": "Authorized applications",
"profile_authorized_clients": "Autorizovan\u00ed klienti",
"profile_scopes": "Scopes",
"profile_revoke": "Revoke",
"profile_personal_access_tokens": "Personal Access Tokens",
"profile_personal_access_tokens": "Personal Access Token",
"profile_personal_access_token": "Personal Access Token",
"profile_personal_access_token_explanation": "Here is your new personal access token. This is the only time it will be shown so don't lose it! You may now use this token to make API requests.",
"profile_no_personal_access_token": "You have not created any personal access tokens.",
"profile_personal_access_token_explanation": "Tohle je v\u00e1\u0161 nov\u00fd p\u0159\u00edstupov\u00fd token. Tohle je naposled kdy ho vid\u00edte, tak\u017ee ho neztra\u0165te! M\u016f\u017eete ho pou\u017e\u00edt pro vol\u00e1n\u00ed API.",
"profile_no_personal_access_token": "Je\u0161t\u011b jste nevytvo\u0159ili \u017e\u00e1dn\u00e9 p\u0159\u00edstupov\u00e9 tokeny.",
"profile_create_new_token": "Vytvo\u0159it nov\u00fd token",
"profile_create_token": "Vytvo\u0159it token",
"profile_create": "Vytvo\u0159it",
@@ -100,8 +100,8 @@
"piggy_bank": "Pokladni\u010dka",
"profile_oauth_client_secret_title": "Client Secret",
"profile_oauth_client_secret_expl": "Here is your new client secret. This is the only time it will be shown so don't lose it! You may now use this secret to make API requests.",
"profile_oauth_confidential": "Confidential",
"profile_oauth_confidential_help": "Require the client to authenticate with a secret. Confidential clients can hold credentials in a secure way without exposing them to unauthorized parties. Public applications, such as native desktop or JavaScript SPA applications, are unable to hold secrets securely.",
"profile_oauth_confidential": "Soukrom\u00e1 aplikace",
"profile_oauth_confidential_help": "Po\u017eadovat aby se klienti autorizovali. Soukrom\u00e9 aplikace mohou bezpe\u010dn\u011b pracovat s p\u0159\u00edstupov\u00fdmi \u00fadaji bez toho aby je zve\u0159ejnily. Ve\u0159ejn\u00e9 aplikace, nativn\u00ed nebo JavaScriptov\u00e9 SPA, toho schopn\u00e9 nejsou.",
"multi_account_warning_unknown": "Depending on the type of transaction you create, the source and\/or destination account of subsequent splits may be overruled by whatever is defined in the first split of the transaction.",
"multi_account_warning_withdrawal": "Zdrojov\u00fd \u00fa\u010del v\u0161ech n\u00e1sleduj\u00edc\u00edch rozd\u011blen\u00ed je ovl\u00e1dan\u00fd zdrojov\u00fdm \u00fa\u010dtem prvn\u00edho rozd\u011blen\u00ed transakce.",
"multi_account_warning_deposit": "C\u00edlov\u00fd \u00fa\u010del v\u0161ech n\u00e1sleduj\u00edc\u00edch rozd\u011blen\u00ed je ovl\u00e1dan\u00fd c\u00edlov\u00fdm \u00fa\u010dtem prvn\u00edho rozd\u011blen\u00ed transakce.",
@@ -134,7 +134,7 @@
"attempt_content_title": "Pokusy webhooku",
"attempt_content_help": "To v\u0161e jsou ne\u00fasp\u011b\u0161n\u00e9 pokusy t\u00e9to zpravy webhooku o odesl\u00e1n\u00ed na nakonfigurovanou URL. Po n\u011bjak\u00e9 dob\u011b, Firefly III p\u0159estane zkou\u0161et odes\u00edlat zpr\u00e1vu.",
"no_attempts": "Nebyly nalezeny \u017e\u00e1dn\u00e9 ne\u00fasp\u011b\u0161n\u00e9 pokusy. To je dobr\u00e1 v\u011bc!",
"webhook_attempt_at": "Attempt at {moment}",
"webhook_attempt_at": "Pokus v {moment}",
"logs": "Logy",
"response": "Odpov\u011b\u010f",
"visit_webhook_url": "Nav\u0161t\u00edvit URL webhooku",

View File

@@ -153,7 +153,7 @@
"url": "URL",
"active": "Activo",
"interest_date": "Fecha de inter\u00e9s",
"administration_currency": "Native currency",
"administration_currency": "Moneda nativa",
"title": "T\u00edtulo",
"date": "Fecha",
"book_date": "Fecha de registro",

View File

@@ -18,7 +18,7 @@
"is_reconciled": "\u5df2\u6838\u9500",
"split": "\u62c6\u5206",
"single_split": "\u62c6\u5206",
"not_enough_currencies": "Not enough currencies",
"not_enough_currencies": "\u6ca1\u6709\u8db3\u591f\u7684\u8d27\u5e01",
"not_enough_currencies_enabled": "\u5982\u679c\u60a8\u53ea\u542f\u7528\u4e86\u4e00\u79cd\u8d27\u5e01\uff0c\u5c31\u4e0d\u9700\u8981\u6dfb\u52a0\u6c47\u7387\u3002",
"transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">\u4ea4\u6613 #{ID} (\u201c{title}\u201d)<\/a> \u5df2\u4fdd\u5b58\u3002",
"webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">\u63a8\u9001 #{ID} (\"{title}\")<\/a> \u5df2\u4fdd\u5b58.",
@@ -153,7 +153,7 @@
"url": "\u7f51\u5740",
"active": "\u542f\u7528",
"interest_date": "\u5229\u606f\u65e5\u671f",
"administration_currency": "Native currency",
"administration_currency": "\u672c\u5730\u8d27\u5e01",
"title": "\u6807\u9898",
"date": "\u65e5\u671f",
"book_date": "\u767b\u8bb0\u65e5\u671f",
@@ -166,14 +166,14 @@
"webhook_response": "\u54cd\u5e94\u5185\u5bb9",
"webhook_trigger": "\u89e6\u53d1\u6761\u4ef6",
"webhook_delivery": "\u53d1\u9001\u683c\u5f0f",
"from_currency_to_currency": "{from} &rarr; {to}",
"to_currency_from_currency": "{to} &rarr; {from}",
"rate": "Rate"
"from_currency_to_currency": "{from}&rarr;{to}",
"to_currency_from_currency": "{to}&rarr;{from}",
"rate": "\u8bc4\u7ea7"
},
"list": {
"title": "\u6807\u9898",
"active": "\u662f\u5426\u542f\u7528\uff1f",
"native_currency": "Native currency",
"native_currency": "\u672c\u5730\u8d27\u5e01",
"trigger": "\u89e6\u53d1\u6761\u4ef6",
"response": "\u7b54\u590d",
"delivery": "\u4ea4\u4ed8",