Skip to content

Firefly III: a personal finances manager

Fixes for tests.

James Colea0b12ece5417
diff --git a/app/models/Limit.php b/app/models/Limit.php
index 856a736acb..275d34249d 100644
--- a/app/models/Limit.php
+++ b/app/models/Limit.php
@@ -35,27 +35,11 @@ class Limit extends Ardent
'component_id' => 'required|exists:components,id',
'startdate' => 'required|date',
'amount' => 'numeric|required|min:0.01',
- 'repeats' => 'required|between:0,1',
+ 'repeats' => 'required|boolean',
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly'
];
- /**
- * @return array
- */
- public static function factory()
- {
- $start = new Carbon;
- $start->startOfMonth();
-
- return [
- 'component_id' => 'factory|Budget',
- 'startdate' => $start,
- 'amount' => '100',
- 'repeats' => 0,
- 'repeat_freq' => 'monthly'
- ];
- }
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
diff --git a/app/models/LimitRepetition.php b/app/models/LimitRepetition.php
index d8b44d4c61..3ce5871432 100644
--- a/app/models/LimitRepetition.php
+++ b/app/models/LimitRepetition.php
@@ -31,24 +31,6 @@ class LimitRepetition extends Ardent
'amount' => 'numeric|required|min:0.01',
];
- /**
- * @return array
- */
- public static function factory()
- {
- $start = new \Carbon\Carbon;
- $start->startOfMonth();
- $end = clone $start;
- $end->endOfMonth();
-
- return [
- 'limit_id' => 'factory|Limit',
- 'startdate' => $start,
- 'enddate' => $end,
- 'amount' => 100
- ];
- }
-
/**
* @return array
*/
diff --git a/app/models/PiggybankRepetition.php b/app/models/PiggybankRepetition.php
index ab23994d79..065734661a 100644
--- a/app/models/PiggybankRepetition.php
+++ b/app/models/PiggybankRepetition.php
@@ -32,23 +32,6 @@ class PiggybankRepetition extends Ardent
'currentamount' => 'required|numeric'
];
- /**
- * @return array
- */
- public static function factory()
- {
- $start = new Carbon;
- $start->startOfMonth();
- $end = new Carbon;
- $end->endOfMonth();
-
- return [
- 'piggybank_id' => 'factory|Piggybank',
- 'startdate' => $start->format('Y-m-d'),
- 'targetdate' => $end->format('Y-m-d'),
- 'currentamount' => 200
- ];
- }
public function pct() {
$total = $this->piggybank->targetamount;
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
index a862a69664..a7c4f74c2d 100644
--- a/app/models/TransactionJournal.php
+++ b/app/models/TransactionJournal.php
@@ -52,22 +52,6 @@ class TransactionJournal extends Ardent
'completed' => 'required|between:0,1'
];
- /**
- * @return array
- */
- public static function factory()
- {
- $date = new \Carbon\Carbon;
-
- return [
- 'transaction_type_id' => 'factory|TransactionType',
- 'transaction_currency_id' => 'factory|TransactionCurrency',
- 'description' => 'string',
- 'completed' => '1',
- 'user_id' => 'factory|User',
- 'date' => $date
- ];
- }
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
diff --git a/app/models/TransactionType.php b/app/models/TransactionType.php
index 652589c782..0fea66cadd 100644
--- a/app/models/TransactionType.php
+++ b/app/models/TransactionType.php
@@ -17,10 +17,6 @@ use LaravelBook\Ardent\Ardent;
*/
class TransactionType extends Ardent
{
- public static $factory
- = [
- 'type' => 'string'
- ];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
diff --git a/app/tests/controllers/ProfileControllerTest.php b/app/tests/controllers/ProfileControllerTest.php
index fb82c75faf..b293c4300a 100644
--- a/app/tests/controllers/ProfileControllerTest.php
+++ b/app/tests/controllers/ProfileControllerTest.php
@@ -71,6 +71,8 @@ class ProfileControllerTest extends TestCase
public function testPostChangePasswordOK()
{
$user = f::create('User');
+ $user->password = 'sander';
+ $user->save();
// for binding
Auth::shouldReceive('user')->andReturn($user);
Auth::shouldReceive('check')->andReturn(true);
@@ -82,6 +84,7 @@ class ProfileControllerTest extends TestCase
'POST', 'ProfileController@postChangePassword',
['old' => 'sander', 'new1' => 'sander2', 'new2' => 'sander2']
);
+ $this->assertSessionHas('success');
$this->assertResponseStatus(302);
}
diff --git a/app/tests/factories/Category.php b/app/tests/factories/Category.php
index 71f1df47e8..559f27a85e 100644
--- a/app/tests/factories/Category.php
+++ b/app/tests/factories/Category.php
@@ -2,7 +2,7 @@
use League\FactoryMuffin\Facade;
Facade::define(
- 'Budget',
+ 'Category',
[
'name' => 'word',
'user_id' => 'factory|User',
diff --git a/app/tests/factories/Limit.php b/app/tests/factories/Limit.php
new file mode 100644
index 0000000000..7c3c36780a
--- /dev/null
+++ b/app/tests/factories/Limit.php
@@ -0,0 +1,24 @@
+<?php
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'Limit',
+ [
+
+ 'component_id' => 'factory|Budget',
+ 'startdate' => function () {
+ $start = new Carbon;
+ $start->startOfMonth();
+ return $start;
+ },
+ 'amount' => 100,
+ 'repeats' => 'boolean',
+ 'repeat_freq' => function(){
+ $frequencies = ['daily','weekly','monthly','quarterly','half-year','yearly'];
+ return $frequencies[rand(0,5)];
+ }
+
+
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/LimitRepetition.php b/app/tests/factories/LimitRepetition.php
new file mode 100644
index 0000000000..61370085a6
--- /dev/null
+++ b/app/tests/factories/LimitRepetition.php
@@ -0,0 +1,26 @@
+<?php
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'LimitRepetition',
+ [
+
+ 'limit_id' => 'factory|Limit',
+ 'startdate' => function () {
+ $start = new Carbon;
+ $start->startOfMonth();
+ return $start;
+
+ },
+ 'enddate' => function () {
+ $end = new Carbon;
+ $end->endOfMonth();
+ return $end;
+
+ },
+ 'amount' => 100
+
+
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/Piggybank.php b/app/tests/factories/Piggybank.php
new file mode 100644
index 0000000000..48b665d49b
--- /dev/null
+++ b/app/tests/factories/Piggybank.php
@@ -0,0 +1,30 @@
+<?php
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'Piggybank',
+ [
+
+ 'account_id' => 'factory|Account',
+ 'name' => 'string',
+ 'targetamount' => 'integer',
+ 'startdate' => function () {
+ $start = new Carbon;
+ $start->startOfMonth();
+ return $start;
+ },
+ 'targetdate' => function () {
+ $end = new Carbon;
+ $end->endOfMonth();
+ return $end;
+ },
+ 'repeats' => 0,
+ 'rep_length' => null,
+ 'rep_times' => 0,
+ 'rep_every' => 0,
+ 'reminder' => null,
+ 'reminder_skip' => 0,
+ 'order' => 1,
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/PiggybankRepetition.php b/app/tests/factories/PiggybankRepetition.php
new file mode 100644
index 0000000000..5589ae294a
--- /dev/null
+++ b/app/tests/factories/PiggybankRepetition.php
@@ -0,0 +1,23 @@
+<?php
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'PiggybankRepetition',
+ [
+
+
+ 'piggybank_id' => 'factory|Piggybank',
+ 'startdate' => function () {
+ $start = new Carbon;
+ $start->startOfMonth();
+ return $start;
+ },
+ 'targetdate' => function () {
+ $end = new Carbon;
+ $end->endOfMonth();
+ return $end;
+ },
+ 'currentamount' => 200
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/RecurringTransaction.php b/app/tests/factories/RecurringTransaction.php
new file mode 100644
index 0000000000..560f6b2f75
--- /dev/null
+++ b/app/tests/factories/RecurringTransaction.php
@@ -0,0 +1,23 @@
+<?php
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+// TODO better factory.
+
+Facade::define(
+ 'RecurringTransaction',
+ [
+
+ 'user_id' => 'factory|User',
+ 'name' => 'string',
+ 'match' => 'string',
+ 'amount_max' => 100,
+ 'amount_min' => 50,
+ 'date' => new Carbon,
+ 'active' => 'boolean',
+ 'automatch' => 'boolean',
+ 'repeat_freq' => 'monthly',
+ 'skip' => 'boolean',
+
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/TransactionCurrency.php b/app/tests/factories/TransactionCurrency.php
new file mode 100644
index 0000000000..2e650df36d
--- /dev/null
+++ b/app/tests/factories/TransactionCurrency.php
@@ -0,0 +1,12 @@
+<?php
+
+
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'TransactionCurrency',
+ [
+ 'code' => 'EUR'
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/TransactionJournal.php b/app/tests/factories/TransactionJournal.php
new file mode 100644
index 0000000000..e952c8d747
--- /dev/null
+++ b/app/tests/factories/TransactionJournal.php
@@ -0,0 +1,17 @@
+<?php
+
+
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'TransactionJournal',
+ [
+ 'transaction_type_id' => 'factory|TransactionType',
+ 'transaction_currency_id' => 'factory|TransactionCurrency',
+ 'description' => 'word',
+ 'completed' => 'boolean',
+ 'user_id' => 'factory|User',
+ 'date' => new Carbon
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/TransactionType.php b/app/tests/factories/TransactionType.php
new file mode 100644
index 0000000000..32bf484f39
--- /dev/null
+++ b/app/tests/factories/TransactionType.php
@@ -0,0 +1,15 @@
+<?php
+
+
+use Carbon\Carbon;
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'TransactionType',
+ [
+ 'type' => function() {
+ $types = ['Withdrawal','Deposit','Transfer','Opening balance'];
+ return $types[rand(0,3)];
+ }
+ ]
+);
\ No newline at end of file
diff --git a/app/views/recurring/show.blade.php b/app/views/recurring/show.blade.php
new file mode 100644
index 0000000000..b2ea1de8c1
--- /dev/null
+++ b/app/views/recurring/show.blade.php
@@ -0,0 +1,71 @@
+@extends('layouts.default')
+@section('content')
+<div class="row">
+ <div class="col-lg-12 col-md-12 col-sm-12">
+ <h1>Firefly
+ <small>Recurring transaction "{{{$recurring->name}}}"</small>
+ </h1>
+ <p class="lead">Use recurring transactions to track repeated withdrawals</p>
+ <p>
+ <div class="btn-group btn-group-xs">
+ <a href="{{route('recurring.edit',$recurring->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> edit</a>
+ <a href="{{route('recurring.delete',$recurring->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> delete</a>
+ </div>
+ </p>
+ </div>
+</div>
+
+<div class="row">
+ <div class="col-lg-6 col-sm-6 col-md-12">
+
+ <table class="table">
+ <tr>
+ <td>Matches on: </td>
+ <td>
+ @foreach(explode(' ',$recurring->match) as $word)
+ <span class="label label-info">{{{$word}}}</span>
+ @endforeach
+ </td>
+ </tr>
+ <tr>
+ <td>Between</td>
+ <td> {{mf($recurring->amount_min)}} &ndash; {{mf($recurring->amount_max)}}</td>
+ </tr>
+ <tr>
+ <td>Repeats</td>
+ <td>{{ucfirst($recurring->repeat_freq)}}</td>
+ </tr>
+ <tr>
+ <td>Next reminder</td>
+ <td>{{$recurring->next()->format('d-m-Y')}}</td>
+ </tr>
+ <tr>
+ <td>Will be auto-matched</td>
+ <td>
+ @if($recurring->automatch)
+ <span class="glyphicon glyphicon-ok"></span>
+ @else
+ <span class="glyphicon glyphicon-remove"></span>
+ @endif
+ </td>
+ </tr>
+ <tr>
+ <td>Is active</td>
+
+ <td>
+ @if($recurring->active)
+ <span class="glyphicon glyphicon-ok"></span>
+ @else
+ <span class="glyphicon glyphicon-remove"></span>
+ @endif
+ </td>
+ </tr>
+ </table>
+
+ <td>
+
+ </td>
+ </tr>
+ </div>
+</div>
+@stop
\ No newline at end of file