<?php

namespace App\Models\Tenants;

use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class JournalEntryLine extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'tenant_id',
        'journal_entry_id',
        'line_no',
        'dc_type',
        'account_code',
        'account_name',
        'trading_partner_id',
        'trading_partner_name',
        'debit_amount',
        'credit_amount',
        'description',
    ];

    protected $casts = [
        'line_no' => 'integer',
        'debit_amount' => 'integer',
        'credit_amount' => 'integer',
        'trading_partner_id' => 'integer',
    ];

    // DC Type
    public const DC_DEBIT = 'debit';
    public const DC_CREDIT = 'credit';

    /**
     * 전표 관계
     */
    public function journalEntry(): BelongsTo
    {
        return $this->belongsTo(JournalEntry::class);
    }
}
