public void RemoveCurrencyLabel() { if (string.IsNullOrEmpty(this.CurrencyCode)) { return; } for (int i = 0; i < this.Labels.Count;) { LabelLine lbl = this.Labels[i]; if (!lbl.Label.StartsWith(this.CurrencyCode)) { i++; continue; } if (!string.IsNullOrEmpty(this.CurrencySymbol)) { if (lbl.Label.Contains(this.CurrencySymbol)) { this.Labels.RemoveAt(i); } else { i++; } } else { this.Labels.RemoveAt(i); } } }
public void ClearReportingPeriod() { if (this.MyContextProperty != null) { this.MyContextProperty.PeriodDisplayName = null; this.MyContextProperty.PeriodStartDate = DateTime.MinValue; this.MyContextProperty.PeriodEndDate = DateTime.MinValue; this.MyContextProperty.PeriodType = Element.PeriodType.na; } //Remove the period labels for (int i = this.Labels.Count - 1; i >= 0; i--) { LabelLine ll = this.Labels[i]; string[] strArray = ll.Label.Split('-'); DateTime dt; if (strArray.Length == 2 && DateTime.TryParse(strArray[0], out dt) && DateTime.TryParse(strArray[1], out dt)) { this.Labels.RemoveAt(i); } else if (DateTime.TryParse(ll.Label, out dt)) { this.Labels.RemoveAt(i); } } }
public override bool Equals(object obj) { LabelLine ll = (LabelLine)obj; if (ll.IgnoreForMatch && IgnoreForMatch) { return(true); } return(Label.Equals(ll.Label)); }
public void ApplyBalanceDateLabel(CalendarPeriod calendarPeriod, string dateFormat) { if (this.BalanceDate == null) { return; } string dtString = this.BalanceDate.StartDate.ToString(dateFormat); LabelLine newLabel = new LabelLine(this.Labels.Count + 1, string.Format(" at {1}", this.Label, dtString)); this.Labels.Add(newLabel); }
public bool ApplySpecialLabel(Segment specialSegment) { if (string.IsNullOrEmpty(specialSegment.ValueName)) { return(false); } if (specialSegment.IsDefaultForEntity) { return(false); } LabelLine newLabel = new LabelLine(this.Labels.Count + 1, string.Format(" ({1})", this.Label, specialSegment.ValueName)); this.Labels.Add(newLabel); return(true); }
public int CompareTo(object obj) { LabelLine other = obj as LabelLine; if (other == null) { return(1); } int result = this.Label.CompareTo(other.Label); if (result != 0) { return(result); } return(this.IgnoreForMatch.CompareTo(other.IgnoreForMatch)); }
public void ApplyCurrencyLabel() { if (string.IsNullOrEmpty(this.CurrencyCode)) { return; } if (this.HasCurrencyLabel()) { return; } string currencyLabel = this.CurrencyCode; if (!string.IsNullOrEmpty(this.CurrencySymbol)) { currencyLabel += " (" + this.CurrencySymbol + ")"; } LabelLine ll = new LabelLine(this.Labels.Count + 1, currencyLabel); this.Labels.Add(ll); }
public void TestMonthsBetweenSameYear() { InstanceReport report = new InstanceReport(); InstanceReportColumn irc = new InstanceReportColumn(); ContextProperty cp = new ContextProperty(); cp.PeriodStartDate = new DateTime(2011, 1, 1); cp.PeriodEndDate = new DateTime(2014, 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); report.Columns.Add(irc); report.SetCalendarLabels("MMM. dd, yyyy", "{n} Months Ended"); Assert.AreEqual("48 Months Ended", (irc.Labels[0]).Label, "wrong label"); }
/// <summary> /// Adds a label to the top of the stack on the column. /// </summary> /// <param name="label">The name of the label.</param> /// <param name="key">The key to use to identify the label.</param> public void PrependLabel( string label, string key ) { LabelLine newLine = new LabelLine( this.Labels.Count, label, key ); this.Labels.Insert( 0, newLine ); }
public void ApplyCurrencyLabel() { if( string.IsNullOrEmpty( this.CurrencyCode ) ) return; if( this.HasCurrencyLabel() ) return; string currencyLabel = this.CurrencyCode; if( !string.IsNullOrEmpty( this.CurrencySymbol ) ) currencyLabel += " (" + this.CurrencySymbol + ")"; LabelLine ll = new LabelLine( this.Labels.Count + 1, currencyLabel ); this.Labels.Add( ll ); }
public bool ApplySpecialLabel( Segment specialSegment ) { if( string.IsNullOrEmpty( specialSegment.ValueName ) ) return false; if( specialSegment.IsDefaultForEntity ) return false; LabelLine newLabel = new LabelLine( this.Labels.Count + 1, string.Format( " ({1})", this.Label, specialSegment.ValueName ) ); this.Labels.Add( newLabel ); return true; }
public void ApplyBalanceDateLabel( CalendarPeriod calendarPeriod, string dateFormat ) { if( this.BalanceDate == null ) return; string dtString = this.BalanceDate.StartDate.ToString( dateFormat ); LabelLine newLabel = new LabelLine( this.Labels.Count + 1, string.Format( " at {1}", this.Label, dtString ) ); this.Labels.Add( newLabel ); }
/// <summary> /// Adds a label to the top of the stack on the column. /// </summary> /// <param name="label">The name of the label.</param> /// <param name="key">The key to use to identify the label.</param> public void PrependLabel(string label, string key) { LabelLine newLine = new LabelLine(this.Labels.Count, label, key); this.Labels.Insert(0, newLine); }
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); }
public LabelLine( LabelLine arg ) : this(arg.Id, arg.Label) { }
public object Clone() { LabelLine ll = this.MemberwiseClone() as LabelLine; return(ll); }
public void TestProcessColumnHeaders() { InitializeTestInstanceReport(); this.ProcessColumnHeaders(); DateTime expectedDate = new DateTime(2006, 12, 31); LabelLine expectedLabel = new LabelLine(1, "3 Months Ended"); Assert.IsTrue(this.Columns[0].Labels.Contains(expectedLabel), "Column 0 does not contain the Months Ended label"); expectedLabel = new LabelLine(2, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[0].Labels.Contains(expectedLabel), "Column 0 does not contain the Date label"); expectedDate = new DateTime(2007, 12, 31); expectedLabel = new LabelLine(1, "3 Months Ended"); Assert.IsTrue(this.Columns[1].Labels.Contains(expectedLabel), "Column 1 does not contain the Months Ended label"); expectedLabel = new LabelLine(2, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[1].Labels.Contains(expectedLabel), "Column 1 does not contain the Date label"); expectedDate = new DateTime(2007, 12, 31); expectedLabel = new LabelLine(1, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[2].Labels.Contains(expectedLabel), "Column 2 does not contain the date label"); expectedDate = new DateTime(2006, 12, 31); expectedLabel = new LabelLine(1, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[3].Labels.Contains(expectedLabel), "Column 2 does not contain the date label"); expectedDate = new DateTime(2008, 12, 31); expectedLabel = new LabelLine(1, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[4].Labels.Contains(expectedLabel), "Column 2 does not contain the date label"); expectedDate = new DateTime(2008, 12, 31); expectedLabel = new LabelLine(1, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[5].Labels.Contains(expectedLabel), "Column 2 does not contain the date label"); expectedDate = new DateTime(2008, 12, 31); expectedLabel = new LabelLine(1, expectedDate.ToString("MMM. dd, yyyy")); Assert.IsTrue(this.Columns[6].Labels.Contains(expectedLabel), "Column 2 does not contain the date label"); }
/// <summary> /// Consider calling <see>report</see>.<see cref="InstanceReport.SortColumns"/> first. Merges 1) non-monetary units and 2) monetary units of the same currency and 3) merges them under the same calendar/segments if possible. /// </summary> /// <param name="report">The report whose columns will be merged.</param> /// <returns>True on success, false on fail.</returns> private static bool MergeColumns(InstanceReport report) { if (report == null) { return(false); } bool hasMergedColumns = false; for (int c = 0; c < report.Columns.Count - 1; c++) { InstanceReportColumn curColumn = report.Columns[c]; InstanceReportColumn nextColumn = report.Columns[c + 1]; if (!curColumn.ReportingPeriodEquals(nextColumn) || !curColumn.SegmentAndScenarioEquals(nextColumn)) { continue; } bool curHasCurrency = !string.IsNullOrEmpty(curColumn.CurrencyCode); if (curHasCurrency) { bool nextHasCurrency = !string.IsNullOrEmpty(nextColumn.CurrencyCode); if (nextHasCurrency) { if (!string.Equals(curColumn.CurrencyCode, nextColumn.CurrencyCode)) { continue; } } } bool columnValuesAreUnique = true; foreach (InstanceReportRow row in report.Rows) { if (row.Cells[c].HasData && row.Cells[c + 1].HasData) { columnValuesAreUnique = false; break; } } if (columnValuesAreUnique) { //since we have unique columns, merge them and remove the column + cells hasMergedColumns = true; foreach (InstanceReportRow row in report.Rows) { if (!row.Cells[c].HasData && row.Cells[c + 1].HasData) { row.Cells[c].AddData(row.Cells[c + 1]); } } //please don't move this up ;-) report.RemoveColumn(c + 1); c--; curColumn.Units.AddRange(nextColumn.Units); if (string.IsNullOrEmpty(curColumn.CurrencyCode) && !string.IsNullOrEmpty(nextColumn.CurrencyCode)) { curColumn.CurrencyCode = nextColumn.CurrencyCode; curColumn.CurrencySymbol = nextColumn.CurrencySymbol; curColumn.MCU.CurrencyCode = nextColumn.MCU.CurrencyCode; curColumn.MCU.CurrencySymbol = nextColumn.MCU.CurrencySymbol; //this is probably the currency label - since we didn't have a currency, we didn't have the label //copy the reference to this label over LabelLine last = nextColumn.Labels[nextColumn.Labels.Count - 1]; last.Id = curColumn.Labels.Count; curColumn.Labels.Add(last); } } } return(hasMergedColumns); }
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 LabelLine(LabelLine arg) : this(arg.Id, arg.Label) { }
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); }
private void ProcessColumnMaps(List <ColumnInstantDurationMap> columnMaps) { //Merge columns in the column map if (columnMaps == null || columnMaps.Count == 0) { return; } ProcessMissingMapsMultiCurrency(columnMaps); //ANY columns that appear in our column map have been approved for merging //THEREFORE we will merge the units from the instant into the duration columnMaps.ForEach( (colMap) => { InstanceReportColumn ircDuration = this.Columns[colMap.DurationColumnIndex] as InstanceReportColumn; InstanceReportColumn ircInstant = this.Columns[colMap.InstantColumnIndex] as InstanceReportColumn; //If the merged column does not have a currency, apply the currency and the currency label if (string.IsNullOrEmpty(ircDuration.CurrencyCode) && !string.IsNullOrEmpty(ircInstant.CurrencyCode)) { ircDuration.CurrencyCode = ircInstant.CurrencyCode; ircDuration.CurrencySymbol = ircInstant.CurrencySymbol; //we MIGHT need to apply the unit label to the duration column LabelLine llCurrency = ircInstant.Labels[ircInstant.Labels.Count - 1]; if (llCurrency.Label.StartsWith(ircInstant.CurrencyCode) && llCurrency.Label.Contains(ircInstant.CurrencySymbol)) { ircDuration.Labels.Add(llCurrency); } } //Merge all units ircInstant.MCU.UPS.ForEach( (iUP) => { bool durationAlreadyHasUnitID = ReportUtils.Exists(ircDuration.MCU.UPS, (dUP) => { bool idMatches = dUP.UnitID == iUP.UnitID; return(idMatches); }); if (!durationAlreadyHasUnitID) { ircDuration.MCU.UPS.Add(iUP); } } ); } ); //Do not allow destination columns to be deleted Dictionary <int, bool> destinationColumns = new Dictionary <int, bool>(); //Only try to delete "source" columns Dictionary <int, Dictionary <string, bool> > sourceColumns = new Dictionary <int, Dictionary <string, bool> >(); //we don't want to remove these - retain them so that 'ProcessBeginningEndingBalance' has some work to do List <ColumnInstantDurationMap> bbMaps = new List <ColumnInstantDurationMap>(); List <ColumnInstantDurationMap> otherMaps = new List <ColumnInstantDurationMap>(); foreach (ColumnInstantDurationMap colMap in columnMaps) { InstanceReportColumn ircInstant = this.Columns[colMap.InstantColumnIndex] as InstanceReportColumn; InstanceReportColumn ircDuration = this.Columns[colMap.DurationColumnIndex] as InstanceReportColumn; //is this a beginning balance column mapping? if (ircInstant.MCU.contextRef.PeriodStartDate == ircDuration.MCU.contextRef.PeriodStartDate.AddDays(-1) || ircInstant.MCU.contextRef.PeriodStartDate == ircDuration.MCU.contextRef.PeriodStartDate) { bbMaps.Add(colMap); } else { otherMaps.Add(colMap); } } Dictionary <int, bool> columnsMapped = new Dictionary <int, bool>(); //For each map, go through the rows and switch the colID foreach (InstanceReportRow irr in this.Rows) { if (irr.IsBeginningBalance) { ProcessMapsOnRow(irr, bbMaps, destinationColumns, sourceColumns); } else { ProcessMapsOnRow(irr, otherMaps, destinationColumns, sourceColumns); } } //Get a SORTED list of all columns to remove List <int> columnsToRemove = new List <int>(); foreach (int col in sourceColumns.Keys) { if (destinationColumns.ContainsKey(col)) { continue; } if (columnsToRemove.Contains(col)) { continue; } int populatedCells = this.CountColumnPopulatedElements(col); if (populatedCells <= sourceColumns[col].Count) { columnsToRemove.Add(col); } else { Dictionary <string, bool> elementLookup = sourceColumns[col]; foreach (InstanceReportRow row in this.Rows) { if (!elementLookup.ContainsKey(row.ElementName)) { continue; } ((Cell)row.Cells[col]).Clear(); } } } columnsToRemove.Sort(); //Remove columns for (int index = columnsToRemove.Count - 1; index >= 0; index--) { this.RemoveColumn(columnsToRemove[index]); } this.SynchronizeGrid(); }