mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01: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');
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense','client_id','id')->withTrashed();
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function expenses()
|
||||
{
|
||||
return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed();
|
||||
}
|
||||
|
||||
public function markInvitationsSent($notify = false)
|
||||
{
|
||||
foreach ($this->invitations as $invitation) {
|
||||
|
@ -47,6 +47,7 @@ class ClientTransformer extends EntityTransformer
|
||||
protected $availableIncludes = [
|
||||
'invoices',
|
||||
'credits',
|
||||
'expenses',
|
||||
];
|
||||
|
||||
public function includeContacts(Client $client)
|
||||
@ -67,6 +68,13 @@ class ClientTransformer extends EntityTransformer
|
||||
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)
|
||||
{
|
||||
return [
|
||||
|
@ -28,6 +28,7 @@ class InvoiceTransformer extends EntityTransformer
|
||||
'invitations',
|
||||
'payments',
|
||||
'client',
|
||||
'expenses',
|
||||
];
|
||||
|
||||
public function includeInvoiceItems(Invoice $invoice)
|
||||
@ -51,9 +52,16 @@ class InvoiceTransformer extends EntityTransformer
|
||||
public function includeClient(Invoice $invoice)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
return [
|
||||
|
@ -17,7 +17,6 @@ class VendorContactTransformer extends EntityTransformer
|
||||
'archived_at' => $this->getTimestamp($contact->deleted_at),
|
||||
'is_primary' => (bool) $contact->is_primary,
|
||||
'phone' => $contact->phone,
|
||||
'last_login' => $contact->last_login,
|
||||
'account_key' => $this->account->account_key,
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user