2018-03-01 08:01:32 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Based on https://github.com/scottlaurent/accounting
|
|
|
|
* With modifications for phpVMS
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Model;
|
2018-04-02 07:02:12 +08:00
|
|
|
use App\Models\Traits\ReferenceTrait;
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2018-03-01 08:01:32 +08:00
|
|
|
/**
|
2018-03-20 09:50:40 +08:00
|
|
|
* @property string id UUID type
|
2018-03-02 12:00:11 +08:00
|
|
|
* @property string currency
|
|
|
|
* @property string memo
|
|
|
|
* @property string transaction_group
|
|
|
|
* @property string post_date
|
2018-08-27 00:40:04 +08:00
|
|
|
* @property int credit
|
|
|
|
* @property int debit
|
2018-04-02 03:32:01 +08:00
|
|
|
* @property string ref_model
|
2018-08-27 00:40:04 +08:00
|
|
|
* @property int ref_model_id
|
2018-03-19 09:37:35 +08:00
|
|
|
* @property Journal journal
|
2018-03-01 08:01:32 +08:00
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class JournalTransaction extends Model
|
2018-03-01 08:01:32 +08:00
|
|
|
{
|
2018-04-02 07:02:12 +08:00
|
|
|
use ReferenceTrait;
|
|
|
|
|
2018-03-01 08:01:32 +08:00
|
|
|
protected $table = 'journal_transactions';
|
2018-03-20 09:50:40 +08:00
|
|
|
|
2018-03-01 08:01:32 +08:00
|
|
|
public $incrementing = false;
|
|
|
|
|
2018-03-21 08:40:19 +08:00
|
|
|
protected $fillable = [
|
2018-03-01 08:01:32 +08:00
|
|
|
'transaction_group',
|
|
|
|
'journal_id',
|
|
|
|
'credit',
|
2018-03-01 11:52:36 +08:00
|
|
|
'debit',
|
2018-03-01 08:01:32 +08:00
|
|
|
'currency',
|
|
|
|
'memo',
|
|
|
|
'tags',
|
2018-04-02 03:32:01 +08:00
|
|
|
'ref_model',
|
|
|
|
'ref_model_id',
|
2018-08-27 00:40:04 +08:00
|
|
|
'post_date',
|
2018-03-01 08:01:32 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'credits' => 'integer',
|
2018-03-01 11:52:36 +08:00
|
|
|
'debit' => 'integer',
|
2018-03-01 08:01:32 +08:00
|
|
|
'post_date' => 'datetime',
|
|
|
|
'tags' => 'array',
|
|
|
|
];
|
|
|
|
|
2018-03-18 11:20:08 +08:00
|
|
|
//protected $dateFormat = 'Y-m-d';
|
2018-03-17 09:12:56 +08:00
|
|
|
protected $dates = [
|
|
|
|
'created_at',
|
|
|
|
'updated_at',
|
|
|
|
'post_date',
|
|
|
|
];
|
|
|
|
|
2018-03-01 08:01:32 +08:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function journal()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Journal::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $currency
|
|
|
|
*/
|
|
|
|
public function setCurrency($currency)
|
|
|
|
{
|
|
|
|
$this->currency = $currency;
|
|
|
|
}
|
|
|
|
}
|