package com.brilliance.isc.common.fecism.calcfee.helper;

import com.brilliance.isc.common.converter.DtoMapper;
import com.brilliance.isc.common.fecism.vo.CalcFeeRequest;
import com.brilliance.isc.common.setfeg.vo.SetfelVo;
import com.brilliance.isc.common.vo.FecVo;

import java.math.BigDecimal;
import java.util.Date;

public class CalcFeeRequestBuilder {

    public static CalcFeeRequest build(SetfelVo setfelVo, FecVo fecVo) {
        CalcFeeRequest request = new CalcFeeRequest();
        DtoMapper.INSTANCE.updateFecToRequest(fecVo, request);
        request.setFeecur(setfelVo.getCur());
        request.setDctamt(setfelVo.getDctamt());
        request.setUnt(setfelVo.getUnt());
        request.setFeecod(setfelVo.getFeecod());
        request.setGraceDays(setfelVo.getGraceDays());
        request.setRelcur(setfelVo.getRelcur());
        request.setRelAmt(setfelVo.getRelamt());
        request.setDat1(setfelVo.getDat1());
        request.setDat2(setfelVo.getDat2());
        request.setDat2dft(setfelVo.getDat2dft());
        request.setModflg(setfelVo.getModflg());
        request.setInftxt(setfelVo.getInftxtBegin());
        request.setCommCbsLines(setfelVo.getCommCbsLines());
        if (setfelVo.isModified("unt")) {
            request.setModflg("u");
        }
        request.setFeetxtinf(setfelVo.getFeetxtinf());
        request.setObjmod(setfelVo.getObjmod());
        request.setRoundFlag(setfelVo.getRoundFlag());
        return request;
    }

    public static CalcFeeRequest build(String cur, String feeCode, String relcur, BigDecimal relamt, Date date1, Date date2, int unt, FecVo fecVo) {
        CalcFeeRequest request = new CalcFeeRequest();
        DtoMapper.INSTANCE.updateFecToRequest(fecVo, request);
        request.setFeecur(cur);
        request.setDctamt(BigDecimal.ZERO);
        request.setUnt(unt);
        request.setFeecod(feeCode);
        request.setRelcur(relcur);
        request.setRelAmt(relamt);
        request.setDat1(date1);
        request.setDat2(date2);
        return request;
    }
}
