コード例 #1
0
 public void ApplyBalanceDate(CalendarPeriod calendarPeriod)
 {
     if (calendarPeriod.PeriodType == Element.PeriodType.duration)
     {
         if (this.IsBeginningBalance)
         {
             this.BalanceDate            = new CalendarPeriod(calendarPeriod.StartDate.AddDays(-1));
             this.BalanceDate.PeriodType = Element.PeriodType.instant;
         }
         else if (this.IsEndingBalance)
         {
             this.BalanceDate            = new CalendarPeriod(calendarPeriod.EndDate);
             this.BalanceDate.PeriodType = Element.PeriodType.instant;
         }
         else
         {
             this.BalanceDate            = new CalendarPeriod(calendarPeriod.StartDate, calendarPeriod.EndDate);
             this.BalanceDate.PeriodType = Element.PeriodType.duration;
         }
     }
     else
     {
         this.BalanceDate            = new CalendarPeriod(calendarPeriod.StartDate, calendarPeriod.EndDate);
         this.BalanceDate.PeriodType = Element.PeriodType.instant;
     }
 }
コード例 #2
0
        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;
        }
コード例 #3
0
        public override bool Equals(object obj)
        {
            CalendarPeriod cp = obj as CalendarPeriod;

            if (cp == null)
            {
                return(false);
            }

            if (this.PeriodType != cp.PeriodType)
            {
                return(false);
            }

            if (this.StartDate != cp.StartDate)
            {
                return(false);
            }

            if (this.EndDate != cp.EndDate)
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        public CalendarPeriod GetCalendarPeriod()
        {
            CalendarPeriod cp = new CalendarPeriod(
                this.MyContextProperty.PeriodStartDate,
                this.MyContextProperty.PeriodEndDate
                );

            cp.PeriodType = this.MyContextProperty.PeriodType;
            return(cp);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <summary>
        /// Sorts the two given <see cref="CalendarPeriod"/> inputs for use on
        /// rows.
        /// </summary>
        /// <param name="cpLeft">The left side comparison operand</param>
        /// <param name="cpRight">The right side comparison operand</param>
        /// <returns>An <see cref="int"/> indicating if <paramref
        /// name="cpLeft"/> occurs after (-1), before (1), or same as (0)
        /// <paramref name="cpRight"/>.</returns>
        public static int ReportSorter(CalendarPeriod cpLeft, CalendarPeriod cpRight)
        {
            if (cpLeft == null)
            {
                if (cpRight == null)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            else if (cpRight == null)
            {
                return(-1);
            }



            int cmp = 0;

            if (cpLeft.PeriodType != cpRight.PeriodType)
            {
                if (cpLeft.PeriodType == Element.PeriodType.instant)
                {
                    return(1);                     //instants last
                }
                else
                {
                    return(-1);                    //durations first
                }
            }

            if (cpLeft.PeriodType == Element.PeriodType.instant)
            {
                return(DateTime.Compare(cpLeft.StartDate, cpRight.StartDate));
            }

            cmp = TimeSpan.Compare(cpLeft.Span, cpLeft.Span);
            if (cmp != 0)
            {
                return(cmp);
            }

            //we actually want the opposite: newer == -1
            cmp = DateTime.Compare(cpLeft.EndDate, cpRight.EndDate);
            return(cmp * -1);
        }
コード例 #7
0
ファイル: CalendarPeriod.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Sorts the two given <see cref="CalendarPeriod"/> inputs for use on
        /// columns.
        /// </summary>
        /// <param name="cpLeft">The left side comparison operand</param>
        /// <param name="cpRight">The right side comparison operand</param>
        /// <returns>An <see cref="int"/> indicating if <paramref
        /// name="cpLeft"/> occurs after (1), before (-1), or same as (0)
        /// <paramref name="cpRight"/>.</returns>
        public static int AscendingSorter( CalendarPeriod cpLeft, CalendarPeriod cpRight )
        {
            if( cpLeft == null )
            {
                if( cpRight == null )
                    return 0;
                else
                    return 1;
            }
            else if( cpRight == null )
            {
                return -1;
            }

            int cmp = 0;
            if( cpLeft.PeriodType == cpRight.PeriodType )
            {
                cmp = DateTime.Compare( cpLeft.StartDate, cpRight.StartDate );

                if( cmp == 0 )
                    cmp = DateTime.Compare( cpLeft.EndDate, cpRight.EndDate );

                return cmp;
            }

            CalendarPeriod cpDuration = null;
            CalendarPeriod cpInstant = null;
            if( cpLeft.PeriodType == Element.PeriodType.instant )
            {
                cpDuration = cpRight;
                cpInstant = cpLeft;
            }
            else
            {
                cpDuration = cpLeft;
                cpInstant = cpRight;
            }

            cmp = DateTime.Compare( cpInstant.StartDate, cpDuration.EndDate );
            if( cmp == 0 )
            {
                if( cpLeft == cpInstant )
                    return -1;
                else
                    return 1;
            }

            return cmp;
        }
コード例 #8
0
        /// <summary>
        /// Compares two <see cref="CalendarPeriod"/> objects.
        /// </summary>
        /// <param name="cpLeft">The first object to compare</param>
        /// <param name="cpRight">The second object to compare</param>
        /// <returns>An integer indicating the results of the comparison.  A
        /// value of 0 indicates the objects are identical.</returns>
        public static int Compare(CalendarPeriod cpLeft, CalendarPeriod cpRight)
        {
            if (cpRight == null)
            {
                return(-1);
            }

            int result = cpLeft.PeriodType.CompareTo(cpRight.PeriodType);

            if (result != 0)
            {
                return(result);
            }

            result = cpLeft.StartDate.CompareTo(cpRight.StartDate);
            if (result != 0)
            {
                return(result);
            }

            return(cpLeft.EndDate.CompareTo(cpRight.EndDate));
        }
コード例 #9
0
 public void ApplyBalanceDate( CalendarPeriod calendarPeriod )
 {
     if( calendarPeriod.PeriodType == Element.PeriodType.duration )
     {
         if( this.IsBeginningBalance )
         {
             this.BalanceDate = new CalendarPeriod( calendarPeriod.StartDate.AddDays( -1 ) );
             this.BalanceDate.PeriodType = Element.PeriodType.instant;
         }
         else if( this.IsEndingBalance )
         {
             this.BalanceDate = new CalendarPeriod( calendarPeriod.EndDate );
             this.BalanceDate.PeriodType = Element.PeriodType.instant;
         }
         else
         {
             this.BalanceDate = new CalendarPeriod( calendarPeriod.StartDate, calendarPeriod.EndDate );
             this.BalanceDate.PeriodType = Element.PeriodType.duration;
         }
     }
     else
     {
         this.BalanceDate = new CalendarPeriod( calendarPeriod.StartDate, calendarPeriod.EndDate );
         this.BalanceDate.PeriodType = Element.PeriodType.instant;
     }
 }
コード例 #10
0
        public Dictionary<string, object> GetPeriodDictionary( CommandIterator.IteratorType iteratorType )
        {
            List<CalendarPeriod> uniqueCalendars = new List<CalendarPeriod>();
            this.Columns.ForEach(
            col =>
            {
                CalendarPeriod cp = new CalendarPeriod( col.MyContextProperty.PeriodStartDate, col.MyContextProperty.PeriodEndDate );
                cp.PeriodType = col.MyContextProperty.PeriodType;

                int foundAt = uniqueCalendars.BinarySearch( cp );
                if( foundAt < 0 )
                    uniqueCalendars.Insert( ~foundAt, cp );
            } );

            if( uniqueCalendars.Count > 1 )
            {
                uniqueCalendars.RemoveAll(
                iCal =>
                {
                    if( iCal.PeriodType == Element.PeriodType.duration )
                        return false;

                    return ReportUtils.Exists( uniqueCalendars, dCal => DateTime.Equals( iCal.StartDate, dCal.EndDate ) );
                } );
            }

            if( uniqueCalendars.Count > 1 )
            {
                if( iteratorType == CommandIterator.IteratorType.Column )
                    uniqueCalendars.Sort( CalendarPeriod.ReportSorter );
                else
                    uniqueCalendars.Sort( CalendarPeriod.AscendingSorter );
            }

            Dictionary<string, object> periodDictionary = new Dictionary<string, object>();
            foreach( CalendarPeriod cp in uniqueCalendars )
            {
                periodDictionary[ cp.ToString() ] = cp;
            }
            return periodDictionary;
        }
コード例 #11
0
        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;
        }
コード例 #12
0
ファイル: CalendarPeriod.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Sorts the two given <see cref="CalendarPeriod"/> inputs for use on
        /// rows.
        /// </summary>
        /// <param name="cpLeft">The left side comparison operand</param>
        /// <param name="cpRight">The right side comparison operand</param>
        /// <returns>An <see cref="int"/> indicating if <paramref
        /// name="cpLeft"/> occurs after (-1), before (1), or same as (0)
        /// <paramref name="cpRight"/>.</returns>
        public static int ReportSorter( CalendarPeriod cpLeft, CalendarPeriod cpRight )
        {
            if( cpLeft == null )
            {
                if( cpRight == null )
                    return 0;
                else
                    return 1;
            }
            else if( cpRight == null )
            {
                return -1;
            }

            int cmp = 0;
            if( cpLeft.PeriodType != cpRight.PeriodType )
            {
                if( cpLeft.PeriodType == Element.PeriodType.instant )
                    return 1;  //instants last
                else
                    return -1; //durations first
            }

            if( cpLeft.PeriodType == Element.PeriodType.instant )
                return DateTime.Compare( cpLeft.StartDate, cpRight.StartDate );

            cmp = TimeSpan.Compare( cpLeft.Span, cpLeft.Span );
            if( cmp != 0 )
                return cmp;

            //we actually want the opposite: newer == -1
            cmp = DateTime.Compare( cpLeft.EndDate, cpRight.EndDate );
            return cmp * -1;
        }
コード例 #13
0
ファイル: CalendarPeriod.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Compares two <see cref="CalendarPeriod"/> objects.
        /// </summary>
        /// <param name="cpLeft">The first object to compare</param>
        /// <param name="cpRight">The second object to compare</param>
        /// <returns>An integer indicating the results of the comparison.  A
        /// value of 0 indicates the objects are identical.</returns>
        public static int Compare( CalendarPeriod cpLeft, CalendarPeriod cpRight )
        {
            if( cpRight == null ) return -1;

            int result = cpLeft.PeriodType.CompareTo( cpRight.PeriodType );
            if( result != 0 ) return result;

            result = cpLeft.StartDate.CompareTo( cpRight.StartDate );
            if( result != 0 ) return result;

            return cpLeft.EndDate.CompareTo( cpRight.EndDate );
        }
コード例 #14
0
 public void ApplyBalanceDateLabel( CalendarPeriod calendarPeriod )
 {
     this.ApplyBalanceDateLabel( calendarPeriod, string.Empty );
 }
コード例 #15
0
        public void ApplyBalanceDateLabel(InstanceReportColumn calendarColumn)
        {
            CalendarPeriod cp = calendarColumn.GetCalendarPeriod();

            this.ApplyBalanceDateLabel(cp);
        }
コード例 #16
0
        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 );
        }
コード例 #17
0
        public void ApplyBalanceDateLabel(InstanceReportColumn calendarColumn, string dateFormat)
        {
            CalendarPeriod cp = calendarColumn.GetCalendarPeriod();

            this.ApplyBalanceDateLabel(cp, dateFormat);
        }
コード例 #18
0
 public CalendarPeriod GetCalendarPeriod()
 {
     CalendarPeriod cp = new CalendarPeriod(
         this.MyContextProperty.PeriodStartDate,
         this.MyContextProperty.PeriodEndDate
     );
     cp.PeriodType = this.MyContextProperty.PeriodType;
     return cp;
 }
コード例 #19
0
 public void ApplyBalanceDateLabel(CalendarPeriod calendarPeriod)
 {
     this.ApplyBalanceDateLabel(calendarPeriod, string.Empty);
 }
コード例 #20
0
        public void TestEquityHelperMethods()
        {
            InitializeTestEquityReport();

            Dictionary<CalendarPeriod, List<InstanceReportColumn>> colsByPer = new Dictionary<CalendarPeriod, List<InstanceReportColumn>>();
            Dictionary<string, int> masterColsBySeg = new Dictionary<string, int>();
            Dictionary<string, List<int>> prevReportColsBySeg = new Dictionary<string, List<int>>();
            Dictionary<string, List<int>> adjustmentColsBySeg = new Dictionary<string, List<int>>();
            Dictionary<int, ColumnMap> colMaps = new Dictionary<int, ColumnMap>();

            //this.BuildColumnGroups(colsByPer, masterColsBySeg, prevReportColsBySeg, adjustmentColsBySeg, colMaps);

            Assert.AreEqual(2, colsByPer.Count, "Invalid number of periods found by BuildColumnGroups");

            CalendarPeriod cp1 = new CalendarPeriod(new DateTime(2006, 10, 1), new DateTime(2006, 12, 31));
            CalendarPeriod cp2 = new CalendarPeriod(new DateTime(2007, 10, 1), new DateTime(2007, 12, 31));
            Assert.IsTrue(colsByPer.ContainsKey(cp1), "Context period 10/1/2006 - 12/31/2006 was not returned as a group");
            Assert.AreEqual(3, colsByPer[cp1].Count, "Invalid number of Coluns grouped under CP1");

            Assert.IsTrue(colsByPer.ContainsKey(cp2), "Context period 10/1/2007 - 12/31/2007 was not returned as a group");
            Assert.AreEqual(3, colsByPer[cp2].Count, "Invalid number of Coluns grouped under CP2");

            Assert.AreEqual(3, masterColsBySeg.Count, "Invalid number of colums define as master columns");
            List<int> expectedMasterColIds = new List<int>(new int[] {0, 2, 4});
            foreach(string segKey in masterColsBySeg.Keys)
            {
                int colId = masterColsBySeg[segKey];
                Assert.IsTrue(expectedMasterColIds.Contains(colId), string.Format("colId, {0}, not found in masterColsBySeg", colId));

                string expectedSegmentString = colMaps[colId].IRC.GetSegmentsString(true, false, false, false, false, this.ReportName);
                Assert.AreEqual(expectedSegmentString, segKey, string.Format("Column {0} was declared a master column for the wrong segment set", colId));
            }

            for(int i = 0; i < masterColsBySeg.Count; i++)
            {
                int colId = i;
                int mappedColId = (i % 2 == 0) ? i : (i - 1);

                Assert.AreEqual(colId, colMaps[colId].IRC.Id, String.Format("Column {0} was not keyed correctly in the Dictionary", colMaps[colId].IRC.Id));
                Assert.AreEqual(mappedColId, colMaps[colId].MappedColumnId, string.Format("Column {0} was not mapped to the correct column", colId));
            }

            //this.RemoveDuplicateSegmentColumns(masterColsBySeg, colMaps);
            Assert.AreEqual(3, this.Columns.Count, "The columns were not correctly condensed by RemoveDuplicateSegmentColumns");

            //            this.BuildEquityRowCollection(colsByPer, prevReportColsBySeg, adjustmentColsBySeg, colMaps, "MMM. dd, yyyy");

            Assert.AreEqual(8, this.Rows.Count, "Incorrect number of rows after BuildEquityRowCollection");

            for (int i = 0; i < 2; i++)
            {
                int beginningBalRowId = i * 4;
                Assert.IsTrue(this.Rows[beginningBalRowId].IsBeginningBalance, string.Format("Row {0} is not marked as a Beginning Balance", beginningBalRowId));
                Assert.IsTrue(this.Rows[beginningBalRowId].IsCalendarTitle, string.Format("Row {0} is not marked as a Calendar Title", beginningBalRowId));
            }

            for (int i = 0; i < 8; i++)
            {
                int rowIdx = i;
                int origRowIdx = rowIdx % 4;

                InstanceReportRow row = this.Rows[rowIdx];
                InstanceReportRow origRow = this.Rows[origRowIdx];

                Assert.AreEqual(this.Columns.Count, row.Cells.Count, string.Format("Incorrect number of cells in row {0}", rowIdx));
                for(int j = 0; j < this.Columns.Count; j++)
                {
                    Cell c = row.Cells[j] as Cell;
                    Assert.AreEqual(this.Columns[j].Id, c.Id, string.Format("Cell {0} on Row {1} does not have a valid cell id", j, i));
                }

                Assert.AreEqual(origRow.SimpleDataType, row.SimpleDataType, "Data types do not match");
                Assert.AreEqual(origRow.ElementName, row.ElementName, "Data types do not match");
                Assert.AreEqual(origRow.ElementPrefix, row.ElementPrefix, "Data types do not match");
                Assert.AreEqual(origRow.BalanceType, row.BalanceType, "Data types do not match");
            }
        }
コード例 #21
0
        /// <summary>
        /// Sorts the two given <see cref="CalendarPeriod"/> inputs for use on
        /// columns.
        /// </summary>
        /// <param name="cpLeft">The left side comparison operand</param>
        /// <param name="cpRight">The right side comparison operand</param>
        /// <returns>An <see cref="int"/> indicating if <paramref
        /// name="cpLeft"/> occurs after (1), before (-1), or same as (0)
        /// <paramref name="cpRight"/>.</returns>
        public static int AscendingSorter(CalendarPeriod cpLeft, CalendarPeriod cpRight)
        {
            if (cpLeft == null)
            {
                if (cpRight == null)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            else if (cpRight == null)
            {
                return(-1);
            }

            int cmp = 0;

            if (cpLeft.PeriodType == cpRight.PeriodType)
            {
                cmp = DateTime.Compare(cpLeft.StartDate, cpRight.StartDate);

                if (cmp == 0)
                {
                    cmp = DateTime.Compare(cpLeft.EndDate, cpRight.EndDate);
                }

                return(cmp);
            }

            CalendarPeriod cpDuration = null;
            CalendarPeriod cpInstant  = null;

            if (cpLeft.PeriodType == Element.PeriodType.instant)
            {
                cpDuration = cpRight;
                cpInstant  = cpLeft;
            }
            else
            {
                cpDuration = cpLeft;
                cpInstant  = cpRight;
            }

            cmp = DateTime.Compare(cpInstant.StartDate, cpDuration.EndDate);
            if (cmp == 0)
            {
                if (cpLeft == cpInstant)
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            }

            return(cmp);
        }