该类为 bidFinance r
//财务预算
function initBidFinance(){
var bidFinanceBody;
if ('' != '${formObj.bidFinance}') {
var bidFinance = JSON.parse('${formObj.bidFinance}');
var bidFinanceSum=formatNum((bidFinance.generalInvoice1==null?0:bidFinance.generalInvoice1)+
(bidFinance.specialInvoice1==null?0:bidFinance.specialInvoice1)+
(bidFinance.generalInvoice2==null?0:bidFinance.generalInvoice2)+
(bidFinance.specialInvoice2==null?0:bidFinance.specialInvoice2)+
(bidFinance.buildingInvoice==null?0:bidFinance.buildingInvoice)+
(bidFinance.softSaleInvoice==null?0:bidFinance.softSaleInvoice)+
(bidFinance.tecDeveInvoice==null?0:bidFinance.tecDeveInvoice)+
(bidFinance.takeUpInterest==null?0:bidFinance.takeUpInterest));
bidFinanceBody = $(".table.bidDetail1").find(".bidFinance1");
bidFinanceBody.find(".bidFinance").text(bidFinanceSum);
}
}
if(null!=bidFinance)
formObj.put("budget_sum_finance", formatDouble((bidFinance.getEighthSum())) + formatDouble(bidFinance.getNinthSum()));
else {
formObj.put("budget_sum_finance", "");
}
它们的定义分别是
private Double takeUpInterest; // 预算7--资金占用利息
private Double eighthSum; // 预算7——合计
private Double generalInvoice1; // 预算8——票种为增值税普通发票17%--金额
private Double specialInvoice1; // 预算8——票种为增值税专用发票17%--金额
private Double generalInvoice2; // 预算8——票种为增值税普通发票6%--金额
private Double specialInvoice2; // 预算8——票种为增值税专用发票6%--金额
private Double buildingInvoice; // 预算8——票种为建筑安装业发票--金额
private Double softSaleInvoice; // 预算8——票种为自主软件销售增值税发票--金额
private Double tecDeveInvoice; // 预算8——票种为技术开发发票--金额
private Double ninthSum; // 预算8——合计
也就是 资金占用利息takeUpInterest+税费 tecDeveInvoice
资金占用利息计算
//财务预算-占用利息计算
Double interest = this.sortAndCalculate(this.getAllFundUsedEdit(bid));
bidFinance.setTakeUpInterest(interest);
bidFinance.setEighthSum(interest);
bidFinance.setNinthSum(generalInvoice1 + specialInvoice1 + generalInvoice2 + specialInvoice2 + buildingInvoice + softSaleInvoice + tecDeveInvoice);
bidFinance.setCreatedTime(new Date());
bidFinance.setDeletedFlag(EDeletedFlag.NOT_DELETED);
bidFinanceEditService.save(bidFinance);
bidFinance.setEighthSum(interest);
计算占用利息总和
/**
* 计算占用利息总和
* @param fundsUsedList
* @return
* @throws IOException
*/
@SuppressWarnings("resource")
public Double sortAndCalculate(List fundsUsedList) throws IOException {
Double sumInterest = 0.0;
if (null == fundsUsedList || fundsUsedList.size() <= 0) {
return sumInterest;
}
//按日期降序排列
Collections.sort(fundsUsedList);
//颠倒顺序
Collections.reverse(fundsUsedList);
//对每一条预算金额计算占用金额及占用利息
for (int i = 0; i < fundsUsedList.size(); i++) {
TFundsUsed fundsUsed = fundsUsedList.get(i);
//当只有一条记录或是最后一条记录 占用金额、利息为空
if (1 == fundsUsedList.size() || i == fundsUsedList.size() - 1) {
fundsUsed.setOccuDays(0);
fundsUsed.setOccuMoney(0.0);
fundsUsed.setInterest(0.0);
} else if (0 == i) {
TFundsUsed nextFundsUsed = fundsUsedList.get(i + 1);
int occuDays = DateMethod.calInterval(fundsUsed.getTime(), nextFundsUsed.getTime(), "d"); //占用天数
Double interest = occuDays * fundsUsed.getMoney() / 365 * 0.1;
fundsUsed.setOccuDays(occuDays);
fundsUsed.setOccuMoney(fundsUsed.getMoney());
fundsUsed.setInterest(interest);
} else {
//
TFundsUsed preFundsUsed = fundsUsedList.get(i - 1);
// BEGIN UPDATE BY TANNC 2015-06-17 20:42:33 相邻的日期
TFundsUsed nextFundsUsed = fundsUsedList.get(i + 1);
// TFundsUsed nextFundsUsed = fundsUsedList.get(i);
// END UPDATE BY TANNC 2015-06-17 20:42:46 相邻的日期
int occuDays = DateMethod.calInterval(fundsUsed.getTime(), nextFundsUsed.getTime(), "d"); //占用天数
Double occuMoney = preFundsUsed.getOccuMoney() + fundsUsed.getMoney(); //占用资金金额
Double interest = occuDays * occuMoney / 365 * 0.1;
fundsUsed.setOccuDays(occuDays);
fundsUsed.setOccuMoney(occuMoney);
fundsUsed.setInterest(interest);
}
}
//
int lastBuyIdx=0;
for (int lk = fundsUsedList.size() - 1; lk > -1; lk--) {
TFundsUsed fundsUsed = fundsUsedList.get(lk);
// 最后一笔采购款的位置 支付款
if (4 == fundsUsed.getCapitalNature()||1==fundsUsed.getCapitalNature()) {
lastBuyIdx=lk;
break;
}
// END UPDATE BY TANNC 2015-06-18 9:46:33 资金性质是 收回回款
}
//当收回最后一笔货款(进度款),并且“占用资金金额为负数时”,不予以计算负利息。
for (int j = fundsUsedList.size() - 1; j > -1; j--) {
TFundsUsed fundsUsed = fundsUsedList.get(j);
// BEGIN UPDATE BY TANNC 2015-06-18 9:45:57 资金性质是 收回回款
if (3 == fundsUsed.getCapitalNature()) {
// 不是同一天
String lastBuyDate=null;
String lastPayDate=null;
if(fundsUsedList.get(lastBuyIdx)!=null&&null!=fundsUsedList.get(lastBuyIdx).getTime())
{
lastBuyDate=DateFormatUtils.format(fundsUsedList.get(lastBuyIdx).getTime(), "yyyy-MM-dd");
}
if(fundsUsedList.get(j)!=null&&null!=fundsUsedList.get(j).getTime())
{
lastPayDate=DateFormatUtils.format(fundsUsedList.get(j).getTime(), "yyyy-MM-dd");
}
// 最后收回货款和最后支付时同一天
if(null!=lastBuyDate&&null!=lastPayDate&&lastPayDate.equals(lastBuyDate)){
if(j>lastBuyIdx)
lastBuyIdx=j;
int lastCount=lastBuyIdx;
//查找最后一位
for (int li=lastBuyIdx; li < fundsUsedList.size(); li++) {
TFundsUsed lastFund = fundsUsedList.get(li);
if(null!=lastFund&&null!=lastFund.getTime()&&lastPayDate.equals(DateFormatUtils.format(lastFund.getTime(), "yyyy-MM-dd"))){
// 最后一个相同的日期
lastCount=li;
}
}
//如果最后一笔是负数则清空
if(null!=fundsUsedList.get(lastCount)&&null!=fundsUsedList.get(lastCount).getMoney()&&fundsUsedList.get(lastCount).getOccuMoney()<0){
fundsUsedList.get(lastCount).setInterest(0.0);
}
// 清空收回货款之后的全部数据的利息
for (int lastP = fundsUsedList.size() - 1; lastP > lastCount; lastP--) {
TFundsUsed lastPfundsUsed = fundsUsedList.get(lastP);
lastPfundsUsed.setInterest(0.0);
}
}
// 支付款和收回货款 不是同一天
else{
// 收回货款之后 不存在支付采购款
if(lastBuyIdx j; lastP--) {
TFundsUsed lastPfundsUsed = fundsUsedList.get(lastP);
lastPfundsUsed.setInterest(0.0);
}
}
// 最后一笔收回货款之后存在支付款,
// 则最后一笔收回货款的资金占用利息(无论正负)都要取,支付款的资金占用利息都要算,
// 最后一笔支付款之后的所有收回款的资金占用利息都不算(为0)
else{
for(int lstc=fundsUsedList.size() - 1;lstc>lastBuyIdx;lstc--){
TFundsUsed lstcfundsUsed = fundsUsedList.get(lstc);
lstcfundsUsed.setInterest(0.0);
}
}
break;
}
// END UPDATE BY TANNC 2015-06-18 9:46:33 资金性质是 收回回款
}
}
OutputStream out=null;
// System.out.println("============================占用金额统计=========================");
// System.out.println("====开始======================================================");
// out = new FileOutputStream(new File("C:/RESULT2.txt"));
//计算每一笔占用资金利息总和
for (TFundsUsed fundsUsed : fundsUsedList) {
// String str = "日期:" + fundsUsed.getTime() + "; 资金性质:" + fundsUsed.getCapitalNature() + "; 金额:" + fundsUsed.getMoney();
// str += "; 占用天数:" + fundsUsed.getOccuDays() + "; 占用资金金额:" + fundsUsed.getOccuMoney() + "; 利息:" + fundsUsed.getInterest();
// System.out.println(str);
// str += "\r\n";
// out.write(str.getBytes());
sumInterest += fundsUsed.getInterest();
}
// System.out.println("====结束; 占用利息总和:" + sumInterest + "=======================================");
return sumInterest;
}
其中 在fundused中的interest(利息)的计算方法是 天数/一年总金0.1