mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-06 09:57:15 +00:00
Fixed the account role view.
This commit is contained in:
@@ -52,7 +52,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
* Basic query:
|
* Basic query:
|
||||||
*/
|
*/
|
||||||
$query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');;
|
$query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');;
|
||||||
$set = $query->get(['accounts.*']);
|
$set = $query->get(['accounts.*', 'account_meta.data as accountRole']);
|
||||||
|
|
||||||
$set->each(
|
$set->each(
|
||||||
function (\Account $account) {
|
function (\Account $account) {
|
||||||
@@ -60,6 +60,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
* Get last activity date.
|
* Get last activity date.
|
||||||
*/
|
*/
|
||||||
$account->lastActivityDate = $this->getLastActivity($account);
|
$account->lastActivityDate = $this->getLastActivity($account);
|
||||||
|
$account->accountRole = \Config::get('firefly.accountRoles.' . json_decode($account->accountRole));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -197,19 +198,19 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
|||||||
}
|
}
|
||||||
\Event::fire('account.destroy', [$model]);
|
\Event::fire('account.destroy', [$model]);
|
||||||
\Account::
|
\Account::
|
||||||
leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||||
->where(
|
->where(
|
||||||
function (EloquentBuilder $q) use ($model) {
|
|
||||||
$q->where('id', $model->id);
|
|
||||||
$q->orWhere(
|
|
||||||
function (EloquentBuilder $q) use ($model) {
|
function (EloquentBuilder $q) use ($model) {
|
||||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
$q->where('id', $model->id);
|
||||||
$q->where('account_types.type', 'Initial balance account');
|
$q->orWhere(
|
||||||
$q->where('accounts.active', 0);
|
function (EloquentBuilder $q) use ($model) {
|
||||||
|
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||||
|
$q->where('account_types.type', 'Initial balance account');
|
||||||
|
$q->where('accounts.active', 0);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
)->delete();
|
||||||
}
|
|
||||||
)->delete();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
|
||||||
use Watson\Validating\ValidatingTrait;
|
|
||||||
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||||
|
use Illuminate\Database\Query\JoinClause;
|
||||||
|
use Watson\Validating\ValidatingTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
@@ -18,15 +18,15 @@ class Account extends Eloquent
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rules
|
public static $rules
|
||||||
= [
|
= [
|
||||||
'name' => ['required', 'between:1,100'],
|
'name' => ['required', 'between:1,100'],
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
'account_type_id' => 'required|exists:account_types,id',
|
'account_type_id' => 'required|exists:account_types,id',
|
||||||
'active' => 'required|boolean'
|
'active' => 'required|boolean'
|
||||||
|
|
||||||
];
|
];
|
||||||
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
protected $dates = ['deleted_at', 'created_at', 'updated_at'];
|
||||||
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account type.
|
* Account type.
|
||||||
@@ -67,7 +67,7 @@ class Account extends Eloquent
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param EloquentBuilder $query
|
* @param EloquentBuilder $query
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*/
|
*/
|
||||||
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
public function scopeAccountTypeIn(EloquentBuilder $query, array $types)
|
||||||
{
|
{
|
||||||
@@ -82,9 +82,13 @@ class Account extends Eloquent
|
|||||||
*
|
*
|
||||||
* @param EloquentBuilder $query
|
* @param EloquentBuilder $query
|
||||||
*/
|
*/
|
||||||
public function scopeWithMeta(EloquentBuilder $query)
|
public function scopeWithMeta(EloquentBuilder $query, $field = 'accountRole')
|
||||||
{
|
{
|
||||||
$query->with(['accountmeta']);
|
$query->leftJoin(
|
||||||
|
'account_meta', function (JoinClause $join) use ($field) {
|
||||||
|
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', $field);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
@if($what == 'asset')
|
@if($what == 'asset')
|
||||||
{{Form::ffBalance('openingbalance')}}
|
{{Form::ffBalance('openingbalance')}}
|
||||||
{{Form::ffDate('openingbalancedate', date('Y-m-d'))}}
|
{{Form::ffDate('openingbalancedate', date('Y-m-d'))}}
|
||||||
@endif
|
@endif
|
||||||
{{Form::ffCheckbox('active','1',true)}}
|
{{Form::ffCheckbox('active','1',true)}}
|
||||||
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
|
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user