public object Clone() { //InstanceReportRow row = new InstanceReportRow( this ); InstanceReportRow row = (InstanceReportRow)this.Clone(true, true); return(row); }
/// <summary> /// A helper method for the 'DisplayZeroAsNone' rule. See <see cref="ApplyRulesToReport"/> /// </summary> /// <param name="thisRow">The row to check if it is based on an element which should display as 'none'.</param> private void ProcessZeroAsNoneCell(InstanceReportRow thisRow) { string elementName = thisRow.ElementName; int sepPos = elementName.IndexOf("_"); if (sepPos > 0) { elementName = elementName.Substring(sepPos + 1); } this.CurrentElementName = elementName; bool isRuleEnabled = this.FireRuleProcessing(RulesEngineUtils.DISPLAY_ZERO_AS_NONE); if (isRuleEnabled) { Dictionary <string, object> contextObjects = new Dictionary <string, object>(); contextObjects.Add("ReportBuilder", this); BuilderRules.ProcessRule(RulesEngineUtils.DISPLAY_ZERO_AS_NONE, contextObjects); this.FireRuleProcessed(RulesEngineUtils.DISPLAY_ZERO_AS_NONE); } else { IsZeroAsNoneElement = false; } }
private bool IsMatchingRow(InstanceReportRow leftRow, InstanceReportRow rightRow) { if (leftRow.ElementName != rightRow.ElementName) { return(false); } foreach (Segment keepSeg in leftRow.EmbedRequirements.Segments) { bool found = false; foreach (Segment remSeg in rightRow.EmbedRequirements.Segments) { if (string.Equals(keepSeg.DimensionInfo.dimensionId, remSeg.DimensionInfo.dimensionId)) { if (string.Equals(keepSeg.DimensionInfo.Id, remSeg.DimensionInfo.Id)) { found = true; break; } else { return(false); } } } if (!found) { return(false); } } return(true); }
/// <summary> /// A helper method for the 'DisplayAsRatio' rule. See <see cref="ApplyRulesToReport"/> /// </summary> /// <param name="thisRow">A row that was passed to <see cref="IsAcceptedpercentItemType"/> resulting in 'true'.</param> private void ProcessRatioCell(InstanceReportRow thisRow) { string elementName = thisRow.ElementName; int sepPos = elementName.IndexOf("_"); if (sepPos > 0) { elementName = elementName.Substring(sepPos + 1); } this.CurrentElementName = elementName; bool isRuleEnabled = this.FireRuleProcessing(RulesEngineUtils.DISPLAY_AS_RATIO); if (isRuleEnabled) { Dictionary <string, object> contextObjects = new Dictionary <string, object>(); contextObjects.Add("ReportBuilder", this); BuilderRules.ProcessRule(RulesEngineUtils.DISPLAY_AS_RATIO, contextObjects); this.FireRuleProcessed(RulesEngineUtils.DISPLAY_AS_RATIO); //If the element is a annual return or the data type is PercentItemType, then this is a ratio element if (thisRow.ElementName.IndexOf("AnnualReturn") >= 0 || IsAcceptedpercentItemType(thisRow)) { IsRatioElement = true; } } else { IsRatioElement = false; } }
public void CopyPrecision(InstanceReportRow arg) { if (arg.MyPrecision != null) { this.MyPrecision = new Precision(arg.MyPrecision.PrecisionType, arg.MyPrecision.NumberOfDigits); } }
public void CopyHeader(InstanceReportRow arg) { if (arg == null) { return; } Type stringType = typeof(string); Type myType = this.GetType(); //get the type from `this` foreach (PropertyInfo pi in myType.GetProperties()) { if (pi.CanRead && pi.CanWrite) { if (pi.PropertyType.IsEnum || pi.PropertyType.IsPrimitive || pi.PropertyType == stringType) { object value = pi.GetValue(arg, null); pi.SetValue(this, value, null); } } } foreach (FieldInfo fi in myType.GetFields()) { if (fi.FieldType.IsEnum || fi.FieldType.IsPrimitive || fi.FieldType == stringType) { object value = fi.GetValue(arg); fi.SetValue(this, value); } } //one extra BalanceDate = arg.BalanceDate; }
public void ApplyDataTo(InstanceReportRow that) { that.BalanceType = this.BalanceType; that.ElementDataType = this.ElementDataType; that.ElementDefenition = this.ElementDefenition; that.ElementName = this.ElementName; that.ElementPrefix = this.ElementPrefix; that.ElementReferences = this.ElementReferences; that.IsAbstractGroupTitle = this.IsAbstractGroupTitle; that.IsBaseElement = this.IsBaseElement; that.IsBeginningBalance = this.IsBeginningBalance; that.IsEndingBalance = this.IsEndingBalance; that.IsEquityAdjustmentRow = this.IsEquityAdjustmentRow; that.IsEquityPrevioslyReportedAsRow = this.IsEquityPrevioslyReportedAsRow; that.IsReverseSign = this.IsReverseSign; that.IsTotalLabel = this.IsTotalLabel; that.MyPrecision = this.MyPrecision; that.PeriodType = this.PeriodType; that.PreferredLabelRole = this.PreferredLabelRole; that.SimpleDataType = this.SimpleDataType; that.Unit = this.Unit; }
/// <summary> /// Generate bar chart data based on data within the embed report. /// </summary> /// <returns>A <see cref="SortedDictionary{TKey,TValue}"/> with the /// keys being years and values containing data.</returns> public SortedDictionary <int, double> GenerateBarChartData() { SortedDictionary <int, double> barChartData = new SortedDictionary <int, double>(); if (!IsBarChartReport()) { return(barChartData); } CommandIterator.IteratorType elPos = this.InstanceReport.GetElementLocation(); List <InstanceReportItem> items = null; if (elPos == CommandIterator.IteratorType.Column) { items = this.InstanceReport.Columns.ConvertAll(col => (InstanceReportItem)col); } else { items = this.InstanceReport.Rows.ConvertAll(row => (InstanceReportItem)row); } foreach (InstanceReportItem item in items) { if (item.EmbedRequirements == null) { continue; } InstanceReportRow irr = item.EmbedRequirements.ElementRow; if (irr.ElementName.IndexOf("AnnualReturn", StringComparison.CurrentCultureIgnoreCase) == -1) { continue; } string yearString = irr.ElementName.Substring(irr.ElementName.Length - 4, 4); int yearValue = 0; if (!int.TryParse(yearString, out yearValue)) { continue; } Cell[] cells = item.GetCellArray(this.InstanceReport); if (cells == null || cells.Length == 0) { continue; } foreach (Cell c in cells) { if (c.HasData) { barChartData[yearValue] = (double)c.NumericAmount; break; } } } return(barChartData); }
public void MergeAndReduceBeginningBalances(EquityPeriod that) { this.DistributeRows(); that.DistributeRows(); foreach (InstanceReportRow ebRow in this.EBRows) { InstanceReportRow bbRow = that.BBRows.Find(bb => IsMatchingRow(ebRow, bb)); if (bbRow == null) { continue; } for (int c = 0; c < ebRow.Cells.Count; c++) { Cell ebCell = ebRow.Cells[c]; Cell bbCell = bbRow.Cells[c]; if (!ebCell.HasData && bbCell.HasData) { Cell newCell = (Cell)bbCell.Clone(); ebRow.ReplaceCell(null, c, newCell); } } that.BBRows.Remove(bbRow); } }
private static InstanceReportRow CloneAndTruncate(InstanceReportRow rowFound, int cellCount) { int cellsToRemove = rowFound.Cells.Count - cellCount; InstanceReportRow newRow = (InstanceReportRow)rowFound.Clone(); newRow.Cells.RemoveRange(cellCount, cellsToRemove); return(newRow); }
private bool CompareRows(InstanceReport baseRep, InstanceReport newRep, DateTime reportDate, out string error) { error = string.Empty; output op = new output(Output); bool retval = true; RowCounter baseCount = BuildRowCount(baseRep); RowCounter newCount = BuildRowCount(newRep); //"Row property {0} mismatched counts: <br>Expected Results: '{1}' Actual Results: '{2}'" //Compare results of each dictionary: foreach (string key in baseCount.Keys) { if (baseCount[key] != newCount[key]) { retval = false; this.htmlStarter(string.Format(mismatchRows, key, baseCount[key], newCount[key]), reportDate, out error); //RLogger.Info(string.Format(debugParameters, baseRep.ReportLongName, newRep.ReportLongName, errorID, 433)); using (BaselineRules baseL = new BaselineRules(baseRep, newRep, errorID)) { baseL.EvaluateIsAbstractGroupRule(); } } } if (baseRep.Rows.Count != newRep.Rows.Count) { retval = false; this.htmlStarter(string.Format("Row counts do not match " + expectedResults, baseRep.Rows.Count, newRep.Rows.Count), reportDate, out error); } int min = Math.Min(baseRep.Rows.Count, newRep.Rows.Count); for (int r = 0; r < min; r++) { InstanceReportRow baseRow = baseRep.Rows[r]; InstanceReportRow newRow = newRep.Rows[r]; string baseLabel = WHITE_SPACE.Replace(baseRow.Label, " "); string newLabel = WHITE_SPACE.Replace(newRow.Label, " "); if (!string.Equals(baseLabel, newLabel)) { retval = false; this.htmlStarter(string.Format("Row '" + r + "' labels do not match " + expectedResults, baseLabel, newLabel), reportDate, out error); } if (!string.Equals(baseRow.FootnoteIndexer, newRow.FootnoteIndexer)) { retval = false; htmlStarter(string.Format(mismatchCell, r.ToString(), baseLabel, "Footnotes: " + baseRow.FootnoteIndexer, "Footnotes: " + newRow.FootnoteIndexer), reportDate, out error); } } return(retval); }
/// <summary> /// When used with a collection Balance Rows, this method will clear all of the empty rows. /// If all of the rows are empty, the first non-empty row will be retained. /// </summary> public void RemoveEmptyRows() { InstanceReportRow firstRow = this.Row; this.Rows.RemoveAll(row => row.IsEmpty()); if (this.Rows.Count == 0) { this.Row = firstRow; } }
public InstanceReportRow(InstanceReportRow arg) : this() { CopyHeader(arg); CopyPrecision(arg); foreach (Cell c in arg.Cells) { this.Cells.Add((Cell)c.Clone()); } }
public void ProcessBeginningAndEndingBalances() { //First, separate the duration columns and instant columns ArrayList durationColumnIndex = new ArrayList(); ArrayList instantColumnIndex = new ArrayList(); for (int colIndex = 0; colIndex < this.Columns.Count; colIndex++) { InstanceReportColumn irc = this.Columns[colIndex] as InstanceReportColumn; if (irc.MyContextProperty != null && irc.MyContextProperty.PeriodType == Element.PeriodType.duration) { durationColumnIndex.Add(colIndex); } else { instantColumnIndex.Add(colIndex); } } //Process Cash & Cash Equivalents Beginning/Ending Balances int beginingBalanceRowIndex = -1; int endingBalanceRowIndex = -1; for (int rowIndex = 0; rowIndex < this.Rows.Count; rowIndex++) { InstanceReportRow irr = this.Rows[rowIndex] as InstanceReportRow; if (!irr.IsReportTitle && !irr.IsSegmentTitle && (irr.IsBeginningBalance || irr.IsEndingBalance)) { if (irr.IsBeginningBalance) { beginingBalanceRowIndex = rowIndex; HandleBalances(true, irr, durationColumnIndex, instantColumnIndex); } if (irr.IsEndingBalance) { endingBalanceRowIndex = rowIndex; HandleBalances(false, irr, durationColumnIndex, instantColumnIndex); } } } //Check if one more step is necesary to realign the beginning/ending balances if (ReportUtils.IsCashFlowFromOps(this.ReportName) && beginingBalanceRowIndex != -1 && endingBalanceRowIndex != -1) { RealignCashRows(durationColumnIndex, beginingBalanceRowIndex, endingBalanceRowIndex); //Check if we should delete the "empty" instance column and possible extra duration columns DeleteEmptyColumns(beginingBalanceRowIndex, endingBalanceRowIndex, instantColumnIndex, durationColumnIndex); } }
/// <summary> /// Evaluates two rows from an instance report /// </summary> /// <param name="baseRows">The base row to compare</param> /// <param name="newRows">The new row to compare</param> /// <param name="errorNumber">The File ID from the SQL database</param> public BaselineRules(InstanceReportRow baseRows, InstanceReportRow newRows, int errorNumber) { if (baseRows != null && newRows != null && errorNumber != 0) { localBaseRows = baseRows; localNewRows = newRows; errorID = errorNumber; } else { throw new ArgumentNullException("report and errorNumber must be declared."); } }
private InstanceReportRow FindCloneAndTruncate(Predicate <InstanceReportRow> rowTest, int cellCount) { InstanceReportRow rowFound = this.Rows.Find(rowTest); if (rowFound == null) { return(null); } InstanceReportRow newRow = CloneAndTruncate(rowFound, cellCount); return(newRow); }
public void Dispose() { if (localBaseReport != null && localNewReport != null) { localBaseReport = null; localNewReport = null; } if (localBaseRows != null && localNewRows != null) { localBaseRows = null; localNewRows = null; } }
/// <summary> /// A helper method for the 'TotalLabel' rule. See <see cref="ApplyRulesToReport"/> /// </summary> /// <param name="thisRow">The row to check if it is based on a 'percent' element.</param> private void ProcessTotalLabelRow(InstanceReportRow thisRow) { bool isRuleEnabled = this.FireRuleProcessing(RulesEngineUtils.TOTAL_LABEL_RULE); if (isRuleEnabled) { Dictionary <string, object> contextObjects = new Dictionary <string, object>(); contextObjects.Add("Row", thisRow); contextObjects.Add("ReportBuilder", this); BuilderRules.ProcessRule(RulesEngineUtils.TOTAL_LABEL_RULE, contextObjects); this.FireRuleProcessed(RulesEngineUtils.TOTAL_LABEL_RULE); } }
public static bool IsEndingBalance(InstanceReportRow row) { if (string.IsNullOrEmpty(row.PreferredLabelRole)) { return(false); } foreach (string role in ENDING_BALANCE_ROLES) { if (row.PreferredLabelRole.IndexOf(role, StringComparison.InvariantCulture) > -1) { return(true); } } return(false); }
private void ProcessMapsOnRow(InstanceReportRow irr, List <ColumnInstantDurationMap> maps, Dictionary <int, bool> destinationColumns, Dictionary <int, Dictionary <string, bool> > sourceColumns) { foreach (ColumnInstantDurationMap colMap in maps) { Cell instantCell = irr.Cells[colMap.InstantColumnIndex]; if (!instantCell.HasData) { continue; } Cell durationCell = irr.Cells[colMap.DurationColumnIndex]; /* * if( durationCell.HasData ) * continue; * * bool hasUnit = false; * foreach( UnitProperty up in this.Columns[ colMap.DurationColumnIndex ].Units ) * { * if( string.Equals( up.UnitID, instantCell.UnitID ) ) * { * hasUnit = true; * break; * } * } */ if (!sourceColumns.ContainsKey(colMap.InstantColumnIndex)) { sourceColumns[colMap.InstantColumnIndex] = new Dictionary <string, bool>(); } sourceColumns[colMap.InstantColumnIndex][irr.ElementName] = true; destinationColumns[colMap.DurationColumnIndex] = true;; durationCell.AddData(instantCell); if (this.Columns[colMap.DurationColumnIndex].IsPseudoColumn) { this.Columns[colMap.DurationColumnIndex].IsPseudoColumnChanged = true; } } }
private void RealignCashRows(ArrayList durationColumnIndex, int beginingBalanceRowIndex, int endingBalanceRowIndex) { InstanceReportRow irBegin = this.Rows[beginingBalanceRowIndex] as InstanceReportRow; InstanceReportRow irEnd = this.Rows[endingBalanceRowIndex] as InstanceReportRow; //Fill in missing beginning balances from ending balance columns foreach (int colIndex in durationColumnIndex) { DateTime periodStartDate = this.Columns[colIndex].MyContextProperty.PeriodStartDate;; //Try look for an ending balance cell that has the end date = periodStartDate, or periodStartDate -1 foreach (int colIndex2 in durationColumnIndex) { DateTime periodEndDate = this.Columns[colIndex2].MyContextProperty.PeriodEndDate; if (periodEndDate == periodStartDate || periodEndDate == periodStartDate.AddDays(-1)) { (irBegin.Cells[colIndex] as Cell).NumericAmount = (irEnd.Cells[colIndex2] as Cell).NumericAmount; (irBegin.Cells[colIndex] as Cell).RoundedNumericAmount = (irEnd.Cells[colIndex2] as Cell).RoundedNumericAmount; break; } } } //Fill in missing ending balances from same period end columns foreach (int colIndex in durationColumnIndex) { if ((irEnd.Cells[colIndex] as Cell).NumericAmount == 0) //find the ending balance from another duration column { DateTime periodEndDate = this.Columns[colIndex].MyContextProperty.PeriodEndDate; foreach (int colIndex2 in durationColumnIndex) { if (colIndex2 != colIndex && periodEndDate == this.Columns[colIndex2].MyContextProperty.PeriodEndDate && (irEnd.Cells[colIndex2] as Cell).NumericAmount != 0) { (irEnd.Cells[colIndex] as Cell).IsNumeric = true; (irEnd.Cells[colIndex] as Cell).NumericAmount = (irEnd.Cells[colIndex2] as Cell).NumericAmount; (irEnd.Cells[colIndex] as Cell).RoundedNumericAmount = (irEnd.Cells[colIndex2] as Cell).RoundedNumericAmount; break; } } } } }
/// <summary> /// A helper method for the 'DisplayAsRatio' rule. See <see cref="ApplyRulesToReport"/> /// </summary> /// <param name="irr">The row to check if it is based on a 'percent' element.</param> /// <returns>True is this <paramref name="irr"/> is based on a 'percent' element.</returns> private bool IsAcceptedpercentItemType(InstanceReportRow irr) { bool isAccepted = false; string elemDataType = irr.ElementDataType; string[] parts = elemDataType.Split(':') as string[]; if (parts.Length == 2) { string namespaceStr = parts[0]; string dataType = parts[1].ToLower(); bool acceptableNamespace = false; foreach (TaxonomyItem taxItem in currentTaxonomy.TaxonomyItems) { //www.xbrl.org/ //xbrl.org/ //xbrl.us/ //xbrl.sec.gov/ //fasb.org/ //xbrl.iasb.org if (taxItem.Namespace == namespaceStr) { string webLocation = taxItem.WebLocation.ToLower(); acceptableNamespace = (webLocation.IndexOf("xbrl.org/") >= 0 || webLocation.IndexOf("xbrl.us/") >= 0 || webLocation.IndexOf("xbrl.sec.gov/") >= 0 || webLocation.IndexOf("fasb.org/") >= 0 || webLocation.IndexOf("xbrl.iasb.org/") >= 0); break; } } isAccepted = acceptableNamespace && (dataType == "percentitemtype"); } return(isAccepted); }
public object Clone(bool keepCells, bool cloneCells) { InstanceReportRow row = (InstanceReportRow)this.MemberwiseClone(); if (this.BalanceDate != null) { row.BalanceDate = new CalendarPeriod(this.BalanceDate.StartDate, this.BalanceDate.EndDate); } //row.EmbedRequirements = null; //row.GroupTotalSegment = null; if (row.MyPrecision != null) { row.MyPrecision = new Precision( this.MyPrecision.PrecisionType, this.MyPrecision.NumberOfDigits); } if (keepCells) { if (cloneCells) { //do not use clear row.Cells = new List <Cell>(); foreach (Cell c in this.Cells) { Cell cp = (Cell)c.Clone(); row.Cells.Add(cp); } } } else { //do not use clear row.Cells = new List <Cell>(); } return(row); }
public void RemoveAbstractsWithoutElements() { List <int> rowsToRemove = new List <int>(); int rowMax = this.Rows.Count - 1; for (int r = 0; r < this.Rows.Count; r++) { InstanceReportRow thisRow = this.Rows[r]; if (!thisRow.IsAbstractGroupTitle) { continue; } if (r == rowMax) { rowsToRemove.Add(r); continue; } InstanceReportRow nextRow = this.Rows[r + 1]; if (!nextRow.IsAbstractGroupTitle) { continue; } rowsToRemove.Add(r); } //put them in order from low to high rowsToRemove.Sort(); //now make it high to low... rowsToRemove.Reverse(); //now remove them rowsToRemove.ForEach(r => this.Rows.RemoveAt(r)); }
private void InitializeTestEquityReport() { this.Columns.Clear(); this.Rows.Clear(); //Add reporting periods to columns for testing MergeInstanceAndDuration InstanceReportColumn irc = new InstanceReportColumn(); irc.Id = 0; ContextProperty cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 10, 1); cp.PeriodEndDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu0", cp); cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value")); LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); irc.Id = 1; cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 10, 1); cp.PeriodEndDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu1", cp); cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value")); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); irc.Id = 2; cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 10, 1); cp.PeriodEndDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu0", cp); cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value")); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); irc.Id = 3; cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 10, 1); cp.PeriodEndDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu1", cp); cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value")); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); irc.Id = 4; cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 10, 1); cp.PeriodEndDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu0", cp); cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value")); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); irc.Id = 5; cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 10, 1); cp.PeriodEndDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu1", cp); cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value")); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); for (int i = 0; i < 4; i++) { InstanceReportRow irr = new InstanceReportRow("Test Elem", 6); irr.ElementName = "Test Elem"; irr.IsBeginningBalance = (i == 0); for (int j = 0; j < 6; j++) { Cell cell = new Cell(); cell.Id = j; cell.NumericAmount = (decimal)((j + 1) * 10.0); irr.Cells.Add(cell); } this.Rows.Add(irr); } }
public void TestRowLevelPromotions_1() { InstanceReport thisReport = new InstanceReport(); //[1], [1], [1], [1], NULL --> [1] promoted InstanceReportRow thisRow = new InstanceReportRow(); thisRow.Label = "Row 1"; thisRow.Id = 1; for (int index = 0; index <= 3; index++) { Cell c = new Cell(index); c.IsNumeric = true; c.NumericAmount = 100; c.FootnoteIndexer = "[1]"; thisRow.Cells.Add(c); } Cell c4 = new Cell(4); c4.IsNumeric = false; thisRow.Cells.Add(c4); thisReport.Rows.Add(thisRow); thisReport.PromoteFootnotes(); Console.WriteLine ("Row level index = " + thisRow.FootnoteIndexer); foreach (Cell c in thisRow.Cells) { Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer); } Assert.IsTrue(thisRow.FootnoteIndexer == "[1]"); for (int index = 0; index <= 3; index++) { Cell c1 = thisRow.Cells[index] as Cell; Assert.IsTrue(String.IsNullOrEmpty(c1.FootnoteIndexer)); } }
private void HandleBalances( bool isBeginningBalance, InstanceReportRow irr, ArrayList durationColumnIndex, ArrayList instantColumnIndex ) { try { Dictionary<int, bool> balanceCellsToClear = new Dictionary<int, bool>(); Dictionary<int, bool> durationCellsChanged = new Dictionary<int, bool>(); for( int colIndex = 0; colIndex < this.Columns.Count; colIndex++ ) { InstanceReportColumn currentCol = this.Columns[ colIndex ] as InstanceReportColumn; DateTime periodStartDate = currentCol.MyContextProperty.PeriodStartDate; DateTime periodEndDate = currentCol.MyContextProperty.PeriodEndDate; bool foundMatch = false; //find the matching begining balance //bool foundAnyMatch = false; for( int colIndexCheck = colIndex + 1; colIndexCheck < this.Columns.Count; colIndexCheck++ ) { if( colIndexCheck == colIndex ) continue; InstanceReportColumn currentBalanceColumn = this.Columns[ colIndexCheck ] as InstanceReportColumn; DateTime checkPeriodEndDate = currentBalanceColumn.MyContextProperty.PeriodEndDate; if( currentBalanceColumn.MyContextProperty.PeriodType == Element.PeriodType.instant ) { checkPeriodEndDate = currentBalanceColumn.MyContextProperty.PeriodStartDate; } if( isBeginningBalance ) { foundMatch = ( checkPeriodEndDate == periodStartDate ) || ( checkPeriodEndDate == periodStartDate.AddDays( -1 ) ); } else { foundMatch = ( checkPeriodEndDate == periodEndDate ); } foundMatch = foundMatch && currentCol.CurrencyCode.ToLower() == currentBalanceColumn.CurrencyCode.ToLower(); if( foundMatch && SegmentsScenarioMatch( currentBalanceColumn.Segments, this.Columns[ colIndex ].Segments, true ) && SegmentsScenarioMatch( currentBalanceColumn.Scenarios, this.Columns[ colIndex ].Scenarios, false ) ) { //foundAnyMatch = true; Cell durationCell = irr.Cells[ colIndex ] as Cell; Cell balanceCell = irr.Cells[ colIndexCheck ] as Cell; /** *because 'MergeInstantAndDuration' should have already placed * the beginning balances in the correct location * ensure that we do not overwrite the correct date * which already exists. **/ if( !durationCell.HasData ) // || ((durationCell.NumericAmount != balanceCell.NumericAmount) && balanceCell.NumericAmount != 0)) { durationCell.AddData( balanceCell ); /* durationCell.ShowCurrencySymbol = balanceCell.ShowCurrencySymbol; durationCell.IsNumeric = balanceCell.IsNumeric; durationCell.NumericAmount = balanceCell.NumericAmount; durationCell.RoundedNumericAmount = balanceCell.RoundedNumericAmount; durationCell.FootnoteIndexer = balanceCell.FootnoteIndexer; //DE1403 //Old note from PH: Need to copy Non-Numeric data along with everything else. durationCell.NonNumbericText = balanceCell.NonNumbericText; */ durationCellsChanged[ colIndex ] = true; balanceCellsToClear[ colIndexCheck ] = true; } } } //if (isBeginningBalance && !foundAnyMatch) //{ // (irr.Cells[colIndex] as Cell).Clear(); //} } if( isBeginningBalance ) { //cycle through CANDIDATES of cells to clear foreach( int cellIndex in balanceCellsToClear.Keys ) { //if this candidate WAS NOT changeded by some other part of the process // clear it //if( durationCellsChanged.ContainsKey( cellIndex ) ) //{ // (irr.Cells[cellIndex] as Cell).Clear(); //} ( irr.Cells[ cellIndex ] as Cell ).Clear(); } } } catch { } }
private static void ShowLastNonDefaultLabel( int depth, Stack<CommandIterator> iteratorHierarchy, InstanceReportRow row ) { Segment ciSegment = null; CommandIterator ciSave = null; CommandIterator[] ciList = iteratorHierarchy.ToArray(); foreach( CommandIterator ci in ciList ) { if( depth > 0 ) depth--; Segment seg = row.EmbedRequirements.GetMemberKeyValue( ci ).Value as Segment; if( seg != null && !seg.IsDefaultForEntity ) { ciSegment = seg; ciSave = ci; break; } } if( ciSave != null ) { row.Level = depth; row.GroupTotalSegment = ciSegment; row.EmbedRequirements.ShowLabel( ciSave, ciSave.SelectionString ); row.GenerateEmbedLabel(); } }
private InstanceReportRow CreateStyleRow( int depth, CommandIterator iterator, object memberValue ) { InstanceReportRow groupedRow = new InstanceReportRow(); groupedRow.EmbedRequirements = new ColumnRowRequirement( iterator ); groupedRow.EmbedRequirements.Add( iterator, memberValue ); groupedRow.IsAbstractGroupTitle = true; groupedRow.GenerateEmbedLabel( groupedRow.EmbedRequirements, true ); groupedRow.Level = depth; for( int c = 0; c < this.Columns.Count; c++ ) groupedRow.Cells.Add( new Cell( this.Columns[ c ].Id ) ); return groupedRow; }
public InstanceReportRow( InstanceReportRow arg ) : this() { CopyHeader( arg ); CopyPrecision( arg ); foreach( Cell c in arg.Cells ) { this.Cells.Add( (Cell)c.Clone() ); } }
private int SortSpecialRows( InstanceReportRow top, InstanceReportRow bot ) { //sort base or extended? if( top.IsBaseElement != bot.IsBaseElement) { if( top.IsBaseElement ) return -1; else return 1; } //sort unit if( top.Unit != bot.Unit ) { if( top.IsMonetary != bot.IsMonetary ) { if( top.IsMonetary ) return -1; else return 1; } if( top.IsShares != bot.IsShares ) { if( top.IsShares ) return -1; else return 1; } if( top.Unit < bot.Unit ) return -1; else return 1; } if( top.IsEquityPrevioslyReportedAsRow != bot.IsEquityPrevioslyReportedAsRow ) { if( top.IsEquityPrevioslyReportedAsRow ) return -1; else return 1; } if( top.IsEquityAdjustmentRow != bot.IsEquityAdjustmentRow ) { if( top.IsEquityAdjustmentRow ) return -1; else return 1; } //we've already established that these are the same if( top.IsEquityPrevioslyReportedAsRow || top.IsEquityAdjustmentRow ) { int cmp = baseReport.CompareSegments( top.EmbedRequirements.Segments, bot.EmbedRequirements.Segments ); if( cmp != 0 ) return cmp; } return 0; }
/// <summary> /// Gets an applies the total label for a row's element and applies it to the row. /// </summary> /// <param name="row">The row whose element will be checked and whose label will be updated.</param> private void RelabelGroupingTotalRows( InstanceReportRow row ) { if( !row.IsGroupTotal ) return; string label; if( GetSegmentTotalLabel( row.GroupTotalSegment, out label ) ) row.Label = label; }
/// <summary> /// <para>Writes the <paramref name="embedWarning"/> to the this.<see cref="currentFilingSummary"/>, exchanging templated tokens for their actual values.</para> /// <para><paramref name="embedWarning"/> is expected to be in a templated format.</para> /// </summary> /// <param name="row">Provides the element's PreferredLabelRole.</param> /// <param name="element">A taxonomy <see cref="Element"/> allowing us to look up its labels.</param> /// <param name="cell">A <see cref="Cell" /> object which provides the context and unit IDs.</param> /// <param name="embedWarning">The warning to rewrite.</param> /// <returns>The warning with substitution tokens replaced.</returns> private string WriteEmbedWarning( InstanceReportRow row, Element element, Cell cell, string embedWarning ) { string labelForWarning = null; // Try preferred if( !string.IsNullOrEmpty( row.PreferredLabelRole ) ) { element.TryGetLabel( this.preferredLanguage, row.PreferredLabelRole, out labelForWarning ); } // If preferred not available, try default if( string.IsNullOrEmpty( labelForWarning ) ) { element.TryGetLabel( this.preferredLanguage, "label", out labelForWarning ); } // If default not available, fall back to element name if( string.IsNullOrEmpty( labelForWarning ) ) { labelForWarning = element.Name; } // Specify warning scope and trace embedWarning = embedWarning.Replace( "[Unknown Element]", labelForWarning ); // Unit refs are not required if( cell.Markup.unitRef != null ) { embedWarning = embedWarning.Replace( "[Unknown UnitID]", cell.Markup.unitRef.UnitID ); } else { embedWarning = embedWarning.Replace( "[Unknown UnitID]", "No UnitID Specified" ); } embedWarning = embedWarning.Replace( "[Unknown ContextID]", cell.Markup.contextRef.ContextID ); this.currentFilingSummary.TraceWarning( embedWarning ); return embedWarning; }
private int SortSpecialRows(InstanceReportRow top, InstanceReportRow bot) { //sort base or extended? if (top.IsBaseElement != bot.IsBaseElement) { if (top.IsBaseElement) { return(-1); } else { return(1); } } //sort unit if (top.Unit != bot.Unit) { if (top.IsMonetary != bot.IsMonetary) { if (top.IsMonetary) { return(-1); } else { return(1); } } if (top.IsShares != bot.IsShares) { if (top.IsShares) { return(-1); } else { return(1); } } if (top.Unit < bot.Unit) { return(-1); } else { return(1); } } if (top.IsEquityPrevioslyReportedAsRow != bot.IsEquityPrevioslyReportedAsRow) { if (top.IsEquityPrevioslyReportedAsRow) { return(-1); } else { return(1); } } if (top.IsEquityAdjustmentRow != bot.IsEquityAdjustmentRow) { if (top.IsEquityAdjustmentRow) { return(-1); } else { return(1); } } //we've already established that these are the same if (top.IsEquityPrevioslyReportedAsRow || top.IsEquityAdjustmentRow) { int cmp = baseReport.CompareSegments(top.EmbedRequirements.Segments, bot.EmbedRequirements.Segments); if (cmp != 0) { return(cmp); } } return(0); }
/// <summary> /// Checks if an row's element is a QName type, and attempts to parse the markup value. /// </summary> /// <param name="row">The row whose element is checked.</param> /// <param name="cellText">The markup value to parse as a QName.</param> /// <param name="newValue">The result of QName parsing.</param> /// <returns>True on success, false on fail.</returns> private bool TryGetQNameValue( InstanceReportRow row, string cellText, out string newValue ) { newValue = string.Empty; if( row == null ) return false; if( !string.Equals( row.ElementDataType, "xbrli:QNameItemType" ) ) return false; if( !qnameRegex.IsMatch( cellText ) ) return false; string[] prefixElement = cellText.Split( ':' ); //we'll overwrite 'newValue' soon newValue = prefixElement[ 1 ]; string elName = cellText.Replace( ':', '_' ); foreach( TaxonomyItem ti in this.currentTaxonomy.TaxonomyItems ) { if( string.Equals( ti.Namespace, prefixElement[ 0 ] ) ) { Element nsEl = this.currentTaxonomy.AllElements[ elName ] as Element; if( nsEl != null ) { string label; if( nsEl.TryGetLabel( this.preferredLanguage, row.PreferredLabelRole, out label ) ) { newValue = label; } else if( nsEl.TryGetLabel( this.preferredLanguage, "label", out label ) ) { newValue = label; } else { newValue = string.Format( "[{0}]", newValue ); } } break; } } return true; }
private static void RemoveEmptyRows(List <InstanceReportRow> rows) { bool hasData = false; foreach (InstanceReportRow row in rows) { hasData |= !row.IsEmpty(); } if (hasData) { rows.RemoveAll(row => row.IsEmpty()); return; } Dictionary <string, List <InstanceReportRow> > elementGroups = new Dictionary <string, List <InstanceReportRow> >(); foreach (InstanceReportRow row in rows) { if (!elementGroups.ContainsKey(row.ElementName)) { elementGroups[row.ElementName] = new List <InstanceReportRow>(); } elementGroups[row.ElementName].Add(row); } InstanceReportRow monetaryRow = null; Dictionary <string, InstanceReportRow> protectedRowsByElement = new Dictionary <string, InstanceReportRow>(); foreach (List <InstanceReportRow> elRows in elementGroups.Values) { int lowScore = int.MaxValue; foreach (InstanceReportRow row in elRows) { int curScore = 0; foreach (Segment seg in row.EmbedRequirements.Segments) { if (!seg.IsDefaultForEntity) { curScore++; } } if (curScore < lowScore) { //Defect: SEC0126 lowScore = curScore; protectedRowsByElement[row.ElementName] = row; if (row.IsMonetary) { monetaryRow = row; } } } } if (monetaryRow != null) { rows.RemoveAll(row => row != monetaryRow); } else { List <InstanceReportRow> protectedRows = new List <InstanceReportRow>(protectedRowsByElement.Values); rows.RemoveAll(row => !protectedRows.Contains(row)); } }
private void InitializeTestInstanceReportCommonSegment() { this.Columns.Clear(); this.Rows.Clear(); Segment sharedSegment = new Segment("SharedSeg", "Shared Segment", "Shared Segment Value"); sharedSegment.DimensionInfo = new ContextDimensionInfo(); sharedSegment.DimensionInfo.Id = "SharedSegmentAxis"; sharedSegment.DimensionInfo.dimensionId = "SharedSegmentMember"; //Add reporting periods to columns for testing MergeInstanceAndDuration InstanceReportColumn irc = new InstanceReportColumn(); ContextProperty cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 10, 1); cp.PeriodEndDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu0", cp); cp.Segments.Add(sharedSegment); LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 10, 1); cp.PeriodEndDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu1", cp); cp.Segments.Add(sharedSegment); ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString())); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.instant; irc.MCU = new MergedContextUnitsWrapper("mcu2", cp); cp.Segments.Add(sharedSegment); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString()); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.instant; irc.MCU = new MergedContextUnitsWrapper("mcu3", cp); cp.Segments.Add(sharedSegment); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString()); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; cp.Segments.Add(sharedSegment); irc.MCU = new MergedContextUnitsWrapper("mcu4", cp); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString()); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; cp.Segments.Add(sharedSegment); irc.MCU = new MergedContextUnitsWrapper("mcu5", cp); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString()); irc.Labels.Add(ll); cp.Segments.Add(sharedSegment); irc.Labels.Add(new LabelLine(1, "Segment One")); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; cp.Segments.Add(sharedSegment); irc.MCU = new MergedContextUnitsWrapper("mcu6", cp); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString()); irc.Labels.Add(ll); cp.Segments.Add(sharedSegment); irc.Labels.Add(new LabelLine(2, "Segment Two")); this.Columns.Add(irc); InstanceReportRow irr = new InstanceReportRow("Test Elem", 7); irr.ElementName = "Test Elem"; for (int i = 0; i < 7; i++) { Cell cell = new Cell(); cell.NumericAmount = (decimal)((i + 1) * 10.0); irr.Cells.Add(cell); } this.Rows.Add(irr); }
public void ApplyDataTo( InstanceReportRow that ) { that.BalanceType = this.BalanceType; that.ElementDataType = this.ElementDataType; that.ElementDefenition = this.ElementDefenition; that.ElementName = this.ElementName; that.ElementPrefix = this.ElementPrefix; that.ElementReferences = this.ElementReferences; that.IsAbstractGroupTitle = this.IsAbstractGroupTitle; that.IsBaseElement = this.IsBaseElement; that.IsBeginningBalance = this.IsBeginningBalance; that.IsEndingBalance = this.IsEndingBalance; that.IsEquityAdjustmentRow = this.IsEquityAdjustmentRow; that.IsEquityPrevioslyReportedAsRow = this.IsEquityPrevioslyReportedAsRow; that.IsReverseSign = this.IsReverseSign; that.IsTotalLabel = this.IsTotalLabel; that.MyPrecision = this.MyPrecision; that.PeriodType = this.PeriodType; that.PreferredLabelRole = this.PreferredLabelRole; that.SimpleDataType = this.SimpleDataType; that.Unit = this.Unit; }
private List <InstanceReportColumn> GetMatchingColumns(InstanceReportColumn calendar, InstanceReportColumn segmentSet, InstanceReportRow row) { bool isInstantElement = row.PeriodType == "instant"; List <InstanceReportColumn> matches = this.Columns.FindAll( col => { if (!col.SegmentAndScenarioEquals(segmentSet)) { return(false); } //calendar must be the first paramter if (!ContainsCalendar(calendar, col, row.IsBeginningBalance, isInstantElement)) { return(false); } return(true); }); if (matches.Count > 1) { List <InstanceReportColumn> tmpMatches = matches.FindAll(m => m.MyPeriodType == calendar.MyPeriodType); if (tmpMatches.Count == 1) { matches = tmpMatches; } } return(matches); }
public void CopyHeader( InstanceReportRow arg ) { if( arg == null ) return; Type stringType = typeof( string ); Type myType = this.GetType(); //get the type from `this` foreach( PropertyInfo pi in myType.GetProperties() ) { if( pi.CanRead && pi.CanWrite ) { if( pi.PropertyType.IsEnum || pi.PropertyType.IsPrimitive || pi.PropertyType == stringType ) { object value = pi.GetValue( arg, null ); pi.SetValue( this, value, null ); } } } foreach( FieldInfo fi in myType.GetFields() ) { if( fi.FieldType.IsEnum || fi.FieldType.IsPrimitive || fi.FieldType == stringType ) { object value = fi.GetValue( arg ); fi.SetValue( this, value ); } } //one extra BalanceDate = arg.BalanceDate; }
private bool RowMatchesHierarchy( InstanceReportRow row, Stack<CommandIterator> iteratorHierarchy, Dictionary<string, object> matchValues ) { foreach( CommandIterator cmdItr in iteratorHierarchy ) { KeyValuePair<string, object> member = row.EmbedRequirements.GetMemberKeyValue( cmdItr ); int cmp = Comparer<object>.Default.Compare( matchValues[ cmdItr.SelectionString ], member.Value ); if( cmp != 0 ) { Segment seg = member.Value as Segment; if( seg == null ) return false; if( !seg.IsDefaultForEntity ) return false; return false; } } return true; }
public void CopyPrecision( InstanceReportRow arg ) { if( arg.MyPrecision != null ) { this.MyPrecision = new Precision( arg.MyPrecision.PrecisionType, arg.MyPrecision.NumberOfDigits ); } }
private Dictionary<string, object> CreateHierarchicalDictionary( InstanceReportRow row, Stack<CommandIterator> iteratorHierarchy ) { Dictionary<string, object> hierarchicalDictionary = new Dictionary<string, object>(); foreach( CommandIterator cmdItr in iteratorHierarchy ) { KeyValuePair<string, object> member = row.EmbedRequirements.GetMemberKeyValue( cmdItr ); hierarchicalDictionary[ member.Key ] = member.Value; } return hierarchicalDictionary; }
/// <summary> /// Loads data from this.<see cref="currentInstance"/> into dictionaries which will be used across all reports. See this.<see cref="ClearMarkupDictionaries"/>. /// </summary> private void PopulateMarkupDictionaries() { //globals this.dar = new DefinitionAndReference(); this.markupCache = new Dictionary<string, List<Cell>>(); this.internalReports = new Dictionary<string, int>( StringComparer.CurrentCultureIgnoreCase ); Dictionary<string,InstanceReportRow> localRowCache = new Dictionary<string, InstanceReportRow>(); Dictionary<string, Dictionary<UnitType, int>> predominantElementTypes = new Dictionary<string, Dictionary<UnitType, int>>(); foreach( MarkupProperty mp in this.currentInstance.markups ) { if( mp.unitRef != null ) { switch( mp.unitRef.UnitType ) { case UnitProperty.UnitTypeCode.Standard: mp.unitRef.DenominatorMeasure = null; mp.unitRef.MultiplyMeasures = null; mp.unitRef.NumeratorMeasure = null; break; case UnitProperty.UnitTypeCode.Multiply: mp.unitRef.DenominatorMeasure = null; mp.unitRef.NumeratorMeasure = null; mp.unitRef.StandardMeasure = null; break; case UnitProperty.UnitTypeCode.Divide: mp.unitRef.MultiplyMeasures = null; mp.unitRef.StandardMeasure = null; break; } } this.customUnits = new Dictionary<string, int>(); this.unitDictionary = new Dictionary<int, string>(); this.unitDictionary[ (int)UnitType.Other ] = "Other"; this.unitDictionary[ (int)UnitType.Shares ] = "EPS"; this.unitDictionary[ (int)UnitType.Monetary ] = "Monetary"; this.unitDictionary[ (int)UnitType.EPS ] = "EPS"; this.unitDictionary[ (int)UnitType.ExchangeRate ] = "ExchangeRate"; this.CountUnitType( predominantElementTypes, mp ); InstanceReportRow row = null; Element element = this.currentTaxonomy.AllElements[ mp.elementId ] as Element; if( !localRowCache.TryGetValue( mp.elementId, out row ) ) { this.markupCache[ mp.elementId ] = new List<Cell>(); row = new InstanceReportRow(); if( element != null ) { row.ElementDataType = element.OrigElementType; row.SimpleDataType = element.MyDataType.ToString().ToLower(); localRowCache[ mp.elementId ] = row; string def = element.GetDefinition( this.preferredLanguage ); if( string.IsNullOrEmpty( def ) ) { def = this.GetDocumentationInformation( mp.elementId, this.preferredLanguage ); if( string.IsNullOrEmpty( def ) ) def = InstanceUtils._noAuthRefAvailable; } string @ref = null; if( !element.TryGetReferences( out @ref ) || string.IsNullOrEmpty( @ref ) ) { @ref = this.GetReferenceInformation( mp.elementId ); if( string.IsNullOrEmpty( @ref ) ) @ref = InstanceUtils._noDefAvailable; } this.dar.Add( element.Id, def, @ref ); } else { row.SimpleDataType = "na"; } } //populate this.markupCache Cell cell = new Cell( mp ); if( row != null ) { if( row.IsNumericDataType ) { if( decimal.TryParse( cell.NonNumbericText, out cell.NumericAmount ) ) { cell.IsNumeric = true; cell.NonNumbericText = string.Empty; } } else if( element != null ) { string newValue; if( this.TryGetW3CDuration( element, cell.NonNumbericText, out newValue ) ) { cell.NonNumbericText = newValue; } else if( cell.NonNumbericText.Contains( "~" ) && EmbedReport.ROLE_COMMAND_SPLITTER.IsMatch( cell.NonNumbericText ) ) { if( EmbedReport.HasMatch( cell.NonNumbericText ) ) { string embedWarning = string.Empty; cell.EmbeddedReport = EmbedReport.LoadAndParse( cell.NonNumbericText, out embedWarning ); if( !string.IsNullOrEmpty( embedWarning ) ) this.WriteEmbedWarning( row, element, cell, embedWarning ); if( !this.internalReports.ContainsKey( cell.EmbeddedReport.Role ) ) this.internalReports[ cell.EmbeddedReport.Role ] = 0; this.internalReports[ cell.EmbeddedReport.Role ]++; } else { const string INCORRECT_FORMAT_WARNING = @"Warning: Incorrectly formatted embedding in Element ""[Unknown Element]"" with UnitID ""[Unknown UnitID]"" and contextID ""[Unknown ContextID]""."; this.WriteEmbedWarning( row, element, cell, INCORRECT_FORMAT_WARNING ); } } } } this.markupCache[ mp.elementId ].Add( cell ); } //now that we have collected all of the types an element is used like, //take the most used type and remember it this.elementUnitTypes = new Dictionary<string, UnitType>(); foreach( string elementID in predominantElementTypes.Keys ) { int lastCount = 0; foreach( KeyValuePair<UnitType, int> unitType in predominantElementTypes[ elementID ] ) { if( lastCount < unitType.Value ) { lastCount = unitType.Value; this.elementUnitTypes[ elementID ] = unitType.Key; } } } //populate this.elementRounding this.elementRounding = new Dictionary<string, Dictionary<string, Precision>>(); foreach( KeyValuePair<string, List<Cell>> markups in this.markupCache ) { bool hasSegments; int previousPrecision = int.MinValue; int previousPrecisionSegmented = int.MinValue; this.elementRounding[ markups.Key ] = new Dictionary<string, Precision>(); Dictionary<int, int> uniqueDecimalValues = new Dictionary<int, int>(); foreach( Cell cell in markups.Value ) { Precision p = InstanceUtils.WritePrecision( cell.Markup, ref previousPrecision, ref previousPrecisionSegmented, out hasSegments ); if( p != null ) { uniqueDecimalValues[ p.NumberOfDigits ] = 1; if( hasSegments ) this.elementRounding[ cell.Markup.elementId ][ InstanceUtils._PrecisionSegmented ] = p; else this.elementRounding[ cell.Markup.elementId ][ InstanceUtils._Precision ] = p; } } if( uniqueDecimalValues.Count > 1 ) { List<int> tmpDecimalValues = new List<int>( uniqueDecimalValues.Keys ); tmpDecimalValues.Sort(); tmpDecimalValues.Reverse(); string[] tmpStrings = new string[ tmpDecimalValues.Count ]; for( int s = 0; s < tmpStrings.Length; s++ ) { tmpStrings[ s ] = tmpDecimalValues[ s ].ToString(); } Array.Reverse( tmpStrings ); string decimalAttributeValues = string.Join( " ", tmpStrings ); string info = string.Format( "Element {0} had a mix of decimals attribute values: {1}.", markups.Key, decimalAttributeValues ); this.currentFilingSummary.TraceInformation( info ); } } //Common dimensions this.commonAxes = new List<string>(); this.commonDimensions = new Dictionary<string,List<Segment>>(); List<DimensionNode> dimensionNodes = null; string labelRole = string.IsNullOrEmpty( this.currentTaxonomy.CurrentLabelRole ) ? "preferredLabel" : currentTaxonomy.CurrentLabelRole; if( currentTaxonomy.TryGetCommonDimensionNodesForDisplay( currentTaxonomy.CurrentLanguage, labelRole, true, out dimensionNodes ) ) { ArrayList topNodes = this.currentTaxonomy.GetNodesByPresentation( false, this.ExcludedReports ); foreach( DimensionNode dNode in dimensionNodes ) { Node pNode = null; foreach( Node topNode in topNodes ) { if( string.Equals( topNode.MyPresentationLink.Role, dNode.MyDefinitionLink.Role ) ) { pNode = topNode; break; } } if( pNode != null ) ReportBuilder.GetDimensions( this.currentTaxonomy, pNode, null, ref this.commonAxes, ref this.commonDimensions ); else this.PopulateCommonDimensions( dNode ); } } }
private void ProcessMapsOnRow( InstanceReportRow irr, List<ColumnInstantDurationMap> maps, Dictionary<int, bool> destinationColumns, Dictionary<int, Dictionary<string, bool>> sourceColumns ) { foreach( ColumnInstantDurationMap colMap in maps ) { Cell instantCell = irr.Cells[ colMap.InstantColumnIndex ]; if( !instantCell.HasData ) continue; Cell durationCell = irr.Cells[ colMap.DurationColumnIndex ]; /* if( durationCell.HasData ) continue; bool hasUnit = false; foreach( UnitProperty up in this.Columns[ colMap.DurationColumnIndex ].Units ) { if( string.Equals( up.UnitID, instantCell.UnitID ) ) { hasUnit = true; break; } } */ if( !sourceColumns.ContainsKey( colMap.InstantColumnIndex ) ) sourceColumns[ colMap.InstantColumnIndex ] = new Dictionary<string, bool>(); sourceColumns[ colMap.InstantColumnIndex ][ irr.ElementName ] = true; destinationColumns[ colMap.DurationColumnIndex ] = true; ; durationCell.AddData( instantCell ); if( this.Columns[ colMap.DurationColumnIndex ].IsPseudoColumn ) this.Columns[ colMap.DurationColumnIndex ].IsPseudoColumnChanged = true; } }
/// <summary> /// Checks for any unused elements in the presentation and populates the <paramref name="missingReport" /> variable. /// </summary> /// <param name="missingReport">The InstanceReport object to populate.</param> /// <returns>True on success or false for fail.</returns> private bool BuildMissingDataReport( out InstanceReport missingReport ) { missingReport = null; if( this.markupCache.Count == this.presentationElements.Count ) return false; missingReport = new InstanceReport(); missingReport.ReportName = ReportBuilder._uncategorizedLineItems; missingReport.ReportLongName = ReportBuilder._uncategorizedLineItems; missingReport.Version = this.currentAssemblyVersion; List<string> markupElements = new List<string>( this.markupCache.Keys ); markupElements.Sort(); foreach( string markupEl in markupElements ) { if( this.presentationElements.ContainsKey( markupEl ) ) continue; InstanceReportRow row = new InstanceReportRow(); row.BalanceType = "na"; row.Cells.AddRange( this.markupCache[ markupEl ] ); row.ElementDataType = "string"; row.ElementDefenition = null; row.ElementReferences = null; row.Label = string.Format( "[{0}]", markupEl ); row.PeriodType = "na"; if( markupEl.Contains( "_" ) ) row.ElementPrefix = markupEl.Split( '_' )[ 0 ]; missingReport.Rows.Add( row ); } if( missingReport.Rows.Count == 0 ) return false; this.BuildReportColumns( missingReport, true ); ReportBuilder.FillMissingCells( missingReport ); //InstanceUtils.TOP_LEVEL_REPORT_INDICATOR string saveAs = Path.Combine( this.currentReportDirectory, InstanceUtils.TOP_LEVEL_REPORT_INDICATOR + _missingReportIndex + ".xml" ); missingReport.SaveAsXml( saveAs ); return true; }
/// <summary> /// Applies any markups from the instance document to <paramref name="row"/> /// </summary> /// <param name="report"></param> /// <param name="parent">The <see cref="Node"/> from the presentation taxonomy which the <paramref name="row"/> will represent</param> /// <param name="row">The resulting <see cref="InstanceReportRow"/> with cells, unless it <see>IsAbstractGroupTitle</see></param> /// <returns>True on success, false on fail.</returns> /// <seealso cref="CellExistsInPresentation"/> private bool BuildReportRowCells( InstanceReport report, Node parent, out InstanceReportRow row ) { row = null; Node dNode; List<Cell> cells; if( ReportBuilder.IsDimension( parent, out dNode ) ) { //Can a axis/dimension tree have actual elements? return false; } else if( parent.IsAbstract ) { row = new InstanceReportRow(); row.IsAbstractGroupTitle = true; return true; } else if( this.markupCache.TryGetValue( parent.Id, out cells ) ) { row = new InstanceReportRow(); row.Cells.AddRange( cells ); return true; } else { //Debug.Assert( false, "Why is this element in the presentation without values?" ); return false; } }
private void HandleBalances(bool isBeginningBalance, InstanceReportRow irr, ArrayList durationColumnIndex, ArrayList instantColumnIndex) { try { Dictionary <int, bool> balanceCellsToClear = new Dictionary <int, bool>(); Dictionary <int, bool> durationCellsChanged = new Dictionary <int, bool>(); for (int colIndex = 0; colIndex < this.Columns.Count; colIndex++) { InstanceReportColumn currentCol = this.Columns[colIndex] as InstanceReportColumn; DateTime periodStartDate = currentCol.MyContextProperty.PeriodStartDate; DateTime periodEndDate = currentCol.MyContextProperty.PeriodEndDate; bool foundMatch = false; //find the matching begining balance //bool foundAnyMatch = false; for (int colIndexCheck = colIndex + 1; colIndexCheck < this.Columns.Count; colIndexCheck++) { if (colIndexCheck == colIndex) { continue; } InstanceReportColumn currentBalanceColumn = this.Columns[colIndexCheck] as InstanceReportColumn; DateTime checkPeriodEndDate = currentBalanceColumn.MyContextProperty.PeriodEndDate; if (currentBalanceColumn.MyContextProperty.PeriodType == Element.PeriodType.instant) { checkPeriodEndDate = currentBalanceColumn.MyContextProperty.PeriodStartDate; } if (isBeginningBalance) { foundMatch = (checkPeriodEndDate == periodStartDate) || (checkPeriodEndDate == periodStartDate.AddDays(-1)); } else { foundMatch = (checkPeriodEndDate == periodEndDate); } foundMatch = foundMatch && currentCol.CurrencyCode.ToLower() == currentBalanceColumn.CurrencyCode.ToLower(); if (foundMatch && SegmentsScenarioMatch(currentBalanceColumn.Segments, this.Columns[colIndex].Segments, true) && SegmentsScenarioMatch(currentBalanceColumn.Scenarios, this.Columns[colIndex].Scenarios, false)) { //foundAnyMatch = true; Cell durationCell = irr.Cells[colIndex] as Cell; Cell balanceCell = irr.Cells[colIndexCheck] as Cell; /** * because 'MergeInstantAndDuration' should have already placed * the beginning balances in the correct location * ensure that we do not overwrite the correct date * which already exists. **/ if (!durationCell.HasData) // || ((durationCell.NumericAmount != balanceCell.NumericAmount) && balanceCell.NumericAmount != 0)) { durationCell.AddData(balanceCell); /* * durationCell.ShowCurrencySymbol = balanceCell.ShowCurrencySymbol; * durationCell.IsNumeric = balanceCell.IsNumeric; * durationCell.NumericAmount = balanceCell.NumericAmount; * durationCell.RoundedNumericAmount = balanceCell.RoundedNumericAmount; * durationCell.FootnoteIndexer = balanceCell.FootnoteIndexer; * * //DE1403 * //Old note from PH: Need to copy Non-Numeric data along with everything else. * durationCell.NonNumbericText = balanceCell.NonNumbericText; */ durationCellsChanged[colIndex] = true; balanceCellsToClear[colIndexCheck] = true; } } } //if (isBeginningBalance && !foundAnyMatch) //{ // (irr.Cells[colIndex] as Cell).Clear(); //} } if (isBeginningBalance) { //cycle through CANDIDATES of cells to clear foreach (int cellIndex in balanceCellsToClear.Keys) { //if this candidate WAS NOT changeded by some other part of the process // clear it //if( durationCellsChanged.ContainsKey( cellIndex ) ) //{ // (irr.Cells[cellIndex] as Cell).Clear(); //} (irr.Cells[cellIndex] as Cell).Clear(); } } } catch { } }
public void TestColumnLevelPromotions_3() { InstanceReport thisReport = new InstanceReport(); InstanceReportColumn irc1 = new InstanceReportColumn(); InstanceReportColumn irc2 = new InstanceReportColumn(); //c0: [1],[2] [1],[2] [1],[2] [1],[2],[3] [1],[2] --> [1],[2] //c1: [4], [5], [6], [7], [8] --> NULL irc1.Id = 1; thisReport.Columns.Add(irc1); irc2.Id = 2; thisReport.Columns.Add(irc2); for (int index = 0; index <= 4; index++) { InstanceReportRow irr = new InstanceReportRow(); irr.Id = index + 1; Cell c1 = new Cell(1); irr.Cells.Add(c1); Cell c2 = new Cell(2); irr.Cells.Add(c2); thisReport.Rows.Add(irr); } (thisReport.Rows[0].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer = "[1],[2]"; (thisReport.Rows[1].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer = "[1],[2]"; (thisReport.Rows[2].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer = "[1],[2]"; (thisReport.Rows[3].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer = "[1],[2],[3]"; (thisReport.Rows[4].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer = "[1],[2]"; (thisReport.Rows[0].Cells[1] as Cell).IsNumeric = true; (thisReport.Rows[0].Cells[1] as Cell).FootnoteIndexer = "[4]"; (thisReport.Rows[1].Cells[1] as Cell).IsNumeric = true; (thisReport.Rows[1].Cells[1] as Cell).FootnoteIndexer = "[5]"; (thisReport.Rows[2].Cells[1] as Cell).IsNumeric = true; (thisReport.Rows[2].Cells[1] as Cell).FootnoteIndexer = "[6]"; (thisReport.Rows[3].Cells[1] as Cell).IsNumeric = true; (thisReport.Rows[3].Cells[1] as Cell).FootnoteIndexer = "[7]"; (thisReport.Rows[4].Cells[1] as Cell).IsNumeric = true; (thisReport.Rows[4].Cells[1] as Cell).FootnoteIndexer = "[8]"; thisReport.PromoteFootnotes(); Console.WriteLine("Column 1 level index = " + irc1.FootnoteIndexer); Console.WriteLine("Column 2 level index = " + irc2.FootnoteIndexer); foreach (InstanceReportRow irr in thisReport.Rows) { Cell c1 = irr.Cells[0] as Cell; Console.WriteLine(c1.Id + " Cell level index = " + c1.FootnoteIndexer); Cell c2 = irr.Cells[1] as Cell; Console.WriteLine(c2.Id + " Cell level index = " + c2.FootnoteIndexer); } Assert.IsTrue(irc1.FootnoteIndexer == "[1],[2]"); Assert.IsTrue(irc2.FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer == "[3]"); Assert.IsTrue((thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[0].Cells[1] as Cell).FootnoteIndexer == "[4]"); Assert.IsTrue((thisReport.Rows[1].Cells[1] as Cell).FootnoteIndexer == "[5]"); Assert.IsTrue((thisReport.Rows[2].Cells[1] as Cell).FootnoteIndexer == "[6]"); Assert.IsTrue((thisReport.Rows[3].Cells[1] as Cell).FootnoteIndexer == "[7]"); Assert.IsTrue((thisReport.Rows[4].Cells[1] as Cell).FootnoteIndexer == "[8]"); }
/// <summary> /// Updates a <paramref name="row"/> with relevant properties from the taxonomy. /// </summary> /// <param name="report">[Obsolete]</param> /// <param name="parent">The <see cref="Node"/> which created this <paramref name="row"/>.</param> /// <param name="row">The row to be updated.</param> /// <seealso cref="BuildReportRows"/> private void BuildReportRowProperties( InstanceReport report, Node parent, InstanceReportRow row ) { row.BalanceType = parent.BalanceType; row.Id = report.Rows.Count + 1; row.IsReverseSign = InstanceUtils.IsDisplayReversed( parent ); row.PreferredLabelRole = parent.PreferredLabel; row.IsBeginningBalance = InstanceUtils.IsBeginningBalance( row ); row.IsEndingBalance = InstanceUtils.IsEndingBalance( row ); row.PeriodType = parent.PeriodType; //apply the element label string label = null; if( !string.IsNullOrEmpty( row.PreferredLabelRole ) && parent.TryGetLabel( this.preferredLanguage, row.PreferredLabelRole, out label ) ) row.Label = label; else if( parent.TryGetLabel( this.preferredLanguage, "label", out label ) ) row.Label = label; else row.Label = string.Format( "[{0}]", parent.Name ); //apply element properties Element element = parent.MyElement; if( element == null && !elementCache.TryGetValue( parent.Id, out element ) ) { element = this.elementCache[ parent.Id ] = this.currentTaxonomy.AllElements[ parent.Id ] as Element; } if( element == null ) { Debug.Assert( false, "Why isn't this element in the taxonomy?" ); } else { if( row.Cells != null && row.Cells.Count > 0 ) { if( !this.presentationElements.ContainsKey( parent.Id ) ) this.presentationElements[ parent.Id ] = 0; this.presentationElements[ parent.Id ]++; } row.ElementDataType = element.OrigElementType; row.ElementName = parent.Id; row.ElementPrefix = parent.Id.Substring( 0, parent.Id.IndexOf( '_' ) + 1 ); row.IsBaseElement = row.ElementPrefix.StartsWith( "usfr_" ) || row.ElementPrefix.StartsWith( "us-gaap_" ); row.SimpleDataType = element.MyDataType.ToString().ToLower(); DefAndRef dr; if( this.dar.references.TryGetValue( parent.Id, out dr ) ) { row.ElementDefenition = dr.Def; row.ElementReferences = dr.Ref; } UnitType unit; if( this.elementUnitTypes.TryGetValue( row.ElementName, out unit ) ) row.Unit = unit; //perhaps the user used the wrong unit - attempt to find monetary, perShare if( row.Unit == UnitType.Other || row.Unit == UnitType.Monetary ) { if( element.OrigElementType.IndexOf( "perShare", StringComparison.CurrentCultureIgnoreCase ) > -1 ) row.Unit = UnitType.EPS; } } if( BuilderRules.IsRuleEnabled( RulesEngineUtils.DISPLAY_US_DATE_FORMAT ) ) { if( string.Equals( row.SimpleDataType, "date", StringComparison.CurrentCultureIgnoreCase ) ) { foreach( Cell cell in row.Cells ) { cell.DisplayDateInUSFormat = true; } } } }
public void TestRowLevelPromotions_4() { InstanceReport thisReport = new InstanceReport(); //[1] [2] [1],[2] NULL [3],[4] --> NOTHING promoted InstanceReportRow thisRow = new InstanceReportRow(); thisRow.Label = "Row 1"; thisRow.Id = 1; Cell c0 = new Cell(0); c0.IsNumeric = true; c0.FootnoteIndexer = "[1]"; thisRow.Cells.Add(c0); Cell c1 = new Cell(1); c1.IsNumeric = true; c1.FootnoteIndexer = "[2]"; thisRow.Cells.Add(c1); Cell c2 = new Cell(2); c2.IsNumeric = true; c2.FootnoteIndexer = "[1],[2]"; thisRow.Cells.Add(c2); Cell c3 = new Cell(3); c3.IsNumeric = false; thisRow.Cells.Add(c3); Cell c4 = new Cell(4); c4.IsNumeric = true; c4.FootnoteIndexer = "[3],[4]"; thisRow.Cells.Add(c4); thisReport.Rows.Add(thisRow); thisReport.PromoteFootnotes(); Console.WriteLine("Row level index = " + thisRow.FootnoteIndexer); foreach (Cell c in thisRow.Cells) { Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer); } Assert.IsTrue(thisRow.FootnoteIndexer == ""); Assert.IsTrue((thisRow.Cells[0] as Cell).FootnoteIndexer == "[1]"); Assert.IsTrue((thisRow.Cells[1] as Cell).FootnoteIndexer == "[2]"); Assert.IsTrue((thisRow.Cells[2] as Cell).FootnoteIndexer == "[1],[2]"); Assert.IsTrue((thisRow.Cells[3] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisRow.Cells[4] as Cell).FootnoteIndexer == "[3],[4]"); }
public override bool Equals(object obj) { InstanceReportRow irr = obj as InstanceReportRow; if (irr == null) { return(false); } if (this.Cells.Count != irr.Cells.Count) { return(false); } if (this.ElementName != irr.ElementName) { return(false); } if (this.ElementPrefix != irr.ElementPrefix) { return(false); } if (this.Id != irr.Id) { return(false); } if (this.IsAbstractGroupTitle != irr.IsAbstractGroupTitle) { return(false); } if (this.IsBaseElement != irr.IsBaseElement) { return(false); } if (this.IsEPS != irr.IsEPS) { return(false); } if (this.PreferredLabelRole != irr.PreferredLabelRole) { return(false); } if (this.IsReverseSign != irr.IsReverseSign) { return(false); } if (this.IsTotalLabel != irr.IsTotalLabel) { return(false); } if (this.Label != irr.Label) { return(false); } if (this.Level != irr.Level) { return(false); } for (int i = 0; i < Cells.Count; ++i) { if (!((Cell)Cells[i]).Equals(irr.Cells[i])) { return(false); } } return(true); }
private void InitializeTestInstanceReport() { this.Columns.Clear(); this.Rows.Clear(); //Add reporting periods to columns for testing MergeInstanceAndDuration InstanceReportColumn irc = new InstanceReportColumn(); ContextProperty cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 10, 1); cp.PeriodEndDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu0", cp); LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()), "Calendar"); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 10, 1); cp.PeriodEndDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.duration; irc.MCU = new MergedContextUnitsWrapper("mcu1", cp); ll = new LabelLine( 0, string.Format( "{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString() ), "Calendar" ); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2007, 12, 31); cp.PeriodType = Element.PeriodType.instant; irc.MCU = new MergedContextUnitsWrapper("mcu2", cp); ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString(), "Calendar"); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2006, 12, 31); cp.PeriodType = Element.PeriodType.instant; irc.MCU = new MergedContextUnitsWrapper("mcu3", cp); ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" ); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; irc.MCU = new MergedContextUnitsWrapper("mcu4", cp); ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" ); irc.Labels.Add(ll); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; cp.Segments.Add(new Segment("Segment1", "Segment One", "Value1")); irc.MCU = new MergedContextUnitsWrapper("mcu5", cp); ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" ); irc.Labels.Add(ll); irc.Labels.Add(new LabelLine(1, "Segment One")); this.Columns.Add(irc); irc = new InstanceReportColumn(); cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2008, 12, 31); cp.PeriodType = Element.PeriodType.instant; cp.Segments.Add(new Segment("Segment2", "Segment Two", "Value2")); irc.MCU = new MergedContextUnitsWrapper("mcu6", cp); ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" ); irc.Labels.Add(ll); irc.Labels.Add(new LabelLine(2, "Segment Two")); this.Columns.Add(irc); InstanceReportRow irr = new InstanceReportRow("Test Elem", 0); irr.ElementName = "Test Elem"; for (int i = 0; i < 7; i++) { Cell cell = new Cell(); if( i < 2 || 4 < i ) { cell.IsNumeric = true; cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 ); } irr.Cells.Add(cell); } this.Rows.Add( irr ); irr = new InstanceReportRow( "Test Elem2", 0 ); irr.ElementName = "Test Elem2"; for( int i = 0; i < 7; i++ ) { Cell cell = new Cell(); if( 1 < i && i < 5 ) { cell.IsNumeric = true; cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 ); } irr.Cells.Add( cell ); } this.Rows.Add(irr); }
private bool IsDefaultMemberGroupRow( InstanceReportRow row ) { if( !IsMemberGroupRow( row ) ) return false; return row.EmbedRequirements.Segments[ 0 ].IsDefaultForEntity; }
public void TestColumnLevelPromotions_1() { InstanceReport thisReport = new InstanceReport(); InstanceReportColumn irc = new InstanceReportColumn(); //[1], [1], [1], [1], [1] --> nothing is promoted to column, should already be promoted to ROW irc.Id = 0; thisReport.Columns.Add(irc); for (int index = 0; index <= 4; index++) { InstanceReportRow irr = new InstanceReportRow(); irr.Id = index; Cell c = new Cell(0); irr.Cells.Add(c); thisReport.Rows.Add(irr); } (thisReport.Rows[0].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer = "[1]"; (thisReport.Rows[1].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer = "[1]"; (thisReport.Rows[2].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer = "[1]"; (thisReport.Rows[3].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer = "[1]"; (thisReport.Rows[4].Cells[0] as Cell).IsNumeric = true; (thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer = "[1]"; thisReport.PromoteFootnotes(); Console.WriteLine("Column level index = " + irc.FootnoteIndexer); foreach (InstanceReportRow irr in thisReport.Rows) { Cell c = irr.Cells[0] as Cell; Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer); } Assert.IsTrue(irc.FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer == ""); Assert.IsTrue((thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer == ""); }
private bool IsMemberGroupRow( InstanceReportRow row ) { if( row == null ) return false; if( !row.IsAbstractGroupTitle || row.EmbedRequirements == null || row.EmbedRequirements.Segments == null || row.EmbedRequirements.Segments.Count != 1 ) return false; return true; }
private bool CompareRowCells( InstanceReportRow baseRow, InstanceReportRow newRow, InstanceReport baseReport, InstanceReport newReport, string basePath, string newPath, int rowCount, DateTime reportDate, out string error) { error = string.Empty; //Row# {0}:'{1}' has unmatched data.<br>Expected Results: '{2}' Actual Results: '{3}' output op = new output(Output); bool retval = true; string labelText = baseRow.Label.Replace("\r\n", " "); //if (!string.Equals( baseRow.ToString(), newRow.ToString(), StringComparison.InvariantCultureIgnoreCase ) ) //{ for (int i = 0; i < baseRow.Cells.Count; i++) { Cell baseCell = baseRow.Cells[i]; Cell newCell = newRow.Cells[i]; if (baseCell.HasEmbeddedReport == newCell.HasEmbeddedReport) { if (newCell.HasEmbeddedReport) { this.ReportCompare(baseCell.EmbeddedReport.InstanceReport, newCell.EmbeddedReport.InstanceReport, basePath, newPath, reportDate, out error); continue; } } else { if (baseCell.HasEmbeddedReport) { this.htmlStarter("Unmatched embedded reports<br>BaseRep cell has an embedded report, but NewRep cell does not.", reportDate, out error); } else { this.htmlStarter("Unmatched embedded reports<br>NewRep cell has an embedded report, but BaseRep cell does not.", reportDate, out error); } } string baseText = WHITE_SPACE.Replace(baseCell.ToString().Trim(), " "); string newText = WHITE_SPACE.Replace(newCell.ToString().Trim(), " "); if (!string.Equals(baseText, newText, StringComparison.InvariantCultureIgnoreCase)) { retval = false; htmlStarter(string.Format(mismatchCell, i.ToString(), labelText, baseRow.Cells[i].ToString(), newRow.Cells[i].ToString()), reportDate, out error); if (errorID > 0) { //RLogger.Info(string.Format(debugParameters, baseReport.ReportName, newReport.ReportName, errorID, 464)); using (BaselineRules baseL = new BaselineRules(baseReport, newReport, errorID)) { baseL.EvaluateUnmatchedDataError(rowCount); } } else if (errorID == 0) { RLogger.Error("No error ID on " + baseReport.ReportName + " " + workingHeader.XmlFileName + " SQL DB returned 0"); } } if (!string.Equals(baseCell.FootnoteIndexer, newCell.FootnoteIndexer)) { retval = false; htmlStarter(string.Format(mismatchCell, i.ToString(), labelText, "Footnotes: " + baseCell.FootnoteIndexer, "Footnotes: " + newCell.FootnoteIndexer), reportDate, out error); } } //} return(retval); }
private bool IsMatchingRow( InstanceReportRow leftRow, InstanceReportRow rightRow ) { if( leftRow.ElementName != rightRow.ElementName ) return false; foreach( Segment keepSeg in leftRow.EmbedRequirements.Segments ) { bool found = false; foreach( Segment remSeg in rightRow.EmbedRequirements.Segments ) { if( string.Equals( keepSeg.DimensionInfo.dimensionId, remSeg.DimensionInfo.dimensionId ) ) { if( string.Equals( keepSeg.DimensionInfo.Id, remSeg.DimensionInfo.Id ) ) { found = true; break; } else { return false; } } } if( !found ) return false; } return true; }