mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01:00
Integrating Expense categories into API
This commit is contained in:
parent
7237f25cba
commit
fedbd74319
@ -365,6 +365,7 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('ENTITY_EXPENSE_ACTIVITY', 'expense_activity');
|
define('ENTITY_EXPENSE_ACTIVITY', 'expense_activity');
|
||||||
define('ENTITY_BANK_ACCOUNT', 'bank_account');
|
define('ENTITY_BANK_ACCOUNT', 'bank_account');
|
||||||
define('ENTITY_BANK_SUBACCOUNT', 'bank_subaccount');
|
define('ENTITY_BANK_SUBACCOUNT', 'bank_subaccount');
|
||||||
|
define('ENTITY_EXPENSE_CATEGORIES', 'expense_categories');
|
||||||
|
|
||||||
define('INVOICE_TYPE_STANDARD', 1);
|
define('INVOICE_TYPE_STANDARD', 1);
|
||||||
define('INVOICE_TYPE_QUOTE', 2);
|
define('INVOICE_TYPE_QUOTE', 2);
|
||||||
|
@ -198,6 +198,11 @@ class Account extends Eloquent
|
|||||||
return $this->belongsTo('App\Models\Company');
|
return $this->belongsTo('App\Models\Company');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expenseCategories()
|
||||||
|
{
|
||||||
|
$this->hasMany('App\Models\ExpenseCategories','account_id','id')->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
public function setIndustryIdAttribute($value)
|
public function setIndustryIdAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['industry_id'] = $value ?: null;
|
$this->attributes['industry_id'] = $value ?: null;
|
||||||
@ -213,8 +218,6 @@ class Account extends Eloquent
|
|||||||
$this->attributes['size_id'] = $value ?: null;
|
$this->attributes['size_id'] = $value ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function isGatewayConfigured($gatewayId = 0)
|
public function isGatewayConfigured($gatewayId = 0)
|
||||||
{
|
{
|
||||||
if ( ! $this->relationLoaded('account_gateways')) {
|
if ( ! $this->relationLoaded('account_gateways')) {
|
||||||
@ -729,6 +732,7 @@ class Account extends Eloquent
|
|||||||
'tax_rates' => [],
|
'tax_rates' => [],
|
||||||
'expenses' => ['client', 'invoice', 'vendor'],
|
'expenses' => ['client', 'invoice', 'vendor'],
|
||||||
'payments' => ['invoice'],
|
'payments' => ['invoice'],
|
||||||
|
'expenseCategories' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($map as $key => $values) {
|
foreach ($map as $key => $values) {
|
||||||
|
@ -7,6 +7,7 @@ use App\Models\Product;
|
|||||||
use App\Models\TaxRate;
|
use App\Models\TaxRate;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
|
use App\Models\ExpenseCategory;
|
||||||
|
|
||||||
class AccountTransformer extends EntityTransformer
|
class AccountTransformer extends EntityTransformer
|
||||||
{
|
{
|
||||||
@ -14,6 +15,7 @@ class AccountTransformer extends EntityTransformer
|
|||||||
'users',
|
'users',
|
||||||
'products',
|
'products',
|
||||||
'taxRates',
|
'taxRates',
|
||||||
|
'expense_categories'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
@ -22,6 +24,12 @@ class AccountTransformer extends EntityTransformer
|
|||||||
'payments',
|
'payments',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function includeExpenseCategories(Account $account)
|
||||||
|
{
|
||||||
|
$transformer = new ExpenseTransformer($account, $this->serializer);
|
||||||
|
return $this->includeCollection($account->expenseCategories, $transformer, ENTITY_EXPENSE_CATEGORIES);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeUsers(Account $account)
|
public function includeUsers(Account $account)
|
||||||
{
|
{
|
||||||
$transformer = new UserTransformer($account, $this->serializer);
|
$transformer = new UserTransformer($account, $this->serializer);
|
||||||
|
Loading…
Reference in New Issue
Block a user