package com.haha.common.enums;

public enum InvoiceType {

    SPECIAL("SPECIAL", "增值税专票"),
    NORMAL("NORMAL", "增值税普票");

    private final String code;
    private final String description;

    InvoiceType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static InvoiceType fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (InvoiceType invoiceType : values()) {
            if (invoiceType.code.equals(code)) {
                return invoiceType;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        InvoiceType invoiceType = fromCode(code);
        return invoiceType != null ? invoiceType.description : "未知";
    }
}
