Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some tests and a rename.
James Cole9f92e1b7bd7f
diff --git a/app/controllers/ReportController.php b/app/controllers/ReportController.phpindex 100da8cbce..9dc5a15f6f 100644--- a/app/controllers/ReportController.php+++ b/app/controllers/ReportController.php@@ -44,7 +44,7 @@ class ReportController extends BaseControllertry {new Carbon($year . '-' . $month . '-01');} catch (Exception $e) {- View::make('error')->with('message', 'Invalid date');+ return View::make('error')->with('message', 'Invalid date');}$date = new Carbon($year . '-' . $month . '-01');$dayEarly = clone $date;@@ -81,7 +81,7 @@ class ReportController extends BaseControllertry {new Carbon($year . '-' . $month . '-01');} catch (Exception $e) {- View::make('error')->with('message', 'Invalid date');+ return View::make('error')->with('message', 'Invalid date.');}$date = new Carbon($year . '-' . $month . '-01');$subTitle = 'Report for ' . $date->format('F Y');@@ -110,7 +110,7 @@ class ReportController extends BaseControllertry {new Carbon('01-01-' . $year);} catch (Exception $e) {- App::abort(500);+ return View::make('error')->with('message', 'Invalid date.');}$date = new Carbon('01-01-' . $year);$end = clone $date;diff --git a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php b/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.phpindex 973617267e..eb762b6395 100644--- a/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php+++ b/app/lib/FireflyIII/Database/PiggyBank/PiggyBankShared.php@@ -174,46 +174,6 @@ class PiggyBankShared}- return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];-- exit;-- if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggy_bank_periods'))) {- $errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');- }- // check period.- if (!$errors->has('reminder') && !$errors->has('targetdate') && isset($model['remind_me']) && intval($model['remind_me']) == 1) {- $today = new Carbon;- $target = new Carbon($model['targetdate']);- switch ($model['reminder']) {- case 'week':- $today->addWeek();- break;- case 'month':- $today->addMonth();- break;- case 'year':- $today->addYear();- break;- }- if ($today > $target) {- $errors->add('reminder', 'Target date is too close to today to set reminders.');- }- }-- $validator = \Validator::make($model, \PiggyBank::$rules);- if ($validator->invalid()) {- $errors->merge($errors);- }-- // add ok messages.- $list = ['name', 'account_id', 'targetamount', 'targetdate', 'remind_me', 'reminder'];- foreach ($list as $entry) {- if (!$errors->has($entry) && !$warnings->has($entry)) {- $successes->add($entry, 'OK');- }- }-return ['errors' => $errors, 'warnings' => $warnings, 'successes' => $successes];}diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.phpindex f7ef12dfea..f6fe78c975 100644--- a/app/lib/FireflyIII/Report/Report.php+++ b/app/lib/FireflyIII/Report/Report.php@@ -388,7 +388,7 @@ class Report implements ReportInterface->where('acm_to.data', '!=', '"sharedExpense"')->before($end)->after($start)->where('transaction_journals.user_id', \Auth::user()->id)- ->groupBy('account_id')->orderBy('sum')->limit(15)+ ->groupBy('t_from.account_id')->orderBy('sum')->limit(15)->get(['t_from.account_id as account_id', 'ac_from.name as name', \DB::Raw('SUM(t_from.amount) as `sum`')]);diff --git a/app/lib/FireflyIII/Report/ReportQuery.php b/app/lib/FireflyIII/Report/ReportQuery.phpindex 199827e7bb..75728b597c 100644--- a/app/lib/FireflyIII/Report/ReportQuery.php+++ b/app/lib/FireflyIII/Report/ReportQuery.php@@ -231,7 +231,7 @@ class ReportQuery implements ReportQueryInterface->where('account_meta.data', '!=', '"sharedExpense"')->where('transaction_types.type', 'Withdrawal')->groupBy('budgets.id')- ->orderBy('name', 'ASC')+ ->orderBy('budgets.name', 'ASC')->get(['budgets.id', 'budgets.name', \DB::Raw('SUM(`transactions`.`amount`) AS `spent`')]);}diff --git a/app/views/repeatedexpense/create.blade.php b/app/views/repeatedExpense/create.blade.phpsimilarity index 100%rename from app/views/repeatedexpense/create.blade.phprename to app/views/repeatedExpense/create.blade.phpdiff --git a/app/views/repeatedexpense/delete.blade.php b/app/views/repeatedExpense/delete.blade.phpsimilarity index 100%rename from app/views/repeatedexpense/delete.blade.phprename to app/views/repeatedExpense/delete.blade.phpdiff --git a/app/views/repeatedexpense/edit.blade.php b/app/views/repeatedExpense/edit.blade.phpsimilarity index 100%rename from app/views/repeatedexpense/edit.blade.phprename to app/views/repeatedExpense/edit.blade.phpdiff --git a/app/views/repeatedexpense/index.blade.php b/app/views/repeatedExpense/index.blade.phpsimilarity index 100%rename from app/views/repeatedexpense/index.blade.phprename to app/views/repeatedExpense/index.blade.phpdiff --git a/app/views/repeatedexpense/show.blade.php b/app/views/repeatedExpense/show.blade.phpsimilarity index 100%rename from app/views/repeatedexpense/show.blade.phprename to app/views/repeatedExpense/show.blade.phpdiff --git a/tests/functional/BillControllerCest.php b/tests/functional/BillControllerCest.phpindex 3dcea51f9b..188bc52f2e 100644--- a/tests/functional/BillControllerCest.php+++ b/tests/functional/BillControllerCest.php@@ -2,6 +2,9 @@/*** Class BillControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")*/class BillControllerCest{@@ -147,6 +150,9 @@ class BillControllerCest$I->see('Could not store bill');}+ /**+ * @param FunctionalTester $I+ */public function storeRecreate(FunctionalTester $I){$I->wantTo('validate a bill and create another one');diff --git a/tests/functional/PreferencesControllerCest.php b/tests/functional/PreferencesControllerCest.phpindex 6a07d47d3f..8149780db8 100644--- a/tests/functional/PreferencesControllerCest.php+++ b/tests/functional/PreferencesControllerCest.php@@ -2,6 +2,10 @@/*** Class PreferencesControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")+ **/class PreferencesControllerCest{diff --git a/tests/functional/ProfileControllerCest.php b/tests/functional/ProfileControllerCest.phpindex fd7e1a53a6..9a83e7ae5f 100644--- a/tests/functional/ProfileControllerCest.php+++ b/tests/functional/ProfileControllerCest.php@@ -2,6 +2,9 @@/*** Class ProfileControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")*/class ProfileControllerCest{diff --git a/tests/functional/ReminderControllerCest.php b/tests/functional/ReminderControllerCest.phpindex 3415dd1ad5..fe5d0e738a 100644--- a/tests/functional/ReminderControllerCest.php+++ b/tests/functional/ReminderControllerCest.php@@ -2,6 +2,9 @@/*** Class ReminderControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")*/class ReminderControllerCest{@@ -21,6 +24,9 @@ class ReminderControllerCest$I->amLoggedAs(['email' => '[email protected]', 'password' => 'james']);}+ /**+ * @param FunctionalTester $I+ */public function act(FunctionalTester $I){$I->wantTo('act on a reminder');@@ -28,6 +34,9 @@ class ReminderControllerCest$I->see('Money for Weekly reminder for clothes');}+ /**+ * @param FunctionalTester $I+ */public function dismiss(FunctionalTester $I){$I->wantTo('dismiss a reminder');@@ -35,6 +44,9 @@ class ReminderControllerCest$I->see('Reminder dismissed');}+ /**+ * @param FunctionalTester $I+ */public function notNow(FunctionalTester $I){$I->wantTo('ignore a reminder');@@ -42,6 +54,9 @@ class ReminderControllerCest$I->see('Reminder dismissed');}+ /**+ * @param FunctionalTester $I+ */public function show(FunctionalTester $I){$I->wantTo('see a reminder');@@ -50,6 +65,9 @@ class ReminderControllerCest$I->see('your piggy bank labelled "Weekly reminder for clothes"');}+ /**+ * @param FunctionalTester $I+ */public function actOnInvalid(FunctionalTester $I){$I->wantTo('act on an invalid reminder');diff --git a/tests/functional/RepeatedExpenseControllerCest.php b/tests/functional/RepeatedExpenseControllerCest.phpindex 75a44f5a85..073a99d9f3 100644--- a/tests/functional/RepeatedExpenseControllerCest.php+++ b/tests/functional/RepeatedExpenseControllerCest.php@@ -2,7 +2,12 @@/*** Class RepeatedExpenseControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")*/++class RepeatedExpenseControllerCest{/**@@ -20,6 +25,9 @@ class RepeatedExpenseControllerCest$I->amLoggedAs(['email' => '[email protected]', 'password' => 'james']);}+ /**+ * @param FunctionalTester $I+ */public function create(FunctionalTester $I){$I->wantTo('create a recurring transaction');@@ -27,6 +35,9 @@ class RepeatedExpenseControllerCest$I->see('Create new repeated expense');}+ /**+ * @param FunctionalTester $I+ */public function delete(FunctionalTester $I){$I->wantTo('delete a recurring transaction');@@ -34,6 +45,9 @@ class RepeatedExpenseControllerCest$I->see('Delete "Nieuwe kleding"');}+ /**+ * @param FunctionalTester $I+ */public function destroy(FunctionalTester $I){$I->wantTo('destroy a recurring transaction');@@ -42,6 +56,9 @@ class RepeatedExpenseControllerCest$I->dontSeeInDatabase('piggy_banks', ['id' => 5]);}+ /**+ * @param FunctionalTester $I+ */public function edit(FunctionalTester $I){$I->wantTo('edit a recurring transaction');@@ -50,6 +67,9 @@ class RepeatedExpenseControllerCest}+ /**+ * @param FunctionalTester $I+ */public function index(FunctionalTester $I){$I->wantTo('see all recurring transactions');@@ -58,6 +78,9 @@ class RepeatedExpenseControllerCest$I->see('Nieuwe kleding');}+ /**+ * @param FunctionalTester $I+ */public function show(FunctionalTester $I){$I->wantTo('view a recurring transaction');@@ -65,6 +88,9 @@ class RepeatedExpenseControllerCest$I->see('Nieuwe kleding');}+ /**+ * @param FunctionalTester $I+ */public function store(FunctionalTester $I){$I->wantTo('store a recurring transaction');@@ -86,6 +112,9 @@ class RepeatedExpenseControllerCest$I->see('Piggy bank "TestRepeatedExpense" stored.');}+ /**+ * @param FunctionalTester $I+ */public function update(FunctionalTester $I){$I->wantTo('update a recurring transaction');@@ -107,6 +136,9 @@ class RepeatedExpenseControllerCest$I->see('Repeated expense "Nieuwe kleding!" updated.');}+ /**+ * @param FunctionalTester $I+ */public function updateAndReturnToEdit(FunctionalTester $I){$I->wantTo('update a recurring transaction and return to edit screen');@@ -128,6 +160,9 @@ class RepeatedExpenseControllerCest$I->see('Repeated expense "Nieuwe kleding!" updated.');}+ /**+ * @param FunctionalTester $I+ */public function updateFail(FunctionalTester $I){$I->wantTo('try to update a recurring transaction and fail');diff --git a/tests/functional/ReportControllerCest.php b/tests/functional/ReportControllerCest.phpnew file mode 100644index 0000000000..6d2ff144b0--- /dev/null+++ b/tests/functional/ReportControllerCest.php@@ -0,0 +1,79 @@+<?php++/**+ * Class ReportControllerCest+ *+ * @SuppressWarnings("CamelCase")+ * @SuppressWarnings("short")+ *+ */+class ReportControllerCest+{+ /**+ * @param FunctionalTester $I+ */+ public function _after(FunctionalTester $I)+ {+ }++ /**+ * @param FunctionalTester $I+ */+ public function _before(FunctionalTester $I)+ {+ $I->amLoggedAs(['email' => '[email protected]', 'password' => 'james']);+ }++ public function budget(FunctionalTester $I)+ {+ $I->wantTo('see a budget report');+ $I->amOnPage('/reports/budget/2014/9');+ $I->see('Budget report for September 2014');+ }++ public function budgetInvalidDate(FunctionalTester $I)+ {+ $I->wantTo('see a budget report for an invalid date');+ $I->amOnPage('/reports/budget/XXXX/XX');+ $I->see('Invalid date');+ }++ public function index(FunctionalTester $I)+ {+ $I->wantTo('see all possible reports');+ $I->amOnPage('/reports');+ $I->see('Reports');+ $I->see('Monthly reports');+ $I->see('Budget reports');+ }++ public function month(FunctionalTester $I)+ {+ $I->wantTo('see a monthly report');+ $I->amOnPage('/reports/2014/9');+ $I->see('Report for September 2014');+ }++ public function monthInvalidDate(FunctionalTester $I)+ {+ $I->wantTo('see a monthly report for an invalid month');+ $I->amOnPage('/reports/XXXX/XX');+ $I->see('Invalid date');+ }++ public function year(FunctionalTester $I)+ {+ $I->wantTo('see a yearly report');+ $I->amOnPage('/reports/2014');+ $I->see('Income vs. expenses');+ $I->see('Account balance');+ }++ public function yearInvalidDate(FunctionalTester $I)+ {+ $I->wantTo('see a yearly report for an invalid year');+ $I->amOnPage('/reports/XXXX');+ $I->see('Invalid date');+ }++}\ No newline at end of file