Esempio n. 1
0
        public static void GetContractFeeSummary(ContractDetail[] list, out ContractDetail footeritem, bool outfooter = false)
        {
            List <int> ContractIDList   = list.Select(p => p.ID).ToList();
            var        fee_list         = RoomFeeAnalysis.GetRoomFeeAnalysisListByContractIDList(ContractIDList);
            var        feehistory_list  = ViewRoomFeeHistory.GetViewRoomFeeHistoryListByContractIDList(ContractIDList);
            var        fee_weiyue_list  = RoomFeeAnalysis.GetContractFeeWeiYueListByContractIDList(ContractIDList);
            decimal    totalRestCost    = 0;
            decimal    totalChargedCost = 0;
            decimal    totalPreCost     = 0;
            decimal    totalDepositCost = 0;
            decimal    totalBreakCost   = 0;
            decimal    totalTotalCost   = 0;

            foreach (var item in list)
            {
                item.RestCost     = fee_list.Where(p => p.ContractID == item.ID && p.TotalCost > 0).Sum(p => p.TotalCost);
                item.ChargedCost  = feehistory_list.Where(p => p.ContractID == item.ID && p.RealCost > 0).Sum(p => p.RealCost);
                item.PreCost      = feehistory_list.Where(p => p.ContractID == item.ID && p.RealCost > 0 && p.CategoryID == 4).Sum(p => p.RealCost);
                item.DepositCost  = feehistory_list.Where(p => p.ContractID == item.ID && p.RealCost > 0 && p.CategoryID == 3).Sum(p => p.RealCost);
                item.TotalCost    = item.RestCost + item.ChargedCost;
                item.BreakCost    = 0;
                totalRestCost    += item.RestCost;
                totalChargedCost += item.ChargedCost;
                totalPreCost     += item.PreCost;
                totalDepositCost += item.DepositCost;
                totalBreakCost   += fee_weiyue_list.Where(p => p.RelatedFeeID == item.ID && p.TotalCost > 0).Sum(p => p.TotalCost);
                totalTotalCost   += item.TotalCost;
            }
            footeritem             = new ContractDetail();
            footeritem.ContractNo  = "合计";
            footeritem.RestCost    = totalRestCost;
            footeritem.ChargedCost = totalChargedCost;
            footeritem.PreCost     = totalPreCost;
            footeritem.DepositCost = totalDepositCost;
            footeritem.TotalCost   = totalTotalCost;
            footeritem.BreakCost   = totalBreakCost;
        }