<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ShopInvoiceReturn extends Model
{
    protected $table = 'shop_invoice_returns';

    protected $fillable = [
        'shop_id',
        'code',
        'contact_code',
        'invoice_code',
        'branch_code',
        'total_amount',
        'return_date',
        'status',
        'return_reason',
        'local_db_created_at',
        'tax_rate',
        'tax_amount',
        'is_tax_inclusive',
    ];

    protected $casts = [
        'total_amount' => 'decimal:2',
        'tax_rate' => 'decimal:2',
        'tax_amount' => 'decimal:2',
        'is_tax_inclusive' => 'boolean',
        'return_date' => 'date',
        'local_db_created_at' => 'datetime',
    ];

    public function items()
    {
        return $this->hasMany(ShopInvoiceReturnItem::class, 'invoice_return_code', 'code');
    }
}
