diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index 29554493b959..198fe0dff3ce 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -14,6 +14,7 @@ namespace App\Jobs\Cron; use App\Jobs\RecurringInvoice\SendRecurring; use App\Libraries\MultiDB; use App\Models\RecurringInvoice; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Request; use Illuminate\Support\Carbon; @@ -46,6 +47,9 @@ class RecurringInvoicesCron $recurring_invoices = RecurringInvoice::whereDate('next_send_date', '=', now()) ->where('status_id', RecurringInvoice::STATUS_ACTIVE) + ->whereHas('company', function(Builder $query){ + $query->where('is_disabled', false); + }) ->cursor(); 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()) ->where('status_id', RecurringInvoice::STATUS_ACTIVE) + ->whereHas('company', function(Builder $query){ + $query->where('is_disabled', false); + }) ->cursor(); Log::info(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count().' On Database # '.$db); diff --git a/app/Models/Company.php b/app/Models/Company.php index f34fd1f6ae9b..df64f0716182 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -107,6 +107,7 @@ class Company extends BaseModel 'enable_shop_api', 'invoice_task_timelog', 'auto_start_tasks', + 'is_disabled', ]; protected $hidden = [ diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 20c35e05621b..add89be0f830 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -148,6 +148,7 @@ class CompanyTransformer extends EntityTransformer 'enabled_item_tax_rates' => (int) $company->enabled_item_tax_rates, 'client_can_register' => (bool) $company->client_can_register, 'is_large' => (bool) $company->is_large, + 'is_disabled' => (bool) $company->is_disabled, 'enable_shop_api' => (bool) $company->enable_shop_api, 'mark_expenses_invoiceable'=> (bool) $company->mark_expenses_invoiceable, 'mark_expenses_paid' => (bool) $company->mark_expenses_paid,