Revert "Cleanup in preparation of an overhaul."

This reverts commit 5662a02a36.
This commit is contained in:
James Cole
2015-01-16 07:07:57 +01:00
parent 9eec6641dd
commit a950e02e9b
20 changed files with 310 additions and 337 deletions

View File

@@ -140,7 +140,8 @@ class AccountController extends BaseController
{
$subTitle = $this->_subTitlesByIdentifier[$what];
$subTitleIcon = $this->_subIconsByIdentifier[$what];
$accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]);
$accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]);
return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
}
@@ -168,23 +169,21 @@ class AccountController extends BaseController
public function store()
{
/*
* always validate using the account validator:
* TODO move to constructor.
*/
/** @var \FireflyIII\Validation\Account $validator */
$validator = App::make('FireflyIII\Validation\Account');
$data = Input::except('_token', 'post_submit_action');
$errors = $validator->store($data);
$data = Input::except('_token');
// always validate:
$messages = $this->_repository->validate($data);
// flash messages:
Session::flash('errors', $errors);
if ($errors->count() > 0) {
Session::flash('error', 'Could not store account: ' . $errors->first());
Session::flash('warnings', $messages['warnings']);
Session::flash('successes', $messages['successes']);
Session::flash('errors', $messages['errors']);
if ($messages['errors']->count() > 0) {
Session::flash('error', 'Could not store account: ' . $messages['errors']->first());
}
// return to create screen:
if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) {
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
return Redirect::route('accounts.create', e($data['what']))->withInput();
}
@@ -206,24 +205,23 @@ class AccountController extends BaseController
*/
public function update(Account $account)
{
/*
* always validate using the account validator:
* TODO move to constructor.
*/
/** @var \FireflyIII\Validation\Account $validator */
$validator = App::make('FireflyIII\Validation\Account');
$data = Input::except('_token');
$data['what'] = $this->_shortNamesByFullName[$account->accountType->type];
$errors = $validator->update($data, $account);
// always validate:
$messages = $this->_repository->validate($data);
// flash messages:
Session::flash('errors', $errors);
if ($errors->count() > 0) {
Session::flash('error', 'Could not update account: ' . $errors->first());
Session::flash('warnings', $messages['warnings']);
Session::flash('successes', $messages['successes']);
Session::flash('errors', $messages['errors']);
if ($messages['errors']->count() > 0) {
Session::flash('error', 'Could not update account: ' . $messages['errors']->first());
}
// return to update screen:
if ($data['post_submit_action'] == 'validate_only' || $errors->count() > 0) {
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
return Redirect::route('accounts.edit', $account->id)->withInput();
}

View File

@@ -88,7 +88,7 @@ class GoogleChartController extends BaseController
/** @var \FireflyIII\Database\Account\Account $acct */
$acct = App::make('FireflyIII\Database\Account\Account');
$accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAccountsByType(['Default account', 'Asset account']);
$accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts();
/** @var Account $account */
foreach ($accounts as $account) {

View File

@@ -33,7 +33,7 @@ class HomeController extends BaseController
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
$count = $acct->countAccountsByType(['Default account', 'Asset account']);
$count = $acct->countAssetAccounts();
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
@@ -42,7 +42,7 @@ class HomeController extends BaseController
// get the preference for the home accounts to show:
$frontPage = $preferences->get('frontPageAccounts', []);
if ($frontPage->data == []) {
$accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
$accounts = $acct->getAssetAccounts();
} else {
$accounts = $acct->getByIds($frontPage->data);
}

View File

@@ -36,7 +36,7 @@ class JsonController extends BaseController
{
/** @var \FireflyIII\Database\Account\Account $accounts */
$accounts = App::make('FireflyIII\Database\Account\Account');
$list = $accounts->getAccountsByType(['Expense account', 'Beneficiary account']);
$list = $accounts->getExpenseAccounts();
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;
@@ -53,7 +53,7 @@ class JsonController extends BaseController
{
/** @var \FireflyIII\Database\Account\Account $accounts */
$accounts = App::make('FireflyIII\Database\Account\Account');
$list = $accounts->getAccountsByType(['Revenue account']);
$list = $accounts->getRevenueAccounts();
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;

View File

@@ -62,7 +62,7 @@ class PiggyBankController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
$subTitle = 'Create new piggy bank';
$subTitleIcon = 'fa-plus';
@@ -107,7 +107,7 @@ class PiggyBankController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
$subTitle = 'Edit piggy bank "' . e($piggyBank->name) . '"';
$subTitleIcon = 'fa-pencil';

View File

@@ -29,7 +29,7 @@ class PreferencesController extends BaseController
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
$accounts = $acct->getAccountsByType(['Default account', 'Asset account']);
$accounts = $acct->getAssetAccounts();
$viewRange = $preferences->get('viewRange', '1M');
$viewRangeValue = $viewRange->data;
$frontPage = $preferences->get('frontPageAccounts', []);

View File

@@ -34,7 +34,7 @@ class RepeatedExpenseController extends BaseController
/** @var \FireflyIII\Database\Account\Account $acct */
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
return View::make('repeatedExpense.create', compact('accounts', 'periods'))->with('subTitle', 'Create new repeated expense')->with(
'subTitleIcon', 'fa-plus'
@@ -79,7 +79,7 @@ class RepeatedExpenseController extends BaseController
$acct = App::make('FireflyIII\Database\Account\Account');
$periods = Config::get('firefly.piggy_bank_periods');
$accounts = FFForm::makeSelectList($acct->getAccountsByType(['Default account', 'Asset account']));
$accounts = FFForm::makeSelectList($acct->getAssetAccounts());
$subTitle = 'Edit repeated expense "' . e($repeatedExpense->name) . '"';
$subTitleIcon = 'fa-pencil';