package com.engine.salary.report.enums;

import com.engine.salary.enums.BaseEnum;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;


/**
 * 应税项目
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum IncomeCategoryEnum implements BaseEnum<Integer> {

    WAGES_AND_SALARIES(1, "正常工资薪金", 160487),
    REMUNERATION_FOR_LABOR(4, "一般劳务报酬所得", 160488),
    ONETIME_ANNUAL_BONUS(2,"全年一次性奖金收入", 160489),
    COMPENSATION_FOR_RETIRE(107,"内退一次性补偿金",0),
    COMPENSATION_FOR_DISMISS(108,"解除劳动合同一次性补偿金", 0),
    INCOME_FOR_INDIVIDUAL_EQUITY_INCENTIVE(109,"个人股权激励收入",0),
    ANNUITY_RECEIPT(110,"年金领取",0),
    INCOME_FOR_INSURANCE_SALESMAN(402,"保险营销员佣金收入",0),
    INCOME_FOR_SECURITIES_BROKER(403,"证券经纪人佣金收入",0),
    REMUNERATION_FOR_OTHER_CONTINUOUS_LABOR(489,"其他连续劳务报酬所得",0),
    REMUNERATION_FOR_OTHER_LABOR(499,"其他非连续劳务报酬所得",0),
    REMUNERATION_FOR_AUTHOR(500,"稿酬所得",0),
    ROYALTIES(600,"特许权使用费所得",0),
    ;

    private int value;

    private String defaultLabel;

    private int labelId;

    IncomeCategoryEnum(int value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    public static IncomeCategoryEnum parseByValue(int value) {
        for (IncomeCategoryEnum incomeCategoryEnum : IncomeCategoryEnum.values()) {
            if (Objects.equals(incomeCategoryEnum.getValue(), value)) {
                return incomeCategoryEnum;
            }
        }
        return null;
    }

    public static List<IncomeCategoryEnum> parseByValue(Collection<Integer> values) {
        if (CollectionUtils.isEmpty(values)) {
            return Collections.emptyList();
        }
        List<IncomeCategoryEnum> incomeCategoryEnums = Lists.newArrayListWithExpectedSize(values.size());
        for (Integer value : values) {
            for (IncomeCategoryEnum incomeCategoryEnum : IncomeCategoryEnum.values()) {
                if (Objects.equals(incomeCategoryEnum.getValue(), value)) {
                    incomeCategoryEnums.add(incomeCategoryEnum);
                }
            }
        }
        return incomeCategoryEnums;
    }
}
