Ejemplo n.º 1
0
        public ActionResult UpdateDealModelSetting(string projectGuid, bool enablePredict)
        {
            return(ActionUtils.Json(() =>
            {
                var project = Platform.GetProject(projectGuid);
                project.EnablePredictMode = enablePredict;
                ABSDealUtils.UpdateDatasetByPredictModel(project);

                return ActionUtils.Success(null);
            }));
        }
Ejemplo n.º 2
0
        private DataTable GetCashFlowTable(string projectGuid, DateTime paymentDate)
        {
            var projectLogicModel = Platform.GetProject(projectGuid);
            var project           = projectLogicModel.Instance;

            var datasetSchedule = projectLogicModel.DealSchedule.GetByPaymentDay(paymentDate);

            CommUtils.AssertNotNull(datasetSchedule.Dataset.Instance, "第{0}期模型未生成", Toolkit.DateToString(paymentDate));

            //获取预测的资产池当期本金与利息
            var acfTable = datasetSchedule.Dataset.DealModel.AssetCashflowDt;

            for (int i = acfTable.Columns.Count - 1; i >= 0; i--)
            {
                var      c = acfTable.Columns[i];
                DateTime date;
                if (DateTime.TryParse(c.ColumnName, out date))
                {
                    if (date < paymentDate)
                    {
                        acfTable.Columns.Remove(c);
                    }
                }
            }

            var assetViewModel = Toolkit.GetAssetCashflow(acfTable, paymentDate);

            //判断本金与利息是否被覆盖
            var assetCashflowVariable     = m_dbAdapter.AssetCashflowVariable.GetByProjectIdPaymentDay(project.ProjectId, paymentDate);
            var predictInterestCollection = double.Parse(assetViewModel.TotalCurrentInterestCollection.ToString("n2"));
            var predictPricipalCollection = double.Parse(assetViewModel.TotalCurrentPrinCollection.ToString("n2"));

            var cashflowDt = ABSDealUtils.GetCashflowDt(datasetSchedule, assetCashflowVariable,
                                                        predictInterestCollection, predictPricipalCollection,
                                                        out double currInterest, out double currPrincipal);

            cashflowDt = ABSDealUtils.CleanAndTranslateCashflowTable(cashflowDt);

            return(cashflowDt);
        }
Ejemplo n.º 3
0
        public void SaveNoteData()
        {
            m_dbAdapter.Task.CheckPrevIsFinished(Task);
            var taskPeriod  = m_dbAdapter.TaskPeriod.GetByShortCode(Task.ShortCode);
            var paymentDate = Task.EndTime.Value;

            var project         = new ProjectLogicModel(m_userName, Task.ProjectId);
            var datasetSchedule = project.DealSchedule.GetByPaymentDay(paymentDate);

            if (taskPeriod != null)
            {
                paymentDate = taskPeriod.PaymentDate;
            }
            else
            {
                if (datasetSchedule != null)
                {
                    paymentDate = datasetSchedule.PaymentDate;
                }
            }

            var dataset        = datasetSchedule.Dataset;
            var acfTable       = dataset.DealModel.AssetCashflowDt;
            var assetViewModel = Toolkit.GetAssetCashflow(acfTable, paymentDate);

            //判断本金与利息是否被覆盖
            var assetCashflowVariable = m_dbAdapter.AssetCashflowVariable.GetByProjectIdPaymentDay(project.Instance.ProjectId, paymentDate);
            var cashflowViewModel     = new CashflowViewModel();

            cashflowViewModel.PredictInterestCollection = double.Parse(assetViewModel.TotalCurrentInterestCollection.ToString("n2"));
            cashflowViewModel.PredictPricipalCollection = double.Parse(assetViewModel.TotalCurrentPrinCollection.ToString("n2"));
            cashflowViewModel.OverridableVariables      = SelectOverridableVariables(datasetSchedule.Dataset);

            var cfTable = ABSDealUtils.GetCashflowDt(datasetSchedule, assetCashflowVariable,
                                                     cashflowViewModel.PredictInterestCollection, cashflowViewModel.PredictPricipalCollection,
                                                     out double currInterest, out double currPrincipal);

            var notes = m_dbAdapter.Dataset.GetNotes(project.Instance.ProjectId);

            var currentDatasetColumnIndex = 2;

            for (int i = 0; i < cfTable.Columns.Count; ++i)
            {
                DateTime temp;
                if (DateTime.TryParse(cfTable.Columns[i].ColumnName, out temp) &&
                    dataset.DatasetSchedule.PaymentDate == temp)
                {
                    currentDatasetColumnIndex = i;
                    break;
                }
            }

            foreach (var n in notes)
            {
                var nd = m_dbAdapter.Dataset.GetNoteData((int)n.NoteId, dataset.Instance.DatasetId);

                var prinKey = n.ShortName + ".Principal";
                var prinRow = cfTable.AsEnumerable().FirstOrDefault(r => r[1].ToString().Contains(prinKey) && r[1].ToString().Contains("Received"));
                CommUtils.AssertNotNull(prinRow, $"在证券端现金流表中,找不到[{prinKey}]");
                var prin = prinRow[currentDatasetColumnIndex].ToString();
                nd.PrincipalPaid = (decimal)((prin == string.Empty || prin == "-") ? 0.0 : double.Parse(prin));

                var interestKey = n.ShortName + ".Interest";
                var interestRow = cfTable.AsEnumerable().FirstOrDefault(r => r[1].ToString().Contains(interestKey) && r[1].ToString().Contains("Received"));
                CommUtils.AssertNotNull(interestRow, $"在证券端现金流表中,找不到[{interestKey}]");
                var interest = interestRow[currentDatasetColumnIndex].ToString();
                nd.InterestPaid = (decimal)((interest == string.Empty || interest == "-") ? 0.0 : double.Parse(interest));

                var endKey = n.ShortName + ".Beginning";
                var endRow = cfTable.AsEnumerable().FirstOrDefault(r => r[1].ToString().Contains(endKey) && r[1].ToString().Contains("Outstanding"));
                CommUtils.AssertNotNull(endRow, $"在证券端现金流表中,找不到[{endKey}]");
                var end = endRow[currentDatasetColumnIndex + 1].ToString();
                nd.EndingBalance = (decimal)((end == string.Empty || end == "-") ? 0.0 : double.Parse(end));

                m_dbAdapter.Dataset.UpdateNoteData(nd);
            }

            Task.TaskExtension.TaskExtensionStatus     = TaskExtensionStatus.Finished;
            Task.TaskExtension.TaskExtensionHandler    = m_userName;
            Task.TaskExtension.TaskExtensionHandleTime = DateTime.Now;
            m_dbAdapter.Task.SaveTaskExtension(Task.TaskExtension);

            new TaskLogicModel(project, Task).Start();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 抽出资产端现金流表
        /// </summary>
        public object ExtractAssetCashflowTable(ABSDeal absDeal, DateTime paymentDay)
        {
            var determinationDates = ABSDealUtils.GetDeterminationDatesByPaymentDates(absDeal);
            var colHeader          = new List <string> {
                "资产", "项目"
            };

            colHeader.AddRange(determinationDates.Keys.Select(x => determinationDates[x].ToString("yyyy-MM-dd")));

            var selectName = new List <string> {
                "利息", "本金", "剩余本金", "损失", "违约", "合计", "费用"
            };
            var selectValue = new List <Func <AcfUnitBase, double> > {
                x => x.Interest,
                x => x.Principal,
                x => x.Performing,
                x => x.Loss,
                x => x.Defaulted,
                x => x.Sum,
                x => x.Fee,
            };

            var dataResult = new List <List <string> >();

            foreach (var acfAsset in Asset)
            {
                for (int i = 0; i < selectName.Count; i++)
                {
                    var row = new List <string>();
                    row.Add(acfAsset.Asset.DisplayName);
                    row.Add(selectName[i]);

                    foreach (var acfUnit in acfAsset)
                    {
                        var value = selectValue[i](acfUnit);
                        row.Add(value.ToString("n2"));
                    }
                    dataResult.Add(row);
                }
            }

            for (int i = 0; i < selectName.Count; i++)
            {
                var row = new List <string>();
                row.Add("总计");
                row.Add("总" + selectName[i]);
                foreach (var acfDataset in Dataset)
                {
                    var value = selectValue[i](acfDataset.Sum);
                    row.Add(value.ToString("n2"));
                }

                dataResult.Add(row);
            }

            List <object> mergeCellsInfo = new List <object>();

            for (int i = 0; i < Asset.Count + 1; i++)
            {
                mergeCellsInfo.Add(new
                {
                    row     = i * 7,
                    col     = 0,
                    rowspan = 7,
                    colspan = 1,
                });
            }
            ;

            var result = new
            {
                colHeader      = colHeader,
                paymentDate    = paymentDay.ToString("yyyy-MM-dd"),
                dataResult     = dataResult,
                mergeCellsInfo = mergeCellsInfo,
                isError        = false
            };

            return(result);
        }
Ejemplo n.º 5
0
        public DataTable ExtractAssetCashflowDataTable(ABSDeal absDeal, DateTime paymentDay)
        {
            var dt = new DataTable();
            var determinationDates = ABSDealUtils.GetDeterminationDatesByPaymentDates(absDeal);
            var colHeader          = new List <string> {
                "资产", "项目"
            };

            colHeader.AddRange(determinationDates.Keys.Select(x => determinationDates[x].ToString("yyyy-MM-dd")));
            colHeader.ForEach(x => dt.Columns.Add(x));

            var selectName = new List <string> {
                "利息", "本金", "剩余本金", "损失", "违约", "合计", "费用"
            };
            var selectValue = new List <Func <AcfUnitBase, double> > {
                x => x.Interest,
                x => x.Principal,
                x => x.Performing,
                x => x.Loss,
                x => x.Defaulted,
                x => x.Sum,
                x => x.Fee,
            };

            var dataResult = new List <List <string> >();

            foreach (var acfAsset in Asset)
            {
                for (int i = 0; i < selectName.Count; i++)
                {
                    var row = new List <string>();
                    row.Add(acfAsset.Asset.DisplayName);
                    row.Add(selectName[i]);

                    foreach (var acfUnit in acfAsset)
                    {
                        var value = selectValue[i](acfUnit);
                        row.Add(value.ToString("n2"));
                    }

                    var dtRow = dt.NewRow();
                    dtRow.ItemArray = row.ToArray();
                    dt.Rows.Add(dtRow);
                }
            }

            for (int i = 0; i < selectName.Count; i++)
            {
                var row = new List <string>();
                row.Add("总计");
                row.Add("总" + selectName[i]);
                foreach (var acfDataset in Dataset)
                {
                    var value = selectValue[i](acfDataset.Sum);
                    row.Add(value.ToString("n2"));
                }

                var dtRow = dt.NewRow();
                dtRow.ItemArray = row.ToArray();
                dt.Rows.Add(dtRow);
            }

            return(dt);
        }
Ejemplo n.º 6
0
        private object GetAssetCashflowTableDetail(string projectGuid, DateTime paymentDate)
        {
            var dictDeterminationDates = new Dictionary <DateTime, DateTime>();
            var allAssetDetail         = new NancyBasicAssetCashflow();

            var projectLogicModel = Platform.GetProject(projectGuid);

            ABSDeal absDeal = null;

            try
            {
                var datasetSchedule = projectLogicModel.DealSchedule.GetByPaymentDay(paymentDate);
                paymentDate = datasetSchedule.PaymentDate;

                CommUtils.AssertNotNull(datasetSchedule.Dataset.Instance, "第{0}期模型未生成", Toolkit.DateToString(paymentDate));
                CommUtils.Assert(datasetSchedule.Dataset.HasDealModel, "找不到第{0}期模型", Toolkit.DateToString(paymentDate));

                absDeal = new ABSDeal(datasetSchedule.Dataset.DealModel);

                dictDeterminationDates = ABSDealUtils.GetDeterminationDatesByPaymentDates(absDeal);

                //获取当期所有的资产明细
                var asOfDate = datasetSchedule.Dataset.Instance.AsOfDate;
                allAssetDetail = NancyUtils.GetUnaggregateAssetCashflowByPath(projectLogicModel.Instance.ProjectId, asOfDate);
            }
            catch (ApplicationException ae)
            {
                var errorResult = new
                {
                    isError      = true,
                    errorMessage = ae.Message,
                    stackTrace   = ae.StackTrace,
                };
                return(errorResult);
            }

            var dictAllAssetDetail = allAssetDetail.BasicAssetCashflowItems.ToList().GroupBy(x => x.AssetId).ToDictionary(x => x.Key, y => y.ToList());

            var dataSetResult = new Dictionary <int, List <AssetCashflowData> >();
            var dictRowSpan   = new Dictionary <int, List <int> >();

            var osaDict = new Dictionary <DateTime, OverrideSingleAssetLogicModel>();

            var osaPrincipalRecords        = m_dbAdapter.OverrideSingleAssetPrincipal.GetByProject(projectLogicModel.Instance.ProjectId);
            var osaPrincipalBalanceRecords = m_dbAdapter.OverrideSingleAssetPrincipalBalance.GetByProject(projectLogicModel.Instance.ProjectId);
            var osaInterestRecords         = m_dbAdapter.OverrideSingleAssetInterest.GetByProject(projectLogicModel.Instance.ProjectId);

            //获取每笔资产的明细
            dictAllAssetDetail.Keys.ToList().ForEach(x =>
            {
                var currAssetDetailList = dictAllAssetDetail[x];
                dictRowSpan[x]          = new List <int>();

                var dictCurrAssetList = new Dictionary <DateTime, List <NancyBasicAssetCashflowItem> >();
                var data = new List <AssetCashflowData>();

                var prevDateTime = DateTime.Parse("1753-01-02");

                foreach (var currPaymentDate in dictDeterminationDates.Keys)
                {
                    var currCompareTime = dictDeterminationDates[currPaymentDate];
                    dictCurrAssetList[currCompareTime] = currAssetDetailList.Where(item => prevDateTime < item.PaymentDate && item.PaymentDate <= currCompareTime).ToList();

                    var currAssetList = dictCurrAssetList[currCompareTime];

                    var assetId = x;

                    OverrideSingleAssetLogicModel osa = null;
                    if (osaDict.ContainsKey(currPaymentDate))
                    {
                        osa = osaDict[currPaymentDate];
                    }
                    else
                    {
                        osa = new OverrideSingleAssetLogicModel(projectLogicModel, currPaymentDate,
                                                                osaPrincipalRecords, osaInterestRecords, osaPrincipalBalanceRecords);
                        osaDict[currPaymentDate] = osa;
                    }

                    var hasOsa = osa.HasOverrideRecords(assetId);

                    if (currAssetList.Count > 0)
                    {
                        dictRowSpan[x].Add(hasOsa ? 1 : (currAssetList.Count + 1));
                        var rowName = Toolkit.DateToString(currCompareTime);

                        for (int i = 0; i < currAssetList.Count; i++)
                        {
                            var ditail = currAssetList[i];

                            var currACFRow     = new AssetCashflowData();
                            currACFRow.RowName = rowName;

                            currACFRow.AddValue("资产回款日", Toolkit.DateToString(ditail.PaymentDate));
                            currACFRow.AddValue("利息", ditail.Interest.ToString("n2"));
                            currACFRow.AddValue("本金", ditail.Principal.ToString("n2"));
                            currACFRow.AddValue("合计", (ditail.Interest + ditail.Principal).ToString("n2"));
                            currACFRow.AddValue("剩余本金", ditail.Performing.ToString("n2"));
                            currACFRow.AddValue("损失", ditail.Loss.ToString("n2"));
                            currACFRow.AddValue("违约", ditail.Defaulted.ToString("n2"));

                            if (!hasOsa)
                            {
                                data.Add(currACFRow);
                            }
                        }

                        var total      = new AssetCashflowData();
                        total.RowName  = rowName;
                        var interest   = currAssetList.Sum(value => value.Interest);
                        var principal  = currAssetList.Sum(value => value.Principal);
                        var performing = currAssetList.Last().Performing;
                        if (osa.GetInterest(assetId) != null)
                        {
                            interest = osa.GetInterest(assetId).Interest;
                        }

                        if (osa.GetPrincipal(assetId) != null)
                        {
                            principal = osa.GetPrincipal(assetId).Principal;
                        }

                        if (osa.GetPrincipalBalance(assetId) != null)
                        {
                            performing = osa.GetPrincipalBalance(assetId).PrincipalBalance;
                        }

                        total.AddValue("资产回款日", "总计");
                        total.AddValue("利息", interest.ToString("n2"));
                        total.AddValue("本金", principal.ToString("n2"));
                        total.AddValue("合计", (interest + principal).ToString("n2"));
                        total.AddValue("剩余本金", performing.ToString("n2"));
                        total.AddValue("损失", currAssetList.Sum(value => value.Loss).ToString("n2"));
                        total.AddValue("违约", currAssetList.Sum(value => value.Defaulted).ToString("n2"));
                        data.Add(total);
                    }
                    prevDateTime = currCompareTime;
                }
                dataSetResult[x] = (data);
            });

            //获取所有的资产的中文名
            var dictAssetIdCNName = absDeal.Assets.GetAssetIdNameMap();

            var detailTableHeader = new List <string>()
            {
                "归集日", "资产回款日", "利息", "本金", "合计", "剩余本金", "损失", "违约"
            };

            return(new
            {
                tableHeader = detailTableHeader,
                assetIdCNName = dictAllAssetDetail.Keys.ToList().ConvertAll(x => new
                {
                    tableKey = x,
                    tableValues = dictAssetIdCNName[x]
                }),
                dataSets = dataSetResult.Keys.ToList().ConvertAll(x => new
                {
                    tableKey = x,
                    tableValues = dataSetResult[x],
                    rowSpanList = dictRowSpan[x]
                }),
                isError = false
            });
        }
Ejemplo n.º 7
0
        public object GetCashflowDetailDataTable(string projectGuid, DateTime paymentDate)
        {
            var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);

            var projectLogicModel = new ProjectLogicModel(CurrentUserName, project);
            var datasetSchedule   = projectLogicModel.DealSchedule.GetByPaymentDay(paymentDate);

            CommUtils.AssertNotNull(datasetSchedule.Dataset.Instance, "第{0}期模型未生成", Toolkit.DateToString(datasetSchedule.PaymentDate));

            var dataset = m_dbAdapter.Dataset.GetDatasetByDurationPeriod(project.ProjectId, paymentDate);

            //同步数据库中参数到模型文件
            var variableDateset = m_dbAdapter.CashflowVariable.GetByPaymentDay(project.ProjectId, paymentDate);

            UpdateVariablesFromCurrPeriodDBToModel(datasetSchedule.Dataset, variableDateset, project.ProjectId, paymentDate);

            var cashflowTableViewModel = new CashflowDetailTableViewModel();

            cashflowTableViewModel.CurrentPaymentDate = Toolkit.DateToString(datasetSchedule.PaymentDate);

            //获取预测的资产池当期本金与利息
            var acfTable = datasetSchedule.Dataset.DealModel.AssetCashflowDt;

            for (int i = acfTable.Columns.Count - 1; i >= 0; i--)
            {
                var      c = acfTable.Columns[i];
                DateTime date;
                if (DateTime.TryParse(c.ColumnName, out date))
                {
                    if (date < paymentDate)
                    {
                        acfTable.Columns.Remove(c);
                    }
                }
            }

            var assetViewModel = Toolkit.GetAssetCashflow(acfTable, paymentDate);

            //判断本金与利息是否被覆盖
            var assetCashflowVariable = m_dbAdapter.AssetCashflowVariable.GetByProjectIdPaymentDay(project.ProjectId, paymentDate);
            var cashflowViewModel     = new CashflowViewModel();

            cashflowViewModel.PredictInterestCollection = double.Parse(assetViewModel.TotalCurrentInterestCollection.ToString("n2"));
            cashflowViewModel.PredictPricipalCollection = double.Parse(assetViewModel.TotalCurrentPrinCollection.ToString("n2"));
            cashflowViewModel.OverridableVariables      = SelectOverridableVariables(datasetSchedule.Dataset);

            var cashflowDt = ABSDealUtils.GetCashflowDt(datasetSchedule, assetCashflowVariable,
                                                        cashflowViewModel.PredictInterestCollection, cashflowViewModel.PredictPricipalCollection,
                                                        out double currInterest, out double currPrincipal);

            cashflowViewModel.CurrentInterestCollection = currInterest;
            cashflowViewModel.CurrentPricipalCollection = currPrincipal;

            cashflowDt = Toolkit.CleanCashflowTable(cashflowDt);
            var revertTable = cashflowDt.Transpose();

            var notes     = m_dbAdapter.Dataset.GetNotes(project.ProjectId);
            var noteDatas = m_dbAdapter.Dataset.GetNoteDatas(dataset.DatasetId);

            Toolkit.GetCashflowDetailData(cashflowTableViewModel, revertTable, notes, noteDatas);
            var result = new
            {
                ProjectCashflowHeader  = cashflowTableViewModel.ProjectCashflowHeader,
                SecurityCashflowHeader = cashflowTableViewModel.SecurityCashflowHeader,
                AssetPoolHeader        = cashflowTableViewModel.AssetPoolHeader,
                CostHeader             = cashflowTableViewModel.CostHeader,
                AccountHeader          = cashflowTableViewModel.AccountHeader,
                TriggerEventHeader     = cashflowTableViewModel.TriggerEventHeader,
                HomePageHeader         = cashflowTableViewModel.HomePageHeader,

                ProjectCashflowList  = cashflowTableViewModel.ProjectCashflowList,
                SecurityCashflowList = cashflowTableViewModel.SecurityCashflowList.Keys.ToList().ConvertAll(x =>
                                                                                                            new
                {
                    TableName = x,
                    DataList  = cashflowTableViewModel.SecurityCashflowList[x]
                }),
                AssetPoolList              = cashflowTableViewModel.AssetPoolList,
                CostList                   = cashflowTableViewModel.CostList,
                AccountList                = cashflowTableViewModel.AccountList,
                TriggerEventList           = cashflowTableViewModel.TriggerEventList,
                CurrPeriodCashflowInfoList = cashflowTableViewModel.CurrPeriodCashflowInfoList,
                CashflowEventList          = cashflowTableViewModel.CashflowEventList,
                FeePayable                 = cashflowTableViewModel.FeePayable,
                CurrentPaymentDate         = cashflowTableViewModel.CurrentPaymentDate,
                PredictInterestCollection  = cashflowViewModel.PredictInterestCollection,
                PredictPricipalCollection  = cashflowViewModel.PredictPricipalCollection,
                CurrentInterestCollection  = cashflowViewModel.CurrentInterestCollection,
                CurrentPricipalCollection  = cashflowViewModel.CurrentPricipalCollection,
                OverridableVariables       = cashflowViewModel.OverridableVariables,
                TestFailRemind             = cashflowTableViewModel.TestFailRemind
            };

            return(result);
        }
Ejemplo n.º 8
0
        private object GetCFTableByProject(CashflowViewModel viewModel, string projectGuid, DateTime paymentDate)
        {
            var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);

            var projectLogicModel = Platform.GetProject(projectGuid);
            var datasetSchedule   = projectLogicModel.DealSchedule.GetByPaymentDay(paymentDate);

            CommUtils.AssertNotNull(datasetSchedule.Dataset.Instance, "第{0}期模型未生成", Toolkit.DateToString(datasetSchedule.PaymentDate));

            //同步数据库中参数到模型文件
            var variableDateset = m_dbAdapter.CashflowVariable.GetByPaymentDay(project.ProjectId, paymentDate);

            UpdateVariablesFromCurrPeriodDBToModel(datasetSchedule.Dataset, variableDateset, project.ProjectId, paymentDate);

            var cashflowTableViewModel = new CashflowDetailTableViewModel();

            cashflowTableViewModel.CurrentPaymentDate = Toolkit.DateToString(datasetSchedule.PaymentDate);

            //获取预测的资产池当期本金与利息
            var acfTable = datasetSchedule.Dataset.DealModel.AssetCashflowDt;

            for (int i = acfTable.Columns.Count - 1; i >= 0; i--)
            {
                var      c = acfTable.Columns[i];
                DateTime date;
                if (DateTime.TryParse(c.ColumnName, out date))
                {
                    if (date < paymentDate)
                    {
                        acfTable.Columns.Remove(c);
                    }
                }
            }

            var assetViewModel = Toolkit.GetAssetCashflow(acfTable, paymentDate);

            //判断本金与利息是否被覆盖
            var assetCashflowVariable = m_dbAdapter.AssetCashflowVariable.GetByProjectIdPaymentDay(project.ProjectId, paymentDate);
            var cashflowViewModel     = new CashflowViewModel();

            cashflowViewModel.PredictInterestCollection = double.Parse(assetViewModel.TotalCurrentInterestCollection.ToString("n2"));
            cashflowViewModel.PredictPricipalCollection = double.Parse(assetViewModel.TotalCurrentPrinCollection.ToString("n2"));
            cashflowViewModel.OverridableVariables      = SelectOverridableVariables(datasetSchedule.Dataset);

            var cashflowDt = ABSDealUtils.GetCashflowDt(datasetSchedule, assetCashflowVariable,
                                                        cashflowViewModel.PredictInterestCollection, cashflowViewModel.PredictPricipalCollection,
                                                        out double currInterest, out double currPrincipal);

            cashflowViewModel.CurrentInterestCollection = currInterest;
            cashflowViewModel.CurrentPricipalCollection = currPrincipal;

            cashflowDt = ABSDealUtils.CleanAndTranslateCashflowTable(cashflowDt);

            var columnNames = new List <string>();

            for (int i = 0; i < cashflowDt.Columns.Count; ++i)
            {
                var columnName = cashflowDt.Columns[i].ColumnName.ToString();
                columnNames.Add(columnName);
            }

            viewModel.ColHeader = columnNames;
            string testFailRemind = null;

            var rowsNum = cashflowDt.Rows.Count;

            if (cashflowDt != null && rowsNum > 0)
            {
                var equalRowsNumber = 0;
                var prevAsset       = cashflowDt.Rows[0][0].ToString();

                for (int i = 0; i < rowsNum; i++)
                {
                    DataRow dr = cashflowDt.Rows[i];

                    var row = dr.ItemArray.ToList().ConvertAll(x => x.ToString());
                    viewModel.CashflowDataResult.Add(row);
                    if (testFailRemind == null)
                    {
                        if (row.Any(x => x.ToString() == "FAIL"))
                        {
                            testFailRemind = "预测将发生违约,启动差额支付";
                        }
                    }
                    var element     = dr["类型"] != null ? dr["类型"].ToString() : "";
                    var description = dr["项目描述"] != null ? dr["项目描述"].ToString() : "";

                    if (prevAsset == element)
                    {
                        equalRowsNumber++;
                        if (i == rowsNum - 1)
                        {
                            var info = new Tuple <int, int, int, int>(rowsNum - equalRowsNumber, 0, equalRowsNumber, 1);
                            viewModel.MergeCellsInfo.Add(info);
                        }
                    }
                    else
                    {
                        var info = new Tuple <int, int, int, int>(i - equalRowsNumber, 0, equalRowsNumber, 1);
                        viewModel.MergeCellsInfo.Add(info);

                        equalRowsNumber = 1;
                        prevAsset       = cashflowDt.Rows[i][0].ToString();
                    }
                }
            }
            var result = new
            {
                colHeader      = viewModel.ColHeader,
                paymentDate    = Toolkit.DateToString(paymentDate),
                dataResult     = viewModel.CashflowDataResult,
                mergeCellsInfo = viewModel.MergeCellsInfo.ConvertAll(x => new
                {
                    row     = x.Item1,
                    col     = x.Item2,
                    rowspan = x.Item3,
                    colspan = x.Item4
                }),
                isError = false,
                PredictInterestCollection = cashflowViewModel.PredictInterestCollection,
                PredictPricipalCollection = cashflowViewModel.PredictPricipalCollection,
                CurrentInterestCollection = cashflowViewModel.CurrentInterestCollection,
                CurrentPricipalCollection = cashflowViewModel.CurrentPricipalCollection,
                OverridableVariables      = cashflowViewModel.OverridableVariables,
                TestFailRemind            = testFailRemind
            };

            return(result);
        }