<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class BatchDeduction extends Model
{
    protected $fillable = [
        'production_batch_id',
        'order_id',
        'order_item_id',
        'weight_grams',
        'scoop_count',
        'cost_amount',
        'notes',
    ];

    protected $casts = [
        'weight_grams' => 'decimal:2',
        'scoop_count' => 'integer',
        'cost_amount' => 'decimal:2',
    ];

    /**
     * Get the production batch for this deduction
     */
    public function productionBatch(): BelongsTo
    {
        return $this->belongsTo(ProductionBatch::class);
    }

    /**
     * Get the order for this deduction
     */
    public function order(): BelongsTo
    {
        return $this->belongsTo(Order::class);
    }

    /**
     * Get the order item for this deduction
     */
    public function orderItem(): BelongsTo
    {
        return $this->belongsTo(OrderItem::class);
    }
}
