package com.jwipc.finance.model.query;

import cn.hutool.core.util.StrUtil;
import com.google.common.base.Strings;
import com.jwipc.query.BasePageQuery;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * SAP入库凭证查询实体类
 * </p>
 *
 * @author likui
 * @version 1.0
 * @since 2019/12/3
 */
@Data
public class ReceiveVoucherQuery extends BasePageQuery {
    private String sort;
    private String order;
    //排除免费订单查询
    private String exclusionFlag;
    private String headUpText;
    private Integer customsType;


    /**
     * 入库凭证ID
     */
    private Long recId;
    /**
     * 入库凭证ID-集合
     */
    private List<Long> recIdList;
    /**
     * 排除入库凭证数据ID
     */
    private String alreadyExistId;
    /**
     * 排除入库凭证数据ID集合
     */
    private List<Long> alreadyExistIdList;
    /**
     * 对账单ID(后续计算剩余开票金额时排除自身)
     */
    private Long asId;
    /**
     * 供应商编码
     */
    private String supplierCode;
    private Long userId;
    private String pgCode;
    /**
     * 供应商名称
     */
    private String supplierName;
    /**
     * 收货单类型 1:材料商入库凭证 2:承运商对账凭证
     */
    private Integer receiveType;
    private String poType;
    private String poTypes;
    private List<String> poTypeList;
    /**
     * 入库凭证号
     */
    private String receiveCode;
    /**
     * 入库凭证行号
     */
    private String rowNo;
    /**
     * 凭证过账日期(起)
     */
    private String postTimeStart;
    /**
     * 凭证过账日期(起)
     */
    private String postTimeEnd;
    private String paymentExpireDateStart;
    private String paymentExpireDateEnd;
    /**
     * 公司代码
     */
    private String companyCode;
    /**
     * 工厂编码
     */
    private String factoryCode;
    /**
     * 币种
     */
    private String currencyCode;
    /**
     * 物料编码
     */
    private String materialCode;
    /**
     * 物料名称
     */
    private String materialName;
    /**
     * SAP订单号
     */
    private String poCode;
    /**
     * 订单行号
     */
    private String poItemNo;
    /**
     * 参考凭证号
     */
    private String cvCode;
    /**
     * 采购组
     */
    private String purchaseGroup;

    /**
     * 税率
     */
    private String taxCode;

    /**
     * 付款条件
     */
    private String paymentTermCode;
    private String removeLists;

    /**
     * 是否对账：-1全部 1-是 2-否
     */
    private String isReconcile;
    private Integer isAllowAccount;

    /**
     * 凭证类型
     */
    private Integer voucherType;
    private String voucherTypes;
    private Integer isSupplier;
    private List<String> voucherTypeList;

    /**
     * 新旧业务查询标识
     */
    private String businessFalg;
    /**
     * 是否允许对账标识；0-否；1-是
     */
    private Integer accountStatementFlag;
    /**
     * 是否查询重复数据；0-否；1-是
     */
    private String isSearchRepeat;
    private String entrustNo;
    private String accountUserFlag;

    public List<String> getVoucherTypeList(){
        if (StringUtils.isNotEmpty(this.voucherTypes)){
            return  Arrays.asList(StringUtils.split(this.voucherTypes, ","));
        }
        return null;
    }

    private List<String> poCodeList;
    public List<String> getPoCodeList(){
        if (StringUtils.isNotEmpty(this.poCode)){
            return  Arrays.asList(StringUtils.split(this.poCode, ","));
        }
        return null;
    }

    private List<String> materialCodeList;
    public List<String> getMaterialCodeList(){
        if (StringUtils.isNotEmpty(this.materialCode)){
            return  Arrays.asList(StringUtils.split(this.materialCode, ","));
        }
        return null;
    }

    public String getSort(){
        if(StringUtils.isNotEmpty(this.sort)){
            return StrUtil.toUnderlineCase(this.sort);
        }
        return "";
    }

    private String type;


}
