package com.tmerclub.cloud.common.constant;

import java.util.Objects;

/**
 * 采购金额类型
 * @author gaozijie
 * @date 2023-08-28
 */
public enum PurchaseAmountType {
    /**
     * 作废
     */
    CANCEL(-1, "采购作废金额", "采购作废金额"),
    /**
     * 收入/支出
     * 对商家来说是“支出”
     * 对供应商来说是“收入”
     */
    IN_OR_OUT(0, "采购支出金额", "采购收入金额");

    private final int value;

    private final String shopDesc;

    private final String supplierDesc;

    PurchaseAmountType(int value, String shopDesc, String supplierDesc) {
        this.value = value;
        this.shopDesc = shopDesc;
        this.supplierDesc = supplierDesc;
    }

    public int getValue() {
        return value;
    }

    public String getShopDesc() {
        return shopDesc;
    }

    public String getSupplierDesc() {
        return supplierDesc;
    }

    public static PurchaseAmountType instance(Integer value) {
        for (PurchaseAmountType type : PurchaseAmountType.values()) {
            if (Objects.equals(value, type.getValue())) {
                return type;
            }
        }
        return null;
    }
}
