diff --git a/app/controllers/GoogleChartController.php b/app/controllers/GoogleChartController.php index 0c96370ddc..2a5786c5f6 100644 --- a/app/controllers/GoogleChartController.php +++ b/app/controllers/GoogleChartController.php @@ -1,7 +1,7 @@ _chart = $chart; + $this->_chart = $chart; + $this->_repository = $repository; + $this->_start = Session::get('start', Carbon::now()->startOfMonth()); + $this->_end = Session::get('end', Carbon::now()->endOfMonth()); } @@ -38,8 +48,8 @@ class GoogleChartController extends BaseController $this->_chart->addColumn('Balance for ' . $account->name, 'number'); // TODO this can be combined in some method, it's coming up quite often, is it? - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end'); + $start = $this->_start; + $end = $this->_end; $count = $account->transactions()->count(); if ($view == 'all' && $count > 0) { @@ -79,22 +89,16 @@ class GoogleChartController extends BaseController $pref = $preferences->get('frontpageAccounts', []); /** @var \FireflyIII\Database\Account\Account $acct */ - $acct = App::make('FireflyIII\Database\Account\Account'); - if (count($pref->data) > 0) { - $accounts = $acct->getByIds($pref->data); - } else { - $accounts = $acct->getAssetAccounts(); - } + $acct = App::make('FireflyIII\Database\Account\Account'); + $accounts = count($pref->data) > 0 ? $acct->getByIds($pref->data) : $acct->getAssetAccounts(); /** @var Account $account */ foreach ($accounts as $account) { $this->_chart->addColumn('Balance for ' . $account->name, 'number'); } - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); - $current = clone $start; + $current = clone $this->_start; - while ($end >= $current) { + while ($this->_end >= $current) { $row = [clone $current]; foreach ($accounts as $account) { $row[] = Steam::balance($account, $current); @@ -118,20 +122,27 @@ class GoogleChartController extends BaseController $this->_chart->addColumn('Budgeted', 'number'); $this->_chart->addColumn('Spent', 'number'); + Log::debug('Now in allBudgetsHomeChart()'); + /** @var \FireflyIII\Database\Budget\Budget $bdt */ $bdt = App::make('FireflyIII\Database\Budget\Budget'); $budgets = $bdt->get(); /** @var Budget $budget */ foreach ($budgets as $budget) { + + Log::debug('Now working budget #'.$budget->id.', '.$budget->name); + /** @var \LimitRepetition $repetition */ - $repetition = $bdt->repetitionOnStartingOnDate($budget, Session::get('start', Carbon::now()->startOfMonth())); + $repetition = $bdt->repetitionOnStartingOnDate($budget, $this->_start); if (is_null($repetition)) { + \Log::debug('Budget #'.$budget->id.' has no repetition on ' . $this->_start->format('Y-m-d')); // use the session start and end for our search query - $searchStart = Session::get('start', Carbon::now()->startOfMonth()); - $searchEnd = Session::get('end'); + $searchStart = $this->_start; + $searchEnd = $this->_end; $limit = 0; // the limit is zero: } else { + \Log::debug('Budget #'.$budget->id.' has a repetition on ' . $this->_start->format('Y-m-d').'!'); // use the limit's start and end for our search query $searchStart = $repetition->startdate; $searchEnd = $repetition->enddate; @@ -144,7 +155,7 @@ class GoogleChartController extends BaseController } } - $noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange(Session::get('start', Carbon::now()->startOfMonth()), Session::get('end')); + $noBudgetSet = $bdt->transactionsWithoutBudgetInDateRange($this->_start, $this->_end); $sum = $noBudgetSet->sum('amount') * -1; $this->_chart->addRow('No budget', 0, $sum); $this->_chart->generate(); @@ -161,24 +172,8 @@ class GoogleChartController extends BaseController $this->_chart->addColumn('Spent', 'number'); // query! - // TODO move to some helper. - $set = \TransactionJournal::leftJoin( - 'transactions', - function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0); - } - ) - ->leftJoin( - 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id' - ) - ->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id') - ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') - ->before(Session::get('end', Carbon::now()->endOfMonth())) - ->after(Session::get('start', Carbon::now()->startOfMonth())) - ->where('transaction_types.type', 'Withdrawal') - ->groupBy('categories.id') - ->orderBy('sum', 'DESC') - ->get(['categories.id', 'categories.name', DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]); + $set = $this->_repository->getCategorySummary($this->_start, $this->_end); + foreach ($set as $entry) { $entry->name = strlen($entry->name) == 0 ? '(no category)' : $entry->name; $this->_chart->addRow($entry->name, floatval($entry->sum)); @@ -191,6 +186,8 @@ class GoogleChartController extends BaseController } /** + * TODO still in use? + * * @param Budget $budget * @param LimitRepetition $repetition * @@ -223,6 +220,8 @@ class GoogleChartController extends BaseController } /** + * TODO still in use? + * * @param Budget $component * @param $year * @@ -231,9 +230,9 @@ class GoogleChartController extends BaseController public function budgetsAndSpending(Budget $component, $year) { try { - $start = new Carbon('01-01-' . $year); + new Carbon('01-01-' . $year); } catch (Exception $e) { - App::abort(500); + return View::make('error')->with('message', 'Invalid year.'); } /** @var \FireflyIII\Database\Budget\Budget $repos */ @@ -243,7 +242,8 @@ class GoogleChartController extends BaseController $this->_chart->addColumn('Budgeted', 'number'); $this->_chart->addColumn('Spent', 'number'); - $end = clone $start; + $start = new Carbon('01-01-' . $year); + $end = clone $start; $end->endOfYear(); while ($start <= $end) { $spent = $repos->spentInMonth($component, $start); @@ -268,6 +268,8 @@ class GoogleChartController extends BaseController } /** + * TODO still in use? + * * @param Category $component * @param $year * @@ -276,9 +278,9 @@ class GoogleChartController extends BaseController public function categoriesAndSpending(Category $component, $year) { try { - $start = new Carbon('01-01-' . $year); + new Carbon('01-01-' . $year); } catch (Exception $e) { - App::abort(500); + return View::make('error')->with('message', 'Invalid year.'); } /** @var \FireflyIII\Database\Category\Category $repos */ @@ -288,7 +290,8 @@ class GoogleChartController extends BaseController $this->_chart->addColumn('Budgeted', 'number'); $this->_chart->addColumn('Spent', 'number'); - $end = clone $start; + $start = new Carbon('01-01-' . $year); + $end = clone $start; $end->endOfYear(); while ($start <= $end) { @@ -370,7 +373,7 @@ class GoogleChartController extends BaseController } /** - * TODO move to helper. + * TODO query move to helper. * * @return \Illuminate\Http\JsonResponse * @throws \FireflyIII\Exception\FireflyException @@ -379,31 +382,10 @@ class GoogleChartController extends BaseController { $paid = ['items' => [], 'amount' => 0]; $unpaid = ['items' => [], 'amount' => 0]; - $start = Session::get('start', Carbon::now()->startOfMonth()); - $end = Session::get('end', Carbon::now()->endOfMonth()); $this->_chart->addColumn('Name', 'string'); $this->_chart->addColumn('Amount', 'number'); - $set = \RecurringTransaction:: - leftJoin( - 'transaction_journals', function (JoinClause $join) use ($start, $end) { - $join->on('recurring_transactions.id', '=', 'transaction_journals.recurring_transaction_id') - ->where('transaction_journals.date', '>=', $start->format('Y-m-d')) - ->where('transaction_journals.date', '<=', $end->format('Y-m-d')); - } - ) - ->leftJoin( - 'transactions', function (JoinClause $join) { - $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0); - } - ) - ->where('active', 1) - ->groupBy('recurring_transactions.id') - ->get( - ['recurring_transactions.id', 'recurring_transactions.name', 'transaction_journals.description', - 'transaction_journals.id as journalId', - DB::Raw('SUM(`recurring_transactions`.`amount_min` + `recurring_transactions`.`amount_max`) / 2 as `averageAmount`'), - 'transactions.amount AS actualAmount'] - ); + + $set = $this->_repository->getRecurringSummary($this->_start, $this->_end); foreach ($set as $entry) { if (intval($entry->journalId) == 0) { @@ -422,6 +404,8 @@ class GoogleChartController extends BaseController } /** + * TODO see reports for better way to do this. + * * @param $year * * @return \Illuminate\Http\JsonResponse @@ -431,7 +415,7 @@ class GoogleChartController extends BaseController try { $start = new Carbon('01-01-' . $year); } catch (Exception $e) { - App::abort(500); + return View::make('error')->with('message', 'Invalid year.'); } $this->_chart->addColumn('Month', 'date'); $this->_chart->addColumn('Income', 'number'); @@ -460,6 +444,8 @@ class GoogleChartController extends BaseController } /** + * TODO see reports for better way to do this. + * * @param $year * * @return \Illuminate\Http\JsonResponse @@ -469,7 +455,7 @@ class GoogleChartController extends BaseController try { $start = new Carbon('01-01-' . $year); } catch (Exception $e) { - App::abort(500); + return View::make('error')->with('message', 'Invalid year.'); } $this->_chart->addColumn('Summary', 'string'); $this->_chart->addColumn('Income', 'number'); diff --git a/app/database/seeds/TestContentSeeder.php b/app/database/seeds/TestContentSeeder.php index 1b3bebb947..ccdb3a15b3 100644 --- a/app/database/seeds/TestContentSeeder.php +++ b/app/database/seeds/TestContentSeeder.php @@ -36,26 +36,36 @@ class TestContentSeeder extends Seeder $deleteBudget = Budget::create(['user_id' => $user->id, 'name' => 'Delete me']); // some limits: - $limitOne = BudgetLimit::create( - ['startdate' => '2014-01-01', 'amount' => 200, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $groceriesBudget->id] + $startDate = Carbon::now()->startOfMonth(); + $endDate = Carbon::now()->endOfMonth(); + $limitOne = BudgetLimit::create( + ['startdate' => $startDate->format('Y-m-d'), 'amount' => 200, 'repeats' => 0, 'repeat_freq' => 'monthly', + 'budget_id' => $groceriesBudget->id] ); - $limitTwo = BudgetLimit::create( - ['startdate' => '2014-01-01', 'amount' => 200, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $billsBudget->id] + $limitTwo = BudgetLimit::create( + ['startdate' => $startDate->format('Y-m-d'), 'amount' => 200, 'repeats' => 0, 'repeat_freq' => 'monthly', + 'budget_id' => $billsBudget->id] ); $limitThree = BudgetLimit::create( ['startdate' => '2014-01-01', 'amount' => 200, 'repeats' => 0, 'repeat_freq' => 'monthly', 'budget_id' => $deleteBudget->id] ); // and because we have no filters, some repetitions: - $repOne = LimitRepetition::create(['budget_limit_id' => $limitOne->id, 'startdate' => '2014-01-01', 'enddate' => '2014-01-31', 'amount' => 200]); - $repTwo = LimitRepetition::create(['budget_limit_id' => $limitTwo->id, 'startdate' => '2014-01-01', 'enddate' => '2014-01-31', 'amount' => 200]); - $repThree = LimitRepetition::create(['budget_limit_id' => $limitThree->id, 'startdate' => '2014-01-01', 'enddate' => '2014-01-31', 'amount' => 200]); + $repOne = LimitRepetition::create( + ['budget_limit_id' => $limitOne->id, 'startdate' => $startDate->format('Y-m-d'), 'enddate' => $endDate->format('Y-m-d'), 'amount' => 200] + ); + $repTwo = LimitRepetition::create( + ['budget_limit_id' => $limitTwo->id, 'startdate' => $startDate->format('Y-m-d'), 'enddate' => $endDate->format('Y-m-d'), 'amount' => 200] + ); + $repThree = LimitRepetition::create( + ['budget_limit_id' => $limitThree->id, 'startdate' => '2014-01-01', 'enddate' => '2014-01-31', 'amount' => 200] + ); // create two categories: $dailyGroceries = Category::create(['user_id' => $user->id, 'name' => 'DailyGroceries']); $lunch = Category::create(['user_id' => $user->id, 'name' => 'Lunch']); $house = Category::create(['user_id' => $user->id, 'name' => 'House']); - $deleteMe= Category::create(['user_id' => $user->id, 'name' => 'Delete me']); + $deleteMe = Category::create(['user_id' => $user->id, 'name' => 'Delete me']); Component::create(['user_id' => $user->id, 'name' => 'Some Component 1', 'class' => 'Budget']); Component::create(['user_id' => $user->id, 'name' => 'Some Component 2', 'class' => 'Budget']); @@ -65,6 +75,58 @@ class TestContentSeeder extends Seeder Component::create(['user_id' => $user->id, 'name' => 'Some Component 6', 'class' => 'Category']); Component::create(['user_id' => $user->id, 'name' => 'Some Component 7', 'class' => 'Category']); + // piggy bank + $piggy = Piggybank::create( + [ + 'account_id' => $savings->id, + 'name' => 'New camera', + 'targetamount' => 2000, + 'startdate' => Carbon::now()->format('Y-m-d'), + 'targetdate' => '', + 'repeats' => 0, + 'rep_length' => null, + 'rep_every' => 0, + 'rep_times' => null, + 'reminder' => null, + 'reminder_skip' => 0, + 'remind_me' => 0, + 'order' => 0, + ] + ); + $piggyBankEvent = PiggyBankEvent::create(['piggybank_id' => 1, 'date' => $startDate->format('Y-m-d'), 'amount' => 100]); + + // recurring transaction + $recurring = \RecurringTransaction::create( + [ + 'user_id' => $user->id, + 'name' => 'Huur', + 'match' => 'huur,portaal', + 'amount_min' => 500, + 'amount_max' => 700, + 'date' => '2014-01-12', + 'active' => 1, + 'automatch' => 1, + 'repeat_freq' => 'monthly', + 'skip' => 0, + ] + ); + + // recurring transaction + $secondRecurring = \RecurringTransaction::create( + [ + 'user_id' => $user->id, + 'name' => 'Gas licht', + 'match' => 'no,match', + 'amount_min' => 500, + 'amount_max' => 700, + 'date' => '2014-01-12', + 'active' => 1, + 'automatch' => 1, + 'repeat_freq' => 'monthly', + 'skip' => 0, + ] + ); + // create some expense accounts. $albert = Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'Albert Heijn', 'active' => 1]); $plus = Account::create(['user_id' => $user->id, 'account_type_id' => $expenseType->id, 'name' => 'PLUS', 'active' => 1]); @@ -92,10 +154,11 @@ class TestContentSeeder extends Seeder // create some expenses and incomes and what-not (for every month): $start = new Carbon('2014-01-01'); - $end = Carbon::now()->startOfMonth()->subDay(); + $end = Carbon::now()->endOfMonth()->addDay(); while ($start <= $end) { $this->createTransaction( - $checking, $portaal, 500, $withdrawal, 'Rent for ' . $start->format('F Y'), $start->format('Y-m-') . '01', $billsBudget, $house + $checking, $portaal, 500, $withdrawal, 'Huur Portaal for ' . $start->format('F Y'), $start->format('Y-m-') . '01', $billsBudget, $house, + $recurring ); $this->createTransaction( $checking, $vitens, 12, $withdrawal, 'Water for ' . $start->format('F Y'), $start->format('Y-m-') . '02', $billsBudget, $house @@ -149,33 +212,37 @@ class TestContentSeeder extends Seeder } /** - * @param Account $from - * @param Account $to - * @param $amount - * @param TransactionType $type - * @param $description - * @param $date + * @param Account $from + * @param Account $to + * @param $amount + * @param TransactionType $type + * @param $description + * @param $date * - * @param Budget $budget - * @param Category $category + * @param Budget $budget + * @param Category $category + * @param RecurringTransaction $recurring * * @return TransactionJournal */ public function createTransaction( - Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null + Account $from, Account $to, $amount, TransactionType $type, $description, $date, Budget $budget = null, Category $category = null, + $recurring = null ) { - $user = User::whereEmail('thegrumpydictator@gmail.com')->first(); - $euro = TransactionCurrency::whereCode('EUR')->first(); + $user = User::whereEmail('thegrumpydictator@gmail.com')->first(); + $euro = TransactionCurrency::whereCode('EUR')->first(); + $recurringID = is_null($recurring) ? null : $recurring->id; /** @var TransactionJournal $journal */ $journal = TransactionJournal::create( [ - 'user_id' => $user->id, - 'transaction_type_id' => $type->id, - 'transaction_currency_id' => $euro->id, - 'description' => $description, - 'completed' => 1, - 'date' => $date + 'user_id' => $user->id, + 'transaction_type_id' => $type->id, + 'transaction_currency_id' => $euro->id, + 'recurring_transaction_id' => $recurringID, + 'description' => $description, + 'completed' => 1, + 'date' => $date ] ); diff --git a/app/lib/FireflyIII/Chart/Chart.php b/app/lib/FireflyIII/Chart/Chart.php new file mode 100644 index 0000000000..302a014c5b --- /dev/null +++ b/app/lib/FireflyIII/Chart/Chart.php @@ -0,0 +1,75 @@ +on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('amount', '>', 0); + } + ) + ->leftJoin( + 'category_transaction_journal', 'category_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id' + ) + ->leftJoin('categories', 'categories.id', '=', 'category_transaction_journal.category_id') + ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') + ->before($end) + ->after($start) + ->where('transaction_types.type', 'Withdrawal') + ->groupBy('categories.id') + ->orderBy('sum', 'DESC') + ->get(['categories.id', 'categories.name', \DB::Raw('SUM(`transactions`.`amount`) AS `sum`')]); + } + + /** + * @param Carbon $start + * @param Carbon $end + * + * @return Collection + */ + public function getRecurringSummary(Carbon $start, Carbon $end) + { + return \RecurringTransaction:: + leftJoin( + 'transaction_journals', function (JoinClause $join) use ($start, $end) { + $join->on('recurring_transactions.id', '=', 'transaction_journals.recurring_transaction_id') + ->where('transaction_journals.date', '>=', $start->format('Y-m-d')) + ->where('transaction_journals.date', '<=', $end->format('Y-m-d')); + } + ) + ->leftJoin( + 'transactions', function (JoinClause $join) { + $join->on('transaction_journals.id', '=', 'transactions.transaction_journal_id')->where('transactions.amount', '>', 0); + } + ) + ->where('active', 1) + ->groupBy('recurring_transactions.id') + ->get( + ['recurring_transactions.id', 'recurring_transactions.name', 'transaction_journals.description', + 'transaction_journals.id as journalId', + \DB::Raw('SUM(`recurring_transactions`.`amount_min` + `recurring_transactions`.`amount_max`) / 2 as `averageAmount`'), + 'transactions.amount AS actualAmount'] + ); + } +} \ No newline at end of file diff --git a/app/lib/FireflyIII/Chart/ChartInterface.php b/app/lib/FireflyIII/Chart/ChartInterface.php new file mode 100644 index 0000000000..7b29e3c9e9 --- /dev/null +++ b/app/lib/FireflyIII/Chart/ChartInterface.php @@ -0,0 +1,31 @@ +where('limit_repetitions.startdate', $date->format('Y-m-d')) - ->where('budget_limits.budget_id', $budget->id) - ->first(['limit_repetitions.*']); + ->where('limit_repetitions.startdate', $date->format('Y-m-d 00:00:00')) + ->where('budget_limits.budget_id', $budget->id) + ->first(['limit_repetitions.*']); } /** diff --git a/app/lib/FireflyIII/FF3ServiceProvider.php b/app/lib/FireflyIII/FF3ServiceProvider.php index c380ea5723..b79fcf3053 100644 --- a/app/lib/FireflyIII/FF3ServiceProvider.php +++ b/app/lib/FireflyIII/FF3ServiceProvider.php @@ -96,6 +96,9 @@ class FF3ServiceProvider extends ServiceProvider // reports $this->app->bind('FireflyIII\Report\ReportInterface', 'FireflyIII\Report\Report'); + + // chart + $this->app->bind('FireflyIII\Chart\ChartInterface', 'FireflyIII\Chart\Chart'); } public function registerAliases() diff --git a/tests/functional/GoogleChartControllerCest.php b/tests/functional/GoogleChartControllerCest.php new file mode 100644 index 0000000000..468ac29683 --- /dev/null +++ b/tests/functional/GoogleChartControllerCest.php @@ -0,0 +1,211 @@ +amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']); + } + + /** + * @param FunctionalTester $I + */ + public function accountBalanceChart(FunctionalTester $I) + { + $I->wantTo('see the session balance chart of an account.'); + $I->amOnPage('chart/account/1/session'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function accountAllBalanceChart(FunctionalTester $I) + { + $I->wantTo('see the complete balance chart of an account.'); + $I->amOnPage('chart/account/1/all'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function allAccountsBalanceChart(FunctionalTester $I) + { + $I->wantTo('see the chart with the balances of all accounts'); + $I->amOnPage('/chart/home/account'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function allBudgetsHomeChart(FunctionalTester $I) + { + $I->wantTo('see the chart with all budgets on it'); + $I->amOnPage('/chart/home/budgets'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function allCategoriesHomeChart(FunctionalTester $I) + { + $I->wantTo('see the chart with all categories on it'); + $I->amOnPage('/chart/home/categories'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function budgetLimitSpending(FunctionalTester $I) + { + $I->wantTo('see the chart for a budget and a repetition'); + $I->amOnPage('/chart/budget/1/1'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function budgetsAndSpending(FunctionalTester $I) + { + $I->wantTo('see the chart for a budget in a specific year'); + $I->amOnPage('/chart/budget/1/spending/2014'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function budgetsAndSpendingInvalidYear(FunctionalTester $I) + { + $I->wantTo('see the chart for a budget in an invalid year'); + $I->amOnPage('/chart/budget/1/spending/XXXX'); + $I->seeResponseCodeIs(200); + $I->see('Invalid year'); + } + + /** + * @param FunctionalTester $I + */ + public function categoriesAndSpending(FunctionalTester $I) + { + $I->wantTo('see the chart for a category in a specific year'); + $I->amOnPage('/chart/category/1/spending/2014'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function categoriesAndSpendingInvalidYear(FunctionalTester $I) + { + $I->wantTo('see the chart for a category in an invalid year'); + $I->amOnPage('/chart/category/1/spending/XXXX'); + $I->seeResponseCodeIs(200); + $I->see('Invalid year'); + } + + /** + * @param FunctionalTester $I + */ + public function piggyBankHistory(FunctionalTester $I) + { + $I->wantTo('see the chart for the history of a piggy bank'); + $I->amOnPage('/chart/piggyhistory/1'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function recurringOverview(FunctionalTester $I) + { + $I->wantTo('see the chart for the history of a recurring transaction'); + $I->amOnPage('/chart/recurring/1'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function emptyRecurringOverview(FunctionalTester $I) + { + $I->wantTo('see the chart for the history of an empty recurring transaction'); + $I->amOnPage('/chart/recurring/2'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function recurringTransactionsOverview(FunctionalTester $I) + { + $I->wantTo('see the chart for which recurring transactions I have yet to pay'); + $I->amOnPage('/chart/home/recurring'); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function yearInExp(FunctionalTester $I) + { + $I->wantTo("see this year's expenses"); + $I->amOnPage('/chart/reports/income-expenses/' . date('Y')); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function yearInExpInvalidYear(FunctionalTester $I) + { + $I->wantTo("see the year's expenses of an invalid year"); + $I->amOnPage('/chart/reports/income-expenses/XXXXX'); + $I->seeResponseCodeIs(200); + $I->see('Invalid year'); + } + + /** + * @param FunctionalTester $I + */ + public function yearInExpSum(FunctionalTester $I) + { + $I->wantTo("see this year's expenses summarized"); + $I->amOnPage('/chart/reports/income-expenses-sum/' . date('Y')); + $I->seeResponseCodeIs(200); + } + + /** + * @param FunctionalTester $I + */ + public function yearInExpSumInvalidYear(FunctionalTester $I) + { + $I->wantTo("see the year's expenses summarized of an invalid year"); + $I->amOnPage('/chart/reports/income-expenses-sum/XXXXX'); + $I->seeResponseCodeIs(200); + $I->see('Invalid year'); + } + + +} \ No newline at end of file