<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class TradeDocumentPayment extends Model {
    use SoftDeletes;
    protected $guarded=['id'];
    protected $casts=['paid_at'=>'datetime','receipt_issued_at'=>'datetime','corrected_at'=>'datetime','voided_at'=>'datetime','reconciled_at'=>'datetime'];
    public function document(){return $this->belongsTo(TradeDocument::class,'trade_document_id');}
    public function parentPayment(){return $this->belongsTo(self::class,'parent_payment_id');}
    public function adjustments(){return $this->hasMany(self::class,'parent_payment_id');}
    public function recorder(){return $this->belongsTo(User::class,'recorded_by');}
    public function corrector(){return $this->belongsTo(User::class,'corrected_by');}
    public function voider(){return $this->belongsTo(User::class,'voided_by');}
    public function reconciler(){return $this->belongsTo(User::class,'reconciled_by');}
}
