<?php

namespace App\Modules\Inventory\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class GoodsReceiptItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'goods_receipt_id',
        'product_id',
        'purchase_order_item_id',
        'quantity_received',
        'unit_price',
        'total_amount',
        'batch_number',
        'expiry_date',
    ];

    protected $casts = [
        'quantity_received' => 'decimal:2',
        'unit_price' => 'decimal:2', // 暫定價格
        'total_amount' => 'decimal:2',
        'expiry_date' => 'date:Y-m-d',
    ];

    public function goodsReceipt()
    {
        return $this->belongsTo(GoodsReceipt::class);
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }
}
