<?php

declare(strict_types=1);

namespace App\Support;

use App\Business\Purchase\Enums\PurchaseRequestStatus;
use App\Business\Sales\Enums\SalesQuoteStatus;
use App\Business\Settlement\Enums\SettlementAdjustmentStatus;
use App\Business\Settlement\Enums\SettlementStatementStatus;
use App\Business\Settlement\Enums\SettlementWriteOffStatus;

final class DberpDocumentQueryPresentation
{
    public static function statusLabel(string $documentType, ?string $status): string
    {
        if ($status === null || $status === '') {
            return '—';
        }

        $options = match ($documentType) {
            'purchase_request' => PurchaseRequestStatus::options(),
            'sales_quote' => SalesQuoteStatus::options(),
            'settlement_write_off' => SettlementWriteOffStatus::options(),
            'settlement_statement' => SettlementStatementStatus::options(),
            'settlement_adjustment' => SettlementAdjustmentStatus::options(),
            default => __('dberp.options.common_document_status'),
        };

        if (is_array($options)) {
            return $options[$status] ?? $status;
        }

        return $status;
    }
}
