mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Create recurring invoice with invitations for draft
This commit is contained in:
parent
32f39d9e6d
commit
55f96e035b
@ -83,8 +83,6 @@ class SendRecurring implements ShouldQueue
|
||||
//->createInvitations() //need to only link invitations to those in the recurring invoice
|
||||
->fillDefaults()
|
||||
->save();
|
||||
|
||||
$invoice = $this->createRecurringInvitations($invoice);
|
||||
|
||||
}
|
||||
else{
|
||||
@ -94,6 +92,8 @@ class SendRecurring implements ShouldQueue
|
||||
->save();
|
||||
}
|
||||
|
||||
$invoice = $this->createRecurringInvitations($invoice);
|
||||
|
||||
nlog("updating recurring invoice dates");
|
||||
/* Set next date here to prevent a recurring loop forming */
|
||||
$this->recurring_invoice->next_send_date = $this->recurring_invoice->nextSendDate();
|
||||
@ -122,27 +122,30 @@ class SendRecurring implements ShouldQueue
|
||||
|
||||
event('eloquent.created: App\Models\Invoice', $invoice);
|
||||
|
||||
//Admin notification for recurring invoice sent.
|
||||
if ($invoice->invitations->count() >= 1 ) {
|
||||
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');
|
||||
}
|
||||
|
||||
nlog("Invoice {$invoice->number} created");
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||
if ($invitation->contact && !$invitation->contact->trashed() && strlen($invitation->contact->email) >=1 && $invoice->client->getSetting('auto_email_invoice')) {
|
||||
|
||||
try{
|
||||
EmailEntity::dispatch($invitation, $invoice->company)->delay(now()->addSeconds(1));
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
nlog("Firing email for invoice {$invoice->number}");
|
||||
if($invoice->client->getSetting('auto_email_invoice'))
|
||||
{
|
||||
//Admin notification for recurring invoice sent.
|
||||
if ($invoice->invitations->count() >= 1 ) {
|
||||
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
nlog("Invoice {$invoice->number} created");
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||
if ($invitation->contact && !$invitation->contact->trashed() && strlen($invitation->contact->email) >=1 && $invoice->client->getSetting('auto_email_invoice')) {
|
||||
|
||||
try{
|
||||
EmailEntity::dispatch($invitation, $invoice->company)->delay(now()->addSeconds(1));
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
|
||||
nlog("Firing email for invoice {$invoice->number}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
$invoice->service()->autoBill();
|
||||
|
@ -222,17 +222,6 @@ class BaseRepository
|
||||
if (array_key_exists('documents', $data))
|
||||
$this->saveDocuments($data['documents'], $model);
|
||||
|
||||
/* Marks whether the client contact should receive emails based on the send_email property */
|
||||
// if (isset($data['client_contacts'])) {
|
||||
// foreach ($data['client_contacts'] as $contact) {
|
||||
// if ($contact['send_email'] == 1 && is_string($contact['id'])) {
|
||||
// $client_contact = ClientContact::find($this->decodePrimaryKey($contact['id']));
|
||||
// $client_contact->send_email = true;
|
||||
// $client_contact->save();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/* If invitations are present we need to filter existing invitations with the new ones */
|
||||
if (isset($data['invitations'])) {
|
||||
$invitations = collect($data['invitations']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user