package com.brilliance.isc.common.liaallg.vo;

import com.brilliance.mda.runtime.mda.CodetableItem;
import com.brilliance.mda.runtime.mda.IStream;
import com.brilliance.mda.runtime.mda.impl.StreamImpl;
import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.mda.support.jakson.serialize.BigDecimalSerializeRate;
import com.brilliance.mda.support.jakson.serialize.DecimalLength;
import com.brilliance.isc.bo.Fee;
import com.brilliance.isc.common.liaone.vo.AcpliaVo;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.FecVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;
@Data
@ApiModel(value = "负债信息", description = "负债信息")
@JsonIgnoreProperties(ignoreUnknown = true)
public class LiaallgVo extends AbstractCommonVo implements Serializable {
    private static Logger log = LoggerFactory.getLogger(LiaallgVo.class);

    @ApiModelProperty(value = "", name = "oldamt", required = true)
    private BigDecimal oldamt = Decimals.ZERO_SCALE2;

    //Old Additional Amount Part
    private BigDecimal oldamt2 = Decimals.ZERO_SCALE2;

    @ApiModelProperty(value = "", name = "amt", required = true)
    private BigDecimal amt = Decimals.ZERO_SCALE2;

    @ApiModelProperty(value = "", name = "amt2", required = true)
    private BigDecimal amt2 = Decimals.ZERO_SCALE2;

    @ApiModelProperty(value = "", name = "tenpct", required = true)
    @JsonSerialize(using = BigDecimalSerializeRate.class)
    @DecimalLength(2)
    private BigDecimal tenpct = Decimals.ZERO_SCALE6;

    @ApiModelProperty(value = "", name = "amtchgflg", required = true)
    private String amtchgflg = NULLSTR;

    @ApiModelProperty(value = "", name = "objmodpath", required = true)
    private String objmodpath = NULLSTR;

    @ApiModelProperty(value = "Liability Group", name = "grpkey", required = true)
    private String grpkey = NULLSTR;

    @ApiModelProperty(value = "", name = "rol", required = true)
    private String rol = NULLSTR;

    @ApiModelProperty(value = "", name = "cdtrol", required = true)
    private String cdtrol = NULLSTR;

    @ApiModelProperty(value = "", name = "bussec", required = true)
    private String bussec = NULLSTR;

    @ApiModelProperty(value = "", name = "trntyp", required = true)
    private String trntyp = NULLSTR;

    @ApiModelProperty(value = "", name = "nam", required = true)
    private String nam = NULLSTR;

    @ApiModelProperty(value = "", name = "acc", required = true)
    private String acc = NULLSTR;

    @ApiModelProperty(value = "", name = "acc2", required = true)
    private String acc2 = NULLSTR;

    @ApiModelProperty(value = "", name = "extamt", required = true)
    private BigDecimal extamt = Decimals.ZERO_SCALE2;

    @ApiModelProperty(value = "", name = "cur", required = true)
    private String cur = NULLSTR;

    @ApiModelProperty(value = "", name = "cbtpfx", required = true)
    private String cbtpfx = NULLSTR;

    @ApiModelProperty(value = "", name = "cbtpfxlst", required = true)
    private String cbtpfxlst = NULLSTR;

    @ApiModelProperty(value = "", name = "oldflg", required = true)
    private String oldflg = NULLSTR;

    @ApiModelProperty(value = "", name = "liaptyinr", required = true)
    private String liaptyinr = NULLSTR;

    @ApiModelProperty(value = "", name = "matdat", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date matdat;

    @ApiModelProperty(value = "", name = "tenday", required = true)
    private int tenday;

    @ApiModelProperty(value = "", name = "valdat", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date valdat;

    @ApiModelProperty(value = "", name = "setdatold", required = true)
    private Date setdatold;

    //Default Feecode
    private String dftfeecod = NULLSTR;

    //Cover Flag to be added
    private  String feecodaddcov = NULLSTR;

    @ApiModelProperty(value = "", name = "feecod", required = true)
    private String feecod = NULLSTR;

    private Date feecodExpdat = null;

    private String tilmat = NULLSTR;

    private String feeinccod = NULLSTR;

    private BigDecimal setmodFactory = BigDecimal.ZERO;

    @ApiModelProperty(value = "", name = "feehndidx", required = true)
    private int feehndidx;

    @ApiModelProperty(value = "", name = "extid", required = true)
    private String extid = NULLSTR;

    @ApiModelProperty(value = "", name = "covtyp", required = true)
    private String covtyp = NULLSTR;

    @ApiModelProperty(value = "", name = "fecold", required = true)
    private IStream fecold = new StreamImpl();

    //List of condition records condition is calculated of
    private  IStream feclst = new StreamImpl();

    private BigDecimal extoldamt = Decimals.ZERO_SCALE2;

    private AcpliaVo acplia = null;

    private FecVo fec = null;

    private Fee fee = null;

    private Fee wrkfee = null;

    private PtegrpVo ptegrp = null;

    /**
     * 前端rol的下拉列表
     */
    private List<CodetableItem> dbtrolSet;

    /**
     * 前端cdtrol的下拉列表
     */
    private List<CodetableItem> cdtrolSet;

    /**
     * 前端acc的下拉列表
     * @param bussec
     */
    private Set<String> accSet;
    /**
     * 前端acc2的下拉列表
     * @param bussec
     */
    private Set<String> acc2Set;

    public void setBussec(String bussec) {
        if (acplia != null) {
            acplia.setBussec(bussec);
        }
        this.bussec = bussec;
    }

    @Override
    public void reset() {
        if (oldamt == null) {
            oldamt = Decimals.ZERO_SCALE2;
        }
        if (amt == null) {
            amt = Decimals.ZERO_SCALE2;
        }
        if (amt2 == null) {
            amt2 = Decimals.ZERO_SCALE2;
        }
        if (tenpct == null) {
            tenpct = Decimals.ZERO_SCALE6;
        }
        if (extamt == null) {
            extamt = Decimals.ZERO_SCALE2;
        }
        if (extoldamt == null) {
            extoldamt = Decimals.ZERO_SCALE2;
        }
        if (acplia == null) {
            acplia = new AcpliaVo();
        }
        acplia.reset();
        if (fec == null) {
            fec = new FecVo();
        }
        if (fee == null) {
            fee = new Fee();
        }
        if (wrkfee == null) {
            wrkfee = new Fee();
        }
        if (ptegrp == null) {
            ptegrp = new PtegrpVo();
        }
        ptegrp.reset();
        if (dbtrolSet == null) {
            dbtrolSet = new ArrayList<>();
        }
        if (cdtrolSet == null) {
            cdtrolSet = new ArrayList<>();
        }
        if (accSet == null) {
            accSet = new HashSet<>();
        }
        if (acc2Set == null) {
            acc2Set = new HashSet<>();
        }
    }

}
