1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Merge branch 'master' of github.com:hillelcoren/invoice-ninja

This commit is contained in:
Hillel Coren 2015-12-21 21:58:02 +02:00
commit 8739a1b46b
5 changed files with 45 additions and 5 deletions

View File

@ -4,6 +4,7 @@ use App\Models\Account;
use App\Models\AccountToken;
use App\Models\Contact;
use App\Models\Product;
use App\Models\TaxRate;
use League\Fractal;
use League\Fractal\TransformerAbstract;
@ -11,10 +12,11 @@ class AccountTransformer extends EntityTransformer
{
protected $defaultIncludes = [
'users',
'clients',
// 'clients',
'invoices',
'contacts',
'products',
'taxRates'
];
public function includeUsers(Account $account)
@ -47,6 +49,13 @@ class AccountTransformer extends EntityTransformer
return $this->includeCollection($account->products, $transformer, 'products');
}
public function includeTaxRates(Account $account)
{
$transformer = new TaxRateTransformer($account, $this->serializer);
return $this->includeCollection($account->tax_rates, $transformer, 'taxRates');
}
public function transform(Account $account)
{
return [

View File

@ -91,7 +91,8 @@ class ClientTransformer extends EntityTransformer
'payment_terms' => (int) $client->payment_terms,
'vat_number' => $client->vat_number,
'id_number' => $client->id_number,
'language_id' => (int) $client->language_id
'language_id' => (int) $client->language_id,
'currency_id' => (int) $client->currency_id
];
}
}

View File

@ -13,7 +13,6 @@ class ContactTransformer extends EntityTransformer
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => $contact->email,
'user_id' => (int) $contact->user_id,
'updated_at' => $contact->updated_at,
'deleted_at' => $contact->deleted_at,
'is_primary' => (bool) $contact->is_primary,

View File

@ -13,8 +13,6 @@ class InvoiceItemTransformer extends EntityTransformer
'product_key' => $item->product_key,
'account_key' => $this->account->account_key,
'user_id' => (int) $item->user_id,
'invoice_id' => (int) $item->invoice->public_id,
'product_id' => (int) $item->product->public_id,
'updated_at' => $item->updated_at,
'deleted_at' => $item->deleted_at,
'product_key' => $item->product_key,

View File

@ -0,0 +1,33 @@
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\TaxRate;
use League\Fractal;
/**
* @SWG\Definition(definition="TaxRate", @SWG\Xml(name="TaxRate"))
*/
class TaxRateTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="name", type="string", example="GST")
* @SWG\Property(property="account_key", type="string", example="34erfdf33fdff" readOnly=true)
* @SWG\Property(property="rate", type="float", example=17.5)
* @SWG\Property(property="updated_at", type="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="date-time", example="2016-01-01 12:10:00")
*/
public function transform(TaxRate $taxRate)
{
return [
'id' => (int) $taxRate->public_id,
'name' => $taxRate->name,
'rate' => (float) $taxRate->rate,
'updated_at' => $taxRate->updated_at,
'archived_at' => $taxRate->deleted_at,
'account_key' => $this->account->account_key,
];
}
}