<?php

namespace App\Models;

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

class SalesReceiptItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'sales_receipt_id',
        'product_id',
        'income_account_id', // Added for financial mapping
        'expense_account_id', // Added for financial mapping
        'asset_account_id', // Added for financial mapping
        'description',
        'qty',
        'rate',
        'amount',
        'tax_amount'
    ];

    /**
     * Relationship: The parent receipt.
     */
    public function salesReceipt()
    {
        return $this->belongsTo(SalesReceipt::class);
    }

    /**
     * Relationship: The product linked to this line.
     */
    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    /**
     * Relationship: The specific Income Account credited for this line.
     */
    public function incomeAccount()
    {
        return $this->belongsTo(Account::class, 'income_account_id');
    }
}