mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 15:04:35 -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()
|
public function getName()
|
||||||
{
|
{
|
||||||
|
return $this->invitation_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLink()
|
public function getLink()
|
||||||
|
@ -16,8 +16,10 @@ use App\Events\Invoice\InvoiceWasUpdated;
|
|||||||
use App\Factory\InvoiceInvitationFactory;
|
use App\Factory\InvoiceInvitationFactory;
|
||||||
use App\Helpers\Invoice\InvoiceCalc;
|
use App\Helpers\Invoice\InvoiceCalc;
|
||||||
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
|
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
|
||||||
|
use App\Models\ClientContact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ use Illuminate\Support\Carbon;
|
|||||||
*/
|
*/
|
||||||
class InvoiceRepository extends BaseRepository
|
class InvoiceRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
|
use MakesHash;
|
||||||
/**
|
/**
|
||||||
* Gets the class name.
|
* Gets the class name.
|
||||||
*
|
*
|
||||||
@ -57,6 +59,19 @@ class InvoiceRepository extends BaseRepository
|
|||||||
|
|
||||||
$invoice->save();
|
$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));
|
event(new CreateInvoiceInvitation($invoice));
|
||||||
|
|
||||||
$invoice_calc = new InvoiceCalc($invoice, $invoice->settings);
|
$invoice_calc = new InvoiceCalc($invoice, $invoice->settings);
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\InvoiceInvitation;
|
||||||
|
use App\Transformers\InvoiceInvitationTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class InvoiceTransformer extends EntityTransformer
|
class InvoiceTransformer extends EntityTransformer
|
||||||
@ -23,12 +25,18 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
// 'invitations',
|
'invitations',
|
||||||
// 'payments',
|
// 'payments',
|
||||||
// 'client',
|
// 'client',
|
||||||
// 'documents',
|
// 'documents',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function includeInvitations(Invoice $invoice)
|
||||||
|
{
|
||||||
|
$transformer = new InvoiceInvitationTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($invoice->invitations, $transformer, InvoiceInvitation::class);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
public function includeInvoiceItems(Invoice $invoice)
|
public function includeInvoiceItems(Invoice $invoice)
|
||||||
{
|
{
|
||||||
@ -37,12 +45,7 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($invoice->invoice_items, $transformer, ENTITY_INVOICE_ITEM);
|
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)
|
public function includePayments(Invoice $invoice)
|
||||||
{
|
{
|
||||||
@ -112,7 +115,7 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
'has_expenses' => (bool) $invoice->has_expenses,
|
'has_expenses' => (bool) $invoice->has_expenses,
|
||||||
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
|
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
|
||||||
'custom_text_value2' => $invoice->custom_text_value2 ?: '',
|
'custom_text_value2' => $invoice->custom_text_value2 ?: '',
|
||||||
'line_items' => $invoice->line_items,
|
'line_items' => $invoice->line_items ?: '',
|
||||||
'backup' => $invoice->backup ?: '',
|
'backup' => $invoice->backup ?: '',
|
||||||
'settings' => $invoice->settings,
|
'settings' => $invoice->settings,
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user