mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:17:32 -05:00 
			
		
		
		
	Merge pull request #6786 from turbo124/v5-develop
Fixes for Invoice Observer
This commit is contained in:
		
						commit
						eb26f647a3
					
				@ -1331,6 +1331,12 @@ class CompanyImport implements ShouldQueue
 | 
			
		||||
                $new_obj->save(['timestamps' => false]);
 | 
			
		||||
                $new_obj->number = $this->getNextQuoteNumber($client = Client::find($obj_array['client_id']), $new_obj);
 | 
			
		||||
            }
 | 
			
		||||
            elseif($class == 'App\Models\ClientContact'){
 | 
			
		||||
                $new_obj = new ClientContact();
 | 
			
		||||
                $new_obj->company_id = $this->company->id;
 | 
			
		||||
                $new_obj->fill($obj_array);
 | 
			
		||||
                $new_obj->save(['timestamps' => false]);
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                $new_obj = $class::firstOrNew(
 | 
			
		||||
                        [$match_key => $obj->{$match_key}, 'company_id' => $this->company->id],
 | 
			
		||||
 | 
			
		||||
@ -34,9 +34,11 @@ class InvoiceObserver
 | 
			
		||||
                            ->where('event_id', Webhook::EVENT_CREATE_INVOICE)
 | 
			
		||||
                            ->exists();
 | 
			
		||||
 | 
			
		||||
        $invoice->load('client');
 | 
			
		||||
 | 
			
		||||
        if ($subscriptions) {
 | 
			
		||||
 | 
			
		||||
            $invoice->load('client');
 | 
			
		||||
    
 | 
			
		||||
            WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice, $invoice->company);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -53,11 +55,14 @@ class InvoiceObserver
 | 
			
		||||
                            ->where('event_id', Webhook::EVENT_UPDATE_INVOICE)
 | 
			
		||||
                            ->exists();
 | 
			
		||||
 | 
			
		||||
        $invoice->load('client');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        if ($subscriptions) {
 | 
			
		||||
        
 | 
			
		||||
            $invoice->load('client');
 | 
			
		||||
        
 | 
			
		||||
            WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company);
 | 
			
		||||
        
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
@ -75,6 +80,9 @@ class InvoiceObserver
 | 
			
		||||
                            ->exists();
 | 
			
		||||
 | 
			
		||||
        if ($subscriptions) {
 | 
			
		||||
        
 | 
			
		||||
            $invoice->load('client');
 | 
			
		||||
            
 | 
			
		||||
            WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice, $invoice->company);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -174,10 +174,6 @@ class BaseRepository
 | 
			
		||||
        if(array_key_exists('client_id', $data)) 
 | 
			
		||||
            $model->client_id = $data['client_id'];
 | 
			
		||||
 | 
			
		||||
        //pickup changes here to recalculate reminders
 | 
			
		||||
        //if($model instanceof Invoice && ($model->isDirty('date') || $model->isDirty('due_date')))
 | 
			
		||||
           // $model->service()->setReminder()->save();
 | 
			
		||||
 | 
			
		||||
        $client = Client::where('id', $model->client_id)->withTrashed()->first();    
 | 
			
		||||
 | 
			
		||||
        $state = [];
 | 
			
		||||
@ -210,6 +206,9 @@ class BaseRepository
 | 
			
		||||
        $model->custom_surcharge_tax3 = $client->company->custom_surcharge_taxes3;
 | 
			
		||||
        $model->custom_surcharge_tax4 = $client->company->custom_surcharge_taxes4;
 | 
			
		||||
 | 
			
		||||
        if(!$model->id)
 | 
			
		||||
            $model->save();
 | 
			
		||||
        else
 | 
			
		||||
            $model->saveQuietly();
 | 
			
		||||
 | 
			
		||||
        /* Model now persisted, now lets do some child tasks */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user