<?php

namespace App\Domain\Pricing\Enums;

/**
 * Fixed reason list for the governed manual discount.
 *
 * Replaces the free-text override reason, which could not be reported on.
 */
enum ManualDiscountReason: string
{
    case Hardship   = 'hardship';
    case Staff      = 'staff';
    case Goodwill   = 'goodwill';
    case Complaint  = 'complaint';
    case Management = 'management';
    case Correction = 'correction';

    public function label(): string
    {
        return match ($this) {
            self::Hardship   => 'حالة اجتماعية',
            self::Staff      => 'موظف أو قريب موظف',
            self::Goodwill   => 'بادرة حسن نية',
            self::Complaint  => 'تعويض عن شكوى',
            self::Management => 'قرار إداري',
            self::Correction => 'تصحيح خطأ تسعير',
        };
    }

    /** Reasons that always need a written note regardless of amount. */
    public function requiresNote(): bool
    {
        return in_array($this, [self::Management, self::Correction, self::Complaint]);
    }

    public static function options(): array
    {
        return array_map(
            fn (self $c) => ['value' => $c->value, 'label' => $c->label(), 'note' => $c->requiresNote()],
            self::cases()
        );
    }
}
