コード例 #1
0
        public CashflowBriefModel GenerateCashflowSummaryModel(List <Cashflow> cashFlows)
        {
            List <CashFlowBriefItem> items = new List <CashFlowBriefItem>();

            foreach (Months month in Enum.GetValues(typeof(Months)))
            {
                string currentMonth = edisRepo.GetEnumDescription(month);

                var currentFlows = cashFlows.Where(c => c.Month == currentMonth);

                CashFlowBriefItem newItem = new CashFlowBriefItem {
                    month   = currentMonth,
                    expense = currentFlows.Sum(c => c.Expenses),
                    income  = currentFlows.Sum(c => c.Income)
                };

                items.Add(newItem);
            }

            CashflowBriefModel model = new CashflowBriefModel {
                totalExpense = items.Sum(i => i.expense),
                totalIncome  = items.Sum(i => i.income),
                data         = items
            };

            return(model);
        }
コード例 #2
0
        public CashflowBriefModel GetCashflow_Client()
        {
            Client      client      = edisRepo.GetClientSync(User.Identity.GetUserId(), DateTime.Now);
            ClientGroup clientGroup = edisRepo.GetClientGroupSync(client.ClientGroupId, DateTime.Now);

            if (clientGroup.MainClientId == client.Id)
            {
                List <GroupAccount>  groupAccounts  = edisRepo.GetAccountsForClientGroupSync(clientGroup.ClientGroupNumber, DateTime.Now);
                List <ClientAccount> clientAccounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now);


                double totalExpenseInAssets = 0;
                double totalIncomeInAssets  = 0;

                List <CashFlowBriefItem> items = new List <CashFlowBriefItem>();

                CashFlowBriefItem jan = new CashFlowBriefItem {
                    month = "Jan"
                };
                CashFlowBriefItem feb = new CashFlowBriefItem {
                    month = "Feb"
                };
                CashFlowBriefItem mar = new CashFlowBriefItem {
                    month = "Mar"
                };
                CashFlowBriefItem apr = new CashFlowBriefItem {
                    month = "Apr"
                };
                CashFlowBriefItem may = new CashFlowBriefItem {
                    month = "May"
                };
                CashFlowBriefItem jun = new CashFlowBriefItem {
                    month = "Jun"
                };
                CashFlowBriefItem jul = new CashFlowBriefItem {
                    month = "Jul"
                };
                CashFlowBriefItem aug = new CashFlowBriefItem {
                    month = "Aug"
                };
                CashFlowBriefItem sep = new CashFlowBriefItem {
                    month = "Sep"
                };
                CashFlowBriefItem oct = new CashFlowBriefItem {
                    month = "Oct"
                };
                CashFlowBriefItem nov = new CashFlowBriefItem {
                    month = "Nov"
                };
                CashFlowBriefItem dec = new CashFlowBriefItem {
                    month = "Dec"
                };


                foreach (var account in groupAccounts)
                {
                    List <Cashflow> cashFlows = account.GetLiabilitiesSync().OfType <Insurance>().Cast <LiabilityBase>().ToList().GetMonthlyCashflows();

                    foreach (var cashflow in cashFlows)
                    {
                        switch (cashflow.Month)
                        {
                        case "Jan": jan.date = DateTime.Now; jan.expense += cashflow.Expenses; jan.income += cashflow.Income; break;

                        case "Feb": feb.date = DateTime.Now; feb.expense += cashflow.Expenses; feb.income += cashflow.Income; break;

                        case "Mar": mar.date = DateTime.Now; mar.expense += cashflow.Expenses; mar.income += cashflow.Income; break;

                        case "Apr": apr.date = DateTime.Now; apr.expense += cashflow.Expenses; apr.income += cashflow.Income; break;

                        case "May": may.date = DateTime.Now; may.expense += cashflow.Expenses; may.income += cashflow.Income; break;

                        case "Jun": jun.date = DateTime.Now; jun.expense += cashflow.Expenses; jun.income += cashflow.Income; break;

                        case "Jul": jul.date = DateTime.Now; jul.expense += cashflow.Expenses; jul.income += cashflow.Income; break;

                        case "Aug": aug.date = DateTime.Now; aug.expense += cashflow.Expenses; aug.income += cashflow.Income; break;

                        case "Sep": sep.date = DateTime.Now; sep.expense += cashflow.Expenses; sep.income += cashflow.Income; break;

                        case "Oct": oct.date = DateTime.Now; oct.expense += cashflow.Expenses; oct.income += cashflow.Income; break;

                        case "Nov": nov.date = DateTime.Now; nov.expense += cashflow.Expenses; nov.income += cashflow.Income; break;

                        case "Dec": dec.date = DateTime.Now; dec.expense += cashflow.Expenses; dec.income += cashflow.Income; break;

                        default: break;
                        }
                        totalExpenseInAssets += cashflow.Expenses;
                        totalIncomeInAssets  += cashflow.Income;
                    }
                }
                foreach (var account in clientAccounts)
                {
                    List <Cashflow> cashFlows = account.GetLiabilitiesSync().OfType <Insurance>().Cast <LiabilityBase>().ToList().GetMonthlyCashflows();

                    foreach (var cashflow in cashFlows)
                    {
                        switch (cashflow.Month)
                        {
                        case "Jan": jan.date = DateTime.Now; jan.expense += cashflow.Expenses; jan.income += cashflow.Income; break;

                        case "Feb": feb.date = DateTime.Now; feb.expense += cashflow.Expenses; feb.income += cashflow.Income; break;

                        case "Mar": mar.date = DateTime.Now; mar.expense += cashflow.Expenses; mar.income += cashflow.Income; break;

                        case "Apr": apr.date = DateTime.Now; apr.expense += cashflow.Expenses; apr.income += cashflow.Income; break;

                        case "May": may.date = DateTime.Now; may.expense += cashflow.Expenses; may.income += cashflow.Income; break;

                        case "Jun": jun.date = DateTime.Now; jun.expense += cashflow.Expenses; jun.income += cashflow.Income; break;

                        case "Jul": jul.date = DateTime.Now; jul.expense += cashflow.Expenses; jul.income += cashflow.Income; break;

                        case "Aug": aug.date = DateTime.Now; aug.expense += cashflow.Expenses; aug.income += cashflow.Income; break;

                        case "Sep": sep.date = DateTime.Now; sep.expense += cashflow.Expenses; sep.income += cashflow.Income; break;

                        case "Oct": oct.date = DateTime.Now; oct.expense += cashflow.Expenses; oct.income += cashflow.Income; break;

                        case "Nov": nov.date = DateTime.Now; nov.expense += cashflow.Expenses; nov.income += cashflow.Income; break;

                        case "Dec": dec.date = DateTime.Now; dec.expense += cashflow.Expenses; dec.income += cashflow.Income; break;

                        default: break;
                        }
                        totalExpenseInAssets += cashflow.Expenses;
                        totalIncomeInAssets  += cashflow.Income;
                    }
                }


                items.Add(jan);
                items.Add(feb);
                items.Add(mar);
                items.Add(apr);
                items.Add(may);
                items.Add(jun);
                items.Add(jul);
                items.Add(aug);
                items.Add(sep);
                items.Add(oct);
                items.Add(nov);
                items.Add(dec);


                CashflowBriefModel model = new CashflowBriefModel
                {
                    totalExpense = totalExpenseInAssets,
                    totalIncome  = totalIncomeInAssets,
                    data         = items
                };
                return(model);
            }
            else
            {
                List <ClientAccount> accounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now);
                double totalExpenseInAssets   = 0;
                double totalIncomeInAssets    = 0;

                List <CashFlowBriefItem> items = new List <CashFlowBriefItem>();

                CashFlowBriefItem jan = new CashFlowBriefItem {
                    month = "Jan"
                };
                CashFlowBriefItem feb = new CashFlowBriefItem {
                    month = "Feb"
                };
                CashFlowBriefItem mar = new CashFlowBriefItem {
                    month = "Mar"
                };
                CashFlowBriefItem apr = new CashFlowBriefItem {
                    month = "Apr"
                };
                CashFlowBriefItem may = new CashFlowBriefItem {
                    month = "May"
                };
                CashFlowBriefItem jun = new CashFlowBriefItem {
                    month = "Jun"
                };
                CashFlowBriefItem jul = new CashFlowBriefItem {
                    month = "Jul"
                };
                CashFlowBriefItem aug = new CashFlowBriefItem {
                    month = "Aug"
                };
                CashFlowBriefItem sep = new CashFlowBriefItem {
                    month = "Sep"
                };
                CashFlowBriefItem oct = new CashFlowBriefItem {
                    month = "Oct"
                };
                CashFlowBriefItem nov = new CashFlowBriefItem {
                    month = "Nov"
                };
                CashFlowBriefItem dec = new CashFlowBriefItem {
                    month = "Dec"
                };

                foreach (var account in accounts)
                {
                    //List<Cashflow> cashFlows = account.GetAssetsSync().GetMonthlyCashflows();

                    List <Cashflow> cashFlows = account.GetLiabilitiesSync().OfType <Insurance>().Cast <LiabilityBase>().ToList().GetMonthlyCashflows();

                    foreach (var cashflow in cashFlows)
                    {
                        switch (cashflow.Month)
                        {
                        case "Jan": jan.date = DateTime.Now; jan.expense += cashflow.Expenses; jan.income += cashflow.Income; break;

                        case "Feb": feb.date = DateTime.Now; feb.expense += cashflow.Expenses; feb.income += cashflow.Income; break;

                        case "Mar": mar.date = DateTime.Now; mar.expense += cashflow.Expenses; mar.income += cashflow.Income; break;

                        case "Apr": apr.date = DateTime.Now; apr.expense += cashflow.Expenses; apr.income += cashflow.Income; break;

                        case "May": may.date = DateTime.Now; may.expense += cashflow.Expenses; may.income += cashflow.Income; break;

                        case "Jun": jun.date = DateTime.Now; jun.expense += cashflow.Expenses; jun.income += cashflow.Income; break;

                        case "Jul": jul.date = DateTime.Now; jul.expense += cashflow.Expenses; jul.income += cashflow.Income; break;

                        case "Aug": aug.date = DateTime.Now; aug.expense += cashflow.Expenses; aug.income += cashflow.Income; break;

                        case "Sep": sep.date = DateTime.Now; sep.expense += cashflow.Expenses; sep.income += cashflow.Income; break;

                        case "Oct": oct.date = DateTime.Now; oct.expense += cashflow.Expenses; oct.income += cashflow.Income; break;

                        case "Nov": nov.date = DateTime.Now; nov.expense += cashflow.Expenses; nov.income += cashflow.Income; break;

                        case "Dec": dec.date = DateTime.Now; dec.expense += cashflow.Expenses; dec.income += cashflow.Income; break;

                        default: break;
                        }
                        totalExpenseInAssets += cashflow.Expenses;
                        totalIncomeInAssets  += cashflow.Income;
                    }
                }

                items.Add(jan);
                items.Add(feb);
                items.Add(mar);
                items.Add(apr);
                items.Add(may);
                items.Add(jun);
                items.Add(jul);
                items.Add(aug);
                items.Add(sep);
                items.Add(oct);
                items.Add(nov);
                items.Add(dec);


                CashflowBriefModel model = new CashflowBriefModel
                {
                    totalExpense = totalExpenseInAssets,
                    totalIncome  = totalIncomeInAssets,
                    data         = items
                };
                return(model);
            }
        }