mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 14:07:32 -04:00 
			
		
		
		
	Fixes for recurring invoice queries
This commit is contained in:
		
							parent
							
								
									7e986b82c7
								
							
						
					
					
						commit
						d69d465abf
					
				| @ -48,12 +48,12 @@ class RecurringInvoicesCron | |||||||
|         Auth::logout(); |         Auth::logout(); | ||||||
| 
 | 
 | ||||||
|         if (! config('ninja.db.multi_db_enabled')) { |         if (! config('ninja.db.multi_db_enabled')) { | ||||||
|             $recurring_invoices = RecurringInvoice::query()->where('recurring_invoices.status_id', RecurringInvoice::STATUS_ACTIVE) |             $recurring_invoices = RecurringInvoice::query()->where('status_id', RecurringInvoice::STATUS_ACTIVE) | ||||||
|                                                         ->where('recurring_invoices.is_deleted', false) |                                                         ->where('is_deleted', false) | ||||||
|                                                         ->where('recurring_invoices.remaining_cycles', '!=', '0') |                                                         ->where('remaining_cycles', '!=', '0') | ||||||
|                                                         ->whereNotNull('recurring_invoices.next_send_date') |                                                         ->whereNotNull('next_send_date') | ||||||
|                                                         ->whereNull('recurring_invoices.deleted_at') |                                                         ->whereNull('deleted_at') | ||||||
|                                                         ->where('recurring_invoices.next_send_date', '<=', now()->toDateTimeString()) |                                                         ->where('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); | ||||||
| @ -87,27 +87,18 @@ class RecurringInvoicesCron | |||||||
|             foreach (MultiDB::$dbs as $db) { |             foreach (MultiDB::$dbs as $db) { | ||||||
|                 MultiDB::setDB($db); |                 MultiDB::setDB($db); | ||||||
| 
 | 
 | ||||||
|                 $recurring_invoices = RecurringInvoice::query()->where('recurring_invoices.status_id', RecurringInvoice::STATUS_ACTIVE) |                 $recurring_invoices = RecurringInvoice::query()->where('status_id', RecurringInvoice::STATUS_ACTIVE) | ||||||
|                                                         ->where('recurring_invoices.is_deleted', false) |                                                         ->where('is_deleted', false) | ||||||
|                                                         ->where('recurring_invoices.remaining_cycles', '!=', '0') |                                                         ->where('remaining_cycles', '!=', '0') | ||||||
|                                                         ->whereNull('recurring_invoices.deleted_at') |                                                         ->whereNull('deleted_at') | ||||||
|                                                         ->whereNotNull('recurring_invoices.next_send_date') |                                                         ->whereNotNull('next_send_date') | ||||||
|                                                         ->where('recurring_invoices.next_send_date', '<=', now()->toDateTimeString()) |                                                         ->where('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(); | ||||||
|  | |||||||
| @ -61,10 +61,10 @@ class QuoteReminderJob implements ShouldQueue | |||||||
|             nrlog("Sending quote reminders on ".now()->format('Y-m-d h:i:s')); |             nrlog("Sending quote reminders on ".now()->format('Y-m-d h:i:s')); | ||||||
| 
 | 
 | ||||||
|             Quote::query() |             Quote::query() | ||||||
|                  ->where('quotes.is_deleted', 0) |                  ->where('is_deleted', 0) | ||||||
|                  ->whereIn('quotes.status_id', [Invoice::STATUS_SENT]) |                  ->whereIn('status_id', [Invoice::STATUS_SENT]) | ||||||
|                  ->whereNull('quotes.deleted_at') |                  ->whereNull('deleted_at') | ||||||
|                  ->where('quotes.next_send_date', '<=', now()->toDateTimeString()) |                  ->where('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); | ||||||
| @ -88,10 +88,10 @@ class QuoteReminderJob implements ShouldQueue | |||||||
|                 nrlog("Sending quote reminders on db {$db} ".now()->format('Y-m-d h:i:s')); |                 nrlog("Sending quote reminders on db {$db} ".now()->format('Y-m-d h:i:s')); | ||||||
| 
 | 
 | ||||||
|                 Quote::query() |                 Quote::query() | ||||||
|                      ->where('quotes.is_deleted', 0) |                      ->where('is_deleted', 0) | ||||||
|                      ->whereIn('quotes.status_id', [Invoice::STATUS_SENT]) |                      ->whereIn('status_id', [Invoice::STATUS_SENT]) | ||||||
|                      ->whereNull('quotes.deleted_at') |                      ->whereNull('deleted_at') | ||||||
|                      ->where('quotes.next_send_date', '<=', now()->toDateTimeString()) |                      ->where('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); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user