diff --git a/app/Ninja/Intents/BaseIntent.php b/app/Ninja/Intents/BaseIntent.php index 97efae3dae5c..b215ca4d5cae 100644 --- a/app/Ninja/Intents/BaseIntent.php +++ b/app/Ninja/Intents/BaseIntent.php @@ -80,6 +80,13 @@ class BaseIntent return new $className($state, $data); } + protected function hasField($field, $value = false) + { + $fieldValue = $this->getField($field); + + return $value ? $value == $fieldValue : !!$fieldValue; + } + protected function getField($field) { foreach ($this->data->entities as $entity) { @@ -106,7 +113,7 @@ class BaseIntent protected function loadStates($entityType) { - $states = array_filter($this->getFields('State'), function($state) { + $states = array_filter($this->getFields('Filter'), function($state) { return in_array($state, [STATUS_ACTIVE, STATUS_ARCHIVED, STATUS_DELETED]); }); diff --git a/app/Ninja/Intents/InvoiceIntent.php b/app/Ninja/Intents/InvoiceIntent.php index ccf6ecb4d8a8..fb3ec5c04877 100644 --- a/app/Ninja/Intents/InvoiceIntent.php +++ b/app/Ninja/Intents/InvoiceIntent.php @@ -109,7 +109,7 @@ class InvoiceIntent extends BaseIntent protected function loadStatuses($entityType) { $statusIds = []; - $statuses = $this->getFields('State'); + $statuses = $this->getFields('Filter'); foreach ($statuses as $status) { if ($statusId = InvoiceStatus::getIdFromAlias($status)) { diff --git a/app/Ninja/Intents/WebApp/ListInvoiceIntent.php b/app/Ninja/Intents/WebApp/ListInvoiceIntent.php index 339493bb00f9..7ca8bffa79e6 100644 --- a/app/Ninja/Intents/WebApp/ListInvoiceIntent.php +++ b/app/Ninja/Intents/WebApp/ListInvoiceIntent.php @@ -11,7 +11,7 @@ class ListInvoiceIntent extends InvoiceIntent $this->loadStates(ENTITY_INVOICE); $this->loadStatuses(ENTITY_INVOICE); - if ($client = $this->requestClient()) { + if (! $this->hasField('Filter', 'all') && $client = $this->requestClient()) { $url = $client->present()->url . '#invoices'; } else { $url = '/invoices';