<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OwnerBillReport extends Model
{
    use ModelLogChanging;

   protected $fillable = [
       "owner_id",       //项目ID
       "counting_month", //结算月
       "work_fee",       //操作费
       "logistic_fee",   //物流费
       "storage_fee",    //仓储费
       "confirm_fee",    //确认账单金额
       "difference",     //差额
       "confirmed",      //确认状态
       "other_fee",      //其他费用
       "storage_tax_fee",//仓储税费
       "other_tax_fee",  //其他税费
   ];
   protected $appends=[
        "initial_fee"
   ];
   public $timestamps=false;

   public function owner()
   {   //货主
       return $this->hasOne(Owner::class,"id","owner_id");
   }

    /* 结算月格式转换，仅截取至月
     * 引用：CreateOwnerReport
     */
    public function getCountingMonthAttribute($value)
    {
        return substr($value,0,7);
    }
    public function getInitialFeeAttribute()
    {   //初始账单金额
        return $this->work_fee + $this->logistic_fee + $this->storage_fee + $this->other_fee;
    }
}
