mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Some code cleanup.
This commit is contained in:
@@ -109,6 +109,7 @@ class Handler extends ExceptionHandler
|
|||||||
* Convert an authentication exception into an unauthenticated response.
|
* Convert an authentication exception into an unauthenticated response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
protected function unauthenticated($request)
|
protected function unauthenticated($request)
|
||||||
|
|||||||
@@ -258,15 +258,15 @@ class ReportHelper implements ReportHelperInterface
|
|||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||||
->where(
|
->where(
|
||||||
// source.account_id in accountIds XOR destination.account_id in accountIds
|
// source.account_id in accountIds XOR destination.account_id in accountIds
|
||||||
function (Builder $sourceXorDestinationQuery) use ($ids) {
|
function (Builder $query) use ($ids) {
|
||||||
$sourceXorDestinationQuery->where(
|
$query->where(
|
||||||
function (Builder $inSourceButNotDestinationQuery) use ($ids) {
|
function (Builder $q1) use ($ids) {
|
||||||
$inSourceButNotDestinationQuery->whereIn('source.account_id', $ids)
|
$q1->whereIn('source.account_id', $ids)
|
||||||
->whereNotIn('destination.account_id', $ids);
|
->whereNotIn('destination.account_id', $ids);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function (Builder $inDestinationButNotSourceQuery) use ($ids) {
|
function (Builder $q2) use ($ids) {
|
||||||
$inDestinationButNotSourceQuery->whereIn('destination.account_id', $ids)
|
$q2->whereIn('destination.account_id', $ids)
|
||||||
->whereNotIn('source.account_id', $ids);
|
->whereNotIn('source.account_id', $ids);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ use FireflyIII\Models\Transaction;
|
|||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Steam;
|
use Steam;
|
||||||
@@ -416,15 +416,15 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
);
|
);
|
||||||
$query->where(
|
$query->where(
|
||||||
// source.account_id in accountIds XOR destination.account_id in accountIds
|
// source.account_id in accountIds XOR destination.account_id in accountIds
|
||||||
function (Builder $sourceXorDestinationQuery) use ($accountIds) {
|
function (Builder $query) use ($accountIds) {
|
||||||
$sourceXorDestinationQuery->where(
|
$query->where(
|
||||||
function (Builder $inSourceButNotDestinationQuery) use ($accountIds) {
|
function (Builder $q1) use ($accountIds) {
|
||||||
$inSourceButNotDestinationQuery->whereIn('source.account_id', $accountIds)
|
$q1->whereIn('source.account_id', $accountIds)
|
||||||
->whereNotIn('destination.account_id', $accountIds);
|
->whereNotIn('destination.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function (Builder $inDestinationButNotSourceQuery) use ($accountIds) {
|
function (Builder $q2) use ($accountIds) {
|
||||||
$inDestinationButNotSourceQuery->whereIn('destination.account_id', $accountIds)
|
$q2->whereIn('destination.account_id', $accountIds)
|
||||||
->whereNotIn('source.account_id', $accountIds);
|
->whereNotIn('source.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ use FireflyIII\Models\LimitRepetition;
|
|||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Query\JoinClause;
|
use Illuminate\Database\Query\JoinClause;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
@@ -371,15 +371,15 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
$accountIds = $accounts->pluck('id')->toArray();
|
$accountIds = $accounts->pluck('id')->toArray();
|
||||||
$query->where(
|
$query->where(
|
||||||
// source.account_id in accountIds XOR destination.account_id in accountIds
|
// source.account_id in accountIds XOR destination.account_id in accountIds
|
||||||
function (Builder $sourceXorDestinationQuery) use ($accountIds) {
|
function (Builder $query) use ($accountIds) {
|
||||||
$sourceXorDestinationQuery->where(
|
$query->where(
|
||||||
function (Builder $inSourceButNotDestinationQuery) use ($accountIds) {
|
function (Builder $q1) use ($accountIds) {
|
||||||
$inSourceButNotDestinationQuery->whereIn('source.account_id', $accountIds)
|
$q1->whereIn('source.account_id', $accountIds)
|
||||||
->whereNotIn('destination.account_id', $accountIds);
|
->whereNotIn('destination.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function (Builder $inDestinationButNotSourceQuery) use ($accountIds) {
|
function (Builder $q2) use ($accountIds) {
|
||||||
$inDestinationButNotSourceQuery->whereIn('destination.account_id', $accountIds)
|
$q2->whereIn('destination.account_id', $accountIds)
|
||||||
->whereNotIn('source.account_id', $accountIds);
|
->whereNotIn('source.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -490,15 +490,15 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
$accountIds = $accounts->pluck('id')->toArray();
|
$accountIds = $accounts->pluck('id')->toArray();
|
||||||
$query->where(
|
$query->where(
|
||||||
// source.account_id in accountIds XOR destination.account_id in accountIds
|
// source.account_id in accountIds XOR destination.account_id in accountIds
|
||||||
function (Builder $sourceXorDestinationQuery) use ($accountIds) {
|
function (Builder $query) use ($accountIds) {
|
||||||
$sourceXorDestinationQuery->where(
|
$query->where(
|
||||||
function (Builder $inSourceButNotDestinationQuery) use ($accountIds) {
|
function (Builder $q1) use ($accountIds) {
|
||||||
$inSourceButNotDestinationQuery->whereIn('source.account_id', $accountIds)
|
$q1->whereIn('source.account_id', $accountIds)
|
||||||
->whereNotIn('destination.account_id', $accountIds);
|
->whereNotIn('destination.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
)->orWhere(
|
)->orWhere(
|
||||||
function (Builder $inDestinationButNotSourceQuery) use ($accountIds) {
|
function (Builder $q2) use ($accountIds) {
|
||||||
$inDestinationButNotSourceQuery->whereIn('destination.account_id', $accountIds)
|
$q2->whereIn('destination.account_id', $accountIds)
|
||||||
->whereNotIn('source.account_id', $accountIds);
|
->whereNotIn('source.account_id', $accountIds);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,13 +35,6 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function connect(TransactionJournal $journal, Tag $tag): bool;
|
public function connect(TransactionJournal $journal, Tag $tag): bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Tag $tag
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getJournals(Tag $tag) : Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method destroys a tag.
|
* This method destroys a tag.
|
||||||
*
|
*
|
||||||
@@ -72,6 +65,13 @@ interface TagRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function get(): Collection;
|
public function get(): Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Tag $tag
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getJournals(Tag $tag) : Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method stores a tag.
|
* This method stores a tag.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
|
|||||||
Log::debug(
|
Log::debug(
|
||||||
sprintf(
|
sprintf(
|
||||||
'RuleTrigger FromAccountContains for journal #%d: "%s" does not contain "%s", return false.',
|
'RuleTrigger FromAccountContains for journal #%d: "%s" does not contain "%s", return false.',
|
||||||
$journal->id, $fromAccountName, $search)
|
$journal->id, $fromAccountName, $search
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
|
|||||||
Log::debug(
|
Log::debug(
|
||||||
sprintf(
|
sprintf(
|
||||||
'RuleTrigger ToAccountContains for journal #%d: "%s" does not contain "%s", return false.',
|
'RuleTrigger ToAccountContains for journal #%d: "%s" does not contain "%s", return false.',
|
||||||
$journal->id, $toAccountName, $search)
|
$journal->id, $toAccountName, $search
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
|
|||||||
|
|
||||||
if ($part === $search) {
|
if ($part === $search) {
|
||||||
Log::debug(sprintf('RuleTrigger ToAccountEnds for journal #%d: "%s" ends with "%s", return true.', $journal->id, $toAccountName, $search));
|
Log::debug(sprintf('RuleTrigger ToAccountEnds for journal #%d: "%s" ends with "%s", return true.', $journal->id, $toAccountName, $search));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
|
|||||||
|
|
||||||
if ($part === $search) {
|
if ($part === $search) {
|
||||||
Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $toAccountName, $search));
|
Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" starts with "%s", return true.', $journal->id, $toAccountName, $search));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" does not start with "%s", return false.', $journal->id, $toAccountName, $search));
|
Log::debug(sprintf('RuleTrigger ToAccountStarts for journal #%d: "%s" does not start with "%s", return false.', $journal->id, $toAccountName, $search));
|
||||||
|
|||||||
Reference in New Issue
Block a user