mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 13:04:30 -04:00
Fixes for recurring
This commit is contained in:
parent
6d1605f746
commit
aba280d9ab
@ -60,6 +60,8 @@ class EmailEntity implements ShouldQueue
|
||||
|
||||
public $template_data; //The data to be merged into the template
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
/**
|
||||
* EmailEntity constructor.
|
||||
*
|
||||
|
@ -94,7 +94,14 @@ class SendRecurring implements ShouldQueue
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||
if ($invitation->contact && strlen($invitation->contact->email) >=1) {
|
||||
|
||||
try{
|
||||
EmailEntity::dispatch($invitation, $invoice->company);
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
nlog("Firing email for invoice {$invoice->number}");
|
||||
}
|
||||
});
|
||||
|
@ -395,9 +395,19 @@ class Invoice extends BaseModel
|
||||
public function pdf_file_path($invitation = null, string $type = 'url')
|
||||
{
|
||||
if (! $invitation) {
|
||||
$invitation = $this->invitations->first();
|
||||
|
||||
if($this->invitations()->exists())
|
||||
$invitation = $this->invitations()->first();
|
||||
else{
|
||||
$this->service()->createInvitations();
|
||||
$invitation = $this->invitations()->first();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!$invitation)
|
||||
throw new \Exception('Hard fail, could not create an invitation - is there a valid contact?');
|
||||
|
||||
$storage_path = Storage::$type($this->client->invoice_filepath().$this->numberFormatter().'.pdf');
|
||||
|
||||
if (! Storage::exists($this->client->invoice_filepath().$this->numberFormatter().'.pdf')) {
|
||||
|
@ -55,6 +55,16 @@ class CreateInvitations extends AbstractService
|
||||
}
|
||||
});
|
||||
|
||||
if($this->invoice->invitations()->count() == 0) {
|
||||
|
||||
$contact = $this->createBlankContact();
|
||||
|
||||
$ii = InvoiceInvitationFactory::create($this->invoice->company_id, $this->invoice->user_id);
|
||||
$ii->invoice_id = $this->invoice->id;
|
||||
$ii->client_contact_id = $contact->id;
|
||||
$ii->save();
|
||||
}
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
@ -65,5 +75,7 @@ class CreateInvitations extends AbstractService
|
||||
$new_contact->contact_key = Str::random(40);
|
||||
$new_contact->is_primary = true;
|
||||
$new_contact->save();
|
||||
|
||||
return $new_contact;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user