diff --git a/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php b/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php index f6bdd6e..32ab447 100644 --- a/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php +++ b/web/modules/custom/figli_compta_ledger/src/Plugin/EntityReferenceSelection/EntreeClientSelection.php @@ -23,9 +23,16 @@ class EntreeClientSelection extends NodeSelection { /** * {@inheritdoc} + * + * Matches on title *or* field_numero_facture -- several entrées for the + * same client often share the same title format ("EPAU - 2026-01-05"), + * so being able to type the invoice number itself ("F2549") is what + * actually finds the right one quickly. $match is withheld from the + * parent call (it would otherwise add its own title-only condition) + * and applied manually below as an OR across both fields instead. */ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') { - $query = parent::buildEntityQuery($match, $match_operator); + $query = parent::buildEntityQuery(NULL, $match_operator); $query->condition('field_type_ligne', 'entree'); $entity = $this->configuration['entity'] ?? NULL; @@ -33,6 +40,14 @@ class EntreeClientSelection extends NodeSelection { $query->condition('field_client', $entity->get('field_client')->target_id); } + if (isset($match)) { + $query->condition( + $query->orConditionGroup() + ->condition('title', $match, $match_operator) + ->condition('field_numero_facture', $match, $match_operator) + ); + } + return $query; }