mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 18:10:56 -04:00
Merge branch 'develop' of github.com:hillelcoren/invoice-ninja into develop
This commit is contained in:
commit
12b754dc32
@ -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()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\ExpenseCategory','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')) {
|
||||||
@ -736,6 +739,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) {
|
||||||
|
20
app/Models/ExpenseCategory.php
Normal file
20
app/Models/ExpenseCategory.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
|
||||||
|
class ExpenseCategory extends EntityModel
|
||||||
|
{
|
||||||
|
// Expense Categories
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function expense()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('App\Models\Expense');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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 ExpenseCategoryTransformer($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);
|
||||||
@ -96,7 +104,8 @@ class AccountTransformer extends EntityTransformer
|
|||||||
'custom_label1' => $account->custom_label1,
|
'custom_label1' => $account->custom_label1,
|
||||||
'custom_label2' => $account->custom_label2,
|
'custom_label2' => $account->custom_label2,
|
||||||
'custom_value1' => $account->custom_value1,
|
'custom_value1' => $account->custom_value1,
|
||||||
'custom_value2' => $account->custom_value2
|
'custom_value2' => $account->custom_value2,
|
||||||
|
'logo' => $account->logo,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
18
app/Ninja/Transformers/ExpenseCategoryTransformer.php
Normal file
18
app/Ninja/Transformers/ExpenseCategoryTransformer.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Ninja\Transformers;
|
||||||
|
|
||||||
|
use App\Models\ExpenseCategory;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class ExpenseCategoryTransformer extends EntityTransformer
|
||||||
|
{
|
||||||
|
|
||||||
|
public function transform(ExpenseCategory $expenseCategory)
|
||||||
|
{
|
||||||
|
return array_merge($this->getDefaults($expenseCategory), [
|
||||||
|
'id' => (int) $expenseCategory->public_id,
|
||||||
|
'name' => $expenseCategory->name,
|
||||||
|
'updated_at' => $this->getTimestamp($expenseCategory->updated_at),
|
||||||
|
'archived_at' => $this->getTimestamp($expenseCategory->deleted_at),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user