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
*/

View File

@@ -1169,6 +1169,14 @@ class OperatorQuerySearch implements SearchInterface
case 'any_external_url':
$this->collector->withExternalUrl();
break;
case '-any_external_id':
case 'no_external_id':
$this->collector->withoutExternalId();
break;
case '-no_external_id':
case 'any_external_id':
$this->collector->withExternalId();
break;
case 'external_url_is':
$this->collector->setExternalUrl($value);

View File

@@ -232,5 +232,8 @@ return [
'attachment_notes_end' => ['alias' => true, 'alias_for' => 'attachment_notes_ends', 'needs_context' => true],
'exists' => ['alias' => false, 'needs_context' => false,],
'sepa_ct_is' => ['alias' => false, 'needs_context' => true],
'no_external_id' => ['alias' => false, 'needs_context' => false],
'any_external_id' => ['alias' => false, 'needs_context' => false],
],
];

View File

@@ -335,9 +335,13 @@ return [
'search_modifier_external_id_is' => 'External ID is ":value"',
'search_modifier_not_external_id_is' => 'External ID is not ":value"',
'search_modifier_no_external_url' => 'The transaction has no external URL',
'search_modifier_no_external_id' => 'The transaction has no external ID',
'search_modifier_not_any_external_url' => 'The transaction has no external URL',
'search_modifier_not_any_external_id' => 'The transaction has no external ID',
'search_modifier_any_external_url' => 'The transaction must have a (any) external URL',
'search_modifier_any_external_id' => 'The transaction must have a (any) external ID',
'search_modifier_not_no_external_url' => 'The transaction must have a (any) external URL',
'search_modifier_not_no_external_id' => 'The transaction must have a (any) external ID',
'search_modifier_internal_reference_is' => 'Internal reference is ":value"',
'search_modifier_not_internal_reference_is' => 'Internal reference is not ":value"',
'search_modifier_description_starts' => 'Description starts with ":value"',
@@ -1490,7 +1494,7 @@ return [
'title_transfer' => 'Transfers',
'title_transfers' => 'Transfers',
'submission_options' => 'Submission options',
'apply_rules_checkbox' => 'Apply rules',
'apply_rules_checkbox' => 'Apply rules',
'fire_webhooks_checkbox' => 'Fire webhooks',
// convert stuff: