<?php

namespace Modules\Accounts\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Modules\Accounts\Enums\VatSettlementEnum;
use Modules\Accounts\Models\Traits\HasAccountVouchar;
use Modules\Core\Traits\AuditableTrait;

class VatSettlement extends Model
{
    use HasAccountVouchar,
        AuditableTrait;

    protected $fillable = [
        'settlement_no',
        'from_date',
        'to_date',
        'input_vat',
        'output_vat',
        'net_vat_payable',
        'carry_forward_amount',
        'is_paid',
        'payment_date',
        'voucher_id',
        'status',
        'note',
        'created_by'
    ];

    protected $casts = [
        'from_date' => 'date',
        'to_date' => 'date',
        'payment_date' => 'date',
        'is_paid' => 'boolean',
        'status' => VatSettlementEnum::class,
        'input_vat' => 'decimal:2',
        'output_vat' => 'decimal:2',
        'net_vat_payable' => 'decimal:2',
        'carry_forward_amount' => 'decimal:2',
    ];

    public function vatTransactions(): HasMany
    {
        return $this->hasMany(VatTransaction::class, 'vat_settlement_id');
    }
}
