<?php

namespace App\Models;

use App\Models\BaseModel;

class VoucherLine extends BaseModel
{
    protected $table = 'voucher_lines';

    protected $fillable = [
        'company_id','voucher_id','line_number','account_id','item_id',
        'description','quantity','uom_id','unit_price',
        'discount_percent','discount_amount',
        'tax_code_id','tax_rate','tax_amount',
        'line_total','foreign_amount','dr_cr',
        'party_id','party_type',
        'dim1_id','dim2_id','dim3_id','dim4_id','dim5_id','dim6_id','dim7_id',
    ];

    protected $casts = [
        'quantity'         => 'decimal:4',
        'unit_price'       => 'decimal:6',
        'discount_percent' => 'decimal:4',
        'discount_amount'  => 'decimal:2',
        'tax_rate'         => 'decimal:4',
        'tax_amount'       => 'decimal:2',
        'line_total'       => 'decimal:2',
        'foreign_amount'   => 'decimal:2',
    ];

    public function company()   { return $this->belongsTo(Company::class); }
    public function voucher()   { return $this->belongsTo(Voucher::class); }
    public function item()      { return $this->belongsTo(Item::class); }
    public function account()   { return $this->belongsTo(Account::class); }
    public function uom()       { return $this->belongsTo(Uom::class); }
    public function taxCode()   { return $this->belongsTo(TaxCode::class); }
}
