diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 6799c3f3a4..e75260a864 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -132,11 +132,6 @@ class ReportController extends Controller
public function modalBalancedTransfers(Account $account, $year = '2014', $month = '1')
{
- try {
- new Carbon($year . '-' . $month . '-01');
- } catch (Exception $e) {
- return view('error')->with('message', 'Invalid date');
- }
$start = new Carbon($year . '-' . $month . '-01');
$end = clone $start;
$end->endOfMonth();
@@ -158,11 +153,6 @@ class ReportController extends Controller
*/
public function modalLeftUnbalanced(Account $account, $year = '2014', $month = '1')
{
- try {
- new Carbon($year . '-' . $month . '-01');
- } catch (Exception $e) {
- return view('error')->with('message', 'Invalid date');
- }
$start = new Carbon($year . '-' . $month . '-01');
$end = clone $start;
$end->endOfMonth();
@@ -189,11 +179,6 @@ class ReportController extends Controller
*/
public function modalNoBudget(Account $account, $year = '2014', $month = '1')
{
- try {
- new Carbon($year . '-' . $month . '-01');
- } catch (Exception $e) {
- return view('error')->with('message', 'Invalid date');
- }
$start = new Carbon($year . '-' . $month . '-01');
$end = clone $start;
$end->endOfMonth();
@@ -211,11 +196,6 @@ class ReportController extends Controller
*/
public function month($year = '2014', $month = '1')
{
- try {
- new Carbon($year . '-' . $month . '-01');
- } catch (Exception $e) {
- return view('error')->with('message', 'Invalid date.');
- }
$date = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y');
$subTitleIcon = 'fa-calendar';
@@ -327,11 +307,6 @@ class ReportController extends Controller
*/
public function year($year)
{
- try {
- new Carbon('01-01-' . $year);
- } catch (Exception $e) {
- return view('error')->with('message', 'Invalid date.');
- }
/** @var Preference $pref */
$pref = Preferences::get('showSharedReports', false);
$showSharedReports = $pref->data;
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 11e5f33a89..9756f34614 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -350,13 +350,8 @@ Route::group(
// pop ups for budget report:
Route::get('/reports/modal/{account}/{year}/{month}/no-budget', ['uses' => 'ReportController@modalNoBudget', 'as' => 'reports.no-budget']);
- Route::get(
- '/reports/modal/{account}/{year}/{month}/balanced-transfers',
- ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']
- );
- Route::get(
- '/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']
- );
+ Route::get('/reports/modal/{account}/{year}/{month}/balanced-transfers', ['uses' => 'ReportController@modalBalancedTransfers', 'as' => 'reports.balanced-transfers']);
+ Route::get('/reports/modal/{account}/{year}/{month}/left-unbalanced', ['uses' => 'ReportController@modalLeftUnbalanced', 'as' => 'reports.left-unbalanced']);
/**
* Search Controller
diff --git a/resources/twig/reports/modal-journal-list.twig b/resources/twig/reports/modal-journal-list.twig
new file mode 100644
index 0000000000..21cad324eb
--- /dev/null
+++ b/resources/twig/reports/modal-journal-list.twig
@@ -0,0 +1,14 @@
+
+
+
+
+ {% include 'list/journals.twig' %}
+
+
+
+
diff --git a/tests/controllers/ReminderControllerTest.php b/tests/controllers/ReminderControllerTest.php
index 55b25e36b7..25864aa2d1 100644
--- a/tests/controllers/ReminderControllerTest.php
+++ b/tests/controllers/ReminderControllerTest.php
@@ -3,7 +3,7 @@ use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
- * Class ProfileControllerTest
+ * Class ReportControllerTest
*/
class ReminderControllerTest extends TestCase
{
diff --git a/tests/controllers/ReportControllerTest.php b/tests/controllers/ReportControllerTest.php
new file mode 100644
index 0000000000..1a13e9d3af
--- /dev/null
+++ b/tests/controllers/ReportControllerTest.php
@@ -0,0 +1,239 @@
+queryAmount = 100;
+ $accounts = new Collection([$account]);
+ $budgets = new Collection([$budget]);
+ $showSharedReports->data = false;
+ $this->be($user);
+ $showSharedReports->save();
+
+ // mock stuff
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+ $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
+
+ // fake it!
+ Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
+ Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
+ Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
+ Amount::shouldReceive('getCurrencyCode')->andReturn('X');
+ Amount::shouldReceive('format')->andReturn('X');
+ $query->shouldReceive('getAllAccounts')->withAnyArgs()->andReturn($accounts);
+ $query->shouldReceive('getBudgetSummary')->withAnyArgs()->andReturn($budgets);
+ $query->shouldReceive('balancedTransactionsSum')->withAnyArgs()->andReturn(100);
+ $helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
+
+
+ $this->call('GET', '/reports/budget/2015/1');
+ $this->assertResponseOk();
+
+ }
+
+ public function testIndex()
+ {
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+
+ // mock stuff
+ $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
+
+ $helper->shouldReceive('listOfMonths')->andReturn([]);
+ $helper->shouldReceive('listOfYears')->andReturn([]);
+
+
+ $this->call('GET', '/reports');
+ $this->assertResponseOk();
+
+ }
+
+ public function testModalBalancedTransfers()
+ {
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $journals = new Collection([$journal]);
+ $this->be($account->user);
+
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+ $query->shouldReceive('balancedTransactionsList')->withAnyArgs()->andReturn($journals);
+
+
+ $this->call('GET', '/reports/modal/' . $account->id . '/2015/1/balanced-transfers');
+ $this->assertResponseOk();
+ }
+
+ public function testModalLeftUnbalanced()
+ {
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $secondJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $group = FactoryMuffin::create('FireflyIII\Models\TransactionGroup');
+ $group->transactionjournals()->save($secondJournal);
+ $journals = new Collection([$journal, $secondJournal]);
+ $this->be($account->user);
+
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+ $query->shouldReceive('getTransactionsWithoutBudget')->withAnyArgs()->andReturn($journals);
+
+ $this->call('GET', '/reports/modal/' . $account->id . '/2015/1/left-unbalanced');
+ $this->assertResponseOk();
+
+ }
+
+ public function testModalNoBudget()
+ {
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $journals = new Collection([$journal]);
+ $this->be($account->user);
+
+
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+ $query->shouldReceive('getTransactionsWithoutBudget')->withAnyArgs()->andReturn($journals);
+
+ $this->call('GET', '/reports/modal/' . $account->id . '/2015/1/no-budget');
+ $this->assertResponseOk();
+
+ }
+
+ public function testMonth()
+ {
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $journals = new Collection([$journal]);
+ $budgets = new Collection([$budget]);
+ $accounts = new Collection([$account]);
+ $this->be($user);
+
+ $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+
+ $query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
+ $query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
+ $helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
+ $query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
+ $query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
+ $query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
+
+ // mock stuff!
+ Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
+ Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
+ Amount::shouldReceive('getCurrencyCode')->andReturn('X');
+ Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
+ Amount::shouldReceive('format')->andReturn('X');
+
+ $this->call('GET', '/reports/2015/1');
+ $this->assertResponseOk();
+ }
+
+ public function testMonthWithShared()
+ {
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $showSharedReports = FactoryMuffin::create('FireflyIII\Models\Preference');
+ $showSharedReports->data = true;
+
+ $journals = new Collection([$journal]);
+ $budgets = new Collection([$budget]);
+ $accounts = new Collection([$account]);
+ $this->be($user);
+
+ $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+
+ $query->shouldReceive('incomeByPeriod')->withAnyArgs()->andReturn([]);
+ $query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
+ $helper->shouldReceive('getBudgetsForMonth')->withAnyArgs()->andReturn($budgets);
+ $query->shouldReceive('journalsByCategory')->withAnyArgs()->andReturn($journals);
+ $query->shouldReceive('sharedExpensesByCategory')->withAnyArgs()->andReturn($journals);
+ $query->shouldReceive('accountList')->withAnyArgs()->andReturn($accounts);
+
+ // mock stuff!
+ Preferences::shouldReceive('get')->withArgs(['showSharedReports', false])->andReturn($showSharedReports);
+ Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
+ Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
+ Amount::shouldReceive('getCurrencyCode')->andReturn('X');
+ Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
+ Amount::shouldReceive('format')->andReturn('X');
+
+ $this->call('GET', '/reports/2015/1');
+ $this->assertResponseOk();
+ }
+
+ public function testYear()
+ {
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $journals = new Collection([$journal]);
+
+ $this->be($user);
+
+ $helper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
+ $query = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
+
+ $helper->shouldReceive('yearBalanceReport')->withAnyArgs()->andReturn([]);
+ $query->shouldReceive('journalsByRevenueAccount')->withAnyArgs()->andReturn($journals);
+ $query->shouldReceive('journalsByExpenseAccount')->withAnyArgs()->andReturn($journals);
+
+ // mock stuff!
+ Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
+ Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
+ Amount::shouldReceive('getCurrencyCode')->andReturn('X');
+ Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
+ Amount::shouldReceive('format')->andReturn('X');
+
+ $this->call('GET', '/reports/2015');
+ $this->assertResponseOk();
+ }
+
+
+}
\ No newline at end of file
diff --git a/tests/factories/all.php b/tests/factories/all.php
index 760980a8da..1c98b5b88e 100644
--- a/tests/factories/all.php
+++ b/tests/factories/all.php
@@ -91,6 +91,14 @@ FactoryMuffin::define(
]
);
+FactoryMuffin::define(
+ 'FireflyIII\Models\TransactionGroup',
+ [
+ 'user_id' => 'factory|FireflyIII\User',
+ 'relation' => 'balance',
+ ]
+);
+
FactoryMuffin::define(
'FireflyIII\Models\Reminder',
[