public ActionResult GetAssetInfo(string projectGuid, string paymentDate, int assetId) { return(ActionUtils.Json(() => { var date = DateUtils.ParseDigitDate(paymentDate); var logicModel = Platform.GetProject(projectGuid); var datasetSchedule = logicModel.DealSchedule.GetByPaymentDay(date); var dataset = datasetSchedule.Dataset; CommUtils.Assert(dataset.HasDealModel, "找不到第{0}期模型", date); var acfTable = dataset.DealModel.AssetCashflowDt; var assets = dataset.Assets; Toolkit.AddAssetIdToRepeatedCNName(acfTable, assets); var assetList = assets.Where(x => x.AssetId == assetId).ToList(); CommUtils.AssertEquals(assetList.Count, 1, "查找资产失败,AssetId={0}", assetId); var result = new CollateralAssetViewModel(assetList.Single()); return ActionUtils.Success(result); })); }
public ActionResult Index(string projectGuid, string paymentDay) { var paymentDate = DateUtils.ParseDigitDate(paymentDay); var projectLogicModel = new ProjectLogicModel(CurrentUserName, projectGuid); var datasetSchedule = projectLogicModel.DealSchedule.GetByPaymentDay(paymentDate); var acfTable = datasetSchedule.Dataset.DealModel.AssetCashflowDt; var assets = datasetSchedule.Dataset.Assets; Toolkit.AddAssetIdToRepeatedCNName(acfTable, assets); var dataset = datasetSchedule.Dataset.Instance; var viewModel = new AssetCashflowDatasetViewModel(); viewModel.ProjectGuid = projectGuid; viewModel.AssetDataset = new AssetDatasetViewModel(); viewModel.AssetDataset.Assets = new List <AssetViewModel>(); foreach (var assetItem in datasetSchedule.Dataset.Assets) { //Asset中可能包含循环购买时,系统生成的Asset //(当AssetId为0,且在collateral.csv中不存在该Asset时,认为是系统生成Asset) if (assetItem.SecurityData == null) { continue; } var asset = assetItem.BasicAsset; //当m_cdo.OverridesCollateralCF为true时(资产覆盖现金流开关打开) //Nancy不返回单笔资产信息(参考CAssetCashflowAnalyzer.vb SVN Revision=28324) if (asset == null) { continue; } viewModel.AssetDataset.Assets.Add(new AssetViewModel { AssetId = asset.AssetId, Interest = (decimal)asset.Interest, Principal = (decimal)asset.Principal, PrincipalBalance = (decimal)asset.Performing, Name = assetItem.SecurityData.SecurityName, AmortizationType = assetItem.AmortizationType }); } viewModel.AssetDataset.PaymentDay = paymentDate; viewModel.AssetDataset.ReCalculateSumAsset(); viewModel.AssetDataset.Sequence = datasetSchedule.Sequence; var amortization = datasetSchedule.Dataset.AmortizationSchedule; viewModel.EnablePrepaymentAssetIds = amortization.ConvertAll(x => x.AssetId).Distinct().ToList(); //添加当期之前(含今天所在的一期)的所有支付日 var nowDate = DateTime.Today; viewModel.ValidPaymentDays = new List <DateTime>(); foreach (var durationPeriod in projectLogicModel.DealSchedule.DurationPeriods) { //只添加已上传模型的支付日 datasetSchedule = projectLogicModel.DealSchedule.GetByPaymentDay(durationPeriod.PaymentDate); if (datasetSchedule.Dataset.Instance != null) { viewModel.ValidPaymentDays.Add(durationPeriod.PaymentDate); } if (durationPeriod.PaymentDate > nowDate) { break; } } var cnabsDealId = projectLogicModel.Instance.CnabsDealId; if (cnabsDealId.HasValue) { viewModel.AllPaymentDays = m_dbAdapter.Model.GetPaymentDates(cnabsDealId.Value); } else { if (projectLogicModel.DealSchedule.Instanse != null) { viewModel.AllPaymentDays = projectLogicModel.DealSchedule.Instanse.PaymentDates.ToList(); } else { viewModel.AllPaymentDays = new List <DateTime>(); } } return(View(viewModel)); }