mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-08 18:58:07 +00:00
Code cleanup.
This commit is contained in:
@@ -150,6 +150,7 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot make it shorter because of query.
|
||||
* @param Eloquent $model
|
||||
*
|
||||
* @return bool
|
||||
@@ -159,25 +160,25 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
$journals = \TransactionJournal::whereIn(
|
||||
'id', function (QueryBuilder $query) use ($model) {
|
||||
$query->select('transaction_journal_id')
|
||||
->from('transactions')->whereIn(
|
||||
'account_id', function (QueryBuilder $query) use ($model) {
|
||||
$query
|
||||
->select('id')
|
||||
->from('accounts')
|
||||
->where(
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
$q->where('accounts.active', 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
)->where('accounts.user_id', $this->getUser()->id);
|
||||
}
|
||||
)->get();
|
||||
->from('transactions')
|
||||
->whereIn(
|
||||
'account_id', function (QueryBuilder $query) use ($model) {
|
||||
$query
|
||||
->select('id')->from('accounts')
|
||||
->where(
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('id', $model->id);
|
||||
$q->orWhere(
|
||||
function (QueryBuilder $q) use ($model) {
|
||||
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
|
||||
$q->where('accounts.account_type_id', 3);
|
||||
$q->where('accounts.active', 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
)->where('accounts.user_id', $this->getUser()->id);
|
||||
}
|
||||
)->get();
|
||||
}
|
||||
)->get();
|
||||
$transactions = [];
|
||||
@@ -218,9 +219,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
public function store(array $data)
|
||||
{
|
||||
|
||||
/*
|
||||
* Find account type.
|
||||
*/
|
||||
/** @var \FireflyIII\Database\AccountType\AccountType $acctType */
|
||||
$acctType = \App::make('FireflyIII\Database\AccountType\AccountType');
|
||||
|
||||
@@ -230,7 +228,6 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
|
||||
$data['account_type_id'] = $accountType->id;
|
||||
$data['active'] = isset($data['active']) && $data['active'] === '1' ? 1 : 0;
|
||||
|
||||
|
||||
$data = array_except($data, ['_token', 'what']);
|
||||
$account = new \Account($data);
|
||||
if (!$account->isValid()) {
|
||||
|
||||
@@ -363,11 +363,13 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
|
||||
$errors->add('account_id', 'Invalid account.');
|
||||
}
|
||||
break;
|
||||
// often seen in deposits
|
||||
case (isset($model['account_id']) && isset($model['revenue_account'])):
|
||||
if (intval($model['account_id']) < 1) {
|
||||
$errors->add('account_id', 'Invalid account.');
|
||||
}
|
||||
break;
|
||||
// often seen in transfers
|
||||
case (isset($model['account_from_id']) && isset($model['account_to_id'])):
|
||||
if (intval($model['account_from_id']) < 1 || intval($model['account_from_id']) < 1) {
|
||||
$errors->add('account_from_id', 'Invalid account selected.');
|
||||
|
||||
Reference in New Issue
Block a user