<?php

namespace App\Models;

use App\Models\BaseModel;

class LedgerEntry extends BaseModel
{
    protected $table = 'ledger_entries';

    protected $fillable = [
        'company_id','fiscal_year_id','account_id','voucher_id','voucher_line_id',
        'entry_date','debit','credit','reference','narration','party_id','party_type',
        'bank_reconciliation_id',
    ];

    protected $casts = [
        'entry_date' => 'date',
        'debit'      => 'decimal:2',
        'credit'     => 'decimal:2',
        'reconciled_at' => 'datetime',
    ];

    public function company()     { return $this->belongsTo(Company::class); }
    public function fiscalYear()  { return $this->belongsTo(FiscalYear::class); }
    public function account()     { return $this->belongsTo(Account::class); }
    public function voucher()     { return $this->belongsTo(Voucher::class); }
    public function voucherLine() { return $this->belongsTo(VoucherLine::class); }
    public function bankReconciliation() { return $this->belongsTo(BankReconciliation::class); }
}
