From 0a483275ad04abbd73b004d5f562e670ba4ea933 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Apr 2022 18:07:52 +1000 Subject: [PATCH] payable filters --- app/Filters/InvoiceFilters.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. *