Clean up and added some TODO's.

This commit is contained in:
James Cole 2014-11-18 09:47:50 +01:00
parent 058e5602a3
commit 9c60443f97
10 changed files with 139 additions and 93 deletions

View File

@ -144,6 +144,7 @@ class Account extends Ardent
} }
/** /**
* TODO see if this scope is still used.
* @param Builder $query * @param Builder $query
* @param array $types * @param array $types
*/ */

View File

@ -21,7 +21,9 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
class AccountType extends Eloquent class AccountType extends Eloquent
{ {
public static $rules public static $rules
= ['type' => ['required', 'between:1,50', 'alphabasic'], 'editable' => 'required|boolean', = [
'type' => ['required', 'between:1,50', 'alphabasic'],
'editable' => 'required|boolean',
]; ];

View File

@ -26,14 +26,18 @@ class Component extends SingleTableInheritanceEntity
{ {
public static $rules public static $rules
= ['user_id' => 'exists:users,id|required', 'name' => ['required', 'between:1,100', 'min:1', 'alphabasic'], = [
'class' => 'required',]; 'user_id' => 'exists:users,id|required',
'name' => 'required|between:1,100|alphabasic',
'class' => 'required',
];
protected $fillable = ['name', 'user_id']; protected $fillable = ['name', 'user_id'];
protected $subclassField = 'class'; protected $subclassField = 'class';
protected $table = 'components'; protected $table = 'components';
/** /**
* TODO remove this method in favour of something in the FireflyIII libraries. * TODO remove this method in favour of something in the FireflyIII libraries.
*
* @return Carbon * @return Carbon
*/ */
public function lastActionDate() public function lastActionDate()

View File

@ -32,8 +32,12 @@ class Limit extends Ardent
{ {
public static $rules public static $rules
= ['component_id' => 'required|exists:components,id', 'startdate' => 'required|date', 'amount' => 'numeric|required|min:0.01', = [
'repeats' => 'required|boolean', 'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly' 'component_id' => 'required|exists:components,id',
'startdate' => 'required|date',
'amount' => 'numeric|required|min:0.01',
'repeats' => 'required|boolean',
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly'
]; ];
@ -47,6 +51,7 @@ class Limit extends Ardent
} }
/** /**
* TODO see if this method is still used.
* Create a new repetition for this limit, starting on * Create a new repetition for this limit, starting on
* the given date. * the given date.
* *

View File

@ -26,7 +26,12 @@ use LaravelBook\Ardent\Ardent as Ardent;
class LimitRepetition extends Ardent class LimitRepetition extends Ardent
{ {
public static $rules public static $rules
= ['limit_id' => 'required|exists:limits,id', 'startdate' => 'required|date', 'enddate' => 'required|date', 'amount' => 'numeric|required|min:0.01',]; = [
'limit_id' => 'required|exists:limits,id',
'startdate' => 'required|date',
'enddate' => 'required|date',
'amount' => 'numeric|required|min:0.01',
];
/** /**
* @return array * @return array
@ -37,6 +42,8 @@ class LimitRepetition extends Ardent
} }
/** /**
* TODO see if this scope is still used.
*
* How much money is left in this? * How much money is left in this?
*/ */
public function leftInRepetition() public function leftInRepetition()
@ -47,6 +54,7 @@ class LimitRepetition extends Ardent
/** /**
* TODO remove this method in favour of something in the FireflyIII libraries. * TODO remove this method in favour of something in the FireflyIII libraries.
*
* @return float * @return float
*/ */
public function spentInRepetition() public function spentInRepetition()

View File

@ -27,7 +27,11 @@ class PiggybankEvent extends Ardent
{ {
public static $rules public static $rules
= ['piggybank_id' => 'required|exists:piggybanks,id', 'date' => 'required|date', 'amount' => 'required|numeric']; = [
'piggybank_id' => 'required|exists:piggybanks,id',
'date' => 'required|date',
'amount' => 'required|numeric'
];
/** /**
* @return array * @return array

View File

@ -24,7 +24,11 @@ use LaravelBook\Ardent\Ardent as Ardent;
class PiggybankRepetition extends Ardent class PiggybankRepetition extends Ardent
{ {
public static $rules public static $rules
= ['piggybank_id' => 'required|exists:piggybanks,id', 'targetdate' => 'date', 'startdate' => 'date', 'currentamount' => 'required|numeric']; = [
'piggybank_id' => 'required|exists:piggybanks,id',
'targetdate' => 'date',
'startdate' => 'date',
'currentamount' => 'required|numeric'];
/** /**
* @return array * @return array

View File

@ -39,9 +39,17 @@ class RecurringTransaction extends Ardent
{ {
public static $rules public static $rules
= ['user_id' => 'required|exists:users,id', 'name' => 'required|between:1,255', 'match' => 'required', 'amount_max' => 'required|between:0,65536', = [
'amount_min' => 'required|between:0,65536', 'date' => 'required|date', 'active' => 'required|between:0,1', 'automatch' => 'required|between:0,1', 'user_id' => 'required|exists:users,id',
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly', 'skip' => 'required|between:0,31',]; 'name' => 'required|between:1,255',
'match' => 'required',
'amount_max' => 'required|between:0,65536',
'amount_min' => 'required|between:0,65536',
'date' => 'required|date',
'active' => 'required|between:0,1',
'automatch' => 'required|between:0,1',
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
'skip' => 'required|between:0,31',];
protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch']; protected $fillable = ['user_id', 'name', 'match', 'amount_min', 'amount_max', 'date', 'repeat_freq', 'skip', 'active', 'automatch'];
@ -53,6 +61,10 @@ class RecurringTransaction extends Ardent
return ['created_at', 'updated_at', 'date']; return ['created_at', 'updated_at', 'date'];
} }
/**
* TODO remove this method in favour of something in the FireflyIII libraries.
* @return null
*/
public function lastFoundMatch() public function lastFoundMatch()
{ {
$last = $this->transactionjournals()->orderBy('date', 'DESC')->first(); $last = $this->transactionjournals()->orderBy('date', 'DESC')->first();

View File

@ -40,8 +40,10 @@ use LaravelBook\Ardent\Builder;
class Transaction extends Ardent class Transaction extends Ardent
{ {
public static $rules public static $rules
= ['account_id' => 'numeric|required|exists:accounts,id', 'piggybank_id' => 'numeric|exists:piggybanks,id', = ['account_id' => 'numeric|required|exists:accounts,id',
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id', 'description' => 'between:1,255', 'piggybank_id' => 'numeric|exists:piggybanks,id',
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
'description' => 'between:1,255',
'amount' => 'required|between:-65536,65536|not_in:0,0.00',]; 'amount' => 'required|between:-65536,65536|not_in:0,0.00',];

View File

@ -57,8 +57,11 @@ class TransactionJournal extends Ardent
{ {
public static $rules public static $rules
= ['transaction_type_id' => 'required|exists:transaction_types,id', 'transaction_currency_id' => 'required|exists:transaction_currencies,id', = ['transaction_type_id' => 'required|exists:transaction_types,id',
'description' => 'required|between:1,255', 'date' => 'required|date', 'completed' => 'required|between:0,1']; 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
'description' => 'required|between:1,255',
'date' => 'required|date',
'completed' => 'required|between:0,1'];
/** /**
@ -91,6 +94,7 @@ class TransactionJournal extends Ardent
/** /**
* TODO remove this method in favour of something in the FireflyIII libraries. * TODO remove this method in favour of something in the FireflyIII libraries.
*
* @return float * @return float
*/ */
public function getAmount() public function getAmount()