<?php

namespace App\Models;

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

class AccountingVoucher extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts = [
        'source_id' => 'integer',
        'source_fingerprint' => 'string',
        'voucher_date' => 'date',
        'total_debit' => 'float',
        'total_credit' => 'float',
        'created_by_admin_id' => 'integer',
        'voided_by_admin_id' => 'integer',
        'voided_at' => 'datetime',
    ];

    public function lines()
    {
        return $this->hasMany(AccountingVoucherLine::class, 'voucher_id');
    }
}
