mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-18 17:14:37 -04:00
Roll back join queries
This commit is contained in:
parent
1adbd3907e
commit
f3dc80ae09
@ -66,25 +66,14 @@ class SendRemindersCron extends Command
|
|||||||
->where('invoices.is_deleted', 0)
|
->where('invoices.is_deleted', 0)
|
||||||
->whereIn('invoices.status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
->whereIn('invoices.status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
->where('invoices.balance', '>', 0)
|
->where('invoices.balance', '>', 0)
|
||||||
|
->whereHas('client', function ($query) {
|
||||||
->leftJoin('clients', function ($join) {
|
$query->where('is_deleted', 0)
|
||||||
$join->on('invoices.client_id', '=', 'clients.id')
|
->where('deleted_at', null);
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('invoices.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// ->whereHas('client', function ($query) {
|
|
||||||
// $query->where('is_deleted', 0)
|
|
||||||
// ->where('deleted_at', null);
|
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
|
|
||||||
->with('invitations')->cursor()->each(function ($invoice) {
|
->with('invitations')->cursor()->each(function ($invoice) {
|
||||||
if ($invoice->isPayable()) {
|
if ($invoice->isPayable()) {
|
||||||
$reminder_template = $invoice->calculateTemplate('invoice');
|
$reminder_template = $invoice->calculateTemplate('invoice');
|
||||||
|
@ -54,21 +54,12 @@ class RecurringInvoicesCron
|
|||||||
->whereNotNull('recurring_invoices.next_send_date')
|
->whereNotNull('recurring_invoices.next_send_date')
|
||||||
->whereNull('recurring_invoices.deleted_at')
|
->whereNull('recurring_invoices.deleted_at')
|
||||||
->where('recurring_invoices.next_send_date', '<=', now()->toDateTimeString())
|
->where('recurring_invoices.next_send_date', '<=', now()->toDateTimeString())
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0)
|
$query->where('is_deleted', 0)
|
||||||
// ->where('deleted_at', null);
|
->where('deleted_at', null);
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('recurring_invoices.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('recurring_invoices.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
->with('company')
|
->with('company')
|
||||||
->cursor();
|
->cursor();
|
||||||
|
@ -53,21 +53,12 @@ class QuoteCheckExpired implements ShouldQueue
|
|||||||
->where('quotes.is_deleted', false)
|
->where('quotes.is_deleted', false)
|
||||||
->whereNull('quotes.deleted_at')
|
->whereNull('quotes.deleted_at')
|
||||||
->whereNotNull('quotes.due_date')
|
->whereNotNull('quotes.due_date')
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0)
|
$query->where('is_deleted', 0)
|
||||||
// ->where('deleted_at', null);
|
->where('deleted_at', null);
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('quotes.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('quotes.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
|
|
||||||
->whereBetween('quotes.due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
->whereBetween('quotes.due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
||||||
@ -84,22 +75,14 @@ class QuoteCheckExpired implements ShouldQueue
|
|||||||
->where('quotes.is_deleted', false)
|
->where('quotes.is_deleted', false)
|
||||||
->whereNull('quotes.deleted_at')
|
->whereNull('quotes.deleted_at')
|
||||||
->whereNotNull('quotes.due_date')
|
->whereNotNull('quotes.due_date')
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0)
|
$query->where('is_deleted', 0)
|
||||||
// ->where('deleted_at', null);
|
->where('deleted_at', null);
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('quotes.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('quotes.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
|
|
||||||
->whereBetween('quotes.due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
->whereBetween('quotes.due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($quote) {
|
->each(function ($quote) {
|
||||||
|
@ -65,21 +65,12 @@ class QuoteReminderJob implements ShouldQueue
|
|||||||
->whereIn('quotes.status_id', [Invoice::STATUS_SENT])
|
->whereIn('quotes.status_id', [Invoice::STATUS_SENT])
|
||||||
->whereNull('quotes.deleted_at')
|
->whereNull('quotes.deleted_at')
|
||||||
->where('quotes.next_send_date', '<=', now()->toDateTimeString())
|
->where('quotes.next_send_date', '<=', now()->toDateTimeString())
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0)
|
$query->where('is_deleted', 0)
|
||||||
// ->where('deleted_at', null);
|
->where('deleted_at', null);
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('quotes.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('quotes.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
->with('invitations')->chunk(50, function ($quotes) {
|
->with('invitations')->chunk(50, function ($quotes) {
|
||||||
foreach ($quotes as $quote) {
|
foreach ($quotes as $quote) {
|
||||||
@ -101,22 +92,14 @@ class QuoteReminderJob implements ShouldQueue
|
|||||||
->whereIn('quotes.status_id', [Invoice::STATUS_SENT])
|
->whereIn('quotes.status_id', [Invoice::STATUS_SENT])
|
||||||
->whereNull('quotes.deleted_at')
|
->whereNull('quotes.deleted_at')
|
||||||
->where('quotes.next_send_date', '<=', now()->toDateTimeString())
|
->where('quotes.next_send_date', '<=', now()->toDateTimeString())
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0)
|
$query->where('is_deleted', 0)
|
||||||
// ->where('deleted_at', null);
|
->where('deleted_at', null);
|
||||||
// })
|
|
||||||
// ->whereHas('company', function ($query) {
|
|
||||||
// $query->where('is_disabled', 0);
|
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('quotes.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->leftJoin('companies', function ($join) {
|
->whereHas('company', function ($query) {
|
||||||
$join->on('quotes.company_id', '=', 'companies.id')
|
$query->where('is_disabled', 0);
|
||||||
->where('companies.is_disabled', 0);
|
|
||||||
})
|
})
|
||||||
|
|
||||||
->with('invitations')->chunk(50, function ($quotes) {
|
->with('invitations')->chunk(50, function ($quotes) {
|
||||||
|
|
||||||
foreach ($quotes as $quote) {
|
foreach ($quotes as $quote) {
|
||||||
|
@ -92,13 +92,8 @@ class ARDetailReport extends BaseExport
|
|||||||
$query = Invoice::query()
|
$query = Invoice::query()
|
||||||
->whereIn('invoices.status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
->whereIn('invoices.status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL])
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0);
|
$query->where('is_deleted', 0);
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('invoices.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->where('invoices.company_id', $this->company->id)
|
->where('invoices.company_id', $this->company->id)
|
||||||
->where('invoices.is_deleted', 0)
|
->where('invoices.is_deleted', 0)
|
||||||
|
@ -265,13 +265,8 @@ class ProfitLoss
|
|||||||
->whereIn('status_id', [1, 4, 5])
|
->whereIn('status_id', [1, 4, 5])
|
||||||
->where('is_deleted', 0)
|
->where('is_deleted', 0)
|
||||||
->whereBetween('date', [$this->start_date, $this->end_date])
|
->whereBetween('date', [$this->start_date, $this->end_date])
|
||||||
// ->whereHas('client', function ($query) {
|
->whereHas('client', function ($query) {
|
||||||
// $query->where('is_deleted', 0);
|
$query->where('is_deleted', 0);
|
||||||
// })
|
|
||||||
->leftJoin('clients', function ($join) {
|
|
||||||
$join->on('payments.client_id', '=', 'clients.id')
|
|
||||||
->where('clients.is_deleted', 0)
|
|
||||||
->whereNull('clients.deleted_at');
|
|
||||||
})
|
})
|
||||||
->with(['company', 'client'])
|
->with(['company', 'client'])
|
||||||
->cursor()
|
->cursor()
|
||||||
|
@ -101,18 +101,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if($invoice->subscription && $invoice->subscription?->allow_cancellation && $invoice->status_id == 2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@if($invoice->subscription && $invoice->subscription?->allow_cancellation)
|
|
||||||
{{-- INV2-591 --}}
|
|
||||||
{{-- @if(false) --}}
|
|
||||||
<div class="bg-white shadow sm:rounded-lg mt-4">
|
<div class="bg-white shadow sm:rounded-lg mt-4">
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($invoice->subscription && $invoice->subscription?->allow_cancellation)
|
@if($invoice->subscription && $invoice->subscription?->allow_cancellation && $invoice->status_id == 2)
|
||||||
<div class="bg-white shadow sm:rounded-lg mt-4">
|
<div class="bg-white shadow sm:rounded-lg mt-4">
|
||||||
<div class="px-4 py-5 sm:p-6">
|
<div class="px-4 py-5 sm:p-6">
|
||||||
<div class="sm:flex sm:items-start sm:justify-between">
|
<div class="sm:flex sm:items-start sm:justify-between">
|
||||||
@ -92,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($invoice->subscription && $invoice->subscription->allow_plan_changes)
|
@if($invoice->subscription && $invoice->subscription->allow_plan_changes && count($invoice->subscription->service()->getPlans()) > 0)
|
||||||
<div class="bg-white shadow overflow-hidden px-4 py-5 lg:rounded-lg mt-4">
|
<div class="bg-white shadow overflow-hidden px-4 py-5 lg:rounded-lg mt-4">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900">{{ ctrans('texts.change_plan') }}</h3>
|
<h3 class="text-lg leading-6 font-medium text-gray-900">{{ ctrans('texts.change_plan') }}</h3>
|
||||||
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">{{ ctrans('texts.change_plan_description') }}</p>
|
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">{{ ctrans('texts.change_plan_description') }}</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user