該類為 bidFinance r
//財(cái)務(wù)預(yù)算
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; // 預(yù)算7--資金占用利息
private Double eighthSum; // 預(yù)算7——合計(jì)
private Double generalInvoice1; // 預(yù)算8——票種為增值稅普通發(fā)票17%--金額
private Double specialInvoice1; // 預(yù)算8——票種為增值稅專用發(fā)票17%--金額
private Double generalInvoice2; // 預(yù)算8——票種為增值稅普通發(fā)票6%--金額
private Double specialInvoice2; // 預(yù)算8——票種為增值稅專用發(fā)票6%--金額
private Double buildingInvoice; // 預(yù)算8——票種為建筑安裝業(yè)發(fā)票--金額
private Double softSaleInvoice; // 預(yù)算8——票種為自主軟件銷售增值稅發(fā)票--金額
private Double tecDeveInvoice; // 預(yù)算8——票種為技術(shù)開發(fā)發(fā)票--金額
private Double ninthSum; // 預(yù)算8——合計(jì)
也就是 資金占用利息takeUpInterest+稅費(fèi) tecDeveInvoice
資金占用利息計(jì)算
//財(cái)務(wù)預(yù)算-占用利息計(jì)算
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);
計(jì)算占用利息總和
/**
* 計(jì)算占用利息總和
* @param fundsUsedList
* @return
* @throws IOException
*/
@SuppressWarnings("resource")
public Double sortAndCalculate(List<TFundsUsed> fundsUsedList) throws IOException {
Double sumInterest = 0.0;
if (null == fundsUsedList || fundsUsedList.size() <= 0) {
return sumInterest;
}
//按日期降序排列
Collections.sort(fundsUsedList);
//顛倒順序
Collections.reverse(fundsUsedList);
//對(duì)每一條預(yù)算金額計(jì)算占用金額及占用利息
for (int i = 0; i < fundsUsedList.size(); i++) {
TFundsUsed fundsUsed = fundsUsedList.get(i);
//當(dāng)只有一條記錄或是最后一條記錄 占用金額屈溉、利息為空
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"); //占用天數(shù)
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"); //占用天數(shù)
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 資金性質(zhì)是 收回回款
}
//當(dāng)收回最后一筆貨款(進(jìn)度款),并且“占用資金金額為負(fù)數(shù)時(shí)”,不予以計(jì)算負(fù)利息叫榕。
for (int j = fundsUsedList.size() - 1; j > -1; j--) {
TFundsUsed fundsUsed = fundsUsedList.get(j);
// BEGIN UPDATE BY TANNC 2015-06-18 9:45:57 資金性質(zhì)是 收回回款
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");
}
// 最后收回貨款和最后支付時(shí)同一天
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"))){
// 最后一個(gè)相同的日期
lastCount=li;
}
}
//如果最后一筆是負(fù)數(shù)則清空
if(null!=fundsUsedList.get(lastCount)&&null!=fundsUsedList.get(lastCount).getMoney()&&fundsUsedList.get(lastCount).getOccuMoney()<0){
fundsUsedList.get(lastCount).setInterest(0.0);
}
// 清空收回貨款之后的全部數(shù)據(jù)的利息
for (int lastP = fundsUsedList.size() - 1; lastP > lastCount; lastP--) {
TFundsUsed lastPfundsUsed = fundsUsedList.get(lastP);
lastPfundsUsed.setInterest(0.0);
}
}
// 支付款和收回貨款 不是同一天
else{
// 收回貨款之后 不存在支付采購款
if(lastBuyIdx<j){
if(fundsUsed.getOccuMoney() < 0)
fundsUsed.setInterest(0.0);
// 清空收回貨款之后的全部數(shù)據(jù)的利息
for (int lastP = fundsUsedList.size() - 1; lastP > j; lastP--) {
TFundsUsed lastPfundsUsed = fundsUsedList.get(lastP);
lastPfundsUsed.setInterest(0.0);
}
}
// 最后一筆收回貨款之后存在支付款,
// 則最后一筆收回貨款的資金占用利息(無論正負(fù))都要取,支付款的資金占用利息都要算,
// 最后一筆支付款之后的所有收回款的資金占用利息都不算(為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 資金性質(zhì)是 收回回款
}
}
OutputStream out=null;
// System.out.println("============================占用金額統(tǒng)計(jì)=========================");
// System.out.println("====開始======================================================");
// out = new FileOutputStream(new File("C:/RESULT2.txt"));
//計(jì)算每一筆占用資金利息總和
for (TFundsUsed fundsUsed : fundsUsedList) {
// String str = "日期:" + fundsUsed.getTime() + "; 資金性質(zhì):" + fundsUsed.getCapitalNature() + "; 金額:" + fundsUsed.getMoney();
// str += "; 占用天數(shù):" + fundsUsed.getOccuDays() + "; 占用資金金額:" + fundsUsed.getOccuMoney() + "; 利息:" + fundsUsed.getInterest();
// System.out.println(str);
// str += "\r\n";
// out.write(str.getBytes());
sumInterest += fundsUsed.getInterest();
}
// System.out.println("====結(jié)束; 占用利息總和:" + sumInterest + "=======================================");
return sumInterest;
}
其中 在fundused中的interest(利息)的計(jì)算方法是 天數(shù)/一年總金0.1