<?php

namespace App\Models;

use App\Models\Concerns\BranchScoped;

use Illuminate\Database\Eloquent\Model;

class SalesReturn extends Model
{
    use BranchScoped;
    protected $fillable = ['return_no', 'sale_id', 'customer_id', 'warehouse_id', 'branch_id', 'financial_year_id', 'return_date', 'taxable_total', 'vat_total', 'grand_total', 'reason', 'status', 'created_by', 'finalized_by', 'finalized_at'];
    protected $casts = ['return_date' => 'date', 'finalized_at' => 'datetime', 'taxable_total' => 'decimal:2', 'vat_total' => 'decimal:2', 'grand_total' => 'decimal:2'];
    public function sale() { return $this->belongsTo(Sale::class); }
    public function customer() { return $this->belongsTo(Customer::class); }
    public function warehouse() { return $this->belongsTo(Warehouse::class); }
    public function items() { return $this->hasMany(SalesReturnItem::class); }
}
