diff --git a/app/DataMapper/ClientSettings.php b/app/DataMapper/ClientSettings.php index 30e221d5c8..5af2962698 100644 --- a/app/DataMapper/ClientSettings.php +++ b/app/DataMapper/ClientSettings.php @@ -88,7 +88,6 @@ class ClientSettings extends BaseSettings */ public $industry_id; public $size_id; - public $invoice_email_list; //default comma separated list of contact ids to email /** * Cast object values and return entire class @@ -116,7 +115,6 @@ class ClientSettings extends BaseSettings 'entity' => Client::class, 'industry_id' => NULL, 'size_id' => NULL, - 'invoice_email_list' => NULL, ]; } diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index ebc7931f17..842e33dd21 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -58,8 +58,8 @@ class SendRecurring $invoice->save(); // Queue: Emails for invoice - // $this->recurring_invoice->settings->invoice_email_list //todo comma separated list of emails to fire this email to - + // foreach invoice->invitations + // Fire Payment if auto-bill is enabled if($this->recurring_invoice->settings->auto_bill) //PAYMENT ACTION HERE TODO diff --git a/app/Listeners/Invoice/CreateInvoiceInvitations.php b/app/Listeners/Invoice/CreateInvoiceInvitations.php deleted file mode 100644 index 0d838025f1..0000000000 --- a/app/Listeners/Invoice/CreateInvoiceInvitations.php +++ /dev/null @@ -1,63 +0,0 @@ -invoice; - - $contacts = ClientContact::whereIn('id', explode(',', $invoice->settings->invoice_email_list))->get(); - - $contacts->each(function ($contact) use($invoice) { - - $i = InvoiceInvitation::firstOrCreate([ - 'client_contact_id' => $contact->id, - 'invoice_id' => $invoice->id - ], - [ - 'company_id' => $invoice->company_id, - 'user_id' => $invoice->user_id, - 'invitation_key' => $this->createDbHash($invoice->company->db), - ]); - - }); - - } -} diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index cd48c91795..f7c47d383b 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -55,7 +55,8 @@ class InvoiceRepository extends BaseRepository $invoice->save(); - $this->saveInvitations($data['invitations'], $invoice); + if(array_key_exists('invitations', $data)) + $this->saveInvitations($data['invitations'], $invoice); $invoice_calc = new InvoiceCalc($invoice, $invoice->settings); @@ -128,12 +129,12 @@ class InvoiceRepository extends BaseRepository foreach($invitations as $invitation) { - //only update new invitations - if(strlen($invitation['invitation_key']) == 0) + //only insert new invitations + if(! array_key_exists('id', $invitation) || strlen($invitation['id']) == 0) { $invitation = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id); - $invitation->client_contact_id = $invitation->['client_contact_id']; + $invitation->client_contact_id = $invitation['client_contact_id']; $invitation->invoice_id = $invoice->id; $invitation->save();