Fixes for queries

This commit is contained in:
David Bomba 2020-11-01 16:18:40 +11:00
parent 0077df1be7
commit 685b7e25c2
3 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,7 @@ namespace App\Jobs\Cron;
use App\Jobs\RecurringInvoice\SendRecurring; use App\Jobs\RecurringInvoice\SendRecurring;
use App\Libraries\MultiDB; use App\Libraries\MultiDB;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -46,6 +47,9 @@ class RecurringInvoicesCron
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now()) $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->whereHas('company', function(Builder $query){
$query->where('is_disabled', false);
})
->cursor(); ->cursor();
Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count()); Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count());
@ -66,6 +70,9 @@ class RecurringInvoicesCron
$recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now()) $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now())
->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('status_id', RecurringInvoice::STATUS_ACTIVE)
->whereHas('company', function(Builder $query){
$query->where('is_disabled', false);
})
->cursor(); ->cursor();
Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db); Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db);

View File

@ -107,6 +107,7 @@ class Company extends BaseModel
'enable_shop_api', 'enable_shop_api',
'invoice_task_timelog', 'invoice_task_timelog',
'auto_start_tasks', 'auto_start_tasks',
'is_disabled',
]; ];
protected $hidden = [ protected $hidden = [

View File

@ -148,6 +148,7 @@ class CompanyTransformer extends EntityTransformer
'enabled_item_tax_rates' => (int) $company->enabled_item_tax_rates, 'enabled_item_tax_rates' => (int) $company->enabled_item_tax_rates,
'client_can_register' => (bool) $company->client_can_register, 'client_can_register' => (bool) $company->client_can_register,
'is_large' => (bool) $company->is_large, 'is_large' => (bool) $company->is_large,
'is_disabled' => (bool) $company->is_disabled,
'enable_shop_api' => (bool) $company->enable_shop_api, 'enable_shop_api' => (bool) $company->enable_shop_api,
'mark_expenses_invoiceable'=> (bool) $company->mark_expenses_invoiceable, 'mark_expenses_invoiceable'=> (bool) $company->mark_expenses_invoiceable,
'mark_expenses_paid' => (bool) $company->mark_expenses_paid, 'mark_expenses_paid' => (bool) $company->mark_expenses_paid,