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

@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
/** /**
* AccountType * AccountType
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property string $type * @property string $type
* @property boolean $editable * @property boolean $editable
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts * @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
* @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value) * @method static \Illuminate\Database\Query\Builder|\AccountType whereId($value)
* @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\AccountType whereCreatedAt($value)
@ -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()
@ -51,7 +55,7 @@ class Component extends SingleTableInheritanceEntity
*/ */
public function transactionjournals() public function transactionjournals()
{ {
return $this->belongsToMany('TransactionJournal','component_transaction_journal','component_id'); return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
} }

View File

@ -8,16 +8,16 @@ use LaravelBook\Ardent\Ardent as Ardent;
/** /**
* Limit * Limit
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $component_id * @property integer $component_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property float $amount * @property float $amount
* @property boolean $repeats * @property boolean $repeats
* @property string $repeat_freq * @property string $repeat_freq
* @property-read \Budget $budget * @property-read \Budget $budget
* @property-read \Component $component * @property-read \Component $component
* @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions * @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions
* @method static \Illuminate\Database\Query\Builder|\Limit whereId($value) * @method static \Illuminate\Database\Query\Builder|\Limit whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\Limit whereCreatedAt($value)
@ -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

@ -7,14 +7,14 @@ use LaravelBook\Ardent\Ardent as Ardent;
/** /**
* LimitRepetition * LimitRepetition
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $limit_id * @property integer $limit_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $enddate * @property \Carbon\Carbon $enddate
* @property float $amount * @property float $amount
* @property-read \Limit $limit * @property-read \Limit $limit
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereId($value) * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereId($value)
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereUpdatedAt($value)
@ -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

@ -6,14 +6,14 @@ use LaravelBook\Ardent\Ardent as Ardent;
/** /**
* PiggybankEvent * PiggybankEvent
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $piggybank_id * @property integer $piggybank_id
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property float $amount * @property float $amount
* @property integer $transaction_journal_id * @property integer $transaction_journal_id
* @property-read \Piggybank $piggybank * @property-read \Piggybank $piggybank
* @property-read \TransactionJournal $transactionJournal * @property-read \TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value)
@ -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

@ -5,13 +5,13 @@ use LaravelBook\Ardent\Ardent as Ardent;
/** /**
* PiggybankRepetition * PiggybankRepetition
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $piggybank_id * @property integer $piggybank_id
* @property \Carbon\Carbon $startdate * @property \Carbon\Carbon $startdate
* @property \Carbon\Carbon $targetdate * @property \Carbon\Carbon $targetdate
* @property float $currentamount * @property float $currentamount
* @property-read \Piggybank $piggybank * @property-read \Piggybank $piggybank
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereId($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereId($value)
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCreatedAt($value)
@ -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

@ -6,21 +6,21 @@ use LaravelBook\Ardent\Ardent;
/** /**
* RecurringTransaction * RecurringTransaction
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $user_id * @property integer $user_id
* @property string $name * @property string $name
* @property string $match * @property string $match
* @property float $amount_min * @property float $amount_min
* @property float $amount_max * @property float $amount_max
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property boolean $active * @property boolean $active
* @property boolean $automatch * @property boolean $automatch
* @property string $repeat_freq * @property string $repeat_freq
* @property integer $skip * @property integer $skip
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals * @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
* @property-read \User $user * @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value) * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUpdatedAt($value)
@ -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

@ -8,20 +8,20 @@ use LaravelBook\Ardent\Builder;
/** /**
* Transaction * Transaction
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $account_id * @property integer $account_id
* @property integer $piggybank_id * @property integer $piggybank_id
* @property integer $transaction_journal_id * @property integer $transaction_journal_id
* @property string $description * @property string $description
* @property float $amount * @property float $amount
* @property-read \Account $account * @property-read \Account $account
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets * @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories * @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components * @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
* @property-read \Piggybank $piggybank * @property-read \Piggybank $piggybank
* @property-read \TransactionJournal $transactionJournal * @property-read \TransactionJournal $transactionJournal
* @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value) * @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\Transaction whereUpdatedAt($value)
@ -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

@ -8,27 +8,27 @@ use LaravelBook\Ardent\Builder;
/** /**
* TransactionJournal * TransactionJournal
* *
* @property integer $id * @property integer $id
* @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at * @property \Carbon\Carbon $updated_at
* @property integer $user_id * @property integer $user_id
* @property integer $transaction_type_id * @property integer $transaction_type_id
* @property integer $recurring_transaction_id * @property integer $recurring_transaction_id
* @property integer $transaction_currency_id * @property integer $transaction_currency_id
* @property string $description * @property string $description
* @property boolean $completed * @property boolean $completed
* @property \Carbon\Carbon $date * @property \Carbon\Carbon $date
* @property-read \Illuminate\Database\Eloquent\Collection|\ * @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Budget[] $budgets * 'Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\ * @property-read \Illuminate\Database\Eloquent\Collection|\
* 'Category[] $categories * 'Category[] $categories
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components * @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents * @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
* @property-read \RecurringTransaction $recurringTransaction * @property-read \RecurringTransaction $recurringTransaction
* @property-read \TransactionCurrency $transactionCurrency * @property-read \TransactionCurrency $transactionCurrency
* @property-read \TransactionType $transactionType * @property-read \TransactionType $transactionType
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
* @property-read \User $user * @property-read \User $user
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value) * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereId($value)
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value) * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUpdatedAt($value)
@ -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()