<?php

namespace App\Domain\Expenses\Enums;

/** Vendor bill status (§44). */
enum BillStatus: string
{
    case Draft = 'draft';
    case PendingApproval = 'pending_approval';
    case Approved = 'approved';
    case PartiallyPaid = 'partially_paid';
    case Paid = 'paid';
    case Cancelled = 'cancelled';

    public function label(): string
    {
        return match ($this) {
            self::Draft => 'Draft',
            self::PendingApproval => 'Pending Approval',
            self::Approved => 'Approved',
            self::PartiallyPaid => 'Partially Paid',
            self::Paid => 'Paid',
            self::Cancelled => 'Cancelled',
        };
    }

    public function isEditable(): bool
    {
        return in_array($this, [self::Draft, self::PendingApproval], true);
    }

    public function acceptsPayment(): bool
    {
        return in_array($this, [self::Approved, self::PartiallyPaid], true);
    }

    /** Whether the bill is owed to the vendor right now. */
    public function isOutstanding(): bool
    {
        return in_array($this, [self::Approved, self::PartiallyPaid], true);
    }

    /** @return array<int, string> */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
