mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Nuances of client contact invitations
This commit is contained in:
parent
308406c0fb
commit
d5ec342764
@ -72,7 +72,7 @@ class InvoiceInvitation extends BaseModel
|
||||
|
||||
public function getName()
|
||||
{
|
||||
|
||||
return $this->invitation_key;
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
|
@ -16,8 +16,10 @@ use App\Events\Invoice\InvoiceWasUpdated;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Helpers\Invoice\InvoiceCalc;
|
||||
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@ -26,7 +28,7 @@ use Illuminate\Support\Carbon;
|
||||
*/
|
||||
class InvoiceRepository extends BaseRepository
|
||||
{
|
||||
|
||||
use MakesHash;
|
||||
/**
|
||||
* Gets the class name.
|
||||
*
|
||||
@ -57,6 +59,19 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
$invoice->save();
|
||||
|
||||
if(isset($data['client_contacts']))
|
||||
{
|
||||
foreach($data['client_contacts'] as $contact)
|
||||
{
|
||||
if($contact['send_invoice'] == 1)
|
||||
{
|
||||
$client_contact = ClientContact::find($this->decodePrimaryKey($contact['id']));
|
||||
$client_contact->send_invoice = true;
|
||||
$client_contact->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event(new CreateInvoiceInvitation($invoice));
|
||||
|
||||
$invoice_calc = new InvoiceCalc($invoice, $invoice->settings);
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Transformers\InvoiceInvitationTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class InvoiceTransformer extends EntityTransformer
|
||||
@ -23,12 +25,18 @@ class InvoiceTransformer extends EntityTransformer
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
// 'invitations',
|
||||
'invitations',
|
||||
// 'payments',
|
||||
// 'client',
|
||||
// 'documents',
|
||||
];
|
||||
|
||||
public function includeInvitations(Invoice $invoice)
|
||||
{
|
||||
$transformer = new InvoiceInvitationTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($invoice->invitations, $transformer, InvoiceInvitation::class);
|
||||
}
|
||||
/*
|
||||
public function includeInvoiceItems(Invoice $invoice)
|
||||
{
|
||||
@ -37,12 +45,7 @@ class InvoiceTransformer extends EntityTransformer
|
||||
return $this->includeCollection($invoice->invoice_items, $transformer, ENTITY_INVOICE_ITEM);
|
||||
}
|
||||
|
||||
public function includeInvitations(Invoice $invoice)
|
||||
{
|
||||
$transformer = new InvitationTransformer($this->account, $this->serializer);
|
||||
|
||||
return $this->includeCollection($invoice->invitations, $transformer, ENTITY_INVITATION);
|
||||
}
|
||||
|
||||
public function includePayments(Invoice $invoice)
|
||||
{
|
||||
@ -112,7 +115,7 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'has_expenses' => (bool) $invoice->has_expenses,
|
||||
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
|
||||
'custom_text_value2' => $invoice->custom_text_value2 ?: '',
|
||||
'line_items' => $invoice->line_items,
|
||||
'line_items' => $invoice->line_items ?: '',
|
||||
'backup' => $invoice->backup ?: '',
|
||||
'settings' => $invoice->settings,
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user