Simplified account name for cash accounts.

This commit is contained in:
James Cole 2015-06-26 04:57:30 +02:00
parent 04164500c8
commit 14934367d8
2 changed files with 16 additions and 10 deletions

View File

@ -159,20 +159,12 @@ class TransactionController extends Controller
if ($journal->transactionType->type == 'Withdrawal') {
$preFilled['account_id'] = $journal->source_account->id;
$preFilled['expense_account'] = $journal->destination_account->name;
$preFilled['expense_account'] = $journal->destination_account->name_for_editform;
} else {
$preFilled['account_id'] = $journal->destination_account->id;
$preFilled['revenue_account'] = $journal->source_account->name;
$preFilled['revenue_account'] = $journal->source_account->name_for_editform;
}
if ($journal->destination_account->accountType->type == 'Cash account') {
$preFilled['expense_account'] = '';
}
if ($journal->source_account->accountType->type == 'Cash account') {
$preFilled['revenue_account'] = '';
}
$preFilled['account_from_id'] = $journal->source_account->id;
$preFilled['account_to_id'] = $journal->destination_account->id;

View File

@ -180,6 +180,20 @@ class Account extends Model
return $value;
}
/**
*
* @return string
*/
public function getNameForEditformAttribute()
{
$name = $this->name;
if ($this->accountType->type == 'Cash account') {
$name = '';
}
return $name;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany