apzl_leasing/calc/com/tenwa/reckon/executor/EvenInterestChangeExecutor.java
2018-06-03 22:26:41 +08:00

74 lines
2.8 KiB
Java

package com.tenwa.reckon.executor;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.reckon.bean.ConditionBean;
import com.tenwa.reckon.bean.FundRentPlanBean;
import com.tenwa.reckon.bean.TabCalBean;
import com.tenwa.reckon.help.CorpusServiceImpl;
import com.tenwa.reckon.help.RentPlanContrCalDAOImpl;
import com.tenwa.reckon.help.RentPlanServiceImpl;
import com.tenwa.reckon.help.RentalServiceImpl;
import com.tenwa.reckon.util.NumTools;
public class EvenInterestChangeExecutor extends FundRentPlanExecutor {
public EvenInterestChangeExecutor(JBOTransaction tx) {
super(tx);
// TODO Auto-generated constructor stub
}
@Override
public FundRentPlanBean create(TabCalBean tcb,Integer startList) throws Exception {
FundRentPlanBean fpb = new FundRentPlanBean();
//均息法变更 先用财务剩余本金 和年利率 根据pmt得到财务本金和利息 业务本金=剩余业务本金/期数 利息=租金-本金
EvenRentExecutor executor = new EvenRentExecutor(tx);
FundRentPlanBean frpb = new RentPlanContrCalDAOImpl().getRentAndDateByTcb(tcb, 1,tx);
String clean_lease_money=NumTools.getSumCorpusOverage(frpb.getColumn_1(),startList);
if(new BigDecimal(tcb.getCb().getRepurchaseMoney()).compareTo(BigDecimal.ZERO)!=0){//回购
clean_lease_money=NumTools.getSumCorpusOverage(frpb.getColumn_1(),startList-1);
}
//删除租金计划
executor.deleteRentPlan(tcb.getRentPlan_tb(), tcb, startList);
executor.getPmtRentPlan(tcb.getCb(), fpb,tcb);
tcb.getCb().setCleanLeaseMoney(new BigDecimal(clean_lease_money).subtract(new BigDecimal(tcb.getCb().getRepurchaseMoney())).toString());
this.rentPlanEvenInterestCal(tcb.getCb(), fpb);
this.addRentPlan(fpb, tcb,startList);
return fpb;
}
public void rentPlanEvenInterestCal(ConditionBean cb, FundRentPlanBean frpb) throws Exception {
//先找到总本金值
BigDecimal corpusTotal=new BigDecimal(cb.getCleanLeaseMoney());
List<String> interest =new ArrayList<String>();
List<String> corpus = new CorpusServiceImpl().getCorpusList(cb.getCleanLeaseMoney(), cb.getIncomeNumber(), cb.getEquipEndValue(), cb.getGrace());
List<String> rentList =frpb.getRentList();
BigDecimal c=BigDecimal.ZERO;
for(int i=0;i<corpus.size()-1;i++){
interest.add(i,new BigDecimal(rentList.get(i)).subtract(new BigDecimal(corpus.get(i))).toString());
c=c.add(new BigDecimal(corpus.get(i)));
}
corpus.set(corpus.size()-1, corpusTotal.subtract(c).toString());
interest.add(new BigDecimal(rentList.get(rentList.size()-1)).subtract(new BigDecimal(corpus.get(corpus.size()-1))).toString());
frpb.setColumn_1(corpus);
frpb.setColumn_2(interest);
List<String> rentListTemp = rentList;
List<String> rentRemainList = new RentalServiceImpl().getRentRemainList(rentListTemp);
frpb.setAllRemainRentList(rentRemainList);
}
}