From ecb4ee7b8f2d4da4a7386320b87afae5f061d507 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 8 Dec 2022 14:35:10 +1100 Subject: [PATCH] Add transaction filters for payments and expenses --- app/Filters/ExpenseFilters.php | 14 ++++++++++++++ app/Filters/PaymentFilters.php | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index d7e10ac0f4f1..657680140a69 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -92,6 +92,20 @@ class ExpenseFilters extends QueryFilters return $this->builder; } + /** + * Returns a list of expenses that can be matched to bank transactions + */ + public function match_transactions($value = '') + { + + if($value == 'true') + { + return $this->builder->where('is_deleted',0)->whereNull('transaction_id'); + } + + return $this->builder; + } + /** * Filters the list based on the status diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index 823cb9fcf741..e09c49e35557 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -81,6 +81,20 @@ class PaymentFilters extends QueryFilters }); } + /** + * Returns a list of payments that can be matched to bank transactions + */ + public function match_transactions($value = '') + { + + if($value == 'true') + { + return $this->builder->where('is_deleted',0)->whereNull('transaction_id'); + } + + return $this->builder; + } + /** * Sorts the list based on $sort. *