first version
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Modules\SystemUser\Models\SysUserModel;
|
||||
|
||||
/**
|
||||
* 财务对账模型(公布金额 vs 实际金额 vs 差额,按品类/供应商筛选)
|
||||
*/
|
||||
class ReconciliationModel extends Model
|
||||
{
|
||||
/** 状态:草稿 */
|
||||
public const STATUS_DRAFT = 0;
|
||||
/** 状态:对账中 */
|
||||
public const STATUS_WORKING = 1;
|
||||
/** 状态:已结算 */
|
||||
public const STATUS_SETTLED = 2;
|
||||
|
||||
protected $table = 'reconciliation';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'recon_no',
|
||||
'title',
|
||||
'period_start',
|
||||
'period_end',
|
||||
'category_id',
|
||||
'supplier_id',
|
||||
'publish_amount',
|
||||
'actual_amount',
|
||||
'diff_amount',
|
||||
'status',
|
||||
'operator_id',
|
||||
'remark',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'period_start' => 'date:Y-m-d',
|
||||
'period_end' => 'date:Y-m-d',
|
||||
'category_id' => 'integer',
|
||||
'supplier_id' => 'integer',
|
||||
'publish_amount' => 'decimal:2',
|
||||
'actual_amount' => 'decimal:2',
|
||||
'diff_amount' => 'decimal:2',
|
||||
'status' => 'integer',
|
||||
'operator_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 制单人(后台系统用户)
|
||||
*/
|
||||
public function operator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SysUserModel::class, 'operator_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 对账明细
|
||||
*/
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(ReconciliationItemModel::class, 'recon_id', 'id')->orderBy('sort');
|
||||
}
|
||||
|
||||
/**
|
||||
* 结算表
|
||||
*/
|
||||
public function settlements(): HasMany
|
||||
{
|
||||
return $this->hasMany(SettlementModel::class, 'recon_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user