财务成本总计是怎么计算的

该类为 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<TFundsUsed> 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){                       
                        if(fundsUsed.getOccuMoney() < 0)
                           fundsUsed.setInterest(0.0);
                        // 清空收回货款之后的全部数据的利息
                        for (int lastP = fundsUsedList.size() - 1; lastP > 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 196,165评论 5 462
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 82,503评论 2 373
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 143,295评论 0 325
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,589评论 1 267
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,439评论 5 358
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,342评论 1 273
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,749评论 3 387
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,397评论 0 255
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,700评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,740评论 2 313
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,523评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,364评论 3 314
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,755评论 3 300
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,024评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,297评论 1 251
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,721评论 2 342
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,918评论 2 336

推荐阅读更多精彩内容