<?php

namespace App\Models;

use App\Models\BaseModel;

class TaxCode extends BaseModel
{
    protected $fillable = [
        'company_id','code','name','rate','type','applicable_on',
        'sales_account_id','purchase_account_id','is_active',
    ];

    protected $casts = [
        'rate'      => 'decimal:4',
        'is_active' => 'boolean',
    ];

    public function company()         { return $this->belongsTo(Company::class); }
    public function salesAccount()    { return $this->belongsTo(Account::class, 'sales_account_id'); }
    public function purchaseAccount() { return $this->belongsTo(Account::class, 'purchase_account_id'); }

    public function scopeActive($q)   { return $q->where('is_active', true); }
}
