public InvestmentPortfolioModel GenerateInvestPortfolioModel(List <AssetBase> assets) { InvestmentPortfolioModel model = new InvestmentPortfolioModel { data = new List <DataNameAmountPair> { new DataNameAmountPair { name = "Australian Equity", amount = assets.GetTotalMarketValue_ByAssetType <AustralianEquity>(), returnValue = assets.OfType <AustralianEquity>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, new DataNameAmountPair { name = "International Equity", amount = assets.GetTotalMarketValue_ByAssetType <InternationalEquity>(), returnValue = assets.OfType <InternationalEquity>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, new DataNameAmountPair { name = "Managed Investments", amount = assets.GetTotalMarketValue_ByAssetType <ManagedInvestment>(), returnValue = assets.OfType <ManagedInvestment>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, new DataNameAmountPair { name = "Direct & Listed Property", amount = assets.GetTotalMarketValue_ByAssetType <DirectProperty>(), returnValue = assets.OfType <DirectProperty>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, new DataNameAmountPair { name = "Fixed Income Investments", amount = assets.GetTotalMarketValue_ByAssetType <FixedIncome>(), returnValue = assets.OfType <FixedIncome>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, new DataNameAmountPair { name = "Cash & Term Deposit", amount = assets.GetTotalMarketValue_ByAssetType <Cash>(), returnValue = assets.OfType <Cash>().Cast <AssetBase>().ToList().GetTotalCost().CapitalGain }, }, }; double totalAmount = model.data.Sum(d => d.amount); model.data.ForEach(d => { d.percentage = (totalAmount == 0 ? 0 : d.amount / totalAmount) * 100; model.total += d.amount; model.totalReturn += d.returnValue; }); model.totalPercentage = 100; return(model); }
public InvestmentPortfolioModel GetAssetAllocationSummary_Adviser(string clientGroupId = null) { if (string.IsNullOrEmpty(clientGroupId)) { List <GroupAccount> groupAccounts = edisRepo.getAllClientGroupAccountsForAdviser(User.Identity.GetUserId(), DateTime.Now); List <ClientAccount> clientAccounts = edisRepo.getAllClientAccountsForAdviser(User.Identity.GetUserId(), DateTime.Now); double totalMarketValueAE = 0; double totalMarketValueIE = 0; double totalMarketValueMI = 0; double totalMarketValueDP = 0; double totalMarketValueFI = 0; double totalMarketValueCD = 0; foreach (var account in groupAccounts) { totalMarketValueAE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <AustralianEquity>(); totalMarketValueIE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <InternationalEquity>(); totalMarketValueMI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <ManagedInvestment>(); totalMarketValueDP += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <DirectProperty>(); totalMarketValueFI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <FixedIncome>(); totalMarketValueCD += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <Cash>(); } foreach (var account in clientAccounts) { totalMarketValueAE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <AustralianEquity>(); totalMarketValueIE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <InternationalEquity>(); totalMarketValueMI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <ManagedInvestment>(); totalMarketValueDP += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <DirectProperty>(); totalMarketValueFI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <FixedIncome>(); totalMarketValueCD += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <Cash>(); } InvestmentPortfolioModel model = new InvestmentPortfolioModel { data = new List <DataNameAmountPair> { new DataNameAmountPair { name = "Australian Equity", amount = totalMarketValueAE }, new DataNameAmountPair { name = "International Equity", amount = totalMarketValueIE }, new DataNameAmountPair { name = "Managed Investments", amount = totalMarketValueMI }, new DataNameAmountPair { name = "Direct & Listed Property", amount = totalMarketValueDP }, new DataNameAmountPair { name = "Miscellaneous Investments", amount = totalMarketValueAE }, new DataNameAmountPair { name = "Fixed Income Investments", amount = totalMarketValueFI }, new DataNameAmountPair { name = "Cash & Term Deposit", amount = totalMarketValueCD }, }, }; return(model); } else { ClientGroup clientGroup = edisRepo.getClientGroupByGroupId(clientGroupId); List <GroupAccount> accounts = edisRepo.GetAccountsForClientGroupSync(clientGroup.ClientGroupNumber, DateTime.Now); List <ClientAccount> clientAccounts = new List <ClientAccount>(); clientGroup.GetClientsSync().ForEach(c => clientAccounts.AddRange(c.GetAccountsSync())); double totalMarketValueAE = 0; double totalMarketValueIE = 0; double totalMarketValueMI = 0; double totalMarketValueDP = 0; double totalMarketValueFI = 0; double totalMarketValueCD = 0; foreach (var account in accounts) { totalMarketValueAE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <AustralianEquity>(); totalMarketValueIE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <InternationalEquity>(); totalMarketValueMI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <ManagedInvestment>(); totalMarketValueDP += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <DirectProperty>(); totalMarketValueFI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <FixedIncome>(); totalMarketValueCD += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <Cash>(); } foreach (var account in clientAccounts) { totalMarketValueAE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <AustralianEquity>(); totalMarketValueIE += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <InternationalEquity>(); totalMarketValueMI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <ManagedInvestment>(); totalMarketValueDP += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <DirectProperty>(); totalMarketValueFI += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <FixedIncome>(); totalMarketValueCD += account.GetAssetsSync().GetTotalMarketValue_ByAssetType <Cash>(); } InvestmentPortfolioModel model = new InvestmentPortfolioModel { data = new List <DataNameAmountPair> { new DataNameAmountPair { name = "Australian Equity", amount = totalMarketValueAE }, new DataNameAmountPair { name = "International Equity", amount = totalMarketValueIE }, new DataNameAmountPair { name = "Managed Investments", amount = totalMarketValueMI }, new DataNameAmountPair { name = "Direct & Listed Property", amount = totalMarketValueDP }, new DataNameAmountPair { name = "Miscellaneous Investments", amount = totalMarketValueAE }, new DataNameAmountPair { name = "Fixed Income Investments", amount = totalMarketValueFI }, new DataNameAmountPair { name = "Cash & Term Deposit", amount = totalMarketValueCD }, }, }; return(model); } //return repo.ManagedInvestment_GetAssetAllocation_Adviser(User.Identity.GetUserId()); }