<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use App\Models\Concerns\Auditable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Expense extends Model
{
    use Auditable, BelongsToTenant, SoftDeletes;

    public const CATEGORIES = [
        'salary' => 'Salariu',
        'purchase' => 'Achiziție piese',
        'rent' => 'Chirie',
        'utilities' => 'Utilități',
        'advance' => 'Avans',
        'tax' => 'Taxe',
        'fuel' => 'Combustibil',
        'tools' => 'Scule / consumabile',
        'marketing' => 'Marketing',
        'other' => 'Altele',
    ];

    public const METHODS = [
        'cash' => 'Numerar',
        'card' => 'Card',
        'transfer' => 'Virament',
        'mobile' => 'Mobile pay',
    ];

    protected $fillable = [
        'company_id', 'supplier_id', 'purchase_id', 'user_id',
        'paid_at', 'category', 'name', 'amount', 'method', 'reference', 'notes',
    ];

    protected $casts = [
        'paid_at' => 'date',
        'amount' => 'decimal:2',
    ];

    public function supplier(): BelongsTo
    {
        return $this->belongsTo(Supplier::class);
    }

    public function purchase(): BelongsTo
    {
        return $this->belongsTo(Purchase::class);
    }
}
