예제 #1
0
        public IncomeStatementCollection ProjectIncomeStatementsAvgRevenueGrowth(string symbol, int fromYear, int yrsToProject)
        {
            IncomeStatementCollection incProjections = IncomeStatementBL.Instance.GetIncomeStatements(symbol, fromYear - 2, fromYear);

            CheckEnoughIncomeStatements(incProjections);
            decimal avgGrowthRate = GetRevenueAverageGrowthRate(incProjections);

            for (int i = fromYear + 1; i < fromYear + yrsToProject + 1; i++)
            {
                IncomeStatement lastYrInc = incProjections.Find(i - 1);
                if (lastYrInc != null)
                {
                    incProjections.Add(new IncomeStatement(
                                           incProjections[0].Symbol,
                                           i,
                                           lastYrInc.Revenue * (1 + avgGrowthRate),
                                           lastYrInc.Revenue * (1 + avgGrowthRate) * GetAvgPercentOfSales("Cogs", incProjections),
                                           lastYrInc.Revenue * (1 + avgGrowthRate) * GetAvgPercentOfSales("OperatingExpenses", incProjections),
                                           lastYrInc.Revenue * (1 + avgGrowthRate) * GetAvgPercentOfSales("Depreciation", incProjections),
                                           lastYrInc.Revenue * (1 + avgGrowthRate) * GetAvgPercentOfSales("NetIncome", incProjections),
                                           lastYrInc.Revenue * (1 + avgGrowthRate) * GetAvgPercentOfSales("CapitalExpenditures", incProjections)
                                           ));
                }
            }

            return(incProjections);
        }
예제 #2
0
        public IncomeStatementCollection GetIncomeStatements(string tickerSymbol, int fromYear, int toYear)
        {
            IncomeStatementCollection incs = null;
            IncomeStatement           inc  = null;

            MySqlParameter[] parms = new MySqlParameter[] {
                new MySqlParameter("@SYMBOL", MySqlDbType.VarChar),
                new MySqlParameter("@FROMYEAR", MySqlDbType.Int16),
                new MySqlParameter("@TOYEAR", MySqlDbType.Int16)
            };

            parms[0].Value = tickerSymbol;
            parms[1].Value = fromYear;
            parms[2].Value = toYear;

            using (MySqlDataReader rdr = MySqlHelper.ExecuteReader(MySqlHelper.SV_CONN_STRING, SQL_SELECT_INCS, parms))
            {
                if (rdr.Read())
                {
                    //If there is one result
                    incs = new IncomeStatementCollection();
                    //Scroll through the results
                    do
                    {
                        inc = ConvertReaderToIncomeStatementObject(rdr);
                        if (inc.Revenue != 0)
                        {
                            incs.Add(inc);
                        }
                    }while (rdr.Read());
                }
            }

            return(incs);
        }
예제 #3
0
 /// <summary>
 /// Sets values for non existing periods from a previous instance
 /// </summary>
 /// <remarks>Used to fill-forward values from previous dates</remarks>
 /// <param name="previous">The previous instance</param>
 public void UpdateValues(FinancialStatements previous)
 {
     TotalRiskBasedCapital.UpdateValues(previous.TotalRiskBasedCapital);
     IncomeStatement.UpdateValues(previous.IncomeStatement);
     BalanceSheet.UpdateValues(previous.BalanceSheet);
     CashFlowStatement.UpdateValues(previous.CashFlowStatement);
 }
        public BalanceSheetCollection ProjectBalanceSheets(string symbol, int fromYear, int yrsToProject, IncomeStatementCollection incs)
        {
            BalanceSheetCollection balProjections = BalanceSheetBL.Instance.GetBalanceSheets(symbol, fromYear - 2, fromYear);

            if (balProjections == null || balProjections.Count < 1)
            {
                throw new Exception("Not enough Balance Sheet Data");
            }

            for (int i = fromYear + 1; i < fromYear + yrsToProject + 1; i++)
            {
                IncomeStatement thisInc = incs.Find(i);
                if (thisInc != null)
                {
                    balProjections.Add(new BalanceSheet(
                                           incs[0].Symbol,
                                           i,
                                           thisInc.Revenue * GetAvgPercentOfSales("CurrentAssets", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("CurrentLiabilities", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("Ppe", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("Cash", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("Debt", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("ShareholdersEquity", balProjections, incs),
                                           thisInc.Revenue * GetAvgPercentOfSales("TotalAssets", balProjections, incs)
                                           ));
                }
            }

            return(balProjections);
        }
        public async Task <FinancialRatio> FindByLoanApplication(long loanApplicationId)
        {
            BalanceSheetSummary balanceSheetSummary = await balanceSheetSummaryRepository.GetByLoanApplication(loanApplicationId);

            IncomeStatement incomeStatement = await businessRepository.GetIncomeStatement(loanApplicationId);

            var personalExpenses = await personalExpenseRepository.GetByLoanApplication(loanApplicationId);

            LoanApplication loanApplication = await context.LoanApplications.SingleOrDefaultAsync(e => e.Id == loanApplicationId);

            var internalLoansAnnualAmortization = (await internalLoanAnnualAmortizationRepository.GetAnnualAmortizations(loanApplication.Id, loanApplication.RecastDate)).ToList();


            var appliedLoanPaymentCapacity = await loanApplicationAnnualAmortizationRepository.GetLoanApplicationCapacity(loanApplication);

            internalLoansAnnualAmortization.Add(appliedLoanPaymentCapacity);

            var externalLoansAnnualAmortization = await externalLoanAnnualAmortizationRepository.GetAnnualAmortizations(loanApplication.Id, loanApplication.RecastDate);

            var existingLoans = (await existingLoanRepository.GetActiveByLoanApplication(loanApplication.Id))
                                .Where(x => x.IsForRenewal == false);

            return(new FinancialRatio
            {
                BalanceSheetSummary = balanceSheetSummary,
                IncomeStatement = incomeStatement,
                PersonalExpenses = personalExpenses,
                LoanApplication = loanApplication,
                ExistingLoans = existingLoans,
                InternalLoansAnnualAmortization = internalLoansAnnualAmortization,
                ExternalLoansAnnualAmortization = externalLoansAnnualAmortization
            });
        }
예제 #6
0
 /// <summary>
 /// Creates an instance of the FinancialStatements class
 /// </summary>
 public FinancialStatements()
 {
     TotalRiskBasedCapital = new TotalRiskBasedCapital();
     IncomeStatement       = new IncomeStatement();
     BalanceSheet          = new BalanceSheet();
     CashFlowStatement     = new CashFlowStatement();
 }
        public void Delete(int id)
        {
            IncomeStatement state = context.IncomeStatements.SingleOrDefault(x => x.Id == id);

            context.IncomeStatements.Remove(state);
            context.SaveChanges();
        }
예제 #8
0
        // GET: Reports
        public ActionResult Index(DateTime?dateFrom, DateTime?dateTo)
        {
            //var dateFrom = DateTime.Parse( "3/1/2020");
            //var dateTo = DateTime.Parse("3/30/2020");
            if (dateFrom == null || dateTo == null)
            {
                return(View());
            }

            var grpId  = Operator().OwnerGroupId;
            var church = db.Churches.Where(x => x.OwnerGroupId == grpId).FirstOrDefault();

            var reporTitle = new ReportTitle()
            {
                ChurchName = church.Name,
                Period     = string.Format("Period: {0} - {1}", dateFrom.Value.ToShortDateString(), dateTo.Value.ToShortDateString())
            };

            var resut = new IncomeStatement()
            {
                Incomes                   = GetReportByType(AccountChartTypeEnum.Income, dateFrom.Value, dateTo.Value),
                Expenses                  = GetReportByType(AccountChartTypeEnum.Expenses, dateFrom.Value, dateTo.Value),
                NetAssetEndOfPeriod       = GetNetAsset(null, dateTo.Value, NetAsset.End),
                NetAssetBeginningOfPeriod = GetNetAsset(null, dateFrom.Value, NetAsset.Begginning),
                ReportTitle               = reporTitle
            };

            return(View(resut));
        }
예제 #9
0
        /// <summary>
        /// SaveIncomeStatement
        /// </summary>
        /// <param name="contract"></param>
        /// <param name="fmpSymbol"></param>
        /// <param name="xmlDocument"></param>
        /// <param name="date"></param>
        private void SaveIncomeStatement(Contract contract, string fmpSymbol, FundamentalsXmlDocument xmlDocument, string date)
        {
            if (DataContext.Instance.IncomeStatements.Any(i => i.Symbol == fmpSymbol && i.Date == date))
            {
                LogCurrent.Add($"Income statement for {contract.Company} for year {date} already exists in database.");
                return;
            }

            if (xmlDocument.Revenue == 0 && xmlDocument.OperatingIncome == 0 && xmlDocument.Eps == 0 && xmlDocument.NetIncome == 0)
            {
                LogCurrent.Add($"No IB data for income statement for {contract.Company} for year {date}.");
                return;
            }

            var incomeStatement = new IncomeStatement()
            {
                Symbol          = fmpSymbol,
                Date            = date,
                Revenue         = xmlDocument.Revenue,
                OperatingIncome = xmlDocument.OperatingIncome,
                Epsdiluted      = xmlDocument.Eps,
                NetIncome       = xmlDocument.NetIncome
            };

            try
            {
                DataContext.Instance.IncomeStatements.Add(incomeStatement);
                DataContext.Instance.SaveChanges();
                LogCurrent.Add($"OK! Income statement for {contract.Company} {date} saved in database.");
            }
            catch (Exception exception)
            {
                LogCurrent.Add(exception.ToString());
            }
        }
예제 #10
0
        public IncomeStatementCollection ProjectIncomeStatementsDecayRevenueGrowth(string symbol, int fromYear, int yrsToProject, decimal endGrowth)
        {
            IncomeStatementCollection incProjections = IncomeStatementBL.Instance.GetIncomeStatements(symbol, fromYear - 2, fromYear);

            CheckEnoughIncomeStatements(incProjections);

            decimal[] yoyGrowth = GetDecayGrowthRates(yrsToProject, endGrowth, incProjections);

            int j = 0;

            for (int i = fromYear + 1; i < fromYear + yrsToProject + 1; i++)
            {
                IncomeStatement lastYrInc = incProjections.Find(i - 1);
                if (lastYrInc != null)
                {
                    incProjections.Add(new IncomeStatement(
                                           incProjections[0].Symbol,
                                           i,
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]),
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]) * GetAvgPercentOfSales("Cogs", incProjections),
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]) * GetAvgPercentOfSales("OperatingExpenses", incProjections),
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]) * GetAvgPercentOfSales("Depreciation", incProjections),
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]) * GetAvgPercentOfSales("NetIncome", incProjections),
                                           lastYrInc.Revenue * (1 + yoyGrowth[j]) * GetAvgPercentOfSales("CapitalExpenditures", incProjections)
                                           ));
                }
                j++;
            }

            return(incProjections);
        }
예제 #11
0
        public async Task <IncomeStatementResponseDTO> GetIncomeStatement(long loanApplicationId)
        {
            IncomeStatement incomeStatement = await this.repository.GetIncomeStatement(loanApplicationId);

            IncomeStatementResponseDTO incomeStatementDTO = mapper.Map <IncomeStatementResponseDTO>(incomeStatement);

            return(incomeStatementDTO);
        }
예제 #12
0
        public ActionResult GenerateIncomeStatement()
        {
            IncomeStatement    statement       = (IncomeStatement)Session["Statement"];
            List <Transaction> transactionList = (List <Transaction>)ServiceFactory.GetTransactionServices().GetAllByPeriodInterval
                                                     ((int)Session["CompanyId"], statement.Start, statement.End);

            Session["transactionList"] = transactionList;
            return(View());
        }
예제 #13
0
        public ActionResult Details(int id)
        {
            IncomeStatement    statement       = ServiceFactory.GetIncomeStatementServices().Get(id);
            List <Transaction> transactionList = (List <Transaction>)ServiceFactory.GetTransactionServices().GetAllByPeriodInterval
                                                     ((int)Session["CompanyId"], statement.Start, statement.End);

            Session["transactionList"] = transactionList;

            return(View(statement));
        }
예제 #14
0
 public void InsertIncomeStatement(IncomeStatement inc)
 {
     MySqlParameter[] parms = GetIncomeStatementParameters();
     SetIncomeStatementParameters(inc, parms);
     using (MySqlConnection conn = new MySqlConnection(MySqlHelper.SV_CONN_STRING))
     {
         conn.Open();
         MySqlHelper.ExecuteNonQuery(conn, SQL_INSERT_INCOMESTATEMENT, parms);
     }
 }
예제 #15
0
        public ActionResult Create(FormCollection Form)
        {
            IncomeStatement statement = new IncomeStatement();

            statement.Start     = new DateTime(Convert.ToInt32(Form["StartYear"]), Convert.ToInt32(Form["StartMonth"]), 1);
            statement.End       = new DateTime(Convert.ToInt32(Form["EndYear"]), Convert.ToInt32(Form["EndMonth"]), 30);
            statement.CompanyId = (int)Session["CompanyId"];

            Session["Statement"] = statement;
            return(RedirectToAction("GenerateIncomeStatement"));
        }
        public void Update(IncomeStatement statement)
        {
            IncomeStatement state = context.IncomeStatements.SingleOrDefault(x => x.Id == statement.Id);

            state.Start       = statement.Start;
            state.End         = statement.End;
            state.Total       = statement.Total;
            state.Description = statement.Description;

            context.SaveChanges();
        }
예제 #17
0
 private static void SetIncomeStatementParameters(IncomeStatement inc, MySqlParameter[] parms)
 {
     parms[0].Value = inc.Symbol;
     parms[1].Value = inc.Year;
     parms[2].Value = inc.Revenue;
     parms[3].Value = inc.Cogs;
     parms[4].Value = inc.OperatingExpenses;
     parms[5].Value = inc.Depreciation;
     parms[6].Value = inc.NetIncome;
     parms[7].Value = inc.CapitalExpenditures;
 }
 public void UpdateIncomeStatement(IncomeStatement inc)
 {
     if (IncomeStatementExists(inc.Symbol, inc.Year))
     {
         _dao.UpdateIncomeStatement(inc);
     }
     else
     {
         _dao.InsertIncomeStatement(inc);
     }
 }
예제 #19
0
        /// <summary>
        /// 获取利润表
        /// </summary>
        /// <param name="id">利润表标识</param>
        /// <returns></returns>
        public IncomeStatement GetIncomeStatement(string id)
        {
            DBHelper        dh  = new DBHelper();
            IncomeStatement rep = new IncomeStatement();

            dh.strCmd = "SP_GetReport";
            dh.AddPare("@RepID", SqlDbType.NVarChar, 40, id);
            rep         = dh.Reader <IncomeStatement>().FirstOrDefault();
            dh.strCmd   = "SP_GetReportDetails";
            rep.Details = dh.Reader <T_ReportDetails>();
            return(rep);
        }
예제 #20
0
        /// <summary>
        /// 利润表信息页
        /// </summary>
        /// <param name="id">利润表标识</param>
        /// <returns></returns>
        public ViewResult IncomeStatement(string id)
        {
            IncomeStatement rep = new IncomeStatement();

            if (string.IsNullOrEmpty(id))
            {
                rep = new ReportSvc().GenPerviewIncomeStatement(Session["CurrentCompany"].ToString());
            }
            else
            {
                rep = new ReportSvc().GetIncomeStatement(id);
            }
            return(View(rep));
        }
예제 #21
0
        public async Task <CashFlowSummary> FindByLoanApplication(long loanApplicationId)
        {
            LoanApplication loanApplication = await loanApplicationRepository.FindAsync(loanApplicationId);


            IncomeStatement incomeStatement = await businessRepository.GetIncomeStatement(loanApplicationId);

            int numberOfYears = (int)Math.Ceiling((loanApplication.TermInMonths + loanApplication.GracePeriods) / (decimal)CoreSystemConstants.MonthsPerYear);

            var personalExpenses = await personalExpenseRepository.GetByLoanApplication(loanApplicationId);

            BalanceSheetSummary balanceSheetSummary = await balanceSheetSummaryRepository.GetByLoanApplication(loanApplicationId);

            IEnumerable <BuyOutLoan> buyOutLoans = await buyOutLoanRepository.GetByLoanApplication(loanApplicationId);

            IEnumerable <ExistingLoan> existingLoans = await existingLoanRepository.GetActiveByLoanApplication(loanApplicationId);

            List <ExistingLoan> excludedMarkedForRenewLoans = existingLoans.Where(e => e.IsForRenewal == false).ToList();


            var loanRepaymentCashFlow = new List <LoanRepaymentCashFlowItem>();

            var internalLoanCashFLow = await internalLoanCashFlowRepository.GenerateCashFlow(loanApplication, numberOfYears);

            var externalLoanCashFlow = await externalLoanCashFlowRepository.GenerateCashFlow(loanApplication, numberOfYears);

            loanRepaymentCashFlow.AddRange(internalLoanCashFLow);

            loanRepaymentCashFlow.AddRange(externalLoanCashFlow);

            loanRepaymentCashFlow.Add(await GenerateAppliedLoanCashFlow(loanApplication, numberOfYears));



            var renewedLoans = existingLoans.Where(e => e.IsForRenewal == true).ToList();

            CashFlowSummary cashFlow = new CashFlowSummary
            {
                IncomeStatement       = incomeStatement,
                NumberOfYears         = numberOfYears,
                LoanApplication       = loanApplication,
                PersonalExpenses      = personalExpenses,
                BalanceSheet          = balanceSheetSummary,
                BuyOutLoans           = buyOutLoans,
                ExistingLoansCashFlow = loanRepaymentCashFlow,
                RenewedLoans          = renewedLoans
            };

            return(cashFlow);
        }
예제 #22
0
        public CashFlowSummary()
        {
            IncomeStatement = new IncomeStatement();

            LoanApplication = new LoanApplication();

            PersonalExpenses = new List <PersonalExpense>();

            BalanceSheet = new BalanceSheetSummary();

            BuyOutLoans = new List <BuyOutLoan>();

            ExistingLoansCashFlow = new List <LoanRepaymentCashFlowItem>();
        }
예제 #23
0
        private IncomeStatement ConvertReaderToIncomeStatementObject(MySqlDataReader rdr)
        {
            IncomeStatement incstm = new IncomeStatement();

            incstm.Symbol              = MySqlHelper.ConvertReaderToString(rdr, "SYMBOL");
            incstm.Year                = MySqlHelper.ConvertReaderToInt(rdr, "YEAR");
            incstm.Revenue             = MySqlHelper.ConvertReaderToDecimal(rdr, "REVENUE");
            incstm.Cogs                = MySqlHelper.ConvertReaderToDecimal(rdr, "COGS");
            incstm.OperatingExpenses   = MySqlHelper.ConvertReaderToDecimal(rdr, "OPERATING_EXPENSES");
            incstm.Depreciation        = MySqlHelper.ConvertReaderToDecimal(rdr, "DEPRECIATION");
            incstm.NetIncome           = MySqlHelper.ConvertReaderToDecimal(rdr, "NET_INCOME");
            incstm.CapitalExpenditures = MySqlHelper.ConvertReaderToDecimal(rdr, "CAPITAL_EXPENDITURES");

            return(incstm);
        }
예제 #24
0
        /// <summary>
        /// Applies updated values from <paramref name="update"/> to this instance
        /// </summary>
        /// <remarks>Used to apply data updates to the current instance. This WILL overwrite existing values. Default update values are ignored.</remarks>
        /// <param name="update">The next data update for this instance</param>
        public void UpdateValues(FinancialStatements update)
        {
            if (update == null)
            {
                return;
            }

            if (update.PeriodEndingDate != default(DateTime))
            {
                PeriodEndingDate = update.PeriodEndingDate;
            }
            if (update.FileDate != default(DateTime))
            {
                FileDate = update.FileDate;
            }
            if (!string.IsNullOrWhiteSpace(update.AccessionNumber))
            {
                AccessionNumber = update.AccessionNumber;
            }
            if (!string.IsNullOrWhiteSpace(update.FormType))
            {
                FormType = update.FormType;
            }
            if (!string.IsNullOrWhiteSpace(update.PeriodAuditor))
            {
                PeriodAuditor = update.PeriodAuditor;
            }
            if (!string.IsNullOrWhiteSpace(update.AuditorReportStatus))
            {
                AuditorReportStatus = update.AuditorReportStatus;
            }
            if (!string.IsNullOrWhiteSpace(update.InventoryValuationMethod))
            {
                InventoryValuationMethod = update.InventoryValuationMethod;
            }
            if (update.NumberOfShareHolders != default(long))
            {
                NumberOfShareHolders = update.NumberOfShareHolders;
            }
            TotalRiskBasedCapital?.UpdateValues(update.TotalRiskBasedCapital);
            if (!string.IsNullOrWhiteSpace(update.PeriodType))
            {
                PeriodType = update.PeriodType;
            }
            IncomeStatement?.UpdateValues(update.IncomeStatement);
            BalanceSheet?.UpdateValues(update.BalanceSheet);
            CashFlowStatement?.UpdateValues(update.CashFlowStatement);
        }
예제 #25
0
        /// <summary>
        /// 利润表
        /// </summary>
        /// <param name="c_id">公司标识</param>
        /// <returns></returns>
        public IncomeStatement GenPerviewIncomeStatement(string c_id)
        {
            IncomeStatement rep = new IncomeStatement();
            DBHelper        dh  = new DBHelper();

            dh.strCmd = "SP_GenPerviewIncomeStatements";
            dh.AddPare("@C_ID", SqlDbType.NVarChar, 40, c_id);
            dh.AddPare("@Year", SqlDbType.Int, ParameterDirection.Output, 0, null);
            dh.AddPare("@Month", SqlDbType.Int, ParameterDirection.Output, 0, null);
            dh.AddPare("@RepNo", SqlDbType.NVarChar, ParameterDirection.Output, 40, null);
            rep.Details = dh.Reader <T_ReportDetails>();
            rep.Year    = dh.GetParaValue <int>("@Year");
            rep.Month   = dh.GetParaValue <int>("@Month");
            rep.RepNo   = dh.GetParaValue <string>("@RepNo");
            return(rep);
        }
예제 #26
0
        public ActionResult GenerateIncomeStatement(FormCollection Form)
        {
            IncomeStatement statement = (IncomeStatement)Session["Statement"];

            statement.Total       = Convert.ToDouble(Form["total"]);
            statement.Description = Form["Description"];

            ServiceFactory.GetIncomeStatementServices().Insert(statement);

            Company c = ServiceFactory.GetCompanyServices().Get((int)Session["CompanyId"]);

            ServiceFactory.GetCompanyServices().Update(c);

            Session["Statement"]       = null;
            Session["transactionList"] = null;
            return(RedirectToAction("Index"));
        }
        public IActionResult IncomeStatement(IncomeStatement incomeStatement)
        {
            var             purchaseSummary     = context.PurchaseProduct.PurchaseSummary(incomeStatement.StartDate, incomeStatement.EndDate);
            var             salesInvoiceSummary = context.SalesInvoice.SalesInvoiceSummary(incomeStatement.StartDate, incomeStatement.EndDate);
            IncomeStatement statement           = new IncomeStatement()
            {
                StartDate           = incomeStatement.StartDate,
                EndDate             = incomeStatement.EndDate,
                TotalPurchaseAmount = purchaseSummary["purchaseTotal"],
                AccountPayable      = purchaseSummary["purchaseDues"],
                TotalSalesAmount    = salesInvoiceSummary["salesGrandTotal"],
                AccountReceivable   = salesInvoiceSummary["salesDuesAmount"],
            };

            statement.FinalStatement = (statement.TotalSalesAmount + statement.AccountReceivable) - (statement.TotalPurchaseAmount + statement.AccountPayable);
            return(PartialView("_IncomeStatement", statement));
        }
예제 #28
0
        public void ProcessXbrlInstanceDocument(string xmlUrl, Dictionary <string, List <string> > xbrlTaxonomyTree)
        {
            JeffFerguson.Gepsio.XbrlDocument xbrlDoc = new XbrlDocument();
            xbrlDoc.Load(xmlUrl);

            //AddXbrlNodes(xbrlDoc);

            int yearsToLoad = 3;

            string fileName     = System.IO.Path.GetFileNameWithoutExtension(xmlUrl);
            string tickerSymbol = fileName.Split(new[] { '-' })[0];
            int    year         = GetFiscalYear(tickerSymbol, xbrlDoc.XbrlFragments[0]);

            IncomeStatement   incToAdd     = new IncomeStatement();
            BalanceSheet      balToAdd     = new BalanceSheet();
            CompanyAnnualData compAnnToAdd = new CompanyAnnualData();

            Dictionary <string, Object> yahooStats = GetYahooStatistics(tickerSymbol);

            CreateCompanyObject(tickerSymbol, xbrlDoc, yahooStats);

            for (int y = year; y > year - yearsToLoad; y--)
            {
                XbrlIncomeStatementFilter incFilter    = new XbrlIncomeStatementFilter();
                XbrlBalanceSheetFilter    bsFilter     = new XbrlBalanceSheetFilter();
                XbrlCompanyAnnualFilter   compAnFilter = new XbrlCompanyAnnualFilter();

                incToAdd     = incFilter.Populate(this, xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                balToAdd     = bsFilter.Populate(xbrlDoc, tickerSymbol, y, xbrlTaxonomyTree);
                compAnnToAdd = compAnFilter.Populate(xbrlDoc, tickerSymbol, y);

                compAnnToAdd.LeveredBeta   = Convert.ToDecimal(yahooStats["Beta"]);
                compAnnToAdd.DividendYield = Convert.ToDecimal(yahooStats["DividendYield"]);

                IncomeStatementBL.Instance.UpdateIncomeStatement(incToAdd);
                BalanceSheetBL.Instance.UpdateBalanceSheet(balToAdd);
                CompanyAnnualDataBL.Instance.UpdateCompanyAnnual(compAnnToAdd);
            }
        }
예제 #29
0
        public FreeCashFlowCollection CalculateFreeCashFlow(string symbol, int year, int yrsToProject, IncomeStatementCollection incomeStatementProjection)
        {
            FreeCashFlowCollection fcfs = null;

            MarketParameters mktParms = MarketParametersBL.Instance.GetMarketParameters();

            BalanceSheetProjectionBL bsProjectionBL = new BalanceSheetProjectionBL();

            BalanceSheetCollection bsProjections = bsProjectionBL.ProjectBalanceSheets(symbol, year, yrsToProject, incomeStatementProjection);

            if (incomeStatementProjection != null && bsProjections != null)
            {
                fcfs = new FreeCashFlowCollection();
                for (int i = year + 1; i < year + yrsToProject + 1; i++)
                {
                    IncomeStatement inc      = incomeStatementProjection.Find(i);
                    BalanceSheet    bs       = bsProjections.Find(i);
                    BalanceSheet    lastYrBs = bsProjections.Find(i - 1);

                    if (inc != null && bs != null)
                    {
                        fcfs.Add(new FreeCashFlow(
                                     symbol,
                                     i,
                                     inc.NOP(mktParms.TaxRate),
                                     inc.NetIncome,
                                     (bs.Ppe - lastYrBs.Ppe + inc.Depreciation),
                                     bs.WorkingCapital,
                                     bs.WorkingCapital - lastYrBs.WorkingCapital,
                                     inc.Depreciation,
                                     bs.InvestedCapital
                                     ));
                    }
                }
            }

            return(fcfs);
        }
        public IncomeStatement Populate(XbrlNodeBL nodeMngr, XbrlDocument xbrlDoc, string symbol, int year, Dictionary <string, List <string> > xbrlTaxonomyTree)
        {
            IncomeStatement inc = new IncomeStatement();

            inc.Symbol = symbol;
            inc.Year   = year;

            IncomeStatementFilterItem item = new IncomeStatementFilterItem();

            foreach (XbrlFragment frag in xbrlDoc.XbrlFragments)
            {
                foreach (Item xbrlItem in frag.Facts)
                {
                    if (nodeMngr.IsAnnualItem(xbrlItem) && xbrlItem.Type.Name.Equals("monetaryItemType"))
                    {
                        if (xbrlItem.ContextRef.PeriodEndDate.Year == inc.Year)
                        {
                            item = CheckItem(xbrlItem, item, xbrlTaxonomyTree);
                        }
                    }
                }
            }
            return(PopulateFinancialStatement(item, inc));
        }
예제 #31
0
        static IncomeStatement incomestatementDB(KNMFin.Google.IncomeStatement inc, StockPortfolioEntities7 spe)
        {
            var incDB = new IncomeStatement( );
            incDB.Accounting_Change = inc.Accounting_Change;
            incDB.Annual = inc.Period == Period.Annual ? true : false;
            incDB.Basic_EPS_after_Stock_Based_Comp_Expense = inc.Basic_EPS_after_Stock_Based_Comp_Expense;
            incDB.Basic_EPS_Excluding_Extraordinary_Items = inc.Basic_EPS_Excluding_Extraordinary_Items;
            incDB.Basic_EPS_Including_Extraordinary_Items = inc.Basic_EPS_Including_Extraordinary_Items;
            incDB.Basic_Normalized_EPS = inc.Basic_Normalized_EPS;
            incDB.Basic_Weighted_Average_Shares = inc.Basic_Weighted_Average_Shares;
            incDB.Cost_of_Revenue_Total = inc.Cost_of_Revenue_Total;
            incDB.Depreciation_and_Amortization = inc.Depreciation_and_Amortization;
            incDB.Depreciation_Supplemental = inc.Depreciation_Supplemental;
            incDB.Diluted_EPS_after_Stock_Based_Comp_Expense = inc.Diluted_EPS_after_Stock_Based_Comp_Expense;
            incDB.Diluted_EPS_Excluding_Extraordinary_Items = inc.Diluted_EPS_Excluding_Extraordinary_Items;
            incDB.Diluted_EPS_Including_Extraordinary_Items = inc.Diluted_EPS_Including_Extraordinary_Items;
            incDB.Diluted_Normalized_EPS = inc.Diluted_Normalized_EPS;
            incDB.Diluted_Weighted_Average_Shares = inc.Diluted_Weighted_Average_Shares;
            incDB.Dilution_Adjustment = inc.Dilution_Adjustment;
            incDB.Discontinued_Operations = inc.Discontinued_Operations;
            incDB.Dividends_per_Share__less__Common_Stock_Primary_Issue = inc.Dividends_per_Share__less__Common_Stock_Primary_Issue;
            incDB.Effect_of_Special_Items_on_Income_Taxes = inc.Effect_of_Special_Items_on_Income_Taxes;
            incDB.Equity_In_Affiliates = inc.Equity_In_Affiliates;
            incDB.Extraordinary_Item = inc.Extraordinary_Item;
            incDB.Gain___Loss___on_Sale_of_Assets = inc.Gain___Loss___on_Sale_of_Assets;
            incDB.Gross_Dividends__less__Common_Stock = inc.Gross_Dividends__less__Common_Stock;
            incDB.Gross_Profit = inc.Gross_Profit;
            incDB.Income_After_Tax = inc.Income_After_Tax;
            incDB.Income_Available_to_Common_Excl_Extra_Items = inc.Income_Available_to_Common_Excl_Extra_Items;
            incDB.Income_Available_to_Common_Incl_Extra_Items = inc.Income_Available_to_Common_Incl_Extra_Items;
            incDB.Income_Before_Tax = inc.Income_Before_Tax;
            incDB.Income_Taxes_Ex_Impact_of_Special_Items = inc.Income_Taxes_Ex_Impact_of_Special_Items;

            incDB.Interest_Income__Expense___Net_NonOperating = inc.Interest_Expense__Income___less_Net_Operating;
            incDB.Interest_Expense__Income___less_Net_Operating = inc.Interest_Income__Expense___Net_NonOperating;
            incDB.Minority_Interest = inc.Minority_Interest;
            incDB.Net_Income = inc.Net_Income;
            incDB.Net_Income_after_Stock_Based_Comp_Expense = inc.Net_Income_after_Stock_Based_Comp_Expense;
            incDB.Net_Income_Before_Extra_Items = inc.Net_Income_Before_Extra_Items;
            incDB.Normalized_Income_After_Taxes = inc.Normalized_Income_After_Taxes;
            incDB.Normalized_Income_Avail_to_Common = inc.Normalized_Income_Avail_to_Common;
            incDB.Normalized_Income_Before_Taxes = inc.Normalized_Income_Before_Taxes;
            incDB.Operating_Income = inc.Operating_Income;
            incDB.Other_Net = inc.Other_Net;
            incDB.Other_Operating_Expenses_Total = inc.Other_Operating_Expenses_Total;
            incDB.Other_Revenue_Total = inc.Other_Revenue_Total;
            incDB.PeriodEnd = inc.PeriodEnd;
            incDB.Preferred_Dividends = inc.Preferred_Dividends;
            incDB.Research_and_Development = inc.Research_and_Development;
            incDB.Revenue = inc.Revenue;
            incDB.Selling_and_General_and_Admin_Expenses_Total = inc.Selling_and_General_and_Admin_Expenses_Total;
            incDB.Total_Operating_Expense = inc.Total_Operating_Expense;
            incDB.Total_Revenue = inc.Total_Revenue;
            incDB.Total_Special_Items = inc.Total_Special_Items;
            incDB.Unusual_Expense___Income__ = inc.Unusual_Expense___Income__;

            int id = spe.IncomeStatements.Count() + 1;
            incDB.ID = id;
            return incDB;
        }