package com.yc.ship.module.trade.enums.invoice;

import com.yc.ship.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 发票种类代码
 *
 * @author le'yang
 */
@RequiredArgsConstructor
@Getter
public enum InvoiceTypeEnum implements IntArrayValuable {
    ORDINARY(0, "增值税普通发票","02"),
    SPECIAL(1, "增值税专用发票","01");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(InvoiceTypeEnum::getType).toArray();

    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 名称
     */
    private final String name;

    private final String code;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static InvoiceTypeEnum valueOf(Integer type){
        return Arrays.stream(InvoiceTypeEnum.values()).filter(item->item.type.equals(type)).findFirst().get();
    }
}
