Small functional changes to all Account related methods and views.

This commit is contained in:
James Cole
2014-08-22 07:44:51 +02:00
parent bc0e8434ec
commit 9ecc8ab547
6 changed files with 308 additions and 48 deletions

View File

@@ -14,7 +14,7 @@ class AccountController extends \BaseController
/**
* @param ARI $repository
* @param AI $accounts
* @param AI $accounts
*/
public function __construct(ARI $repository, AI $accounts)
{
@@ -37,6 +37,12 @@ class AccountController extends \BaseController
*/
public function delete(Account $account)
{
$accountType = $account->accountType()->first();
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
return \View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
}
return View::make('accounts.delete')->with('account', $account);
}
@@ -47,6 +53,11 @@ class AccountController extends \BaseController
*/
public function destroy(Account $account)
{
$accountType = $account->accountType()->first();
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
return View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
}
$result = $this->_repository->destroy($account);
if ($result === true) {
Session::flash('success', 'The account was deleted.');
@@ -65,6 +76,11 @@ class AccountController extends \BaseController
*/
public function edit(Account $account)
{
$accountType = $account->accountType()->first();
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
return View::make('error')->with('message', 'Cannot edit this account type (' . $accountType->description . ').');
}
$openingBalance = $this->_accounts->openingBalanceTransaction($account);
return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance);
@@ -88,6 +104,11 @@ class AccountController extends \BaseController
*/
public function show(Account $account)
{
$accountType = $account->accountType()->first();
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
return View::make('error')->with('message', 'Cannot show this account type (' . $accountType->description . ').');
}
$show = $this->_accounts->show($account, 40);
return View::make('accounts.show')->with('account', $account)->with('show', $show);
@@ -125,6 +146,10 @@ class AccountController extends \BaseController
*/
public function update(Account $account)
{
$accountType = $account->accountType()->first();
if ($accountType->description == 'Initial balance account' || $accountType->description == 'Cash account') {
return View::make('error')->with('message', 'Cannot show this account type (' . $accountType->description . ').');
}
$account = $this->_repository->update($account, Input::all());
if ($account->validate()) {
Session::flash('success', 'Account "' . $account->name . '" updated.');