mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Cleanup all models and migrations.
This commit is contained in:
parent
754336b3cf
commit
359e1b3943
@ -3,7 +3,8 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateImportentriesTable extends Migration {
|
||||
class CreateImportentriesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
@ -12,21 +13,21 @@ class CreateImportentriesTable extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('importentries', function(Blueprint $table)
|
||||
{
|
||||
Schema::create(
|
||||
'importentries', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->string('class',200);
|
||||
$table->string('class', 200);
|
||||
$table->integer('importmap_id')->unsigned();
|
||||
$table->integer('old')->unsigned();
|
||||
$table->integer('new')->unsigned();
|
||||
|
||||
// map import entries to import map.
|
||||
// connect accounts to account_types
|
||||
// connect import map.
|
||||
$table->foreign('importmap_id')
|
||||
->references('id')->on('importmaps')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateAccountMeta extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
Schema::create(
|
||||
'account_meta', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->integer('account_id')->unsigned();
|
||||
$table->string('name');
|
||||
$table->text('data');
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
Schema::drop('account_meta');
|
||||
}
|
||||
|
||||
}
|
@ -42,17 +42,7 @@ class Account extends Ardent
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = ['name','user_id','account_type_id','active'];
|
||||
|
||||
/**
|
||||
* Account type.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function accountType()
|
||||
{
|
||||
return $this->belongsTo('AccountType');
|
||||
}
|
||||
protected $fillable = ['name', 'user_id', 'account_type_id', 'active'];
|
||||
|
||||
/**
|
||||
* Get an accounts current balance.
|
||||
@ -74,6 +64,11 @@ class Account extends Ardent
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balanceBeforeJournal(TransactionJournal $journal)
|
||||
{
|
||||
return floatval(
|
||||
@ -83,11 +78,21 @@ class Account extends Ardent
|
||||
)
|
||||
->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)
|
||||
->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.
|
||||
*
|
||||
@ -114,8 +119,7 @@ class Account extends Ardent
|
||||
public function predict(
|
||||
/** @noinspection PhpUnusedParameterInspection */
|
||||
\Carbon\Carbon $date
|
||||
)
|
||||
{
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -129,12 +133,17 @@ class Account extends Ardent
|
||||
return $this->belongsTo('User');
|
||||
}
|
||||
|
||||
public function scopeAccountTypeIn(Builder $query, array $types) {
|
||||
if(is_null($this->joinedAccountTypes)) {
|
||||
$query->leftJoin('account_types','account_types.id','=','accounts.account_type_id');
|
||||
/**
|
||||
* @param Builder $query
|
||||
* @param array $types
|
||||
*/
|
||||
public function scopeAccountTypeIn(Builder $query, array $types)
|
||||
{
|
||||
if (is_null($this->joinedAccountTypes)) {
|
||||
$query->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id');
|
||||
$this->joinedAccountTypes = true;
|
||||
}
|
||||
$query->whereIn('account_types.type',$types);
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
|
||||
|
35
app/models/AccountMeta.php
Normal file
35
app/models/AccountMeta.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
|
||||
/**
|
||||
* AccountMeta
|
||||
*
|
||||
* @property-read \Account $account
|
||||
*/
|
||||
class AccountMeta extends Ardent
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $rules
|
||||
= [
|
||||
'account_id' => 'numeric|required|exists:accounts,id',
|
||||
'name' => 'required|between:1,250',
|
||||
'data' => 'required'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['account_id', 'name', 'date'];
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* Importentry
|
||||
*
|
||||
* @property-read \Importmap $importmap
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
* @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)
|
||||
@ -19,7 +20,8 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereOld($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importentry whereNew($value)
|
||||
*/
|
||||
class Importentry extends Eloquent {
|
||||
class Importentry extends Eloquent
|
||||
{
|
||||
public function importmap()
|
||||
{
|
||||
return $this->belongsTo('Importmap');
|
||||
|
@ -2,21 +2,21 @@
|
||||
use LaravelBook\Ardent\Ardent as Ardent;
|
||||
|
||||
/**
|
||||
* Class Importmap
|
||||
* Importmap
|
||||
*
|
||||
* @property-read \User $user
|
||||
* @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)
|
||||
* @property integer $totaljobs
|
||||
* @property integer $jobsdone
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereTotaljobs($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Importmap whereJobsdone($value)
|
||||
*/
|
||||
|
@ -19,11 +19,11 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
* @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|\PiggybankReminder[] $piggybankreminders
|
||||
* @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)
|
||||
@ -39,6 +39,7 @@ use LaravelBook\Ardent\Ardent as Ardent;
|
||||
* @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
|
||||
|
@ -18,7 +18,6 @@ use LaravelBook\Ardent\Ardent;
|
||||
* @property boolean $automatch
|
||||
* @property string $repeat_freq
|
||||
* @property integer $skip
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\RecurringTransactionReminder[] $reminders
|
||||
* @property-read \User $user
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\RecurringTransaction whereCreatedAt($value)
|
||||
|
@ -11,7 +11,6 @@ use LaravelBook\Ardent\Ardent;
|
||||
* @property integer $id
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $class
|
||||
* @property integer $user_id
|
||||
* @property \Carbon\Carbon $startdate
|
||||
* @property \Carbon\Carbon $enddate
|
||||
@ -20,7 +19,6 @@ use LaravelBook\Ardent\Ardent;
|
||||
* @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 whereClass($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)
|
||||
|
@ -17,10 +17,10 @@ use LaravelBook\Ardent\Builder;
|
||||
* @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 \Piggybank $piggybank
|
||||
* @property-read \TransactionJournal $transactionJournal
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Transaction whereCreatedAt($value)
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
|
||||
/**
|
||||
* TransactionCurrency
|
||||
*
|
||||
|
@ -4,6 +4,49 @@ use Carbon\Carbon;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
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-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|\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()
|
||||
*/
|
||||
class TransactionJournal extends Ardent
|
||||
{
|
||||
|
||||
|
@ -6,7 +6,6 @@ use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use LaravelBook\Ardent\Ardent;
|
||||
|
||||
|
||||
/**
|
||||
* User
|
||||
*
|
||||
@ -20,8 +19,6 @@ use LaravelBook\Ardent\Ardent;
|
||||
* @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|\Reminder[] $reminders
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankReminder[] $piggybankreminders
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences
|
||||
|
Loading…
Reference in New Issue
Block a user