<?php

namespace App\Models;

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

class InventoryJournalTemp extends Model
{
    use HasFactory;

    protected $table = 'inventory_journal_temps';
    
    protected $fillable = [
        'date',
        'item_id',
        'warehouse_id',
        'gl_control_account_id',
        'reference',
        'description',
        'project_id',
        'quantity_in',
        'quantity_out',
        'uom_id',
        'currency_id',
        'unit_cost',
        'status'
    ];

    protected $casts = [
        'date' => 'date',
        'quantity_in' => 'decimal:2',
        'quantity_out' => 'decimal:2',
        'unit_cost' => 'decimal:2'
    ];

    public function item()
    {
        return $this->belongsTo(PriceListingSetup::class, 'item_id');
    }

    public function warehouse()
    {
        return $this->belongsTo(Warehouse::class);
    }

    public function glAccount()
    {
        return $this->belongsTo(MainAccount::class, 'gl_control_account_id');
    }

    public function project()
    {
        return $this->belongsTo(Project::class);
    }

    public function uom()
    {
        return $this->belongsTo(Uom::class);
    }

    public function currency()
    {
        return $this->belongsTo(Currency::class);
    }
}
