mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 06:24:30 -04:00
Api work/Bug fixes
This commit is contained in:
parent
a6e9c5198d
commit
aef4658873
@ -139,6 +139,10 @@ class Client extends EntityModel
|
|||||||
return $this->hasMany('App\Models\Credit');
|
return $this->hasMany('App\Models\Credit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expenses()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Expense','client_id','id')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
public function addContact($data, $isPrimary = false)
|
public function addContact($data, $isPrimary = false)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +197,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id');
|
return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expenses()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
public function markInvitationsSent($notify = false)
|
public function markInvitationsSent($notify = false)
|
||||||
{
|
{
|
||||||
foreach ($this->invitations as $invitation) {
|
foreach ($this->invitations as $invitation) {
|
||||||
|
@ -47,6 +47,7 @@ class ClientTransformer extends EntityTransformer
|
|||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'invoices',
|
'invoices',
|
||||||
'credits',
|
'credits',
|
||||||
|
'expenses',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeContacts(Client $client)
|
public function includeContacts(Client $client)
|
||||||
@ -67,6 +68,13 @@ class ClientTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($client->credits, $transformer, ENTITY_CREDIT);
|
return $this->includeCollection($client->credits, $transformer, ENTITY_CREDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeExpenses(Client $client)
|
||||||
|
{
|
||||||
|
$transformer = new ExpenseTransformer($this->account, $this->serializer);
|
||||||
|
return $this->includeCollection($client->expenses, $transformer, ENTITY_EXPENSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function transform(Client $client)
|
public function transform(Client $client)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -28,6 +28,7 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
'invitations',
|
'invitations',
|
||||||
'payments',
|
'payments',
|
||||||
'client',
|
'client',
|
||||||
|
'expenses',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function includeInvoiceItems(Invoice $invoice)
|
public function includeInvoiceItems(Invoice $invoice)
|
||||||
@ -51,9 +52,16 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
public function includeClient(Invoice $invoice)
|
public function includeClient(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$transformer = new ClientTransformer($this->account, $this->serializer);
|
$transformer = new ClientTransformer($this->account, $this->serializer);
|
||||||
return $this->includeItem($invoice->client, $transformer, 'client');
|
return $this->includeItem($invoice->client, $transformer, ENTITY_CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeExpenses(Invoice $invoice)
|
||||||
|
{
|
||||||
|
$transformer = new ExpenseTransformer($this->account, $this->serializer);
|
||||||
|
return $this->includeCollection($invoice->expenses, $transformer, ENTITY_EXPENSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function transform(Invoice $invoice)
|
public function transform(Invoice $invoice)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -17,7 +17,6 @@ class VendorContactTransformer extends EntityTransformer
|
|||||||
'archived_at' => $this->getTimestamp($contact->deleted_at),
|
'archived_at' => $this->getTimestamp($contact->deleted_at),
|
||||||
'is_primary' => (bool) $contact->is_primary,
|
'is_primary' => (bool) $contact->is_primary,
|
||||||
'phone' => $contact->phone,
|
'phone' => $contact->phone,
|
||||||
'last_login' => $contact->last_login,
|
|
||||||
'account_key' => $this->account->account_key,
|
'account_key' => $this->account->account_key,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user