Exclude deleted client/vendor

This commit is contained in:
David Bomba 2024-04-25 20:07:42 +10:00
parent c27d5ad8e9
commit 45f2970579
10 changed files with 31 additions and 1 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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]);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);