package com.brilliance.isc.vo.model;

import com.brilliance.mda.runtime.mda.CodetableItem;
import com.brilliance.mda.runtime.mda.util.Decimals;
import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.json.BigDecimalSerialize;
import com.brilliance.isc.common.vo.AbstractCommonVo;
import com.brilliance.isc.common.vo.PtsptaVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

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

import static com.brilliance.mda.runtime.mda.Constants.NULLSTR;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class FinmodVo extends AbstractCommonVo {

    private FinmodBizInfoVo rec;

    private Map<String, Cbb> cbsMap;

    private List<PtsptaVo> ptsptaList;
    //业务种类
    private String trntyp = NULLSTR;
    //借据号
    private String fincod = NULLSTR;
    //合同编号
    private String conref = NULLSTR;
    //计息周期
    private String intprd = NULLSTR;
    //固定周期
    private int fixprd;
    //计息日期
    private String intdat = NULLSTR;
    //利率调?'方式
    private String ratchgtyp = NULLSTR;
    //利率调?'周期
    private String ratchgprd = NULLSTR;
    //利率调?'月日数
    private String ratchgdat = NULLSTR;
    //宽限期
    private int graday;
    //浮动方式
    private String flttyp = NULLSTR;
    //浮动值
    @JsonFormat(pattern = "#0.0000000", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal fltval = Decimals.ZERO_SCALE7;
    //呆滞计息方式
    private String ovdinttyp = NULLSTR;
    //罚息比率
    @JsonFormat(pattern = "#0.00000", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal ovdintrat = Decimals.ZERO_SCALE5;
    //收息类型
    private String intflg = NULLSTR;
    //计复息标志
    private String cmpflg = NULLSTR;
    //第一还款?'?号
    private String act1 = NULLSTR;
    //第二还款?'?号
    private String act2 = NULLSTR;
    //第三方还款?'?号
    private String act3 = NULLSTR;
    //第三方还款方式
    private String acttyp = NULLSTR;
    //违约利率
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal viorat = Decimals.ZERO_SCALE7;
    //押汇种类
    private String purtyp = NULLSTR;
    //押汇编号
    private String purcod = NULLSTR;
    //信?'?柜员
    private String usr = NULLSTR;
    //放?'?部门
    private String branch = NULLSTR;
    //入?'?机构
    private String accbch = NULLSTR;
    //还款方式
    private String reptyp = NULLSTR;
    //利息付款?'?号
    private String intact = NULLSTR;
    //预收息金额
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal intamt = Decimals.ZERO_SCALE3;
    //接口操作标志
    private String itftyp = NULLSTR;
    //Percentage Label
    private String pctlab = NULLSTR;
    //预扣息方式
    private String inttyp = NULLSTR;
    //Settlement Label
    private String setlab = NULLSTR;
    //old mac
    private String oldfinmac = NULLSTR;
    //new mac
    private String newfinmac = NULLSTR;
    //是否到期主动扣收款
    private String wjdkfl = NULLSTR;
    //定价审批代码
    private String dinjdm = NULLSTR;
    //定价接口开关
    private String opnflg = NULLSTR;
    //税率
    @JsonFormat(pattern = "#0.0000", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal shuilv = Decimals.ZERO_SCALE4;
    //经办机构
    private String actbch = NULLSTR;

    private DinmodVo dinmod;

    private FincbsVo cbs;

    private Set<String> disableSet;

    private Set<String> act1Set = null;

    private Set<String> intactSet = null;

    private List<CodetableItem> accbchSet = null;

    public void resetEnabled(String field) {
        if (disableSet == null) {
            disableSet = new HashSet<>();
        }
        disableSet.add(field);
    }

    public void setEnabled(String field) {
        if (disableSet == null) {
            disableSet = new HashSet<>();
        }
        disableSet.remove(field);
    }

    @Override
    public void reset() {
        if (rec == null) {
            rec = new FinmodBizInfoVo();
        }
        if (cbsMap == null) {
            cbsMap = new HashMap<>();
        }
        if (ptsptaList == null) {
            ptsptaList = new ArrayList<>();
        }
        if (dinmod == null) {
            dinmod = new DinmodVo();
        }
        if (cbs == null) {
            cbs = new FincbsVo();
        }
        cbs.reset();
        if (act1Set == null) {
            act1Set = new HashSet<>();
        }
        if (intactSet == null) {
            intactSet = new HashSet<>();
        }
        if (accbchSet == null) {
            accbchSet = new ArrayList<>();
        }
    }
}
