From 14934367d8fd673bf89ab222bfe7a8d37f374bf6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 26 Jun 2015 04:57:30 +0200 Subject: [PATCH] Simplified account name for cash accounts. --- app/Http/Controllers/TransactionController.php | 12 ++---------- app/Models/Account.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index f7cb8e10bb..0708263271 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -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; diff --git a/app/Models/Account.php b/app/Models/Account.php index 8a9f1f80fd..a09825c266 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -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