package com.ruoyi.warehouseBusiness.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author caifc
 * @date 2021-10-22 17:19
 */
@Getter
@AllArgsConstructor
public enum FeesTypeEnum {

    // 费用状态
    INIT("1", "新建"),
    SAVE("2", "保存"),
    DISMISS("3", "请核驳回"),
    SUBMIT("4", "请核"),
    UNDER_REVIEW("5", "请核中"),
    APPROVE("6", "请核完成"),

    // 收款、付款
    D("D", "收款"),
    C("C", "付款"),


    // 费用变更来源类型

    MANUAL_ENTRY("0", "手动录入"),
    PROTOCOL_IMPORT("1", "协议导入"),
    BOOKING("2", "凯和订舱"),
    FEE_CHANGES("10", "费用变更"),

    // 类型
    CHARGE("SF", "收费"),
    CHARGE_REVOKE("SFRevoke", "撤销收费"),
    CONTRAST("DZ", "对账"),
    CONTRAST_REVOKE("DZRevoke", "撤销对账"),
    PAYMENT("FF", "付费"),
    PAYMENT_REVOKE("FFRevoke", "撤销付费"),
    INVOICE("FP", "发票"),
    INVOICE_REVOKE("FPRevoke", "撤销发票"),

    ;

    private final String type;
    private final String name;

    public static FeesTypeEnum fromType(String tp) {
        for (FeesTypeEnum type : FeesTypeEnum.values()) {
            if (Objects.equals(type.getType(), tp)) {
                return type;
            }
        }
        throw new IllegalArgumentException("fees type not exist");
    }

    /**
     * 是否能删除
     *
     * @return
     */
    public boolean isDelete() {
        return this.getType().equals(INIT.type) || this.getType().equals(SAVE.type) ||
                this.getType().equals(DISMISS.type);
    }

}
