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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发票抬头类型枚举，与 {@code app_invoice_title.title_type} 一致。
 *
 * @author jeesharp
 * @since 2026-06-12
 */
@Getter
@AllArgsConstructor
public enum InvoiceTitleTypeEnum {

    /** 个人 */
    PERSONAL("personal", "个人"),

    /** 企业 */
    COMPANY("company", "企业");

    private final String value;
    private final String desc;

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

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