mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 15:34:30 -04:00
Ensure invoice always has an invitation
This commit is contained in:
parent
e6266b3b10
commit
b39f2f4ba5
@ -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…
x
Reference in New Issue
Block a user