//public static DataSet GetOverridableVariables(int projectId, string asOfDate = null) //{ // var folderInfo = new ModelFolderInfo(projectId, asOfDate); // return m_nancy.GetOverridableVariables(folderInfo.YmlFolder, folderInfo.DsFolder); //} public static NancyStaticAnalysisResult RunStaticResultByPath(string cdr, string cpr, string path, string dsPath, AssetOverrideSetting assetOverrideSetting = null) { if (assetOverrideSetting == null) { assetOverrideSetting = new AssetOverrideSetting(); } var result = m_nancy.RunStaticResultByPath(cdr, cpr, path, dsPath, assetOverrideSetting.PaymentDate.ToString("yyyy-MM-dd"), assetOverrideSetting.IsOverride, assetOverrideSetting.Interest, assetOverrideSetting.Principal); var isCsdcDeal = false; var ymlFilePath = Path.Combine(path, @"Script.yml"); if (File.Exists(ymlFilePath)) { using (StreamReader sr = new StreamReader(ymlFilePath)) { var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream); if (nancyDealData != null) { isCsdcDeal = nancyDealData.IsCsdcDeal; } } } RunSpecialRules(result, isCsdcDeal); return(result); }
public static NancyStaticAnalysisResult GetStaticAnalyticsResult(int projectId, DataSet dsVariables = null, string asOfDate = null, AssetOverrideSetting assetOverrideSetting = null) { if (assetOverrideSetting == null) { assetOverrideSetting = new AssetOverrideSetting(); } //if (dsVariables == null) //{ // dsVariables = GetOverridableVariables(projectId, asOfDate); //} var folderInfo = new ModelFolderInfo(projectId, asOfDate); //NancyMockUtils.SetOverridableVariables(dsVariables, folderInfo.DsFolder); var result = m_nancy.RunStaticResultByPath("0", "0", folderInfo.YmlFolder, folderInfo.DsFolder, assetOverrideSetting.PaymentDate.ToString("yyyy-MM-dd"), assetOverrideSetting.IsOverride, assetOverrideSetting.Interest, assetOverrideSetting.Principal); var isCsdcDeal = false; var ymlFilePath = Path.Combine(folderInfo.YmlFolder, "Script.yml"); if (File.Exists(ymlFilePath)) { using (StreamReader sr = new StreamReader(ymlFilePath)) { var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream); if (nancyDealData != null) { isCsdcDeal = nancyDealData.IsCsdcDeal; } } } RunSpecialRules(result, isCsdcDeal); return(result); }
public static DataTable GetCashflowDt(DatasetScheduleLogicModel datasetSchedule, AssetCashflowVariable assetCashflowVariable, double sysPredictInterest, double sysPredictPrincipal, out double currInterestCollection, out double currPrincipalCollection) { currInterestCollection = sysPredictInterest; currPrincipalCollection = sysPredictPrincipal; var assetOverrideSetting = new AssetOverrideSetting(assetCashflowVariable); DataTable cashflowDt = new DataTable(); var project = datasetSchedule.ProjectLogicModel.Instance; var dataset = datasetSchedule.Dataset.Instance; var paymentDate = datasetSchedule.PaymentDate; var hasOsa = false; var osa = datasetSchedule.Dataset.DealModel.OverrideSingleAsset; foreach (var asset in datasetSchedule.Dataset.Assets) { var overridePrincipal = osa.GetPrincipal(asset.AssetId); var overrideInterest = osa.GetInterest(asset.AssetId); if (overridePrincipal != null || overrideInterest != null) { hasOsa = true; break; } } //测算优先级: //1、覆盖现金流测算 //2、单笔资产覆盖的方式测算 //3、系统测算 //未填写覆盖现金流值,或填写值和系统测算值一致,认为是不使用本息覆盖现金流测算 var hasOverrideCashflow = assetCashflowVariable != null && assetCashflowVariable.EnableOverride; if (hasOverrideCashflow) { //使用覆盖现金流的方式测算 cashflowDt = NancyUtils.GetStaticAnalyticsResult(project.ProjectId, null, dataset.AsOfDate, assetOverrideSetting).CashflowDt; currInterestCollection = assetOverrideSetting.Interest; currPrincipalCollection = assetOverrideSetting.Principal; } else { if (hasOsa) { //未填写覆盖现金流参数,已填写单笔资产覆盖 //重新计算本息,使用覆盖现金流的方式测算 var dealModel = datasetSchedule.Dataset.DealModel; var absDeal = new ABSDeal(dealModel.YmlFolder, dealModel.DsFolder); var acfResult = absDeal.Result.AcfResult; var acfDataset = acfResult.Dataset.SingleOrDefault(x => x.PaymentDay == paymentDate); acfResult.MergeOsa(osa); acfResult.ReCalcSum(); var sumPrincipal = double.Parse(acfDataset.Sum.Principal.ToString("n2")); var sumInterest = double.Parse(acfDataset.Sum.Interest.ToString("n2")); assetOverrideSetting.IsOverride = true; assetOverrideSetting.Principal = sumPrincipal; assetOverrideSetting.Interest = sumInterest; assetOverrideSetting.PaymentDate = paymentDate; cashflowDt = NancyUtils.GetStaticAnalyticsResult(project.ProjectId, null, dataset.AsOfDate, assetOverrideSetting).CashflowDt; currInterestCollection = assetOverrideSetting.Interest; currPrincipalCollection = assetOverrideSetting.Principal; } else { //未填写覆盖现金流参数,且未填写单笔资产覆盖 //使用非覆盖现金流的方式测算 cashflowDt = NancyUtils.GetStaticAnalyticsResult(project.ProjectId, null, dataset.AsOfDate).CashflowDt; } } return(cashflowDt); }