Exemplo n.º 1
0
        /// <summary>
        /// For each report, check to see if at least ONE element do not exist in all other reports. If not, delete the report.
        /// For each column, check to see if at least ONE element do not exist in all other reports. If not, delete the column.
        /// </summary>
        public void CleanupFlowThroughReports()
        {
            ArrayList reportsToRemove = new ArrayList();

            foreach (ReportHeader rh in this.currentFilingSummary.MyReports)
            {
                //EH: Based on Christy's request, if the report is Stockholder's Equity, do not remove columns
                //DuPont and Oceanic filings will not look correct if we remove the columns. All elements for certain periods are in both
                //Balance Sheet and Stockholder's Equity
                if ((rh.ReportType == ReportHeaderType.Sheet || rh.ReportType == ReportHeaderType.Notes))
                {
                    if (!rh.IsStatementOfStockholdersEquity())
                    {
                        Dictionary <string, int> htElementsCurrentReport = this.BuildInUseElementsForCurrentReport(rh);
                        Dictionary <string, int> htElementsOtherReports  = this.BuildInUseElementsForAllReports(rh);
                        //Dictionary<string, int> uniqueSegments = this.BuildInUseSegmentsForAllReports( rh );

                        int elementFoundInOtherReports = 0;
                        foreach (string currentElementName in htElementsCurrentReport.Keys)
                        {
                            if (htElementsOtherReports.ContainsKey(currentElementName))
                            {
                                elementFoundInOtherReports += 1;
                            }
                        }

                        if (elementFoundInOtherReports == htElementsCurrentReport.Count)                          //all elements in other report
                        {
                            //Remove the report
                            if (!ReportUtils.IsHighlights(rh.ShortName) && !ReportUtils.IsBalanceSheet(rh.ShortName) && !ReportUtils.IsIncomeStatement(rh.ShortName))
                            {
                                reportsToRemove.Add(rh);
                            }
                        }
                        else
                        {
                            InstanceReport.ElementSegmentCombinations allInUseElementsSegments = this.BuildInUseElementSegmentCombinationsForAllReports(rh);
                            this.CleanupColumns(rh, allInUseElementsSegments);
                            this.uniqueReportElementSegmentCombos.Remove(rh.XmlFileName);

                            //CleanupColumns( rh, htElementsOtherReports, uniqueSegments );
                        }
                    }
                }
            }

            if (reportsToRemove.Count > 0)
            {
                foreach (ReportHeader rhToRemove in reportsToRemove)
                {
                    //delete from MyFilingSummary
                    for (int rIndex = currentFilingSummary.MyReports.Count - 1; rIndex >= 0; rIndex--)
                    {
                        ReportHeader rh1 = currentFilingSummary.MyReports[rIndex] as ReportHeader;
                        if (rh1.XmlFileName == rhToRemove.XmlFileName)
                        {
                            currentFilingSummary.MyReports.RemoveAt(rIndex);
                            break;
                        }
                    }
                    string fileName = currentReportDirectory + Path.DirectorySeparatorChar + rhToRemove.XmlFileName;
                    this.currentFilingSummary.TraceWarning("Process Flow-Through Report: removing '" + rhToRemove.LongName + "'");
                    File.Delete(fileName);
                }
            }
        }