Expand search with external ID searches.

This commit is contained in:
James Cole
2022-12-29 15:42:26 +01:00
parent 8c320fd199
commit 5e3f9f9bce
5 changed files with 63 additions and 2 deletions

View File

@@ -930,6 +930,18 @@ trait MetaCollection
return $this;
}
/**
* @inheritDoc
*/
public function withExternalId(): GroupCollectorInterface
{
$this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id');
$this->query->whereNotNull('journal_meta.data');
return $this;
}
/**
* Limit results to a transactions without a bill.
*
@@ -988,6 +1000,26 @@ trait MetaCollection
return $this;
}
/**
* @inheritDoc
*/
public function withoutExternalId(): GroupCollectorInterface
{
$this->joinMetaDataTables();
// TODO not sure if this will work properly.
$this->query->where(function (Builder $q1) {
$q1->where(function (Builder $q2) {
$q2->where('journal_meta.name', '=', 'external_id');
$q2->whereNull('journal_meta.data');
})->orWhere(function (Builder $q3) {
$q3->where('journal_meta.name', '!=', 'external_id');
})->orWhere(function (Builder $q4) {
$q4->whereNull('journal_meta.name');
});
});
return $this;
}
/**
* @return GroupCollectorInterface

View File

@@ -1306,12 +1306,19 @@ interface GroupCollectorInterface
public function withCategoryInformation(): GroupCollectorInterface;
/**
* Transactions with an external URL
* Transactions with any external URL
*
* @return GroupCollectorInterface
*/
public function withExternalUrl(): GroupCollectorInterface;
/**
* Transactions with any external ID
*
* @return GroupCollectorInterface
*/
public function withExternalId(): GroupCollectorInterface;
/**
* Transaction must have meta date field X.
*
@@ -1362,6 +1369,13 @@ interface GroupCollectorInterface
*/
public function withoutExternalUrl(): GroupCollectorInterface;
/**
* Transactions without an external ID
*
* @return GroupCollectorInterface
*/
public function withoutExternalId(): GroupCollectorInterface;
/**
* @return GroupCollectorInterface
*/