mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 13:44:58 -06:00
Code clean up and reformat.
This commit is contained in:
parent
4aa9a04516
commit
71d174d765
@ -5,25 +5,25 @@ use LaravelBook\Ardent\Builder;
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property-read \AccountType $accountType
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $account_type_id
|
||||
* @property string $name
|
||||
* @property boolean $active
|
||||
* @property-read \AccountType $accountType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Piggybank[] $piggybanks
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereActive($value)
|
||||
* @method static \Account accountTypeIn($types)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Piggybank[] $piggybanks
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereAccountTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Account whereActive($value)
|
||||
* @method static \Account accountTypeIn($types)
|
||||
*/
|
||||
class Account extends Ardent
|
||||
{
|
||||
@ -34,16 +34,23 @@ class Account extends Ardent
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
'name' => ['required', 'between:1,100', 'alphabasic'],
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id',
|
||||
'active' => 'required|boolean'
|
||||
= ['name' => ['required', 'between:1,100', 'alphabasic'], 'user_id' => 'required|exists:users,id',
|
||||
'account_type_id' => 'required|exists:account_types,id', 'active' => 'required|boolean'
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
||||
|
||||
/**
|
||||
* Account type.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function accountType()
|
||||
{
|
||||
return $this->belongsTo('AccountType');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an accounts current balance.
|
||||
*
|
||||
@ -56,43 +63,12 @@ class Account extends Ardent
|
||||
$date = is_null($date) ? new \Carbon\Carbon : $date;
|
||||
|
||||
return floatval(
|
||||
$this->transactions()
|
||||
->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
$this->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balanceBeforeJournal(TransactionJournal $journal)
|
||||
{
|
||||
return floatval(
|
||||
$this->transactions()
|
||||
->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)
|
||||
->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))
|
||||
->where('transaction_journals.created_at', '<=', $journal->created_at->format('Y-m-d H:i:s'))
|
||||
->where('transaction_journals.id', '!=', $journal->id)
|
||||
->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Account type.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function accountType()
|
||||
{
|
||||
return $this->belongsTo('AccountType');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transactions.
|
||||
*
|
||||
@ -103,6 +79,22 @@ class Account extends Ardent
|
||||
return $this->hasMany('Transaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balanceBeforeJournal(TransactionJournal $journal)
|
||||
{
|
||||
return floatval(
|
||||
$this->transactions()->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
)->where('transaction_journals.date', '<=', $journal->date->format('Y-m-d'))->where(
|
||||
'transaction_journals.created_at', '<=', $journal->created_at->format('Y-m-d H:i:s')
|
||||
)->where('transaction_journals.id', '!=', $journal->id)->sum('transactions.amount')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -123,16 +115,6 @@ class Account extends Ardent
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
@ -146,5 +128,15 @@ class Account extends Ardent
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -12,11 +12,7 @@ class AccountMeta extends Ardent
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
'account_id' => 'numeric|required|exists:accounts,id',
|
||||
'name' => 'required|between:1,250',
|
||||
'data' => 'required'
|
||||
];
|
||||
= ['account_id' => 'numeric|required|exists:accounts,id', 'name' => 'required|between:1,250', 'data' => 'required'];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
@ -5,24 +5,22 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* AccountType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property boolean $editable
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property boolean $editable
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereEditable($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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\AccountType whereEditable($value)
|
||||
*/
|
||||
class AccountType extends Eloquent
|
||||
{
|
||||
public static $rules
|
||||
= [
|
||||
'type' => ['required', 'between:1,50', 'alphabasic'],
|
||||
'editable' => 'required|boolean',
|
||||
= ['type' => ['required', 'between:1,50', 'alphabasic'], 'editable' => 'required|boolean',
|
||||
|
||||
];
|
||||
|
||||
|
@ -3,22 +3,22 @@
|
||||
/**
|
||||
* Budget
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Budget whereClass($value)
|
||||
*/
|
||||
class Budget extends Component
|
||||
{
|
||||
|
@ -3,22 +3,22 @@
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereClass($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Category whereClass($value)
|
||||
*/
|
||||
class Category extends Component
|
||||
{
|
||||
|
@ -4,36 +4,32 @@ use FireflyIII\Shared\SingleTableInheritanceEntity;
|
||||
/**
|
||||
* Component
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $name
|
||||
* @property integer $user_id
|
||||
* @property string $class
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Limit[] $limits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereClass($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Component whereClass($value)
|
||||
*/
|
||||
class Component extends SingleTableInheritanceEntity
|
||||
{
|
||||
|
||||
public static $rules
|
||||
= [
|
||||
'user_id' => 'exists:users,id|required',
|
||||
'name' => ['required', 'between:1,100','min:1', 'alphabasic'],
|
||||
'class' => 'required',
|
||||
];
|
||||
protected $table = 'components';
|
||||
protected $subclassField = 'class';
|
||||
protected $fillable = ['name','user_id'];
|
||||
|
||||
= ['user_id' => 'exists:users,id|required', 'name' => ['required', 'between:1,100', 'min:1', 'alphabasic'],
|
||||
'class' => 'required',];
|
||||
protected $fillable = ['name', 'user_id'];
|
||||
protected $subclassField = 'class';
|
||||
protected $table = 'components';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
|
@ -4,21 +4,21 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* Importentry
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $class
|
||||
* @property integer $importmap_id
|
||||
* @property integer $old
|
||||
* @property integer $new
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $class
|
||||
* @property integer $importmap_id
|
||||
* @property integer $old
|
||||
* @property integer $new
|
||||
* @property-read \Importmap $importmap
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereClass($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereImportmapId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereOld($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereNew($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereClass($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereImportmapId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereOld($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereNew($value)
|
||||
*/
|
||||
class Importentry extends Eloquent
|
||||
{
|
||||
|
@ -4,33 +4,38 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* Importmap
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $file
|
||||
* @property integer $totaljobs
|
||||
* @property integer $jobsdone
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereFile($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereTotaljobs($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereJobsdone($value)
|
||||
* @property integer $user_id
|
||||
* @property string $file
|
||||
* @property integer $totaljobs
|
||||
* @property integer $jobsdone
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereFile($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereTotaljobs($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereJobsdone($value)
|
||||
*/
|
||||
class Importmap extends Ardent
|
||||
{
|
||||
public static $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'file' => 'required',
|
||||
'totaljobs' => 'numeric|required|min:0',
|
||||
'jobsdone' => 'numeric|required|min:0',
|
||||
= ['user_id' => 'required|exists:users,id', 'file' => 'required', 'totaljobs' => 'numeric|required|min:0', 'jobsdone' => 'numeric|required|min:0',
|
||||
|
||||
];
|
||||
|
||||
public function pct()
|
||||
{
|
||||
if ($this->jobsdone == 0 || $this->totaljobs == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return round((($this->jobsdone / $this->totaljobs) * 100), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
@ -40,13 +45,4 @@ class Importmap extends Ardent
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
public function pct()
|
||||
{
|
||||
if ($this->jobsdone == 0 || $this->totaljobs == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return round((($this->jobsdone / $this->totaljobs) * 100), 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,36 +7,32 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* Limit
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $component_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property float $amount
|
||||
* @property boolean $repeats
|
||||
* @property string $repeat_freq
|
||||
* @property-read \Budget $budget
|
||||
* @property-read \Component $component
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $component_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property float $amount
|
||||
* @property boolean $repeats
|
||||
* @property string $repeat_freq
|
||||
* @property-read \Budget $budget
|
||||
* @property-read \Component $component
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\LimitRepetition[] $limitrepetitions
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereComponentId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereAmount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Limit whereRepeatFreq($value)
|
||||
*/
|
||||
class Limit extends Ardent
|
||||
{
|
||||
|
||||
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'
|
||||
|
||||
];
|
||||
|
||||
@ -90,15 +86,15 @@ class Limit extends Ardent
|
||||
}
|
||||
$end->subDay();
|
||||
$count = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->count();
|
||||
\Log::debug('All: '.$this->limitrepetitions()->count().' (#'.$this->id.')');
|
||||
\Log::debug('Found ' . $count.' limit-reps for limit #' . $this->id.' with start '.$start->format('Y-m-d') .' and end ' . $end->format('Y-m-d'));
|
||||
\Log::debug('All: ' . $this->limitrepetitions()->count() . ' (#' . $this->id . ')');
|
||||
\Log::debug('Found ' . $count . ' limit-reps for limit #' . $this->id . ' with start ' . $start->format('Y-m-d') . ' and end ' . $end->format('Y-m-d'));
|
||||
|
||||
if ($count == 0) {
|
||||
|
||||
$repetition = new \LimitRepetition();
|
||||
$repetition = new \LimitRepetition();
|
||||
$repetition->startdate = $start;
|
||||
$repetition->enddate = $end;
|
||||
$repetition->amount = $this->amount;
|
||||
$repetition->enddate = $end;
|
||||
$repetition->amount = $this->amount;
|
||||
$repetition->limit()->associate($this);
|
||||
|
||||
try {
|
||||
@ -113,12 +109,14 @@ class Limit extends Ardent
|
||||
if (isset($repetition->id)) {
|
||||
\Event::fire('limits.repetition', [$repetition]);
|
||||
}
|
||||
} else if($count == 1) {
|
||||
// update this one:
|
||||
$repetition = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->first();
|
||||
$repetition->amount = $this->amount;
|
||||
$repetition->save();
|
||||
} else {
|
||||
if ($count == 1) {
|
||||
// update this one:
|
||||
$repetition = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where('enddate', $end->format('Y-m-d'))->first();
|
||||
$repetition->amount = $this->amount;
|
||||
$repetition->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,31 +6,26 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* LimitRepetition
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $limit_id
|
||||
* @property integer $limit_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property float $amount
|
||||
* @property-read \Limit $limit
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereLimitId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereAmount($value)
|
||||
* @property float $amount
|
||||
* @property-read \Limit $limit
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereLimitId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\LimitRepetition whereAmount($value)
|
||||
*/
|
||||
class LimitRepetition extends Ardent
|
||||
{
|
||||
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
|
||||
@ -40,20 +35,6 @@ class LimitRepetition extends Ardent
|
||||
return ['created_at', 'updated_at', 'startdate', 'enddate'];
|
||||
}
|
||||
|
||||
public function spentInRepetition() {
|
||||
$sum = \DB::table('transactions')
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')
|
||||
->leftJoin('limits', 'limits.component_id', '=', 'components.id')
|
||||
->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'limits.id')
|
||||
->where('transaction_journals.date', '>=', $this->startdate->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))
|
||||
->where('transactions.amount', '>', 0)
|
||||
->where('limit_repetitions.id', '=', $this->id)->sum('transactions.amount');
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* How much money is left in this?
|
||||
*/
|
||||
@ -63,6 +44,21 @@ class LimitRepetition extends Ardent
|
||||
|
||||
}
|
||||
|
||||
public function spentInRepetition()
|
||||
{
|
||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
||||
'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
)->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')->leftJoin(
|
||||
'limits', 'limits.component_id', '=', 'components.id'
|
||||
)->leftJoin('limit_repetitions', 'limit_repetitions.limit_id', '=', 'limits.id')->where(
|
||||
'transaction_journals.date', '>=', $this->startdate->format('Y-m-d')
|
||||
)->where('transaction_journals.date', '<=', $this->enddate->format('Y-m-d'))->where('transactions.amount', '>', 0)->where(
|
||||
'limit_repetitions.id', '=', $this->id
|
||||
)->sum('transactions.amount');
|
||||
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -5,77 +5,62 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* Piggybank
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property float $targetamount
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property boolean $repeats
|
||||
* @property string $rep_length
|
||||
* @property integer $rep_every
|
||||
* @property integer $rep_times
|
||||
* @property string $reminder
|
||||
* @property integer $reminder_skip
|
||||
* @property boolean $remind_me
|
||||
* @property integer $order
|
||||
* @property-read \Account $account
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property string $name
|
||||
* @property float $targetamount
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property boolean $repeats
|
||||
* @property string $rep_length
|
||||
* @property integer $rep_every
|
||||
* @property integer $rep_times
|
||||
* @property string $reminder
|
||||
* @property integer $reminder_skip
|
||||
* @property boolean $remind_me
|
||||
* @property integer $order
|
||||
* @property-read \Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankRepetition[] $piggybankrepetitions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetamount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepLength($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepEvery($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepTimes($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRemindMe($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetamount($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepeats($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepLength($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepEvery($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRepTimes($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereRemindMe($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
|
||||
*/
|
||||
class Piggybank extends Ardent
|
||||
{
|
||||
public static $rules
|
||||
= [
|
||||
'account_id' => 'required|exists:accounts,id', // link to Account
|
||||
'name' => 'required|between:1,255', // name
|
||||
'targetamount' => 'required|min:0', // amount you want to save
|
||||
'startdate' => 'date', // when you started
|
||||
'targetdate' => 'date', // when its due
|
||||
'repeats' => 'required|boolean', // does it repeat?
|
||||
'rep_length' => 'in:day,week,month,year', // how long is the period?
|
||||
'rep_every' => 'required|min:1|max:100', // how often does it repeat? every 3 years.
|
||||
'rep_times' => 'min:1|max:100', // how many times do you want to save this amount? eg. 3 times
|
||||
'reminder' => 'in:day,week,month,year', // want a reminder to put money in this?
|
||||
'reminder_skip' => 'required|min:0|max:100', // every week? every 2 months?
|
||||
'remind_me' => 'required|boolean',
|
||||
'order' => 'required:min:1', // not yet used.
|
||||
];
|
||||
public $fillable
|
||||
= [
|
||||
'account_id',
|
||||
'name',
|
||||
'targetamount',
|
||||
'startdate',
|
||||
'targetdate',
|
||||
'repeats',
|
||||
'rep_length',
|
||||
'rep_every',
|
||||
'rep_times',
|
||||
'reminder',
|
||||
'reminder_skip',
|
||||
'remind_me',
|
||||
'order'
|
||||
= ['account_id' => 'required|exists:accounts,id', // link to Account
|
||||
'name' => 'required|between:1,255', // name
|
||||
'targetamount' => 'required|min:0', // amount you want to save
|
||||
'startdate' => 'date', // when you started
|
||||
'targetdate' => 'date', // when its due
|
||||
'repeats' => 'required|boolean', // does it repeat?
|
||||
'rep_length' => 'in:day,week,month,year', // how long is the period?
|
||||
'rep_every' => 'required|min:1|max:100', // how often does it repeat? every 3 years.
|
||||
'rep_times' => 'min:1|max:100', // how many times do you want to save this amount? eg. 3 times
|
||||
'reminder' => 'in:day,week,month,year', // want a reminder to put money in this?
|
||||
'reminder_skip' => 'required|min:0|max:100', // every week? every 2 months?
|
||||
'remind_me' => 'required|boolean', 'order' => 'required:min:1', // not yet used.
|
||||
];
|
||||
public $fillable
|
||||
= ['account_id', 'name', 'targetamount', 'startdate', 'targetdate', 'repeats', 'rep_length', 'rep_every', 'rep_times', 'reminder', 'reminder_skip',
|
||||
'remind_me', 'order'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@ -89,8 +74,8 @@ class Piggybank extends Ardent
|
||||
{
|
||||
$rep = new \PiggybankRepetition;
|
||||
$rep->piggybank()->associate($this);
|
||||
$rep->startdate = $start;
|
||||
$rep->targetdate = $target;
|
||||
$rep->startdate = $start;
|
||||
$rep->targetdate = $target;
|
||||
$rep->currentamount = 0;
|
||||
$rep->save();
|
||||
\Event::fire('piggybanks.repetition', [$rep]);
|
||||
@ -98,14 +83,6 @@ class Piggybank extends Ardent
|
||||
return $rep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'targetdate', 'startdate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active
|
||||
*
|
||||
@ -113,8 +90,7 @@ class Piggybank extends Ardent
|
||||
*/
|
||||
public function currentRelevantRep()
|
||||
{
|
||||
$query = $this->piggybankrepetitions()
|
||||
->where(
|
||||
$query = $this->piggybankrepetitions()->where(
|
||||
function ($q) {
|
||||
|
||||
$q->where(
|
||||
@ -123,8 +99,7 @@ class Piggybank extends Ardent
|
||||
$q->whereNull('startdate');
|
||||
$q->orWhere('startdate', '<=', $today->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->where(
|
||||
)->where(
|
||||
function ($q) {
|
||||
$today = new Carbon;
|
||||
$q->whereNull('targetdate');
|
||||
@ -154,6 +129,14 @@ class Piggybank extends Ardent
|
||||
return $this->hasMany('PiggybankRepetition');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDates()
|
||||
{
|
||||
return ['created_at', 'updated_at', 'targetdate', 'startdate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -171,8 +154,7 @@ class Piggybank extends Ardent
|
||||
*/
|
||||
public function repetitionForDate(Carbon $date)
|
||||
{
|
||||
$query = $this->piggybankrepetitions()
|
||||
->where(
|
||||
$query = $this->piggybankrepetitions()->where(
|
||||
function ($q) use ($date) {
|
||||
|
||||
$q->where(
|
||||
@ -180,8 +162,7 @@ class Piggybank extends Ardent
|
||||
$q->whereNull('startdate');
|
||||
$q->orWhere('startdate', '<=', $date->format('Y-m-d'));
|
||||
}
|
||||
)
|
||||
->where(
|
||||
)->where(
|
||||
function ($q) use ($date) {
|
||||
$q->whereNull('targetdate');
|
||||
$q->orWhere('targetdate', '>=', $date->format('Y-m-d'));
|
||||
|
@ -5,29 +5,25 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* PiggybankEvent
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property float $amount
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property float $amount
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($value)
|
||||
*/
|
||||
class PiggybankEvent extends Ardent
|
||||
{
|
||||
|
||||
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
|
||||
|
@ -4,31 +4,26 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
/**
|
||||
* PiggybankRepetition
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property float $currentamount
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $piggybank_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $targetdate
|
||||
* @property float $currentamount
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCurrentamount($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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereTargetdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\PiggybankRepetition whereCurrentamount($value)
|
||||
*/
|
||||
class PiggybankRepetition extends Ardent
|
||||
{
|
||||
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
|
||||
|
@ -5,44 +5,24 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* Preference
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereData($value)
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Preference whereData($value)
|
||||
*/
|
||||
class Preference extends Ardent
|
||||
{
|
||||
public static $rules
|
||||
= [
|
||||
'user_id' => 'required|exists:users,id',
|
||||
'name' => 'required|between:1,255',
|
||||
'data' => 'required'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
= ['user_id' => 'required|exists:users,id', 'name' => 'required|between:1,255', 'data' => 'required'];
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
@ -54,4 +34,20 @@ class Preference extends Ardent
|
||||
return json_decode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setDataAttribute($value)
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
}
|
@ -5,52 +5,43 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* RecurringTransaction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property float $amount_max
|
||||
* @property float $amount_min
|
||||
* @property integer $user_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property float $amount_max
|
||||
* @property float $amount_min
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property boolean $active
|
||||
* @property boolean $automatch
|
||||
* @property string $repeat_freq
|
||||
* @property integer $skip
|
||||
* @property-read \User $user
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereMatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMax($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value)
|
||||
* @property boolean $active
|
||||
* @property boolean $automatch
|
||||
* @property string $repeat_freq
|
||||
* @property integer $skip
|
||||
* @property-read \User $user
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereMatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMax($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAmountMin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereDate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereAutomatch($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereRepeatFreq($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereSkip($value)
|
||||
*/
|
||||
class RecurringTransaction extends Ardent
|
||||
{
|
||||
|
||||
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',
|
||||
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly',
|
||||
'skip' => 'required|between:0,31',
|
||||
];
|
||||
= ['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',
|
||||
'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'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@ -68,7 +59,7 @@ class RecurringTransaction extends Ardent
|
||||
{
|
||||
$today = new Carbon;
|
||||
$start = clone $this->date;
|
||||
$skip = $this->skip == 0 ? 1 : $this->skip;
|
||||
$skip = $this->skip == 0 ? 1 : $this->skip;
|
||||
if ($today < $start) {
|
||||
return $start;
|
||||
}
|
||||
|
@ -1,27 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* Reminder
|
||||
*
|
||||
* @property integer $id
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $user_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
* @property boolean $active
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
|
||||
* @property boolean $active
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereStartdate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereEnddate($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Reminder whereActive($value)
|
||||
*/
|
||||
class Reminder extends Ardent
|
||||
{
|
||||
|
@ -9,45 +9,41 @@ use LaravelBook\Ardent\Builder;
|
||||
/**
|
||||
* Transaction
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property integer $piggybank_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property-read \Account $account
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $account_id
|
||||
* @property integer $piggybank_id
|
||||
* @property integer $transaction_journal_id
|
||||
* @property string $description
|
||||
* @property float $amount
|
||||
* @property-read \Account $account
|
||||
* @property-read \Piggybank $piggybank
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value)
|
||||
* @method static \Transaction accountIs($account)
|
||||
* @method static \Transaction after($date)
|
||||
* @method static \Transaction before($date)
|
||||
* @method static \Transaction lessThan($amount)
|
||||
* @method static \Transaction moreThan($amount)
|
||||
* @method static \Transaction transactionTypes($types)
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAccountId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction wherePiggybankId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereTransactionJournalId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereAmount($value)
|
||||
* @method static \Transaction accountIs($account)
|
||||
* @method static \Transaction after($date)
|
||||
* @method static \Transaction before($date)
|
||||
* @method static \Transaction lessThan($amount)
|
||||
* @method static \Transaction moreThan($amount)
|
||||
* @method static \Transaction transactionTypes($types)
|
||||
*/
|
||||
class Transaction extends Ardent
|
||||
{
|
||||
public static $rules
|
||||
= [
|
||||
'account_id' => 'numeric|required|exists:accounts,id',
|
||||
'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',
|
||||
];
|
||||
= ['account_id' => 'numeric|required|exists:accounts,id', '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',];
|
||||
|
||||
|
||||
/**
|
||||
@ -58,36 +54,6 @@ class Transaction extends Ardent
|
||||
return $this->belongsTo('Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connectPiggybank(\Piggybank $piggybank = null)
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
// if (is_null($piggybank)) {
|
||||
// return true;
|
||||
// }
|
||||
// /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||
// $piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||
// if ($this->account_id == $piggybank->account_id) {
|
||||
// $this->piggybank()->associate($piggybank);
|
||||
// $this->save();
|
||||
// \Event::fire('piggybanks.createRelatedTransfer', [$piggybank, $this->transactionJournal, $this]);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function piggybank()
|
||||
{
|
||||
return $this->belongsTo('Piggybank');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
@ -112,6 +78,36 @@ class Transaction extends Ardent
|
||||
return $this->belongsToMany('Component');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connectPiggybank(\Piggybank $piggybank = null)
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
// if (is_null($piggybank)) {
|
||||
// return true;
|
||||
// }
|
||||
// /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||
// $piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||
// if ($this->account_id == $piggybank->account_id) {
|
||||
// $this->piggybank()->associate($piggybank);
|
||||
// $this->save();
|
||||
// \Event::fire('piggybanks.createRelatedTransfer', [$piggybank, $this->transactionJournal, $this]);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function piggybank()
|
||||
{
|
||||
return $this->belongsTo('Piggybank');
|
||||
}
|
||||
|
||||
public function scopeAccountIs(Builder $query, Account $account)
|
||||
{
|
||||
$query->where('transactions.account_id', $account->id);
|
||||
@ -121,8 +117,7 @@ class Transaction extends Ardent
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=',
|
||||
'transactions.transaction_journal_id'
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
);
|
||||
$this->joinedJournals = true;
|
||||
}
|
||||
@ -133,8 +128,7 @@ class Transaction extends Ardent
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=',
|
||||
'transactions.transaction_journal_id'
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
);
|
||||
$this->joinedJournals = true;
|
||||
}
|
||||
@ -155,15 +149,13 @@ class Transaction extends Ardent
|
||||
{
|
||||
if (is_null($this->joinedJournals)) {
|
||||
$query->leftJoin(
|
||||
'transaction_journals', 'transaction_journals.id', '=',
|
||||
'transactions.transaction_journal_id'
|
||||
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
|
||||
);
|
||||
$this->joinedJournals = true;
|
||||
}
|
||||
if (is_null($this->joinedTransactionTypes)) {
|
||||
$query->leftJoin(
|
||||
'transaction_types', 'transaction_types.id', '=',
|
||||
'transaction_journals.transaction_type_id'
|
||||
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||
);
|
||||
$this->joinedTransactionTypes = true;
|
||||
}
|
||||
|
@ -4,15 +4,15 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
/**
|
||||
* TransactionCurrency
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $code
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $code
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCode($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionCurrency whereCode($value)
|
||||
*/
|
||||
class TransactionCurrency extends Eloquent
|
||||
{
|
||||
|
@ -7,57 +7,52 @@ use LaravelBook\Ardent\Builder;
|
||||
/**
|
||||
* TransactionJournal
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $transaction_type_id
|
||||
* @property integer $recurring_transaction_id
|
||||
* @property integer $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property boolean $completed
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property integer $user_id
|
||||
* @property integer $transaction_type_id
|
||||
* @property integer $recurring_transaction_id
|
||||
* @property integer $transaction_currency_id
|
||||
* @property string $description
|
||||
* @property boolean $completed
|
||||
* @property \Carbon\Carbon $date
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\
|
||||
* 'Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \RecurringTransaction $recurringTransaction
|
||||
* @property-read \TransactionCurrency $transactionCurrency
|
||||
* @property-read \TransactionType $transactionType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \RecurringTransaction $recurringTransaction
|
||||
* @property-read \TransactionCurrency $transactionCurrency
|
||||
* @property-read \TransactionType $transactionType
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
|
||||
* @property-read \User $user
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereRecurringTransactionId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
|
||||
* @method static \TransactionJournal accountIs($account)
|
||||
* @method static \TransactionJournal after($date)
|
||||
* @method static \TransactionJournal before($date)
|
||||
* @method static \TransactionJournal defaultSorting()
|
||||
* @method static \TransactionJournal moreThan($amount)
|
||||
* @method static \TransactionJournal lessThan($amount)
|
||||
* @method static \TransactionJournal onDate($date)
|
||||
* @method static \TransactionJournal transactionTypes($types)
|
||||
* @method static \TransactionJournal withRelevantData()
|
||||
* @property-read \User $user
|
||||
* @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 whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionTypeId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereRecurringTransactionId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereTransactionCurrencyId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
|
||||
* @method static \TransactionJournal accountIs($account)
|
||||
* @method static \TransactionJournal after($date)
|
||||
* @method static \TransactionJournal before($date)
|
||||
* @method static \TransactionJournal defaultSorting()
|
||||
* @method static \TransactionJournal moreThan($amount)
|
||||
* @method static \TransactionJournal lessThan($amount)
|
||||
* @method static \TransactionJournal onDate($date)
|
||||
* @method static \TransactionJournal transactionTypes($types)
|
||||
* @method static \TransactionJournal withRelevantData()
|
||||
*/
|
||||
class TransactionJournal extends Ardent
|
||||
{
|
||||
|
||||
public static $rules
|
||||
= [
|
||||
'transaction_type_id' => 'required|exists:transaction_types,id',
|
||||
'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'description' => 'required|between:1,255',
|
||||
'date' => 'required|date',
|
||||
'completed' => 'required|between:0,1'
|
||||
];
|
||||
= ['transaction_type_id' => 'required|exists:transaction_types,id', 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
|
||||
'description' => 'required|between:1,255', 'date' => 'required|date', 'completed' => 'required|between:0,1'];
|
||||
|
||||
|
||||
/**
|
||||
@ -99,15 +94,8 @@ class TransactionJournal extends Ardent
|
||||
return floatval($t->amount);
|
||||
}
|
||||
}
|
||||
return -0.01;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function recurringTransaction()
|
||||
{
|
||||
return $this->belongsTo('RecurringTransaction');
|
||||
return -0.01;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,6 +106,14 @@ class TransactionJournal extends Ardent
|
||||
return ['created_at', 'updated_at', 'date'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function recurringTransaction()
|
||||
{
|
||||
return $this->belongsTo('RecurringTransaction');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param Account $account
|
||||
@ -158,25 +154,11 @@ class TransactionJournal extends Ardent
|
||||
$query->orderBy('date', 'DESC')->orderBy('transaction_journals.id', 'DESC');
|
||||
}
|
||||
|
||||
public function scopeMoreThan(Builder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
$query->leftJoin(
|
||||
'transactions', 'transactions.transaction_journal_id', '=',
|
||||
'transaction_journals.id'
|
||||
);
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
|
||||
$query->where('transactions.amount', '>=', $amount);
|
||||
}
|
||||
|
||||
public function scopeLessThan(Builder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
$query->leftJoin(
|
||||
'transactions', 'transactions.transaction_journal_id', '=',
|
||||
'transaction_journals.id'
|
||||
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
);
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
@ -184,6 +166,18 @@ class TransactionJournal extends Ardent
|
||||
$query->where('transactions.amount', '<=', $amount);
|
||||
}
|
||||
|
||||
public function scopeMoreThan(Builder $query, $amount)
|
||||
{
|
||||
if (is_null($this->joinedTransactions)) {
|
||||
$query->leftJoin(
|
||||
'transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
);
|
||||
$this->joinedTransactions = true;
|
||||
}
|
||||
|
||||
$query->where('transactions.amount', '>=', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param Carbon $date
|
||||
@ -199,8 +193,7 @@ class TransactionJournal extends Ardent
|
||||
{
|
||||
if (is_null($this->joinedTransactionTypes)) {
|
||||
$query->leftJoin(
|
||||
'transaction_types', 'transaction_types.id', '=',
|
||||
'transaction_journals.transaction_type_id'
|
||||
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||
);
|
||||
$this->joinedTransactionTypes = true;
|
||||
}
|
||||
|
@ -5,15 +5,15 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* TransactionType
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionJournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\TransactionType whereType($value)
|
||||
*/
|
||||
class TransactionType extends Ardent
|
||||
{
|
||||
|
@ -9,29 +9,29 @@ use LaravelBook\Ardent\Ardent;
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @property boolean $migrated
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $reset
|
||||
* @property string $remember_token
|
||||
* @property boolean $migrated
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\RecurringTransaction[] $recurringtransactions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\TransactionJournal[] $transactionjournals
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereReset($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value)
|
||||
*/
|
||||
class User extends Ardent implements UserInterface, RemindableInterface
|
||||
{
|
||||
@ -40,24 +40,20 @@ class User extends Ardent implements UserInterface, RemindableInterface
|
||||
|
||||
|
||||
public static $rules
|
||||
= [
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'migrated' => 'required|boolean',
|
||||
'password' => 'required|between:60,60',
|
||||
'reset' => 'between:32,32',
|
||||
];
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
= ['email' => 'required|email|unique:users,email', 'migrated' => 'required|boolean', 'password' => 'required|between:60,60',
|
||||
'reset' => 'between:32,32',];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['remember_token'];
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@ -91,6 +87,11 @@ class User extends Ardent implements UserInterface, RemindableInterface
|
||||
return $this->hasMany('Component');
|
||||
}
|
||||
|
||||
public function piggybanks()
|
||||
{
|
||||
return $this->hasManyThrough('Piggybank', 'Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
@ -115,11 +116,6 @@ class User extends Ardent implements UserInterface, RemindableInterface
|
||||
$this->attributes['password'] = Hash::make($value);
|
||||
}
|
||||
|
||||
public function piggybanks()
|
||||
{
|
||||
return $this->hasManyThrough('Piggybank', 'Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user