Create recurring invoice with invitations for draft

This commit is contained in:
David Bomba 2021-12-15 07:05:12 +11:00
parent 32f39d9e6d
commit 55f96e035b
2 changed files with 25 additions and 33 deletions

View File

@ -84,8 +84,6 @@ class SendRecurring implements ShouldQueue
->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,6 +122,8 @@ class SendRecurring implements ShouldQueue
event('eloquent.created: App\Models\Invoice', $invoice);
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');
@ -142,6 +144,7 @@ class SendRecurring implements ShouldQueue
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}");

View File

@ -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']);