<?php

namespace Modules\Accounts\Enums;

enum AcctVoucherTypeEnum: string
{
    case JOURNAL = 'journal';            // Non-cash/non-bank adjusting adjustments and corrections
    case PURCHASE = 'purchase';         // Credit purchase of goods or inventory items
    case SALES = 'sales';              // Credit sale of goods or inventory items
    case PAYMENT = 'payment';         // Cash or bank outflows (paying expenses, suppliers, etc.)
    case PURCHASE_RETURN = 'purchase_return'; // Returning purchased goods back to the supplier (Debit Note)
    case SALES_RETURN = 'sales_return';      // Receiving returned goods back from a customer (Credit Note)
    case RECEIPT = 'receipt';               // Cash or bank inflows (receiving payments from clients, etc.)
    case CONTRA = 'contra';                // Internal bank-to-cash or bank-to-bank fund transfers
    case OPENING = 'opening';             // System initialization migration balances (First-time setup entries)
    case DEPRECIATION = 'depreciation';  // Fixed asset monthly/yearly value reduction tracking
    case REVERSING = 'reversing';       // Direct automated voiding/cancellation of accidental historical entries

    public static function casesAsArray(): array
    {
        return array_map(fn(self $case) => $case->value, self::cases());
    }

    public function label(): string
    {
        return match ($this) {
            self::JOURNAL => 'Journal',
            self::PURCHASE => 'Purchase',
            self::SALES => 'Sales',
            self::PAYMENT => 'Payment',
            self::PURCHASE_RETURN => 'Purchase Return',
            self::SALES_RETURN => 'Sales Return',
            self::RECEIPT => 'Receipt',
            self::CONTRA => 'Contra',
            self::OPENING => 'Opening',
            self::DEPRECIATION => 'Depreciation',
            self::REVERSING => 'Reversing',
        };
    }

    public function prefix(): string
    {
        return match ($this) {
            self::JOURNAL => 'JV',
            self::PURCHASE => 'PRV',
            self::SALES => 'SV',
            self::PAYMENT => 'PV',
            self::PURCHASE_RETURN => 'PRTV',
            self::SALES_RETURN => 'SRV',
            self::RECEIPT => 'RV',
            self::CONTRA => 'CV',
            self::OPENING => 'OV',
            self::DEPRECIATION => 'DV',
            self::REVERSING => 'REV',
        };
    }
}
