財(cái)務(wù)成本總計(jì)是怎么計(jì)算的

該類為 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末妄荔,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子谍肤,更是在濱河造成了極大的恐慌啦租,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,265評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件荒揣,死亡現(xiàn)場(chǎng)離奇詭異篷角,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)系任,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,078評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門内地,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人赋除,你說我怎么就攤上這事》橇瑁” “怎么了举农?”我有些...
    開封第一講書人閱讀 156,852評(píng)論 0 347
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)敞嗡。 經(jīng)常有香客問我颁糟,道長(zhǎng),這世上最難降的妖魔是什么喉悴? 我笑而不...
    開封第一講書人閱讀 56,408評(píng)論 1 283
  • 正文 為了忘掉前任棱貌,我火速辦了婚禮,結(jié)果婚禮上箕肃,老公的妹妹穿的比我還像新娘婚脱。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,445評(píng)論 5 384
  • 文/花漫 我一把揭開白布障贸。 她就那樣靜靜地躺著错森,像睡著了一般。 火紅的嫁衣襯著肌膚如雪篮洁。 梳的紋絲不亂的頭發(fā)上涩维,一...
    開封第一講書人閱讀 49,772評(píng)論 1 290
  • 那天,我揣著相機(jī)與錄音袁波,去河邊找鬼瓦阐。 笑死,一個(gè)胖子當(dāng)著我的面吹牛篷牌,可吹牛的內(nèi)容都是我干的睡蟋。 我是一名探鬼主播,決...
    沈念sama閱讀 38,921評(píng)論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼娃磺,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼薄湿!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起偷卧,我...
    開封第一講書人閱讀 37,688評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤豺瘤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后听诸,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體坐求,經(jīng)...
    沈念sama閱讀 44,130評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,467評(píng)論 2 325
  • 正文 我和宋清朗相戀三年晌梨,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了桥嗤。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,617評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡仔蝌,死狀恐怖泛领,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情敛惊,我是刑警寧澤渊鞋,帶...
    沈念sama閱讀 34,276評(píng)論 4 329
  • 正文 年R本政府宣布,位于F島的核電站瞧挤,受9級(jí)特大地震影響锡宋,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜特恬,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,882評(píng)論 3 312
  • 文/蒙蒙 一执俩、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧癌刽,春花似錦役首、人聲如沸尝丐。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,740評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽摊崭。三九已至,卻和暖如春杰赛,著一層夾襖步出監(jiān)牢的瞬間呢簸,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,967評(píng)論 1 265
  • 我被黑心中介騙來泰國(guó)打工乏屯, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留根时,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,315評(píng)論 2 360
  • 正文 我出身青樓辰晕,卻偏偏與公主長(zhǎng)得像蛤迎,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子含友,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,486評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容

  • Spinnaker簡(jiǎn)介 Spinnaker是一款企業(yè)級(jí)持續(xù)交付工具替裆,最初由Netflix構(gòu)建,是優(yōu)秀的項(xiàng)目套件Ne...
    KalvinDai閱讀 1,463評(píng)論 0 4
  • 可能每個(gè)人心里都有傷口窘问,想起來就會(huì)痛辆童,想治好就要手術(shù),得開刀惠赫,開刀會(huì)造成新的傷口把鉴,有時(shí)候我們只能用傷痛來治愈傷痛
    孫悟空_4005閱讀 147評(píng)論 0 0
  • 現(xiàn)在當(dāng)我們問每個(gè)人庭砍,你最大的心愿是什么,大家都會(huì)毫不猶豫的說混埠,財(cái)富自由啊怠缸。財(cái)富自由已成大家的追求和向往。 李笑來老...
    離錢最近的運(yùn)營(yíng)YUKI閱讀 397評(píng)論 0 2
  • 從前有一個(gè)叫做保羅的人,生長(zhǎng)在美國(guó)猶他州使套,在他家的附近有一片美麗的森林,可是后來這建造了一家煉銅廠鞠柄,工廠常常排除二...
    圓謹(jǐn)閱讀 840評(píng)論 0 1
  • 20190614楊燕分享:【每天進(jìn)步一點(diǎn)點(diǎn)】 2019要愛好自己侦高,選擇清晨運(yùn)動(dòng),恰好看到一個(gè)曳步舞隊(duì)厌杜,雖然跳舞的人...
    楊燕_愛自然生命力閱讀 163評(píng)論 0 0