package com.jeesharp.business.modules.finance.invoice.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发票申请状态枚举，与 {@code app_member_invoice_apply.status} 一致。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@Getter
@AllArgsConstructor
public enum MemberInvoiceApplyStatusEnum {

    /** 待审核 */
    PENDING("pending", "待审核"),

    /** 已开票 */
    APPROVED("approved", "已开票"),

    /** 已驳回 */
    REJECTED("rejected", "已驳回");

    private final String value;
    private final String desc;

    public static MemberInvoiceApplyStatusEnum fromValue(String value) {
        if (value == null || value.isBlank()) {
            return null;
        }
        for (MemberInvoiceApplyStatusEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(String value) {
        MemberInvoiceApplyStatusEnum e = fromValue(value);
        return e != null ? e.getDesc() : value != null ? value : "";
    }
}
