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