diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 1a85c6d1af30..657f0659f866 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -138,6 +138,18 @@ class InvoiceFilters extends QueryFilters }); } + public function payable(string $client_id) + { + if (strlen($client_id) == 0) { + return $this->builder; + } + + return $this->builder->whereIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) + ->where('balance', '>', 0) + ->where('is_deleted', 0) + ->where('client_id', $this->decodePrimaryKey($client_id)); + } + /** * Sorts the list based on $sort. *