<?php

namespace Modules\LandedCost\Entities;

use Illuminate\Database\Eloquent\Model;
use App\PurchaseLine;

class LcExpenseDistribution extends Model
{
    protected $table = 'lc_expense_distributions';

    protected $fillable = [
        'lc_expense_id',
        'purchase_line_id',
        'product_id',
        'distribution_ratio',
        'allocated_amount',
        'allocated_base_amount',
        'is_custom',
    ];

    protected $casts = [
        'distribution_ratio'    => 'decimal:6',
        'allocated_amount'      => 'decimal:4',
        'allocated_base_amount' => 'decimal:4',
        'is_custom'             => 'boolean',
    ];

    public function expense()
    {
        return $this->belongsTo(LcExpense::class, 'lc_expense_id');
    }

    public function purchaseLine()
    {
        return $this->belongsTo(PurchaseLine::class, 'purchase_line_id');
    }
}
