mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01: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_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')) {
|
||||
@ -736,6 +739,7 @@ class Account extends Eloquent
|
||||
'tax_rates' => [],
|
||||
'expenses' => ['client', 'invoice', 'vendor'],
|
||||
'payments' => ['invoice'],
|
||||
'expenseCategories' => [],
|
||||
];
|
||||
|
||||
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 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);
|
||||
@ -96,7 +104,8 @@ class AccountTransformer extends EntityTransformer
|
||||
'custom_label1' => $account->custom_label1,
|
||||
'custom_label2' => $account->custom_label2,
|
||||
'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…
Reference in New Issue
Block a user