diff --git a/app/Export/CSV/ContactExport.php b/app/Export/CSV/ContactExport.php index 45a239beee98..38c9b1fdd87b 100644 --- a/app/Export/CSV/ContactExport.php +++ b/app/Export/CSV/ContactExport.php @@ -58,7 +58,10 @@ class ContactExport extends BaseExport } $query = ClientContact::query() - ->where('company_id', $this->company->id); + ->where('company_id', $this->company->id) + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }); $query = $this->addDateRange($query); diff --git a/app/Export/CSV/CreditExport.php b/app/Export/CSV/CreditExport.php index 43a8b1ecb383..5964b350a8b3 100644 --- a/app/Export/CSV/CreditExport.php +++ b/app/Export/CSV/CreditExport.php @@ -102,6 +102,9 @@ class CreditExport extends BaseExport $query = Credit::query() ->withTrashed() ->with('client') + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/InvoiceItemExport.php b/app/Export/CSV/InvoiceItemExport.php index fda1737e1a60..b8f411dfc1c3 100644 --- a/app/Export/CSV/InvoiceItemExport.php +++ b/app/Export/CSV/InvoiceItemExport.php @@ -70,6 +70,9 @@ class InvoiceItemExport extends BaseExport $query = Invoice::query() ->withTrashed() ->with('client') + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/PaymentExport.php b/app/Export/CSV/PaymentExport.php index 8c1242aa54ad..efe6d93a40f8 100644 --- a/app/Export/CSV/PaymentExport.php +++ b/app/Export/CSV/PaymentExport.php @@ -56,6 +56,9 @@ class PaymentExport extends BaseExport $query = Payment::query() ->withTrashed() + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', 0); diff --git a/app/Export/CSV/ProductSalesExport.php b/app/Export/CSV/ProductSalesExport.php index 5b3654750591..dc6479db5bfa 100644 --- a/app/Export/CSV/ProductSalesExport.php +++ b/app/Export/CSV/ProductSalesExport.php @@ -120,6 +120,9 @@ class ProductSalesExport extends BaseExport //insert the header $query = Invoice::query() ->withTrashed() + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID]); diff --git a/app/Export/CSV/PurchaseOrderExport.php b/app/Export/CSV/PurchaseOrderExport.php index 8d676879c9bb..48aea177b504 100644 --- a/app/Export/CSV/PurchaseOrderExport.php +++ b/app/Export/CSV/PurchaseOrderExport.php @@ -58,6 +58,9 @@ class PurchaseOrderExport extends BaseExport $query = PurchaseOrder::query() ->withTrashed() ->with('vendor') + ->whereHas('vendor', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/PurchaseOrderItemExport.php b/app/Export/CSV/PurchaseOrderItemExport.php index 8d891fc87946..0de2e1e217d8 100644 --- a/app/Export/CSV/PurchaseOrderItemExport.php +++ b/app/Export/CSV/PurchaseOrderItemExport.php @@ -62,6 +62,9 @@ class PurchaseOrderItemExport extends BaseExport $query = PurchaseOrder::query() ->withTrashed() + ->whereHas('vendor', function ($q){ + $q->where('is_deleted', false); + }) ->with('vendor')->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/QuoteExport.php b/app/Export/CSV/QuoteExport.php index e4eb6b038770..13f48266bcee 100644 --- a/app/Export/CSV/QuoteExport.php +++ b/app/Export/CSV/QuoteExport.php @@ -64,6 +64,9 @@ class QuoteExport extends BaseExport $query = Quote::query() ->withTrashed() ->with('client') + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/QuoteItemExport.php b/app/Export/CSV/QuoteItemExport.php index 34853b3432f4..754951f13afb 100644 --- a/app/Export/CSV/QuoteItemExport.php +++ b/app/Export/CSV/QuoteItemExport.php @@ -65,6 +65,9 @@ class QuoteItemExport extends BaseExport $query = Quote::query() ->withTrashed() + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->with('client')->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false); diff --git a/app/Export/CSV/RecurringInvoiceExport.php b/app/Export/CSV/RecurringInvoiceExport.php index 35ad60c65466..2410230dc649 100644 --- a/app/Export/CSV/RecurringInvoiceExport.php +++ b/app/Export/CSV/RecurringInvoiceExport.php @@ -56,6 +56,9 @@ class RecurringInvoiceExport extends BaseExport $query = RecurringInvoice::query() ->withTrashed() ->with('client') + ->whereHas('client', function ($q){ + $q->where('is_deleted', false); + }) ->where('company_id', $this->company->id) ->where('is_deleted', $this->input['include_deleted'] ?? false);