Ensure invoice always has an invitation
This commit is contained in:
parent
e6266b3b10
commit
b39f2f4ba5
1 changed files with 6 additions and 1 deletions
|
|
@ -86,11 +86,16 @@ class InvoiceService extends BaseService
|
|||
$sendInvoiceIds = [];
|
||||
|
||||
foreach ($client->contacts as $contact) {
|
||||
if ($contact->send_invoice || count($client->contacts) == 1) {
|
||||
if ($contact->send_invoice) {
|
||||
$sendInvoiceIds[] = $contact->id;
|
||||
}
|
||||
}
|
||||
|
||||
// if no contacts are selected auto-select the first to enusre there's an invitation
|
||||
if ( ! count($sendInvoiceIds)) {
|
||||
$sendInvoiceIds[] = $client->contacts[0]->id;
|
||||
}
|
||||
|
||||
foreach ($client->contacts as $contact) {
|
||||
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue