mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some general cleaning up.
This commit is contained in:
parent
36cbb3d71f
commit
696e9a6fde
@ -36,8 +36,11 @@ class Account extends Ardent
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rules
|
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'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -56,6 +59,8 @@ class Account extends Ardent
|
|||||||
/**
|
/**
|
||||||
* Get an accounts current balance.
|
* Get an accounts current balance.
|
||||||
*
|
*
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* @param \Carbon\Carbon $date
|
* @param \Carbon\Carbon $date
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
@ -82,6 +87,9 @@ class Account extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
@ -98,6 +106,8 @@ class Account extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* @return Carbon
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
public function lastActionDate()
|
public function lastActionDate()
|
||||||
@ -119,6 +129,8 @@ class Account extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* @param \Carbon\Carbon $date
|
* @param \Carbon\Carbon $date
|
||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
|
@ -13,7 +13,10 @@ class AccountMeta extends Ardent
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rules
|
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
|
* @var array
|
||||||
|
@ -32,12 +32,5 @@ class Budget extends Component
|
|||||||
return $this->hasMany('Limit', 'component_id');
|
return $this->hasMany('Limit', 'component_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|\TransactionJournal
|
|
||||||
*/
|
|
||||||
public function transactionjournals()
|
|
||||||
{
|
|
||||||
return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -25,24 +25,5 @@ class Category extends Component
|
|||||||
{
|
{
|
||||||
protected $isSubclass = true;
|
protected $isSubclass = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Carbon
|
|
||||||
*/
|
|
||||||
public function lastActionDate()
|
|
||||||
{
|
|
||||||
$transaction = $this->transactionjournals()->orderBy('updated_at', 'DESC')->first();
|
|
||||||
if (is_null($transaction)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $transaction->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
||||||
*/
|
|
||||||
public function transactionjournals()
|
|
||||||
{
|
|
||||||
return $this->belongsToMany('TransactionJournal', 'component_transaction_journal', 'component_id');
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -33,11 +33,17 @@ class Component extends SingleTableInheritanceEntity
|
|||||||
protected $table = 'components';
|
protected $table = 'components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
* @return Carbon
|
||||||
*/
|
*/
|
||||||
public function limits()
|
public function lastActionDate()
|
||||||
{
|
{
|
||||||
return $this->hasMany('Limit');
|
$transaction = $this->transactionjournals()->orderBy('updated_at', 'DESC')->first();
|
||||||
|
if (is_null($transaction)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $transaction->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,9 +51,10 @@ class Component extends SingleTableInheritanceEntity
|
|||||||
*/
|
*/
|
||||||
public function transactionjournals()
|
public function transactionjournals()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany('TransactionJournal');
|
return $this->belongsToMany('TransactionJournal','component_transaction_journal','component_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
*/
|
*/
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
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-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)
|
|
||||||
*/
|
|
||||||
class Importentry extends Eloquent
|
|
||||||
{
|
|
||||||
public function importmap()
|
|
||||||
{
|
|
||||||
return $this->belongsTo('Importmap');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
use LaravelBook\Ardent\Ardent as Ardent;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Importmap
|
|
||||||
*
|
|
||||||
* @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)
|
|
||||||
*/
|
|
||||||
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',
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
public function pct()
|
|
||||||
{
|
|
||||||
if ($this->jobsdone == 0 || $this->totaljobs == 0) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return round((($this->jobsdone / $this->totaljobs) * 100), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
|
||||||
public function user()
|
|
||||||
{
|
|
||||||
return $this->belongsTo('User');
|
|
||||||
}
|
|
||||||
}
|
|
@ -46,14 +46,6 @@ class Limit extends Ardent
|
|||||||
return $this->belongsTo('Budget', 'component_id');
|
return $this->belongsTo('Budget', 'component_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
|
||||||
public function component()
|
|
||||||
{
|
|
||||||
return $this->belongsTo('Component', 'component_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new repetition for this limit, starting on
|
* Create a new repetition for this limit, starting on
|
||||||
* the given date.
|
* the given date.
|
||||||
|
@ -45,6 +45,10 @@ class LimitRepetition extends Ardent
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
public function spentInRepetition()
|
public function spentInRepetition()
|
||||||
{
|
{
|
||||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
||||||
@ -69,6 +73,8 @@ class LimitRepetition extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* Returns a string used to sort this particular repetition
|
* Returns a string used to sort this particular repetition
|
||||||
* based on the date and period it falls into. Ie. the limit
|
* based on the date and period it falls into. Ie. the limit
|
||||||
* repeats monthly and the start date is 12 dec 2012, this will
|
* repeats monthly and the start date is 12 dec 2012, this will
|
||||||
@ -105,6 +111,8 @@ class LimitRepetition extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* Same as above, just with a more natural view. So "March 2012".
|
* Same as above, just with a more natural view. So "March 2012".
|
||||||
*/
|
*/
|
||||||
public function periodShow()
|
public function periodShow()
|
||||||
|
@ -71,16 +71,34 @@ class Piggybank extends Ardent
|
|||||||
return $this->belongsTo('Account');
|
return $this->belongsTo('Account');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function amountPerReminder() {
|
public function amountPerReminder() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function countFutureReminders()
|
public function countFutureReminders()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $target
|
||||||
|
*
|
||||||
|
* @return PiggybankRepetition
|
||||||
|
*/
|
||||||
public function createRepetition(Carbon $start = null, Carbon $target = null)
|
public function createRepetition(Carbon $start = null, Carbon $target = null)
|
||||||
{
|
{
|
||||||
$rep = new \PiggybankRepetition;
|
$rep = new \PiggybankRepetition;
|
||||||
@ -94,6 +112,8 @@ class Piggybank extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* Grabs the PiggyBankRepetition that's currently relevant / active
|
* Grabs the PiggyBankRepetition that's currently relevant / active
|
||||||
*
|
*
|
||||||
* @returns \PiggybankRepetition
|
* @returns \PiggybankRepetition
|
||||||
@ -167,6 +187,8 @@ class Piggybank extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* Same but for specific date.
|
* Same but for specific date.
|
||||||
*
|
*
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
|
@ -34,6 +34,11 @@ class PiggybankRepetition extends Ardent
|
|||||||
return ['created_at', 'updated_at', 'targetdate', 'startdate'];
|
return ['created_at', 'updated_at', 'targetdate', 'startdate'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
|
* @return float|int
|
||||||
|
*/
|
||||||
public function pct()
|
public function pct()
|
||||||
{
|
{
|
||||||
$total = $this->piggybank->targetamount;
|
$total = $this->piggybank->targetamount;
|
||||||
|
@ -72,6 +72,8 @@ class RecurringTransaction extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
|
*
|
||||||
* Find the next expected match based on the set journals and the date stuff from the recurring
|
* Find the next expected match based on the set journals and the date stuff from the recurring
|
||||||
* transaction.
|
* transaction.
|
||||||
*/
|
*/
|
||||||
|
@ -50,19 +50,6 @@ class Reminder extends Ardent
|
|||||||
return $this->belongsTo('User');
|
return $this->belongsTo('User');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Expected data in this value:
|
|
||||||
*
|
|
||||||
* type: Piggybank, Test
|
|
||||||
* action_uri: where to go when the user wants to do this?
|
|
||||||
* text: full text to present to user
|
|
||||||
* amount: any relevant amount.
|
|
||||||
* model: id of relevant model.
|
|
||||||
*
|
|
||||||
* @param $value
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getDataAttribute($value)
|
public function getDataAttribute($value)
|
||||||
{
|
{
|
||||||
return json_decode($value);
|
return json_decode($value);
|
||||||
|
@ -86,6 +86,7 @@ class TransactionJournal extends Ardent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getAmount()
|
public function getAmount()
|
||||||
|
@ -221,7 +221,7 @@ Route::group(
|
|||||||
// user controller
|
// user controller
|
||||||
Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
|
Route::get('/logout', ['uses' => 'UserController@logout', 'as' => 'logout']);
|
||||||
|
|
||||||
//Route::post('budgets/amount/{budget}', ['uses' => 'BudgetController@amount']);
|
Route::post('budgets/amount/{budget}', ['uses' => 'BudgetController@amount']);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,4 +102,5 @@ Event::subscribe('FireflyIII\Event\Piggybank');
|
|||||||
// although this not changes the amount in the piggy bank).
|
// although this not changes the amount in the piggy bank).
|
||||||
// TODO check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
|
// TODO check if recurring transactions are being updated when journals are updated (aka no longer fitting, thus removed).
|
||||||
// TODO think about reminders.
|
// TODO think about reminders.
|
||||||
|
// TODO an event that triggers and creates a limit + limit repetition when a budget is created, or something?
|
||||||
return $app;
|
return $app;
|
||||||
|
Loading…
Reference in New Issue
Block a user