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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发票类型枚举，与 {@code app_member_invoice_apply.invoice_type} 一致。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@Getter
@AllArgsConstructor
public enum MemberInvoiceApplyInvoiceTypeEnum {

    /** 个人/普通发票 */
    PERSONAL(1, "个人"),

    /** 企业发票 */
    COMPANY(2, "企业");

    private final Integer value;
    private final String desc;

    public static MemberInvoiceApplyInvoiceTypeEnum fromValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (MemberInvoiceApplyInvoiceTypeEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

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