mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 08:17:32 -05:00 
			
		
		
		
	Logic to update e_invoice
This commit is contained in:
		
							parent
							
								
									c52bc3dae7
								
							
						
					
					
						commit
						94da1d9ded
					
				@ -298,7 +298,7 @@ class BaseModel extends Model
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // special catch here for einvoicing eventing
 | 
					        // special catch here for einvoicing eventing
 | 
				
			||||||
        if($event_id == Webhook::EVENT_SENT_INVOICE && ($this instanceof Invoice) && is_null($this->backup)){
 | 
					        if($event_id == Webhook::EVENT_SENT_INVOICE && ($this instanceof Invoice) && is_null($this->backup) && $this->client->getSetting('e_invoice_type') == 'PEPPOL'){
 | 
				
			||||||
            \App\Services\EDocument\Jobs\SendEDocument::dispatch(get_class($this), $this->id, $this->company->db);
 | 
					            \App\Services\EDocument\Jobs\SendEDocument::dispatch(get_class($this), $this->id, $this->company->db);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -320,6 +320,17 @@ class BaseRepository
 | 
				
			|||||||
                UpdateTaxData::dispatch($client, $client->company);
 | 
					                UpdateTaxData::dispatch($client, $client->company);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /** If Peppol is enabled - we will save the e_invoice document here at this point, document will not update after being sent */
 | 
				
			||||||
 | 
					            if(strlen($model->backup ?? '') == 0 && $client->getSetting('e_invoice_type') == 'PEPPOL' && $model->company->legal_entity_id)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                try{
 | 
				
			||||||
 | 
					                    $model->service()->getEInvoice();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch(\Exception $e){
 | 
				
			||||||
 | 
					                    nlog("EXCEPTION:: BASEREPOSITORY:: Error generating e_invoice for model {$model->id}");
 | 
				
			||||||
 | 
					                    nlog($e->getMessage());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($model instanceof Credit) {
 | 
					        if ($model instanceof Credit) {
 | 
				
			||||||
 | 
				
			|||||||
@ -50,10 +50,11 @@ class SendEDocument implements ShouldQueue
 | 
				
			|||||||
        MultiDB::setDB($this->db);
 | 
					        MultiDB::setDB($this->db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $model = $this->entity::find($this->id);
 | 
					        $model = $this->entity::find($this->id);
 | 
				
			||||||
        $e_invoice_standard = $model->client ? $model->client->getSetting('e_invoice_type') : $model->company->getSetting('e_invoice_type');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($e_invoice_standard != 'PEPPOL')
 | 
					        // $e_invoice_standard = $model->client ? $model->client->getSetting('e_invoice_type') : $model->company->getSetting('e_invoice_type');
 | 
				
			||||||
            return;
 | 
					
 | 
				
			||||||
 | 
					        // if($e_invoice_standard != 'PEPPOL')
 | 
				
			||||||
 | 
					        //     return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(Ninja::isSelfHost() && ($model instanceof Invoice) && $model->company->legal_entity_id)
 | 
					        if(Ninja::isSelfHost() && ($model instanceof Invoice) && $model->company->legal_entity_id)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
				
			|||||||
@ -287,8 +287,11 @@ class Peppol extends AbstractService
 | 
				
			|||||||
        $this->senderSpecificLevelMutators()
 | 
					        $this->senderSpecificLevelMutators()
 | 
				
			||||||
             ->receiverSpecificLevelMutators();
 | 
					             ->receiverSpecificLevelMutators();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(strlen($this->invoice->backup ?? '') == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
            $this->invoice->e_invoice = $this->toObject();
 | 
					            $this->invoice->e_invoice = $this->toObject();
 | 
				
			||||||
            $this->invoice->save();
 | 
					            $this->invoice->save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user