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 DigitalInvoiceTypeEnum implements IntArrayValuable {
    DIGITAL_SPECIAL(1, "数电专用发票","001"),
    DIGITAL_ORDINARY(0, "数电普通发票","002");

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

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

    private final String code;

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

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