Clean up code.

This commit is contained in:
James Cole
2023-12-10 06:51:59 +01:00
parent c2b22a2bac
commit 46e130fdfe
195 changed files with 973 additions and 984 deletions

View File

@@ -116,7 +116,7 @@ class AccountRepository implements AccountRepositoryInterface
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number) { /** @phpstan-ignore-line */
static function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
$json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json);
@@ -433,7 +433,7 @@ class AccountRepository implements AccountRepositoryInterface
$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
/** @var AccountType $type */
$type = AccountType::where('type', AccountType::RECONCILIATION)->first();
$type = AccountType::where('type', AccountType::RECONCILIATION)->first();
/** @var Account|null $current */
$current = $this->user->accounts()->where('account_type_id', $type->id)

View File

@@ -123,8 +123,8 @@ interface AccountRepositoryInterface
public function getAccountsById(array $accountIds): Collection;
/**
* @param array<int, int|string> $types
* @param array|null $sort
* @param array<int, int|string> $types
* @param array|null $sort
*
* @return Collection
*/

View File

@@ -174,8 +174,8 @@ class AccountTasker implements AccountTaskerInterface
$sourceId = (int)$journal['destination_account_id'];
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $sourceId, $currencyId);
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$report['accounts'][$key] ??= [
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$report['accounts'][$key] ??= [
'id' => $sourceId,
'name' => $journal['destination_account_name'],
'sum' => '0',
@@ -200,7 +200,7 @@ class AccountTasker implements AccountTaskerInterface
$report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);
}
$currencyId = $report['accounts'][$key]['currency_id'];
$report['sums'][$currencyId] ??= [
$report['sums'][$currencyId] ??= [
'sum' => '0',
'currency_id' => $report['accounts'][$key]['currency_id'],
'currency_name' => $report['accounts'][$key]['currency_name'],
@@ -272,7 +272,7 @@ class AccountTasker implements AccountTaskerInterface
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%s-%s', $sourceId, $currencyId);
if (!array_key_exists($key, $report['accounts'])) {
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$currencies[$currencyId] ??= $currencyRepos->find($currencyId);
$report['accounts'][$key] = [
'id' => $sourceId,
'name' => $journal['source_account_name'],
@@ -296,7 +296,7 @@ class AccountTasker implements AccountTaskerInterface
$report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);
}
$currencyId = $report['accounts'][$key]['currency_id'];
$report['sums'][$currencyId] ??= [
$report['sums'][$currencyId] ??= [
'sum' => '0',
'currency_id' => $report['accounts'][$key]['currency_id'],
'currency_name' => $report['accounts'][$key]['currency_name'],

View File

@@ -264,7 +264,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -272,12 +272,12 @@ class OperationsRepository implements OperationsRepositoryInterface
'currency_code' => $journal['currency_code'],
'currency_decimal_places' => $journal['currency_decimal_places'],
];
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount']));/** @phpstan-ignore-line */
$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->$direction($journal['amount'])); // @phpstan-ignore-line
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] ??= [
$array[$foreignId] ??= [
'sum' => '0',
'currency_id' => $foreignId,
'currency_name' => $journal['foreign_currency_name'],
@@ -324,7 +324,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$key = sprintf('%s-%s', $journal[$idKey], $journal['currency_id']);
$array[$key] ??= [
$array[$key] ??= [
'id' => $journal[$idKey],
'name' => $journal[$nameKey],
'sum' => '0',
@@ -339,7 +339,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// also do foreign amount:
if (0 !== (int)$journal['foreign_currency_id']) {
$key = sprintf('%s-%s', $journal[$idKey], $journal['foreign_currency_id']);
$array[$key] ??= [
$array[$key] ??= [
'id' => $journal[$idKey],
'name' => $journal[$nameKey],
'sum' => '0',

View File

@@ -311,7 +311,7 @@ class BillRepository implements BillRepositoryInterface
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$currencyId = (int)$journal->transaction_currency_id;
$currency = $journal->transactionCurrency;
$result[$currencyId] ??= [
$result[$currencyId] ??= [
'sum' => '0',
'count' => 0,
'avg' => '0',
@@ -373,12 +373,12 @@ class BillRepository implements BillRepositoryInterface
return $bill->transactionJournals()
->before($end)->after($start)->get(
[
[
'transaction_journals.id',
'transaction_journals.date',
'transaction_journals.transaction_group_id',
]
);
);
}
/**
@@ -416,7 +416,7 @@ class BillRepository implements BillRepositoryInterface
$array = [];
/** @var Rule $rule */
foreach ($rules as $rule) {
$array[$rule->action_value] ??= [];
$array[$rule->action_value] ??= [];
$array[$rule->action_value][] = ['id' => $rule->id, 'title' => $rule->title, 'active' => $rule->active];
}
$return = [];
@@ -456,7 +456,7 @@ class BillRepository implements BillRepositoryInterface
}
$currencyId = (int)$journal->transaction_currency_id;
$currency = $journal->transactionCurrency;
$result[$currencyId] ??= [
$result[$currencyId] ??= [
'sum' => '0',
'count' => 0,
'avg' => '0',
@@ -676,7 +676,7 @@ class BillRepository implements BillRepositoryInterface
if ($total > 0) {
$currency = $bill->transactionCurrency;
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
$return[$currency->id] ??= [
$return[$currency->id] ??= [
'id' => (string)$currency->id,
'name' => $currency->name,
'symbol' => $currency->symbol,

View File

@@ -133,7 +133,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
*/
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string
{
$amount = '0';
$amount = '0';
/** @var AvailableBudget|null $availableBudget */
$availableBudget = $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id)

View File

@@ -60,32 +60,32 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
// same complex where query as below.
->where(
static function (Builder $q5) use ($start, $end) {
$q5->where(
static function (Builder $q1) use ($start, $end) {
$q1->where(
static function (Builder $q2) use ($start, $end) {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));
}
)
->orWhere(
static function (Builder $q3) use ($start, $end) {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
);
}
)
->orWhere(
static function (Builder $q4) use ($start, $end) {
// or start is before start AND end is after end.
$q4->where('budget_limits.start_date', '<=', $start->format('Y-m-d'));
$q4->where('budget_limits.end_date', '>=', $end->format('Y-m-d'));
}
);
static function (Builder $q5) use ($start, $end) {
$q5->where(
static function (Builder $q1) use ($start, $end) {
$q1->where(
static function (Builder $q2) use ($start, $end) {
$q2->where('budget_limits.end_date', '>=', $start->format('Y-m-d'));
$q2->where('budget_limits.end_date', '<=', $end->format('Y-m-d'));
}
)
->orWhere(
static function (Builder $q3) use ($start, $end) {
$q3->where('budget_limits.start_date', '>=', $start->format('Y-m-d'));
$q3->where('budget_limits.start_date', '<=', $end->format('Y-m-d'));
}
);
}
)
->orWhere(
static function (Builder $q4) use ($start, $end) {
// or start is before start AND end is after end.
$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)
@@ -252,11 +252,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
)
// budget limit start within period
->orWhere(
static function (Builder $q3) use ($start, $end) {
$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'));
}
);
static function (Builder $q3) use ($start, $end) {
$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(

View File

@@ -694,7 +694,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'id' => (string)$currencyId,
'name' => $journal['currency_name'],
'symbol' => $journal['currency_symbol'],
@@ -707,7 +707,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] ??= [
$array[$foreignId] ??= [
'id' => (string)$foreignId,
'name' => $journal['foreign_currency_name'],
'symbol' => $journal['foreign_currency_symbol'],
@@ -757,7 +757,7 @@ class BudgetRepository implements BudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'id' => (string)$currencyId,
'name' => $journal['currency_name'],
'symbol' => $journal['currency_symbol'],
@@ -770,7 +770,7 @@ class BudgetRepository implements BudgetRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] ??= [
$array[$foreignId] ??= [
'id' => (string)$foreignId,
'name' => $journal['foreign_currency_name'],
'symbol' => $journal['foreign_currency_symbol'],

View File

@@ -178,7 +178,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -105,7 +105,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$currencyId = (int)$journal['currency_id'];
$key = sprintf('%d-%d', $budgetId, $currencyId);
$data[$key] ??= [
$data[$key] ??= [
'id' => $budgetId,
'name' => sprintf('%s (%s)', $budgetName, $journal['currency_name']),
'sum' => '0',
@@ -298,7 +298,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -311,7 +311,7 @@ class OperationsRepository implements OperationsRepositoryInterface
// also do foreign amount:
$foreignId = (int)$journal['foreign_currency_id'];
if (0 !== $foreignId) {
$array[$foreignId] ??= [
$array[$foreignId] ??= [
'sum' => '0',
'currency_id' => $foreignId,
'currency_name' => $journal['foreign_currency_name'],

View File

@@ -306,7 +306,7 @@ class CategoryRepository implements CategoryRepositoryInterface
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
$attachment->notes_text = null !== $notes ? $notes->text : '';
return $attachment;
}

View File

@@ -175,7 +175,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -212,7 +212,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],
@@ -243,7 +243,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => $currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -371,7 +371,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -414,7 +414,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],
@@ -457,7 +457,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id'];
$array[$currencyId] ??= [
$array[$currencyId] ??= [
'sum' => '0',
'currency_id' => (string)$currencyId,
'currency_name' => $journal['currency_name'],

View File

@@ -198,9 +198,9 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface
*/
public function getSplitJournals(): Collection
{
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->groupBy('transaction_journals.id');
$result = $query->get(['transaction_journals.id as id', DB::raw('count(transactions.id) as transaction_count')]); /** @phpstan-ignore-line */
$query = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_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 */
foreach ($result as $row) {

View File

@@ -125,7 +125,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
static function (Attachment $attachment) use ($disk) {
$notes = $attachment->notes()->first();
$attachment->file_exists = $disk->exists($attachment->fileName());
$attachment->notes_text = null !== $notes ? $notes->text : '';
$attachment->notes_text = null !== $notes ? $notes->text : '';
return $attachment;
}

View File

@@ -534,9 +534,9 @@ class RecurringRepository implements RecurringRepositoryInterface
}
if ('yearly' === $repetition->repetition_type) {
//
$today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
if(false === $repDate) {
$today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
if (false === $repDate) {
$repDate = clone $today;
}
$diffInYears = $today->diffInYears($repDate);

View File

@@ -196,7 +196,7 @@ class OperationsRepository implements OperationsRepositoryInterface
}
$listedJournals[] = $journalId;
$array[$currencyId]['tags'][$tagId] ??= [
$array[$currencyId]['tags'][$tagId] ??= [
'id' => $tagId,
'name' => $tagName,
'transaction_journals' => [],

View File

@@ -374,6 +374,26 @@ class TagRepository implements TagRepositoryInterface
return $sums;
}
/**
* @inheritDoc
*/
public function tagEndsWith(string $query): Collection
{
$search = sprintf('%%%s', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
}
/**
* @inheritDoc
*/
public function tagStartsWith(string $query): Collection
{
$search = sprintf('%s%%', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
}
/**
* @param Tag $tag
* @param Carbon $start
@@ -454,24 +474,4 @@ class TagRepository implements TagRepositoryInterface
/** @var Location|null */
return $tag->locations()->first();
}
/**
* @inheritDoc
*/
public function tagStartsWith(string $query): Collection
{
$search = sprintf('%s%%', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
}
/**
* @inheritDoc
*/
public function tagEndsWith(string $query): Collection
{
$search = sprintf('%%%s', $query);
return $this->user->tags()->where('tag', 'LIKE', $search)->get(['tags.*']);
}
}

View File

@@ -153,24 +153,6 @@ interface TagRepositoryInterface
*/
public function searchTag(string $query): Collection;
/**
* Find one or more tags that start with the string in the query
*
* @param string $query
*
* @return Collection
*/
public function tagStartsWith(string $query): Collection;
/**
* Find one or more tags that start with the string in the query
*
* @param string $query
*
* @return Collection
*/
public function tagEndsWith(string $query): Collection;
/**
* Search the users tags.
*
@@ -206,6 +188,24 @@ interface TagRepositoryInterface
*/
public function sumsOfTag(Tag $tag, ?Carbon $start, ?Carbon $end): array;
/**
* Find one or more tags that start with the string in the query
*
* @param string $query
*
* @return Collection
*/
public function tagEndsWith(string $query): Collection;
/**
* Find one or more tags that start with the string in the query
*
* @param string $query
*
* @return Collection
*/
public function tagStartsWith(string $query): Collection;
/**
* @param Tag $tag
* @param Carbon $start

View File

@@ -176,7 +176,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
/** @var Attachment $attachment */
foreach ($set as $attachment) {
$journalId = $attachment->attachable_id;
$result[$journalId] ??= [];
$result[$journalId] ??= [];
$current = $attachment->toArray();
$current['file_exists'] = true;
$current['notes'] = $repository->getNoteText($attachment);

View File

@@ -130,7 +130,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
while ($exists && $loop < 10) {
$existingGroup = $this->findByName($groupName);
if (null === $existingGroup) {
$exists = false;
$exists = false;
/** @var UserGroup|null $existingGroup */
$existingGroup = $this->store(['user' => $user, 'title' => $groupName]);
}

View File

@@ -40,6 +40,50 @@ class AccountRepository implements AccountRepositoryInterface
{
use UserGroupTrait;
/**
* @inheritDoc
*/
public function findByAccountNumber(string $number, array $types): ?Account
{
$dbQuery = $this->userGroup
->accounts()
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number) { // @phpstan-ignore-line
$json = json_encode($number);
$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');
$dbQuery->whereIn('account_types.type', $types);
}
/** @var Account|null */
return $dbQuery->first(['accounts.*']);
}
/**
* @param string $iban
* @param array $types
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account
{
$query = $this->userGroup->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (0 !== count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
/** @var Account|null */
return $query->where('iban', $iban)->first(['accounts.*']);
}
/**
* @inheritDoc
*/
@@ -66,31 +110,6 @@ class AccountRepository implements AccountRepositoryInterface
return $account;
}
/**
* @inheritDoc
*/
public function findByAccountNumber(string $number, array $types): ?Account
{
$dbQuery = $this->userGroup
->accounts()
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('accounts.active', true)
->where(
static function (EloquentBuilder $q1) use ($number) { /** @phpstan-ignore-line */
$json = json_encode($number);
$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');
$dbQuery->whereIn('account_types.type', $types);
}
/** @var Account|null */
return $dbQuery->first(['accounts.*']);
}
/**
* @param Account $account
*
@@ -245,22 +264,4 @@ class AccountRepository implements AccountRepositoryInterface
return $dbQuery->take($limit)->get(['accounts.*']);
}
/**
* @param string $iban
* @param array $types
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account
{
$query = $this->userGroup->accounts()->where('iban', '!=', '')->whereNotNull('iban');
if (0 !== count($types)) {
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
$query->whereIn('account_types.type', $types);
}
/** @var Account|null */
return $query->where('iban', $iban)->first(['accounts.*']);
}
}

View File

@@ -37,19 +37,11 @@ use Illuminate\Support\Collection;
interface AccountRepositoryInterface
{
/**
* @param UserGroup $userGroup
*
* @return void
*/
public function setUserGroup(UserGroup $userGroup): void;
/**
* @param string $iban
* @param array $types
* @param int $accountId
*
* @return Account|null
*/
public function findByIbanNull(string $iban, array $types): ?Account;
public function find(int $accountId): ?Account;
/**
* @param string $number
@@ -60,18 +52,12 @@ interface AccountRepositoryInterface
public function findByAccountNumber(string $number, array $types): ?Account;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param int $accountId
* @param string $iban
* @param array $types
*
* @return Account|null
*/
public function find(int $accountId): ?Account;
public function findByIbanNull(string $iban, array $types): ?Account;
/**
* @param string $name
@@ -129,5 +115,19 @@ interface AccountRepositoryInterface
*/
public function searchAccount(string $query, array $types, int $limit): Collection;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param UserGroup $userGroup
*
* @return void
*/
public function setUserGroup(UserGroup $userGroup): void;
}

View File

@@ -157,7 +157,7 @@ class BillRepository implements BillRepositoryInterface
$currencyId = $bill->transaction_currency_id;
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
$nativeAverage = $converter->convert($currency, $default, $start, $average);
$return[$currencyId] ??= [
$return[$currencyId] ??= [
'currency_id' => (string)$currency->id,
'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol,

View File

@@ -35,13 +35,6 @@ use Illuminate\Support\Collection;
*/
interface BillRepositoryInterface
{
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* TODO duplicate of other repos
* Add correct order to bills.
@@ -84,6 +77,13 @@ interface BillRepositoryInterface
*/
public function nextDateMatch(Bill $bill, Carbon $date): Carbon;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* Collect multi-currency of sum of bills already paid.
*

View File

@@ -54,7 +54,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {
$currencyId = $availableBudget->transaction_currency_id;
$return[$currencyId] ??= [
$return[$currencyId] ??= [
'currency_id' => $currencyId,
'currency_code' => $availableBudget->transactionCurrency->code,
'currency_symbol' => $availableBudget->transactionCurrency->symbol,

View File

@@ -33,12 +33,6 @@ use FireflyIII\User;
*/
interface AvailableBudgetRepositoryInterface
{
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param Carbon $start
* @param Carbon $end
@@ -47,4 +41,11 @@ interface AvailableBudgetRepositoryInterface
*/
public function getAvailableBudgetWithCurrency(Carbon $start, Carbon $end): array;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
}

View File

@@ -34,6 +34,11 @@ use Illuminate\Support\Collection;
*/
interface BudgetRepositoryInterface
{
/**
* @return Collection
*/
public function getActiveBudgets(): Collection;
/**
* @param User $user
*
@@ -47,8 +52,4 @@ interface BudgetRepositoryInterface
* @return void
*/
public function setUserGroup(UserGroup $userGroup): void;
/**
* @return Collection
*/
public function getActiveBudgets(): Collection;
}

View File

@@ -34,13 +34,6 @@ use Illuminate\Support\Collection;
*/
interface OperationsRepositoryInterface
{
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* This method returns a list of all the withdrawal transaction journals (as arrays) set in that period
* which have the specified budget set to them. It's grouped per currency, with as few details in the array
@@ -54,4 +47,11 @@ interface OperationsRepositoryInterface
* @return array
*/
public function listExpenses(Carbon $start, Carbon $end, ?Collection $accounts = null, ?Collection $budgets = null): array;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
}

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\UserGroups\Currency;
use FireflyIII\Api\V1\Controllers\Data\Bulk\TransactionController;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
@@ -33,12 +32,6 @@ use Illuminate\Support\Collection;
interface CurrencyRepositoryInterface
{
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param TransactionCurrency $currency
*
@@ -162,6 +155,13 @@ interface CurrencyRepositoryInterface
*/
public function searchCurrency(string $search, int $limit): Collection;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* @param array $data
*

View File

@@ -31,13 +31,6 @@ use Illuminate\Support\Collection;
*/
interface JournalRepositoryInterface
{
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
/**
* Search in journal descriptions.
*
@@ -47,4 +40,11 @@ interface JournalRepositoryInterface
* @return Collection
*/
public function searchJournalDescriptions(string $search, int $limit): Collection;
/**
* @param User $user
*
* @return void
*/
public function setUser(User $user): void;
}