diff --git a/.gitignore b/.gitignore
index 7c2baa148d..d0be83396b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,4 @@ firefly-iii-import-*.json
tests/_output/*
testing.sqlite
c3.php
+_ide_helper_models.php
diff --git a/app/config/firefly.php b/app/config/firefly.php
index e259b2c0fa..eea3380786 100644
--- a/app/config/firefly.php
+++ b/app/config/firefly.php
@@ -18,8 +18,8 @@ return [
],
'accountRoles' => [
- 'default' => 'Default expense account',
- 'sharedExpense' => 'Shared expense account'
+ 'defaultExpense' => 'Default expense account',
+ 'sharedExpense' => 'Shared expense account'
],
'range_to_text' => [
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 73d8ec9338..b4fe3cd03d 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -1,7 +1,7 @@
['Default account', 'Asset account'],
+ 'expense' => ['Expense account', 'Beneficiary account'],
+ 'revenue' => ['Revenue account'],
+ ];
+
+ /** @var AccountRepository */
+ protected $_repository;
+
+ /** @var array */
+ protected $_shortNamesByFullName
+ = [
+ 'Default account' => 'asset',
+ 'Asset account' => 'asset',
+ 'Expense account' => 'expense',
+ 'Beneficiary account' => 'expense',
+ 'Revenue account' => 'revenue',
+ ];
+
+ /** @var array */
+ protected $_subIconsByIdentifier
+ = [
+ 'asset' => 'fa-money',
+ 'Asset account' => 'fa-money',
+ 'Default account' => 'fa-money',
+ 'expense' => 'fa-shopping-cart',
+ 'Expense account' => 'fa-shopping-cart',
+ 'Beneficiary account' => 'fa-shopping-cart',
+ 'revenue' => 'fa-download',
+ 'Revenue account' => 'fa-download',
+ ];
+ /** @var array */
+ protected $_subTitlesByIdentifier
+ = [
+ 'asset' => 'Asset accounts',
+ 'expense' => 'Expense accounts',
+ 'revenue' => 'Revenue accounts',
+ ];
+
/**
- *
+ * @param AccountRepository $repository
*/
- public function __construct()
+ public function __construct(AccountRepository $repository)
{
+ $this->_repository = $repository;
View::share('mainTitleIcon', 'fa-credit-card');
View::share('title', 'Accounts');
}
@@ -25,18 +67,8 @@ class AccountController extends BaseController
*/
public function create($what)
{
- switch ($what) {
- case 'asset':
- $subTitleIcon = 'fa-money';
- break;
- case 'expense':
- $subTitleIcon = 'fa-shopping-cart';
- break;
- case 'revenue':
- $subTitleIcon = 'fa-download';
- break;
- }
- $subTitle = 'Create a new ' . $what . ' account';
+ $subTitleIcon = $this->_subIconsByIdentifier[$what];
+ $subTitle = 'Create a new ' . $what . ' account';
return View::make('accounts.create', compact('subTitleIcon', 'what', 'subTitle'));
}
@@ -61,28 +93,15 @@ class AccountController extends BaseController
public function destroy(Account $account)
{
- $type = $account->accountType->type;
- $name = $account->name;
+ $type = $account->accountType->type;
+ $typeName = $this->_shortNamesByFullName[$type];
+ $name = $account->name;
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
+ $this->_repository->destroy($account);
- $acct->destroy($account);
+ Session::flash('success', 'The ' . $typeName . ' account "' . e($name) . '" was deleted.');
- $return = 'asset';
- switch ($type) {
- case 'Expense account':
- case 'Beneficiary account':
- $return = 'expense';
- break;
- case 'Revenue account':
- $return = 'revenue';
- break;
- }
-
- Session::flash('success', 'The ' . $return . ' account "' . e($name) . '" was deleted.');
-
- return Redirect::route('accounts.index', $return);
+ return Redirect::route('accounts.index', $type);
}
/**
@@ -92,42 +111,24 @@ class AccountController extends BaseController
*/
public function edit(Account $account)
{
- $prefilled = [];
- switch ($account->accountType->type) {
- case 'Asset account':
- case 'Default account':
- $subTitleIcon = 'fa-money';
- $prefilled['account_role'] = $account->getMeta('accountRole');
- break;
- case 'Expense account':
- case 'Beneficiary account':
- $subTitleIcon = 'fa-shopping-cart';
- break;
- case 'Revenue account':
- $subTitleIcon = 'fa-download';
- break;
- }
+ $openingBalance = $this->_repository->openingBalanceTransaction($account);
+ $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type];
+ $subTitle = 'Edit ' . strtolower($account->accountType->type) . ' "' . $account->name . '"';
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
+ // pre fill some useful values.
+ $preFilled = [
+ 'account_role' => $account->getMeta('accountRole'),
+ 'openingBalanceDate' => $openingBalance ? $openingBalance->date->format('Y-m-d') : null,
+ 'openingBalance' => $openingBalance ? $openingBalance->getAmount($account) : null
+ ];
+ Session::flash('preFilled', $preFilled);
- $openingBalance = $acct->openingBalanceTransaction($account);
- Session::forget('prefilled');
- if (!is_null($openingBalance)) {
- $prefilled['openingbalancedate'] = $openingBalance->date->format('Y-m-d');
- $prefilled['openingbalance'] = floatval($openingBalance->transactions()->where('account_id', $account->id)->first()->amount);
- }
- Session::flash('prefilled', $prefilled);
-
- return View::make('accounts.edit', compact('account', 'openingBalance', 'subTitleIcon'))->with(
- 'subTitle', 'Edit ' . strtolower(
- $account->accountType->type
- ) . ' "' . $account->name . '"'
- );
+ return View::make('accounts.edit', compact('account', 'subTitle', 'openingBalance', 'subTitleIcon'));
}
/**
+ *
* @param string $what
*
* @return View
@@ -135,94 +136,28 @@ class AccountController extends BaseController
*/
public function index($what = 'default')
{
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
+ $subTitle = $this->_subTitlesByIdentifier[$what];
+ $subTitleIcon = $this->_subIconsByIdentifier[$what];
- switch ($what) {
- default:
- throw new FireflyException('Cannot handle account type "' . e($what) . '".');
- break;
- case 'asset':
- $subTitleIcon = 'fa-money';
- $subTitle = 'Asset accounts';
- $accounts = $acct->getAssetAccounts();
- break;
- case 'expense':
- $subTitleIcon = 'fa-shopping-cart';
- $subTitle = 'Expense accounts';
- $accounts = $acct->getExpenseAccounts();
- break;
- case 'revenue':
- $subTitleIcon = 'fa-download';
- $subTitle = 'Revenue accounts';
- $accounts = $acct->getRevenueAccounts();
- break;
- }
-
- $accounts->each(
- function (Account $account) {
- if (Cache::has('account.' . $account->id . '.lastActivityDate')) {
- $account->lastActionDate = Cache::get('account.' . $account->id . '.lastActivityDate');
- } else {
- $transaction = $account->transactions()->orderBy('updated_at', 'DESC')->first();
- if (is_null($transaction)) {
- $account->lastActionDate = null;
- Cache::forever('account.' . $account->id . '.lastActivityDate', 0);
- } else {
- $account->lastActionDate = $transaction->updated_at;
- Cache::forever('account.' . $account->id . '.lastActivityDate', $transaction->updated_at);
- }
- }
-
- }
- );
+ $accounts = $this->_repository->getAccountsByType($this->_accountTypesByIdentifier[$what]);
return View::make('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
}
/**
* @param Account $account
- * @param string $view
+ * @param string $range
*
* @return $this
*/
- public function show(Account $account, $view = 'session')
+ public function show(Account $account, $range = 'session')
{
- switch ($account->accountType->type) {
- case 'Asset account':
- case 'Default account':
- $subTitleIcon = 'fa-money';
- $what = 'asset';
- break;
- case 'Expense account':
- case 'Beneficiary account':
- $subTitleIcon = 'fa-shopping-cart';
- $what = 'expense';
- break;
- case 'Revenue account':
- $subTitleIcon = 'fa-download';
- $what = 'revenue';
- break;
- }
+ $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type];
+ $what = $this->_shortNamesByFullName[$account->accountType->type];
+ $journals = $this->_repository->getTransactionJournals($account, 50, $range);
+ $subTitle = 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"';
- // get a paginated view of all transactions for this account:
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
- switch ($view) {
- default:
- case 'session':
- $journals = $acct->getTransactionJournals($account, 50);
- break;
- case 'all':
- $journals = $acct->getAllTransactionJournals($account, 50);
-
- break;
- }
-
-
- return View::make('accounts.show', compact('account', 'what', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
- 'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
- );
+ return View::make('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle'));
}
/**
@@ -232,45 +167,36 @@ class AccountController extends BaseController
public function store()
{
- $data = Input::all();
- $data['what'] = isset($data['what']) && $data['what'] != '' ? $data['what'] : 'asset';
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
+ $data = Input::except('_token');
- switch ($data['post_submit_action']) {
- default:
- throw new FireflyException('Cannot handle post_submit_action "' . e($data['post_submit_action']) . '"');
- break;
- case 'return_to_edit':
- case 'store':
- $messages = $acct->validate($data);
- /** @var MessageBag $messages ['errors'] */
- if ($messages['errors']->count() > 0) {
- Session::flash('warnings', $messages['warnings']);
- Session::flash('successes', $messages['successes']);
- Session::flash('error', 'Could not save account: ' . $messages['errors']->first());
+ // always validate:
+ $messages = $this->_repository->validate($data);
- return Redirect::route('accounts.create', $data['what'])->withInput()->withErrors($messages['errors']);
- }
- // store!
- $acct->store($data);
- Session::flash('success', 'New account stored!');
-
- if ($data['post_submit_action'] == 'create_another') {
- return Redirect::route('accounts.create', $data['what']);
- } else {
- return Redirect::route('accounts.index', $data['what']);
- }
- break;
- case 'validate_only':
- $messageBags = $acct->validate($data);
- Session::flash('warnings', $messageBags['warnings']);
- Session::flash('successes', $messageBags['successes']);
- Session::flash('errors', $messageBags['errors']);
-
- return Redirect::route('accounts.create', $data['what'])->withInput();
- break;
+ // flash messages:
+ 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' || $messages['errors']->count() > 0) {
+ return Redirect::route('accounts.create', $data['what'])->withInput();
+ }
+
+ // store:
+ $this->_repository->store($data);
+ Session::flash('success', 'Account "' . e($data['name']) . '" stored.');
+ if ($data['post_submit_action'] == 'store') {
+ return Redirect::route('accounts.index', $data['what']);
+ }
+ // create another.
+ if ($data['post_submit_action'] == 'create_another') {
+ return Redirect::route('accounts.create', $data['what'])->withInput();
+ }
+
+ return Redirect::route('accounts.index', $data['what']);
}
/**
@@ -281,62 +207,38 @@ class AccountController extends BaseController
*/
public function update(Account $account)
{
+ $data = Input::except('_token');
+ $data['what'] = $this->_shortNamesByFullName[$account->accountType->type];
- /** @var \FireflyIII\Database\Account $acct */
- $acct = App::make('FireflyIII\Database\Account');
- $data = Input::except('_token');
+ // always validate:
+ $messages = $this->_repository->validate($data);
- switch ($account->accountType->type) {
- default:
- throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
- break;
- case 'Default account':
- case 'Asset account':
- $data['what'] = 'asset';
- break;
- case 'Expense account':
- case 'Beneficiary account':
- $data['what'] = 'expense';
- break;
- case 'Revenue account':
- $data['what'] = 'revenue';
- break;
+ // flash messages:
+ 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());
}
- switch (Input::get('post_submit_action')) {
- default:
- throw new FireflyException('Cannot handle post_submit_action "' . e(Input::get('post_submit_action')) . '"');
- break;
- case 'create_another':
- case 'update':
- $messages = $acct->validate($data);
- /** @var MessageBag $messages ['errors'] */
- if ($messages['errors']->count() > 0) {
- Session::flash('warnings', $messages['warnings']);
- Session::flash('successes', $messages['successes']);
- Session::flash('error', 'Could not save account: ' . $messages['errors']->first());
-
- return Redirect::route('accounts.edit', $account->id)->withInput()->withErrors($messages['errors']);
- }
- // store!
- $acct->update($account, $data);
- Session::flash('success', 'Account updated!');
-
- if ($data['post_submit_action'] == 'create_another') {
- return Redirect::route('accounts.edit', $account->id);
- } else {
- return Redirect::route('accounts.index', $data['what']);
- }
- case 'validate_only':
- $messageBags = $acct->validate($data);
- Session::flash('warnings', $messageBags['warnings']);
- Session::flash('successes', $messageBags['successes']);
- Session::flash('errors', $messageBags['errors']);
-
- return Redirect::route('accounts.edit', $account->id)->withInput();
- break;
+ // return to update screen:
+ if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
+ return Redirect::route('accounts.edit', $account->id)->withInput();
}
+
+ // update
+ $this->_repository->update($account, $data);
+ Session::flash('success', 'Account "' . e($data['name']) . '" updated.');
+
+ // go back to list
+ if ($data['post_submit_action'] == 'update') {
+ return Redirect::route('accounts.index', $data['what']);
+ }
+ // go back to update screen.
+ if ($data['post_submit_action'] == 'return_to_edit') {
+ return Redirect::route('accounts.edit', $account->id);
+ }
+
+ return Redirect::route('accounts.index', $data['what']);
}
-
-
-}
+}
\ No newline at end of file
diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.php
index c2a857fb6d..e46a75bcf2 100644
--- a/app/controllers/BudgetController.php
+++ b/app/controllers/BudgetController.php
@@ -110,7 +110,7 @@ class BudgetController extends BaseController
*/
public function edit(Budget $budget)
{
- Session::flash('prefilled', ['name' => $budget->name]);
+ Session::flash('preFilled', ['name' => $budget->name]);
return View::make('budgets.edit')->with('budget', $budget)->with('subTitle', 'Edit budget "' . $budget->name . '"');
diff --git a/app/controllers/PiggybankController.php b/app/controllers/PiggybankController.php
index 0b4a8a61ab..eb933934af 100644
--- a/app/controllers/PiggybankController.php
+++ b/app/controllers/PiggybankController.php
@@ -103,16 +103,16 @@ class PiggybankController extends BaseController
/*
* Flash some data to fill the form.
*/
- $prefilled = ['name' => $piggybank->name,
+ $preFilled = ['name' => $piggybank->name,
'account_id' => $piggybank->account_id,
'targetamount' => $piggybank->targetamount,
'targetdate' => !is_null($piggybank->targetdate) ? $piggybank->targetdate->format('Y-m-d') : null,
'reminder' => $piggybank->reminder,
'remind_me' => intval($piggybank->remind_me) == 1 || !is_null($piggybank->reminder) ? true : false
];
- Session::flash('prefilled', $prefilled);
+ Session::flash('preFilled', $preFilled);
- return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods', 'prefilled'))->with('title', 'Piggybanks')->with(
+ return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods', 'preFilled'))->with('title', 'Piggybanks')->with(
'mainTitleIcon', 'fa-sort-amount-asc'
)->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil');
}
diff --git a/app/controllers/ReminderController.php b/app/controllers/ReminderController.php
index fe8c186e88..e22823e836 100644
--- a/app/controllers/ReminderController.php
+++ b/app/controllers/ReminderController.php
@@ -33,13 +33,13 @@ class ReminderController extends BaseController
break;
case 'Piggybank':
$amount = Reminders::amountForReminder($reminder);
- $prefilled = [
+ $preFilled = [
'amount' => round($amount, 2),
'description' => 'Money for ' . $reminder->remindersable->name,
'piggybank_id' => $reminder->remindersable_id,
'account_to_id' => $reminder->remindersable->account_id
];
- Session::flash('prefilled', $prefilled);
+ Session::flash('preFilled', $preFilled);
return Redirect::route('transactions.create', 'transfer');
break;
diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.php
index ecc45c9649..1bb335e453 100644
--- a/app/controllers/ReportController.php
+++ b/app/controllers/ReportController.php
@@ -1,11 +1,41 @@
_accounts = $accounts;
+ $this->_journals = $journals;
+ $this->_reports = $reports;
+ $this->_repository = $repository;
+
+ }
/**
* @param $year
@@ -115,38 +145,13 @@ class ReportController extends BaseController
*/
public function index()
{
- /** @var \FireflyIII\Database\TransactionJournal $journals */
- $journals = App::make('FireflyIII\Database\TransactionJournal');
- /** @var TransactionJournal $journal */
- $journal = $journals->first();
- if (is_null($journal)) {
- $date = Carbon::now();
- } else {
- $date = clone $journal->date;
- }
- $years = [];
- $months = [];
- while ($date <= Carbon::now()) {
- $years[] = $date->format('Y');
- $date->addYear();
- }
- // months
- if (is_null($journal)) {
- $date = Carbon::now();
- } else {
- $date = clone $journal->date;
- }
- while ($date <= Carbon::now()) {
- $months[] = [
- 'formatted' => $date->format('F Y'),
- 'month' => intval($date->format('m')),
- 'year' => intval($date->format('Y')),
- ];
- $date->addMonth();
- }
+ $start = $this->_journals->firstDate();
+ $months = $this->_reports->listOfMonths(clone $start);
+ $years = $this->_reports->listOfYears(clone $start);
+ $title = 'Reports';
+ $mainTitleIcon = 'fa-line-chart';
-
- return View::make('reports.index', compact('years', 'months'))->with('title', 'Reports')->with('mainTitleIcon', 'fa-line-chart');
+ return View::make('reports.index', compact('years', 'months', 'title', 'mainTitleIcon'));
}
/**
@@ -235,40 +240,43 @@ class ReportController extends BaseController
*/
public function year($year)
{
- Config::set('app.debug', false);
try {
- $date = new Carbon('01-01-' . $year);
+ new Carbon('01-01-' . $year);
} catch (Exception $e) {
App::abort(500);
}
- $date = new Carbon('01-01-' . $year);
+ $date = new Carbon('01-01-' . $year);
+ $title = 'Reports';
+ $subTitle = $year;
+ $subTitleIcon = 'fa-bar-chart';
+ $mainTitleIcon = 'fa-line-chart';
- /** @var \FireflyIII\Database\TransactionJournal $tj */
- $tj = App::make('FireflyIII\Database\TransactionJournal');
+ $balances = $this->_reports->yearBalanceReport($date);
+ $groupedIncomes = $this->_reports->groupByRevenue($date, 'income');
+ $groupedExpenses = $this->_reports->groupByRevenue($date, 'expense');
- /** @var \FireflyIII\Database\Account $accountRepository */
- $accountRepository = App::make('FireflyIII\Database\Account');
- /** @var \FireflyIII\Database\Report $reportRepository */
- $reportRepository = App::make('FireflyIII\Database\Report');
+ return View::make(
+ 'reports.year', compact('date', 'groupedIncomes', 'groupedExpenses', 'year', 'balances', 'title', 'subTitle', 'subTitleIcon', 'mainTitleIcon')
+ );
+
+
+ /*
+ * For this year, get:
+ * - the sum of all expenses.
+ * - the sum of all incomes
+ * - per month, the sum of all expenses
+ * - per month, the sum of all incomes
+ * - 2x for shared and not-shared alike.
+ *
+ * - balance difference for all accounts.
+ */
$accounts = $accountRepository->getAssetAccounts();
// get some sums going
$summary = [];
- /** @var \Account $account */
- $accounts->each(
- function (\Account $account) {
- if ($account->getMeta('accountRole') == 'sharedExpense') {
- $account->sharedExpense = true;
- } else {
- $account->sharedExpense = false;
- }
- }
- );
-
-
$end = clone $date;
$end->endOfYear();
while ($date < $end) {
@@ -280,7 +288,7 @@ class ReportController extends BaseController
$expenseShared = 0;
foreach ($accounts as $account) {
- if ($account->sharedExpense === true) {
+ if ($account->accountRole == 'sharedExpense') {
$incomeShared += $reportRepository->getIncomeByMonth($account, $date);
$expenseShared += $reportRepository->getExpenseByMonth($account, $date);
} else {
diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php
index 69333d6852..5885f53f2d 100644
--- a/app/controllers/TransactionController.php
+++ b/app/controllers/TransactionController.php
@@ -103,14 +103,14 @@ class TransactionController extends BaseController
/*
* respond to a possible given values in the URL.
*/
- $prefilled = Session::has('prefilled') ? Session::get('prefilled') : [];
+ $preFilled = Session::has('preFilled') ? Session::get('preFilled') : [];
$respondTo = ['account_id', 'account_from_id'];
foreach ($respondTo as $r) {
if (!is_null(Input::get($r))) {
- $prefilled[$r] = Input::get($r);
+ $preFilled[$r] = Input::get($r);
}
}
- Session::put('prefilled', $prefilled);
+ Session::put('preFilled', $preFilled);
return View::make('transactions.create')->with('accounts', $assetAccounts)->with('budgets', $budgets)->with('what', $what)->with('piggies', $piggies)
->with('subTitle', 'Add a new ' . $what);
@@ -244,7 +244,7 @@ class TransactionController extends BaseController
/*
* Data to properly display the edit form.
*/
- $prefilled = [
+ $preFilled = [
'date' => $journal->date->format('Y-m-d'),
'category' => '',
'budget_id' => 0,
@@ -256,7 +256,7 @@ class TransactionController extends BaseController
*/
$category = $journal->categories()->first();
if (!is_null($category)) {
- $prefilled['category'] = $category->name;
+ $preFilled['category'] = $category->name;
}
/*
@@ -267,33 +267,33 @@ class TransactionController extends BaseController
case 'withdrawal':
if (floatval($journal->transactions[0]->amount) < 0) {
// transactions[0] is the asset account that paid for the withdrawal.
- $prefilled['account_id'] = $journal->transactions[0]->account->id;
- $prefilled['expense_account'] = $journal->transactions[1]->account->name;
- $prefilled['amount'] = floatval($journal->transactions[1]->amount);
+ $preFilled['account_id'] = $journal->transactions[0]->account->id;
+ $preFilled['expense_account'] = $journal->transactions[1]->account->name;
+ $preFilled['amount'] = floatval($journal->transactions[1]->amount);
} else {
// transactions[1] is the asset account that paid for the withdrawal.
- $prefilled['account_id'] = $journal->transactions[1]->account->id;
- $prefilled['expense_account'] = $journal->transactions[0]->account->name;
- $prefilled['amount'] = floatval($journal->transactions[0]->amount);
+ $preFilled['account_id'] = $journal->transactions[1]->account->id;
+ $preFilled['expense_account'] = $journal->transactions[0]->account->name;
+ $preFilled['amount'] = floatval($journal->transactions[0]->amount);
}
$budget = $journal->budgets()->first();
if (!is_null($budget)) {
- $prefilled['budget_id'] = $budget->id;
+ $preFilled['budget_id'] = $budget->id;
}
break;
case 'deposit':
if (floatval($journal->transactions[0]->amount) < 0) {
// transactions[0] contains the account the money came from.
- $prefilled['account_id'] = $journal->transactions[1]->account->id;
- $prefilled['revenue_account'] = $journal->transactions[0]->account->name;
- $prefilled['amount'] = floatval($journal->transactions[1]->amount);
+ $preFilled['account_id'] = $journal->transactions[1]->account->id;
+ $preFilled['revenue_account'] = $journal->transactions[0]->account->name;
+ $preFilled['amount'] = floatval($journal->transactions[1]->amount);
} else {
// transactions[1] contains the account the money came from.
- $prefilled['account_id'] = $journal->transactions[0]->account->id;
- $prefilled['revenue_account'] = $journal->transactions[1]->account->name;
- $prefilled['amount'] = floatval($journal->transactions[0]->amount);
+ $preFilled['account_id'] = $journal->transactions[0]->account->id;
+ $preFilled['revenue_account'] = $journal->transactions[1]->account->name;
+ $preFilled['amount'] = floatval($journal->transactions[0]->amount);
}
@@ -301,17 +301,17 @@ class TransactionController extends BaseController
case 'transfer':
if (floatval($journal->transactions[0]->amount) < 0) {
// zero = from account.
- $prefilled['account_from_id'] = $journal->transactions[0]->account->id;
- $prefilled['account_to_id'] = $journal->transactions[1]->account->id;
- $prefilled['amount'] = floatval($journal->transactions[1]->amount);
+ $preFilled['account_from_id'] = $journal->transactions[0]->account->id;
+ $preFilled['account_to_id'] = $journal->transactions[1]->account->id;
+ $preFilled['amount'] = floatval($journal->transactions[1]->amount);
} else {
// one = from account
- $prefilled['account_from_id'] = $journal->transactions[1]->account->id;
- $prefilled['account_to_id'] = $journal->transactions[0]->account->id;
- $prefilled['amount'] = floatval($journal->transactions[0]->amount);
+ $preFilled['account_from_id'] = $journal->transactions[1]->account->id;
+ $preFilled['account_to_id'] = $journal->transactions[0]->account->id;
+ $preFilled['amount'] = floatval($journal->transactions[0]->amount);
}
if ($journal->piggybankevents()->count() > 0) {
- $prefilled['piggybank_id'] = $journal->piggybankevents()->first()->piggybank_id;
+ $preFilled['piggybank_id'] = $journal->piggybankevents()->first()->piggybank_id;
}
break;
}
@@ -322,7 +322,7 @@ class TransactionController extends BaseController
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
'what', $what
- )->with('budgets', $budgets)->with('data', $prefilled)->with('piggies', $piggies)->with(
+ )->with('budgets', $budgets)->with('data', $preFilled)->with('piggies', $piggies)->with(
'subTitle', 'Edit ' . $what . ' "' . $journal->description . '"'
);
}
diff --git a/app/database/seeds/DefaultUserSeeder.php b/app/database/seeds/DefaultUserSeeder.php
index 1b484c895c..0e4c292529 100644
--- a/app/database/seeds/DefaultUserSeeder.php
+++ b/app/database/seeds/DefaultUserSeeder.php
@@ -16,6 +16,9 @@ class DefaultUserSeeder extends Seeder
User::create(
['email' => 'acceptance@example.com', 'password' => 'acceptance', 'reset' => null, 'remember_token' => null, 'migrated' => 0]
);
+ User::create(
+ ['email' => 'functional@example.com', 'password' => 'functional', 'reset' => null, 'remember_token' => null, 'migrated' => 0]
+ );
}
}
diff --git a/app/lib/Firefly/Form/Form.php b/app/lib/Firefly/Form/Form.php
index a06c3184ec..ccb6b2944f 100644
--- a/app/lib/Firefly/Form/Form.php
+++ b/app/lib/Firefly/Form/Form.php
@@ -229,10 +229,10 @@ class Form
$options['placeholder'] = ucfirst($name);
/*
- * Get prefilled value:
+ * Get pre filled value:
*/
if (\Session::has('prefilled')) {
- $prefilled = \Session::get('prefilled');
+ $preFilled = \Session::get('preFilled');
$value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value;
}
diff --git a/app/lib/FireflyIII/Database/Account.php b/app/lib/FireflyIII/Database/Account.php
index 6dcd5ae0b3..3e26eb3aaf 100644
--- a/app/lib/FireflyIII/Database/Account.php
+++ b/app/lib/FireflyIII/Database/Account.php
@@ -88,57 +88,47 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
/*
* Basic query:
*/
- $query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta();
+ $query = $this->getUser()->accounts()->accountTypeIn($types)->withMeta()->orderBy('name', 'ASC');;
+ $set = $query->get(['accounts.*']);
-
- /*
- * Without an opening balance, the rest of these queries will fail.
- */
-
- $query->leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id');
- $query->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id');
-
- /*
- * Not used, but useful for the balance within a certain month / year.
- */
- $query->where(
- function ($q) {
- $q->where('transaction_journals.date', '<=', Carbon::now()->format('Y-m-d'));
- $q->orWhereNull('transaction_journals.date');
+ $set->each(
+ function (\Account $account) {
+ /*
+ * Get last activity date.
+ */
+ $account->lastActivityDate = $this->getLastActivity($account);
}
);
- $query->groupBy('accounts.id');
-
- /*
- * If present, process parameters for sorting:
- */
- $query->orderBy('name', 'ASC');
-
- return $query->get(['accounts.*', \DB::Raw('SUM(`transactions`.`amount`) as `balance`')]);
+ return $set;
}
/**
* Get all asset accounts. Optional JSON based parameters.
*
- * @param array $parameters
+ * @param array $metaFilter
*
* @return Collection
*/
- public function getAssetAccounts()
+ public function getAssetAccounts($metaFilter = [])
{
$list = $this->getAccountsByType(['Default account', 'Asset account']);
$list->each(
function (\Account $account) {
+
+ // get accountRole:
+
/** @var \AccountMeta $entry */
- foreach ($account->accountmeta as $entry) {
- if ($entry->name == 'accountRole') {
- $account->accountRole = \Config::get('firefly.accountRoles.' . $entry->data);
- }
- }
- if (!isset($account->accountRole)) {
- $account->accountRole = 'Default expense account';
+ $accountRole = $account->accountmeta()->whereName('accountRole')->first();
+ if (!$accountRole) {
+ $accountRole = new \AccountMeta;
+ $accountRole->account_id = $account->id;
+ $accountRole->name = 'accountRole';
+ $accountRole->data = 'defaultExpense';
+ $accountRole->save();
+
}
+ $account->accountRole = $accountRole->data;
}
);
@@ -274,7 +264,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
$q->where('accounts.active', 0);
}
);
- })->delete();
+ }
+ )->delete();
return true;
@@ -331,7 +322,7 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
*/
@@ -552,19 +543,49 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
}
- public function getTransactionJournals(\Account $account, $limit = 50)
+ /**
+ * @param \Account $account
+ *
+ * @return int
+ */
+ public function getLastActivity(\Account $account)
+ {
+ $lastActivityKey = 'account.' . $account->id . '.lastActivityDate';
+ if (\Cache::has($lastActivityKey)) {
+ return \Cache::get($lastActivityKey);
+ }
+
+ $transaction = $account->transactions()
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->orderBy('transaction_journals.date', 'DESC')->first();
+ if ($transaction) {
+ $date = $transaction->transactionJournal->date;
+ } else {
+ $date = 0;
+ }
+ \Cache::forever($lastActivityKey, $date);
+
+ return $date;
+ }
+
+ public function getTransactionJournals(\Account $account, $limit = 50, $range = 'session')
{
- $start = \Session::get('start');
- $end = \Session::get('end');
$offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0;
- $set = $this->getUser()->transactionJournals()->withRelevantData()->leftJoin(
- 'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
- )->where('transactions.account_id', $account->id)->take($limit)->offset($offset)->before($end)->after($start)->orderBy('date', 'DESC')->get(
- ['transaction_journals.*']
- );
- $count = $this->getUser()->transactionJournals()->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
- ->before($end)->after($start)->orderBy('date', 'DESC')->where('transactions.account_id', $account->id)->count();
$items = [];
+ $query = $this->getUser()
+ ->transactionJournals()
+ ->withRelevantData()
+ ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->where('transactions.account_id', $account->id)
+ ->orderBy('date', 'DESC');
+
+ if ($range == 'session') {
+ $query->before(\Session::get('end'));
+ $query->after(\Session::get('start'));
+ }
+ $count = $query->count();
+ $set = $query->take($limit)->offset($offset)->get(['transaction_journals.*']);
+
foreach ($set as $entry) {
$items[] = $entry;
}
diff --git a/app/lib/FireflyIII/Database/Report.php b/app/lib/FireflyIII/Database/Report.php
index db48935f09..4cd5d5238c 100644
--- a/app/lib/FireflyIII/Database/Report.php
+++ b/app/lib/FireflyIII/Database/Report.php
@@ -42,7 +42,7 @@ class Report implements ReportInterface
$sum = 0;
// get all journals.
- $journals = \TransactionJournal::whereIn(
+ $journals = \TransactionJournal::with(['transactionType','transactions'])->whereIn(
'id', function ($query) use ($account, $start, $end) {
$query->select('transaction_journal_id')
->from('transactions')
@@ -125,7 +125,7 @@ class Report implements ReportInterface
$sum = 0;
// get all journals.
- $journals = \TransactionJournal::whereIn(
+ $journals = \TransactionJournal::with(['transactionType','transactions'])->whereIn(
'id', function ($query) use ($account, $start, $end) {
$query->select('transaction_journal_id')
->from('transactions')
diff --git a/app/lib/FireflyIII/Database/TransactionJournal.php b/app/lib/FireflyIII/Database/TransactionJournal.php
index e0f8184fc0..4a51e9e607 100644
--- a/app/lib/FireflyIII/Database/TransactionJournal.php
+++ b/app/lib/FireflyIII/Database/TransactionJournal.php
@@ -171,7 +171,7 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
/**
* @param \Eloquent $model
- * @param array $data
+ * @param array $data
*
* @return bool
*/
@@ -486,6 +486,19 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
return $this->getUser()->transactionjournals()->with('transactions')->whereIn('id', $ids)->orderBy('date', 'ASC')->get();
}
+ /**
+ * @return Carbon
+ */
+ public function firstDate()
+ {
+ $journal = $this->first();
+ if ($journal) {
+ return $journal->date;
+ }
+
+ return Carbon::now();
+ }
+
/**
* @return TransactionJournal
*/
diff --git a/app/lib/FireflyIII/FF3ServiceProvider.php b/app/lib/FireflyIII/FF3ServiceProvider.php
index 0dad668bcf..6c86ead5b3 100644
--- a/app/lib/FireflyIII/FF3ServiceProvider.php
+++ b/app/lib/FireflyIII/FF3ServiceProvider.php
@@ -87,6 +87,10 @@ class FF3ServiceProvider extends ServiceProvider
// registration and user mail:
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
+ // reports
+ $this->app->bind('FireflyIII\Report\ReportInterface', 'FireflyIII\Report\Report');
+
+
// Shortcut so developers don't need to add an Alias in app/config/app.php
$this->app->booting(
function () {
diff --git a/app/lib/FireflyIII/Form/Form.php b/app/lib/FireflyIII/Form/Form.php
index 7388523742..9b11b13678 100644
--- a/app/lib/FireflyIII/Form/Form.php
+++ b/app/lib/FireflyIII/Form/Form.php
@@ -57,11 +57,11 @@ class Form
$options['placeholder'] = ucfirst($name);
/*
- * Get prefilled value:
+ * Get pre filled value:
*/
- if (\Session::has('prefilled')) {
- $prefilled = \Session::get('prefilled');
- $value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value;
+ if (\Session::has('preFilled')) {
+ $preFilled = \Session::get('preFilled');
+ $value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
}
diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php
new file mode 100644
index 0000000000..ebbf8ce990
--- /dev/null
+++ b/app/lib/FireflyIII/Report/Report.php
@@ -0,0 +1,125 @@
+_accounts = $accounts;
+
+ }
+
+ /**
+ * @param Carbon $date
+ * @param string $direction
+ *
+ * @return mixed
+ */
+ public function groupByRevenue(Carbon $date, $direction = 'income')
+ {
+ $operator = $direction == 'income' ? '<' : '>';
+ $type = $direction == 'income' ? 'Deposit' : 'Withdrawal';
+ $order = $direction == 'income' ? 'ASC' : 'DESC';
+ $start = clone $date;
+ $end = clone $date;
+ $start->startOfYear();
+ $end->endOfYear();
+
+ // TODO remove shared accounts
+ return \TransactionJournal::
+ leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')
+ ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
+ ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
+ ->where('transaction_types.type', '=', $type)
+ ->where('transactions.amount', $operator, 0)
+ ->before($end)
+ ->after($start)
+ ->groupBy('accounts.id')
+ ->where('transaction_journals.user_id', \Auth::user()->id)
+ ->orderBy('sum', $order)
+ ->take(10)
+ ->get(['accounts.name', 'transactions.account_id', \DB::Raw('SUM(`transactions`.`amount`) as `sum`')]);
+
+ }
+
+ /**
+ * @param Carbon $start
+ *
+ * @return array
+ */
+ public function listOfMonths(Carbon $start)
+ {
+ $end = Carbon::now();
+ $months = [];
+ while ($start <= $end) {
+ $months[] = [
+ 'formatted' => $start->format('F Y'),
+ 'month' => intval($start->format('m')),
+ 'year' => intval($start->format('Y')),
+ ];
+ $start->addMonth();
+ }
+
+ return $months;
+ }
+
+ /**
+ * @param Carbon $start
+ *
+ * @return array
+ */
+ public function listOfYears(Carbon $start)
+ {
+ $end = Carbon::now();
+ $years = [];
+ while ($start <= $end) {
+ $years[] = $start->format('Y');
+ $start->addYear();
+ }
+
+ return $years;
+ }
+
+ /**
+ * @param Carbon $date
+ *
+ * @return array
+ */
+ public function yearBalanceReport(Carbon $date)
+ {
+ $start = clone $date;
+ $end = clone $date;
+ // TODO filter accounts, no shared accounts.
+ $accounts = $this->_accounts->getAssetAccounts();
+ $report = [];
+ $start->startOfYear();
+ $end->endOfYear();
+
+ foreach ($accounts as $account) {
+ $report[] = [
+ 'start' => \Steam::balance($account, $start),
+ 'end' => \Steam::balance($account, $end),
+ 'account' => $account,
+ 'shared' => $account->accountRole == 'sharedExpense'
+ ];
+ }
+
+ return $report;
+ }
+
+}
\ No newline at end of file
diff --git a/app/lib/FireflyIII/Report/ReportInterface.php b/app/lib/FireflyIII/Report/ReportInterface.php
new file mode 100644
index 0000000000..20f201b579
--- /dev/null
+++ b/app/lib/FireflyIII/Report/ReportInterface.php
@@ -0,0 +1,42 @@
+id . '.latestBalance')) {
-
- return \Cache::get('account.' . $account->id . '.latestBalance');
- }
+ $key = 'account.' . $account->id . '.latestBalance';
+ } else {
+ $key = 'account.' . $account->id . '.balanceOn' . $date->format('dmy');
+ }
+ if (\Cache::has($key)) {
+ return \Cache::get($key);
}
$date = is_null($date) ? Carbon::now() : $date;
$balance = floatval(
@@ -37,9 +37,7 @@ class Steam
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
);
- if ($latest === true) {
- \Cache::forever('account.' . $account->id . '.latestBalance', $balance);
- }
+ \Cache::put($key, $balance, 20160);
return $balance;
}
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
index 61dd4424c9..a1bcb40794 100644
--- a/app/models/TransactionJournal.php
+++ b/app/models/TransactionJournal.php
@@ -49,10 +49,13 @@ class TransactionJournal extends Eloquent
*
* @return float
*/
- public function getAmount()
+ public function getAmount(\Account $account = null)
{
foreach ($this->transactions as $t) {
+ if (!is_null($account) && $account->id == $t->account_id) {
+ return floatval($t->amount);
+ }
if (floatval($t->amount) > 0) {
return floatval($t->amount);
}
diff --git a/app/routes.php b/app/routes.php
index cb18fcd3cf..eff0807f35 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -327,7 +327,6 @@ Route::group(
// user controller
Route::get('/login', ['uses' => 'UserController@login', 'as' => 'login']);
Route::get('/register', ['uses' => 'UserController@register', 'as' => 'register']);
- Route::get('/verify/{verification}', ['uses' => 'UserController@verify', 'as' => 'verify']);
Route::get('/reset/{reset}', ['uses' => 'UserController@reset', 'as' => 'reset']);
Route::get('/remindme', ['uses' => 'UserController@remindme', 'as' => 'remindme']);
@@ -340,8 +339,8 @@ Route::group(
['before' => 'csrf|guest'], function () {
// user controller
- Route::post('/login', ['uses' => 'UserController@postLogin']);
- Route::post('/register', ['uses' => 'UserController@postRegister']);
- Route::post('/remindme', ['uses' => 'UserController@postRemindme']);
+ Route::post('/login', ['uses' => 'UserController@postLogin','as' => 'login.post']);
+ Route::post('/register', ['uses' => 'UserController@postRegister','as' => 'register.post']);
+ Route::post('/remindme', ['uses' => 'UserController@postRemindme','as' => 'remindme.post']);
}
);
\ No newline at end of file
diff --git a/app/views/accounts/edit.blade.php b/app/views/accounts/edit.blade.php
index 6a596f87ba..8b02f2d20f 100644
--- a/app/views/accounts/edit.blade.php
+++ b/app/views/accounts/edit.blade.php
@@ -26,8 +26,8 @@
{{Form::ffCheckbox('active','1')}}
@if($account->accounttype->type == 'Default account' || $account->accounttype->type == 'Asset account')
- {{Form::ffBalance('openingbalance')}}
- {{Form::ffDate('openingbalancedate')}}
+ {{Form::ffBalance('openingBalance')}}
+ {{Form::ffDate('openingBalanceDate')}}
{{Form::ffSelect('account_role',Config::get('firefly.accountRoles'))}}
@endif
diff --git a/app/views/accounts/show.blade.php b/app/views/accounts/show.blade.php
index 9445421f28..ce978f17bc 100644
--- a/app/views/accounts/show.blade.php
+++ b/app/views/accounts/show.blade.php
@@ -21,7 +21,7 @@
- @if($view == 'all')
+ @if($range == 'all')
Stick to date-range
@else
Show all transactions
@@ -74,7 +74,7 @@
@section('scripts')
diff --git a/app/views/list/accounts.blade.php b/app/views/list/accounts.blade.php
index 0bbf841fc6..b7976d4df3 100644
--- a/app/views/list/accounts.blade.php
+++ b/app/views/list/accounts.blade.php
@@ -26,8 +26,8 @@
@endif
- @if($account->lastActionDate)
- {{{$account->lastActionDate->format('j F Y')}}}
+ @if($account->lastActivityDate)
+ {{{$account->lastActivityDate->format('j F Y')}}}
@else
Never
@endif
diff --git a/app/views/piggybanks/edit.blade.php b/app/views/piggybanks/edit.blade.php
index e94d3f18ec..4fb7333d78 100644
--- a/app/views/piggybanks/edit.blade.php
+++ b/app/views/piggybanks/edit.blade.php
@@ -30,8 +30,8 @@
{{Form::ffDate('targetdate')}}
- {{Form::ffCheckbox('remind_me','1',$prefilled['remind_me'],['label' => 'Remind me'])}}
- {{Form::ffSelect('reminder',$periods,$prefilled['reminder'],['label' => 'Remind every'])}}
+ {{Form::ffCheckbox('remind_me','1',$preFilled['remind_me'],['label' => 'Remind me'])}}
+ {{Form::ffSelect('reminder',$periods,$preFilled['reminder'],['label' => 'Remind every'])}}
diff --git a/app/views/reports/year.blade.php b/app/views/reports/year.blade.php
index 7ceaf3eb52..e3a358494f 100644
--- a/app/views/reports/year.blade.php
+++ b/app/views/reports/year.blade.php
@@ -25,85 +25,72 @@
-
+
- Summary (without shared accounts)
+ Account balance
-
-
- |
- @foreach($summary as $entry)
- {{$entry['month']}} |
- @endforeach
- Sum |
-
-
- In |
-
- @foreach($summary as $entry)
- {{mf($entry['income'])}} |
-
- @endforeach
- {{mf($inSum)}} |
-
- Out |
-
- @foreach($summary as $entry)
- {{mf($entry['expense']*-1)}} |
-
- @endforeach
- {{mf($outSum)}} |
-
- Difference |
- @foreach($summary as $entry)
- {{mf($entry['income']- $entry['expense'])}} |
- @endforeach
- {{mf($inSum + $outSum)}} |
-
-
+
+
+ @foreach($balances as $balance)
+
+
+
+ {{{$balance['account']->name}}}
+ @if($balance['shared'])
+ shared
+ @endif
+ |
+ {{mf($balance['start'])}} |
+ {{mf($balance['end'])}} |
+ {{mf($balance['end']-$balance['start'])}} |
+
+ @endforeach
+
+ Sum of sums |
+ {{mf($start)}} |
+ {{mf($end)}} |
+ {{mf($diff)}} |
+
+
-
-
-
-
+
- Summary (shared accounts only)
+ Income
-
-
- |
- @foreach($summary as $entry)
- {{$entry['month']}} |
- @endforeach
- Sum |
-
-
- In |
-
- @foreach($summary as $entry)
- {{mf($entry['incomeShared'])}} |
-
- @endforeach
- {{mf($inSum)}} |
-
- Out |
-
- @foreach($summary as $entry)
- {{mf($entry['expenseShared']*-1)}} |
-
- @endforeach
- {{mf($outSum)}} |
-
- Difference |
- @foreach($summary as $entry)
- {{mf($entry['incomeShared']- $entry['expenseShared'])}} |
- @endforeach
- {{mf($inSum + $outSum)}} |
-
-
+
+ @foreach($groupedIncomes as $income)
+
+ {{{$income->name}}} |
+ {{mf(floatval($income->sum)*-1)}} |
+
+ @endforeach
+
+
+
+
+
+
+ Expenses
+
+
+ @foreach($groupedExpenses as $expense)
+
+ {{{$expense->name}}} |
+ {{mf(floatval($expense->sum)*-1)}} |
+
+ @endforeach
+
@@ -115,7 +102,7 @@
Budgets
diff --git a/app/views/user/login.blade.php b/app/views/user/login.blade.php
index 3458043cdf..c3b6efe898 100644
--- a/app/views/user/login.blade.php
+++ b/app/views/user/login.blade.php
@@ -10,7 +10,7 @@
- {{Form::open()}}
+ {{Form::open(['id' => 'login'])}}
diff --git a/tests/functional.suite.yml b/tests/functional.suite.yml
index 86edef7270..6c67a707ca 100644
--- a/tests/functional.suite.yml
+++ b/tests/functional.suite.yml
@@ -12,4 +12,5 @@ modules:
populate: false
cleanup: false
Laravel4:
- environment: 'testing'
\ No newline at end of file
+ environment: 'testing'
+ filters: false
\ No newline at end of file
diff --git a/tests/functional/FunctionalTester.php b/tests/functional/FunctionalTester.php
index 7e84a3ff8d..c96dd6d033 100644
--- a/tests/functional/FunctionalTester.php
+++ b/tests/functional/FunctionalTester.php
@@ -1,4 +1,4 @@
-wantTo('perform actions and see result');
diff --git a/tests/functional/RegisterCept.php b/tests/functional/RegisterCept.php
deleted file mode 100644
index e7d150a947..0000000000
--- a/tests/functional/RegisterCept.php
+++ /dev/null
@@ -1,7 +0,0 @@
-wantTo('register a new account');
-$I->amOnPage('/register');
-$I->submitForm('#register', ['email' => 'noreply@gmail.com']);
-$I->see('Password sent!');
-$I->seeRecord('users', ['email' => 'noreply@gmail.com']);
\ No newline at end of file
diff --git a/tests/functional/UserControllerCest.php b/tests/functional/UserControllerCest.php
new file mode 100644
index 0000000000..ce7340c404
--- /dev/null
+++ b/tests/functional/UserControllerCest.php
@@ -0,0 +1,104 @@
+wantTo('login');
+ $I->amOnPage('/login');
+ $I->see('Sign In');
+ $I->submitForm('#login', ['email' => 'functional@example.com','password' => 'functional']);
+ $I->see('functional@example.com');
+
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function logout(FunctionalTester $I)
+ {
+ $I->wantTo('logout');
+ #$I->amOnPage('/logout');
+ #$I->am
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function postLogin(FunctionalTester $I)
+ {
+ $I->wantTo('post login');
+ $I->amOnRoute('login');
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function postRegister(FunctionalTester $I)
+ {
+ // @codingStandardsIgnoreStart
+ $I->wantTo('post-register a new account');
+ $I->amOnPage('/register');
+ $token = $I->grabValueFrom('input[name=_token]');
+ $I->submitForm('#register', ['email' => 'noreply@gmail.com','_token' => $token]);
+ $I->see('Password sent!');
+ $I->seeRecord('users', ['email' => 'noreply@gmail.com']);
+ // @codingStandardsIgnoreEnd
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function postRemindme(FunctionalTester $I)
+ {
+ $I->wantTo('get a password reminder');
+ $I->amOnRoute('remindme');
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function register(FunctionalTester $I)
+ {
+ $I->wantTo('register a new account');
+ $I->amOnRoute('register');
+
+
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function remindme(FunctionalTester $I)
+ {
+ $I->wantTo('reminded of my password');
+ $I->amOnRoute('remindme');
+ }
+
+ /**
+ * @param FunctionalTester $I
+ */
+ public function reset(FunctionalTester $I)
+ {
+ $I->wantTo('reset my password');
+ $I->amOnRoute('reset');
+ }
+
+}
\ No newline at end of file
|