This commit is contained in:
James Cole
2023-12-21 05:07:26 +01:00
parent 1f7ceb6df6
commit a445bc53cd
61 changed files with 165 additions and 163 deletions

View File

@@ -87,7 +87,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
static function (EloquentBuilder $query) use ($accountIds): void { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->orWhereIn('destination.account_id', $accountIds);
}
@@ -106,7 +106,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
static function (EloquentBuilder $query) use ($accountIds): void { // @phpstan-ignore-line
$query->whereIn('source.account_id', $accountIds);
$query->whereIn('destination.account_id', $accountIds);
}
@@ -140,7 +140,7 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $query) use ($accountIds) { // @phpstan-ignore-line
static function (EloquentBuilder $query) use ($accountIds): void { // @phpstan-ignore-line
$query->whereNotIn('source.account_id', $accountIds);
$query->whereNotIn('destination.account_id', $accountIds);
}
@@ -174,18 +174,18 @@ trait AccountCollection
if ($accounts->count() > 0) {
$accountIds = $accounts->pluck('id')->toArray();
$this->query->where(
static function (EloquentBuilder $q1) use ($accountIds) { // @phpstan-ignore-line
static function (EloquentBuilder $q1) use ($accountIds): void { // @phpstan-ignore-line
// sourceAccount is in the set, and destination is NOT.
$q1->where(
static function (EloquentBuilder $q2) use ($accountIds) {
static function (EloquentBuilder $q2) use ($accountIds): void {
$q2->whereIn('source.account_id', $accountIds);
$q2->whereNotIn('destination.account_id', $accountIds);
}
);
// destination is in the set, and source is NOT
$q1->orWhere(
static function (EloquentBuilder $q3) use ($accountIds) {
static function (EloquentBuilder $q3) use ($accountIds): void {
$q3->whereNotIn('source.account_id', $accountIds);
$q3->whereIn('destination.account_id', $accountIds);
}

View File

@@ -38,7 +38,7 @@ trait AmountCollection
public function amountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->where('source.amount', app('steam')->negative($amount));
}
);
@@ -49,7 +49,7 @@ trait AmountCollection
public function amountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->where('source.amount', '!=', app('steam')->negative($amount));
}
);
@@ -63,7 +63,7 @@ trait AmountCollection
public function amountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->where('destination.amount', '<=', app('steam')->positive($amount));
}
);
@@ -77,7 +77,7 @@ trait AmountCollection
public function amountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->where('destination.amount', '>=', app('steam')->positive($amount));
}
);
@@ -91,7 +91,7 @@ trait AmountCollection
public function foreignAmountIs(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->whereNotNull('source.foreign_amount');
$q->where('source.foreign_amount', app('steam')->negative($amount));
}
@@ -106,7 +106,7 @@ trait AmountCollection
public function foreignAmountIsNot(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->whereNull('source.foreign_amount');
$q->orWhere('source.foreign_amount', '!=', app('steam')->negative($amount));
}
@@ -121,7 +121,7 @@ trait AmountCollection
public function foreignAmountLess(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '<=', app('steam')->positive($amount));
}
@@ -136,7 +136,7 @@ trait AmountCollection
public function foreignAmountMore(string $amount): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($amount) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($amount): void { // @phpstan-ignore-line
$q->whereNotNull('destination.foreign_amount');
$q->where('destination.foreign_amount', '>=', app('steam')->positive($amount));
}

View File

@@ -495,10 +495,10 @@ trait AttachmentCollection
app('log')->debug('Add filter on no attachments.');
$this->joinAttachmentTables();
$this->query->where(static function (Builder $q1) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
$q1
->whereNull('attachments.attachable_id')
->orWhere(static function (Builder $q2) {
->orWhere(static function (Builder $q2): void {
$q2
->whereNotNull('attachments.attachable_id')
->whereNotNull('attachments.deleted_at')
@@ -522,7 +522,7 @@ trait AttachmentCollection
$this->hasJoinedAttTables = true;
$this->query->leftJoin('attachments', 'attachments.attachable_id', '=', 'transaction_journals.id')
->where(
static function (EloquentBuilder $q1) { // @phpstan-ignore-line
static function (EloquentBuilder $q1): void { // @phpstan-ignore-line
$q1->where('attachments.attachable_type', TransactionJournal::class);
$q1->where('attachments.uploaded', true);
$q1->whereNull('attachments.deleted_at');

View File

@@ -42,7 +42,7 @@ trait MetaCollection
public function excludeBills(Collection $bills): GroupCollectorInterface
{
$this->withBillInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($bills) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q1) use ($bills): void { // @phpstan-ignore-line
$q1->whereNotIn('transaction_journals.bill_id', $bills->pluck('id')->toArray());
$q1->orWhereNull('transaction_journals.bill_id');
});
@@ -74,7 +74,7 @@ trait MetaCollection
{
$this->withBudgetInformation();
$this->query->where(static function (EloquentBuilder $q2) use ($budget) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q2) use ($budget): void { // @phpstan-ignore-line
$q2->where('budgets.id', '!=', $budget->id);
$q2->orWhereNull('budgets.id');
});
@@ -105,7 +105,7 @@ trait MetaCollection
{
if ($budgets->count() > 0) {
$this->withBudgetInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($budgets) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q1) use ($budgets): void { // @phpstan-ignore-line
$q1->whereNotIn('budgets.id', $budgets->pluck('id')->toArray());
$q1->orWhereNull('budgets.id');
});
@@ -118,7 +118,7 @@ trait MetaCollection
{
if ($categories->count() > 0) {
$this->withCategoryInformation();
$this->query->where(static function (EloquentBuilder $q1) use ($categories) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q1) use ($categories): void { // @phpstan-ignore-line
$q1->whereNotIn('categories.id', $categories->pluck('id')->toArray());
$q1->orWhereNull('categories.id');
});
@@ -153,7 +153,7 @@ trait MetaCollection
{
$this->withCategoryInformation();
$this->query->where(static function (EloquentBuilder $q2) use ($category) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q2) use ($category): void { // @phpstan-ignore-line
$q2->where('categories.id', '!=', $category->id);
$q2->orWhereNull('categories.id');
});
@@ -456,7 +456,7 @@ trait MetaCollection
// join bill table
$this->query->leftJoin(
'notes',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('notes.noteable_id', '=', 'transaction_journals.id');
$join->where('notes.noteable_type', '=', 'FireflyIII\Models\TransactionJournal');
$join->whereNull('notes.deleted_at');
@@ -473,7 +473,7 @@ trait MetaCollection
public function notesDoNotContain(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s%%', $value));
});
@@ -484,7 +484,7 @@ trait MetaCollection
public function notesDontEndWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%%%s', $value));
});
@@ -495,7 +495,7 @@ trait MetaCollection
public function notesDontStartWith(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', 'NOT LIKE', sprintf('%s%%', $value));
});
@@ -522,7 +522,7 @@ trait MetaCollection
public function notesExactlyNot(string $value): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) use ($value) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q) use ($value): void { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '!=', sprintf('%s', $value));
});
@@ -801,13 +801,13 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
$this->query->where(static function (Builder $q1) { // @phpstan-ignore-line
$q1->where(static function (Builder $q2) {
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
$q1->where(static function (Builder $q2): void {
$q2->where('journal_meta.name', '=', 'external_id');
$q2->whereNull('journal_meta.data');
})->orWhere(static function (Builder $q3) {
})->orWhere(static function (Builder $q3): void {
$q3->where('journal_meta.name', '!=', 'external_id');
})->orWhere(static function (Builder $q4) {
})->orWhere(static function (Builder $q4): void {
$q4->whereNull('journal_meta.name');
});
});
@@ -819,13 +819,13 @@ trait MetaCollection
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
$this->query->where(static function (Builder $q1) { // @phpstan-ignore-line
$q1->where(static function (Builder $q2) {
$this->query->where(static function (Builder $q1): void { // @phpstan-ignore-line
$q1->where(static function (Builder $q2): void {
$q2->where('journal_meta.name', '=', 'external_url');
$q2->whereNull('journal_meta.data');
})->orWhere(static function (Builder $q3) {
})->orWhere(static function (Builder $q3): void {
$q3->where('journal_meta.name', '!=', 'external_url');
})->orWhere(static function (Builder $q4) {
})->orWhere(static function (Builder $q4): void {
$q4->whereNull('journal_meta.name');
});
});
@@ -836,7 +836,7 @@ trait MetaCollection
public function withoutNotes(): GroupCollectorInterface
{
$this->withNotes();
$this->query->where(static function (Builder $q) { // @phpstan-ignore-line
$this->query->where(static function (Builder $q): void { // @phpstan-ignore-line
$q->whereNull('notes.text');
$q->orWhere('notes.text', '');
});

View File

@@ -145,9 +145,9 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionDoesNotEnd(array $array): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q1->where('transaction_journals.description', 'NOT LIKE', $keyword);
@@ -155,7 +155,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->where(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q2->where('transaction_groups.title', 'NOT LIKE', $keyword);
@@ -172,9 +172,9 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionDoesNotStart(array $array): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q1->where('transaction_journals.description', 'NOT LIKE', $keyword);
@@ -182,7 +182,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->where(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q2->where('transaction_groups.title', 'NOT LIKE', $keyword);
@@ -199,9 +199,9 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionEnds(array $array): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
@@ -209,7 +209,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->orWhere(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
@@ -225,7 +225,7 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionIs(string $value): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($value) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
$q->where('transaction_journals.description', '=', $value);
$q->orWhere('transaction_groups.title', '=', $value);
}
@@ -237,10 +237,10 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionIsNot(string $value): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($value) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($value): void { // @phpstan-ignore-line
$q->where('transaction_journals.description', '!=', $value);
$q->where(
static function (EloquentBuilder $q2) use ($value) {
static function (EloquentBuilder $q2) use ($value): void {
$q2->where('transaction_groups.title', '!=', $value);
$q2->orWhereNull('transaction_groups.title');
}
@@ -254,9 +254,9 @@ class GroupCollector implements GroupCollectorInterface
public function descriptionStarts(array $array): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
@@ -264,7 +264,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->orWhere(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
@@ -310,10 +310,10 @@ class GroupCollector implements GroupCollectorInterface
public function excludeCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($currency) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($currency): void { // @phpstan-ignore-line
$q->where('source.transaction_currency_id', '!=', $currency->id);
$q->where(
static function (EloquentBuilder $q2) use ($currency) {
static function (EloquentBuilder $q2) use ($currency): void {
$q2->where('source.foreign_currency_id', '!=', $currency->id);
$q2->orWhereNull('source.foreign_currency_id');
}
@@ -326,7 +326,7 @@ class GroupCollector implements GroupCollectorInterface
public function excludeForeignCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(static function (EloquentBuilder $q2) use ($currency) { // @phpstan-ignore-line
$this->query->where(static function (EloquentBuilder $q2) use ($currency): void { // @phpstan-ignore-line
$q2->where('source.foreign_currency_id', '!=', $currency->id);
$q2->orWhereNull('source.foreign_currency_id');
});
@@ -368,9 +368,9 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q1->where('transaction_journals.description', 'NOT LIKE', $keyword);
@@ -378,7 +378,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->where(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q2->where('transaction_groups.title', 'NOT LIKE', $keyword);
@@ -519,7 +519,7 @@ class GroupCollector implements GroupCollectorInterface
public function setCurrency(TransactionCurrency $currency): GroupCollectorInterface
{
$this->query->where(
static function (EloquentBuilder $q) use ($currency) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($currency): void { // @phpstan-ignore-line
$q->where('source.transaction_currency_id', $currency->id);
$q->orWhere('source.foreign_currency_id', $currency->id);
}
@@ -588,9 +588,9 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
$this->query->where(
static function (EloquentBuilder $q) use ($array) { // @phpstan-ignore-line
static function (EloquentBuilder $q) use ($array): void { // @phpstan-ignore-line
$q->where(
static function (EloquentBuilder $q1) use ($array) {
static function (EloquentBuilder $q1) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q1->where('transaction_journals.description', 'LIKE', $keyword);
@@ -598,7 +598,7 @@ class GroupCollector implements GroupCollectorInterface
}
);
$q->orWhere(
static function (EloquentBuilder $q2) use ($array) {
static function (EloquentBuilder $q2) use ($array): void {
foreach ($array as $word) {
$keyword = sprintf('%%%s%%', $word);
$q2->where('transaction_groups.title', 'LIKE', $keyword);
@@ -972,7 +972,7 @@ class GroupCollector implements GroupCollectorInterface
// join source transaction.
->leftJoin(
'transactions as source',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
->where('source.amount', '<', 0)
;
@@ -981,7 +981,7 @@ class GroupCollector implements GroupCollectorInterface
// join destination transaction
->leftJoin(
'transactions as destination',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
->where('destination.amount', '>', 0)
;
@@ -1016,7 +1016,7 @@ class GroupCollector implements GroupCollectorInterface
// join source transaction.
->leftJoin(
'transactions as source',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')
->where('source.amount', '<', 0)
;
@@ -1025,7 +1025,7 @@ class GroupCollector implements GroupCollectorInterface
// join destination transaction
->leftJoin(
'transactions as destination',
static function (JoinClause $join) {
static function (JoinClause $join): void {
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')
->where('destination.amount', '>', 0)
;