public IExpression <Decimal?> CreateBaseLessOverlayTotalExpression( GlobeModel root, GlobeTraverser traverser, IModelFormula <IModel, Decimal?> baseLessOverlayFormula, IExpression <Decimal?> cashRescaledBase ) { var models = traverser.TraverseGlobe(root); var result = new Expression <Decimal?>( ValueNames.BaseLessOverlayTotal, new BaseLessOverlayTotalFormula( models, baseLessOverlayFormula, cashRescaledBase ), this.commonParts.NullableDecimalValueAdapter, this.commonParts.ValidateWhatever ); return(result); }
protected void RegisterMissingCountriesIfAny(ManagingBpt.RootModel result, Computations computations, CountryRepository countryRepository, TargetingType targetingType, SecurityRepository securityRepository, PortfolioRepository portfolioRepository, ManagingPst.PortfolioSecurityTargetRepository portfolioSecurityTargetRepository, IEnumerable <BenchmarkSumByIsoInfo> benchmarks) { // figuring out missing ISO country codes (if any) from benchmarks and overlays var missingCountriesIsoCodes = this.countriesDetector.FindMissingCountries( targetingType.Taxonomy, benchmarks, result.Factors.Items.Where(x => x.OverlayFactor.EditedValue.HasValue).Select(x => x.BottomUpPortfolio.Name), portfolioSecurityTargetRepository, portfolioRepository, securityRepository ); if (missingCountriesIsoCodes.Any()) { List <string> clearedMissingCountriesIsoCode; var traverser = new GlobeTraverser(); var otherModel = traverser.TraverseGlobe(result.Globe).Where(m => m.TryAsOther() != null).FirstOrDefault(); if (otherModel != null) { clearedMissingCountriesIsoCode = new List <string>(); var codesInModel = otherModel.TryAsOther().UnsavedBasketCountries.Select(b => b.Country.IsoCode).Union(otherModel.TryAsOther().BasketCountries.Select(b => b.Basket.Country.IsoCode)); clearedMissingCountriesIsoCode.AddRange(codesInModel.Except(missingCountriesIsoCodes)); } else { clearedMissingCountriesIsoCode = new List <string>(missingCountriesIsoCodes); } if (clearedMissingCountriesIsoCode.Any()) { // there are some missing ISO country codes // we need to resolve them to countries // and put these countries to the taxonomy var missingCountries = clearedMissingCountriesIsoCode.Select(x => countryRepository.GetCountry(x)); this.RegisterMissingCountries(result, missingCountries, computations); } } }