Beispiel #1
0
        public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention)
        {
            bool hr;

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

            DBPercent          = schedule.DeprPercent;
            YearElapsed        = 0;
            Life               = schedule.DeprLife;
            SalvageDeduction   = schedule.SalvageDeduction;
            AdjustedCost       = schedule.AdjustedCost;
            PostUsageDeduction = schedule.PostUsageDeduction;



            if (m_pObjSwitchMethod != null)
            {
                if (!(hr = m_pObjSwitchMethod.Initialize(schedule, convention)))
                {
                    return(hr);
                }
            }

            return(true);
        }
        public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention)
        {
            BAUSDeprTable obj;
            IBACalendar   Calendar;
            IBAFiscalYear FY;
            string        AvgConvention;
            short         deprPercent;
            long          tablePeriodCount;
            DateTime      PlacedInServiceDate;
            double        deprLife;
            double        adjCost;
            double        PostUse;
            double        Salvage;

            // life id pairs are a life in years (year only) followed by the table id.
            LIFEIDTABLE[] MM100 = new LIFEIDTABLE[] { new LIFEIDTABLE(27, 1), new LIFEIDTABLE(31, 2), new LIFEIDTABLE(39, 3), new LIFEIDTABLE(40, 179) };
            LIFEIDTABLE[] HY100 = new LIFEIDTABLE[] {
                new LIFEIDTABLE(30, 101), new LIFEIDTABLE(36, 102), new LIFEIDTABLE(42, 103), new LIFEIDTABLE(48, 104), new LIFEIDTABLE(60, 105), new LIFEIDTABLE(72, 106), new LIFEIDTABLE(78, 107),
                new LIFEIDTABLE(84, 108), new LIFEIDTABLE(90, 109), new LIFEIDTABLE(96, 110), new LIFEIDTABLE(102, 111), new LIFEIDTABLE(108, 112), new LIFEIDTABLE(114, 113), new LIFEIDTABLE(120, 114),
                new LIFEIDTABLE(126, 115), new LIFEIDTABLE(132, 116), new LIFEIDTABLE(138, 117), new LIFEIDTABLE(144, 118), new LIFEIDTABLE(150, 119), new LIFEIDTABLE(156, 120), new LIFEIDTABLE(162, 121),
                new LIFEIDTABLE(168, 122), new LIFEIDTABLE(180, 123), new LIFEIDTABLE(192, 124), new LIFEIDTABLE(198, 125), new LIFEIDTABLE(204, 126), new LIFEIDTABLE(216, 127), new LIFEIDTABLE(228, 128),
                new LIFEIDTABLE(240, 129), new LIFEIDTABLE(264, 130), new LIFEIDTABLE(288, 131), new LIFEIDTABLE(300, 132), new LIFEIDTABLE(318, 133), new LIFEIDTABLE(336, 134), new LIFEIDTABLE(360, 135),
                new LIFEIDTABLE(420, 136), new LIFEIDTABLE(480, 137), new LIFEIDTABLE(540, 138), new LIFEIDTABLE(600, 139)
            };

            LIFEIDTABLE[] MQ100 = new LIFEIDTABLE[] {
                new LIFEIDTABLE(30, 140), new LIFEIDTABLE(36, 141), new LIFEIDTABLE(42, 142), new LIFEIDTABLE(48, 143), new LIFEIDTABLE(60, 144), new LIFEIDTABLE(72, 145), new LIFEIDTABLE(78, 146),
                new LIFEIDTABLE(84, 147), new LIFEIDTABLE(90, 148), new LIFEIDTABLE(96, 149), new LIFEIDTABLE(102, 150), new LIFEIDTABLE(108, 151), new LIFEIDTABLE(114, 152), new LIFEIDTABLE(120, 153),
                new LIFEIDTABLE(126, 154), new LIFEIDTABLE(132, 155), new LIFEIDTABLE(138, 156), new LIFEIDTABLE(144, 157), new LIFEIDTABLE(150, 158), new LIFEIDTABLE(156, 159), new LIFEIDTABLE(162, 160),
                new LIFEIDTABLE(168, 161), new LIFEIDTABLE(180, 162), new LIFEIDTABLE(192, 163), new LIFEIDTABLE(198, 164), new LIFEIDTABLE(204, 165), new LIFEIDTABLE(216, 166), new LIFEIDTABLE(228, 167),
                new LIFEIDTABLE(240, 168), new LIFEIDTABLE(264, 169), new LIFEIDTABLE(288, 170), new LIFEIDTABLE(300, 171), new LIFEIDTABLE(318, 172), new LIFEIDTABLE(336, 173), new LIFEIDTABLE(360, 174),
                new LIFEIDTABLE(420, 175), new LIFEIDTABLE(480, 176), new LIFEIDTABLE(540, 177), new LIFEIDTABLE(600, 178)
            };

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

            m_Table             = null;
            deprPercent         = schedule.DeprPercent;
            deprLife            = schedule.DeprLife;
            Salvage             = schedule.SalvageDeduction;
            adjCost             = schedule.AdjustedCost;
            PostUse             = schedule.PostUsageDeduction;
            PlacedInServiceDate = schedule.PlacedInServiceDate;
            AvgConvention       = schedule.AvgConvention;

            DBPercent          = deprPercent;
            YearElapsed        = 0;
            Life               = deprLife;
            SalvageDeduction   = Salvage;
            AdjustedCost       = adjCost;
            PostUsageDeduction = PostUse;

            m_tableId = 0;
            int    len = AvgConvention.Length;
            string tmp = AvgConvention;

            if (tmp == AvgConvention)
            {
                m_tableId = FindID((short)(deprLife + 0.01), MM100, 4);
            }

            if (string.Compare(AvgConvention, "MM") == 0 || string.Compare(AvgConvention, "MMM") == 0)
            {
                m_tableId = FindID((short)(deprLife + 0.01), MM100, 4);
            }
            else if (string.Compare(AvgConvention, "HY") == 0)
            {
                m_tableId = FindID((short)((deprLife * 12) + 0.01), HY100, 39);
            }
            else if (string.Compare(AvgConvention, "MQ") == 0)
            {
                m_tableId = FindID((short)((deprLife * 12) + 0.01), MQ100, 39);
            }

            if (m_tableId == 0)
            {
                throw new Exception("Invalid table information");
            }
            //
            // Load the table interface
            //
            obj     = new BAUSDeprTable();
            m_Table = (IBADeprTable)obj;

            //
            // Load the appropriate table into the interface
            //
            obj.LoadTable(m_altMacrsTable, m_tableId);
            tablePeriodCount = m_Table.PeriodCount;

            //
            // Now we need to determine the period that the asset was placed in service.
            // This will be used to look up the appropriate information in the table.
            //
            if (tablePeriodCount == 1)
            {
                m_sPlacedInServicePeriod = 1;
            }
            else
            {
                if (tablePeriodCount == 4)
                {
                    m_sPlacedInServicePeriod = convention.DetermineTablePeriod;
                }
                else if (tablePeriodCount == 12 && deprPercent == 100 &&
                         (string.Compare(AvgConvention, "MM") == 0 || string.Compare(AvgConvention, "MMM") == 0))
                {
                    DateTime yearEnd;
                    int      monthCount;

                    Calendar = schedule.Calendar;
                    Calendar.GetFiscalYear(PlacedInServiceDate, out FY);
                    yearEnd = FY.YREndDate;

                    if (yearEnd.Day < 8)
                    {
                        // If the day is less than 8, then we need to "TRUE" it up to the proper month
                        yearEnd = yearEnd.AddDays(-yearEnd.Day);
                    }
                    if (PlacedInServiceDate.Year < yearEnd.Year)
                    {
                        monthCount = yearEnd.Month - PlacedInServiceDate.Month + 13;
                    }
                    else
                    {
                        monthCount = yearEnd.Month - PlacedInServiceDate.Month + 1;
                    }
                    if (monthCount > 12)
                    {
                        monthCount = 12;
                    }
                    m_sPlacedInServicePeriod = (short)(13 - monthCount);
                }
                else
                {
                    throw new Exception("Invalid MACRS table definition.");
                }
            }
            m_iSwitchYearNum = FindSwitchYearNumber(schedule, convention);
            //
            // All done
            //
            if (m_pObjSwitchMethod != null)
            {
                m_pObjSwitchMethod.Initialize(schedule, convention);
                m_pObjSwitchMethod.SalvageDeduction = 0;
            }

            return(true);
        }
Beispiel #3
0
        public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention)
        {
            bool          hr;
            BAUSDeprTable obj;
            IBACalendar   Calendar;
            IBAFiscalYear FY;
            string        AvgConvention;
            short         deprPercent;
            long          tablePeriodCount;
            DateTime      PlacedInServiceDate;
            double        deprLife;
            double        adjCost;
            double        PostUse;
            double        Salvage;

            // life id pairs are a life in years (year only) followed by the table id.
            LIFEIDTABLE[] HY200 = new LIFEIDTABLE[]
            { new LIFEIDTABLE(3, 1), new LIFEIDTABLE(5, 2), new LIFEIDTABLE(7, 3), new LIFEIDTABLE(10, 4), new LIFEIDTABLE(15, 101), new LIFEIDTABLE(20, 102) };
            LIFEIDTABLE[] MQ200 = new LIFEIDTABLE[]
            { new LIFEIDTABLE(3, 5), new LIFEIDTABLE(5, 8), new LIFEIDTABLE(7, 11), new LIFEIDTABLE(10, 13), new LIFEIDTABLE(15, 103), new LIFEIDTABLE(16, 104) };
            LIFEIDTABLE[] MM100 = new LIFEIDTABLE[]
            { new LIFEIDTABLE(27, 29), new LIFEIDTABLE(31, 30), new LIFEIDTABLE(39, 31) };
            LIFEIDTABLE[] HY150 = new LIFEIDTABLE[] {
                new LIFEIDTABLE(30, 105), new LIFEIDTABLE(36, 19), new LIFEIDTABLE(42, 106), new LIFEIDTABLE(48, 20), new LIFEIDTABLE(60, 21), new LIFEIDTABLE(72, 22), new LIFEIDTABLE(78, 107),
                new LIFEIDTABLE(84, 23), new LIFEIDTABLE(90, 108), new LIFEIDTABLE(96, 109), new LIFEIDTABLE(102, 110), new LIFEIDTABLE(108, 111), new LIFEIDTABLE(114, 112), new LIFEIDTABLE(120, 24),
                new LIFEIDTABLE(126, 113), new LIFEIDTABLE(132, 114), new LIFEIDTABLE(138, 115), new LIFEIDTABLE(144, 25), new LIFEIDTABLE(150, 116), new LIFEIDTABLE(156, 117), new LIFEIDTABLE(162, 118),
                new LIFEIDTABLE(168, 119), new LIFEIDTABLE(180, 26), new LIFEIDTABLE(192, 120), new LIFEIDTABLE(198, 121), new LIFEIDTABLE(204, 122), new LIFEIDTABLE(216, 123), new LIFEIDTABLE(228, 124),
                new LIFEIDTABLE(240, 27), new LIFEIDTABLE(264, 125), new LIFEIDTABLE(288, 126), new LIFEIDTABLE(300, 127), new LIFEIDTABLE(318, 128), new LIFEIDTABLE(336, 129), new LIFEIDTABLE(360, 130),
                new LIFEIDTABLE(420, 131), new LIFEIDTABLE(480, 28), new LIFEIDTABLE(540, 132), new LIFEIDTABLE(600, 133)
            };

            LIFEIDTABLE[] MQ150 = new LIFEIDTABLE[] {
                new LIFEIDTABLE(30, 134), new LIFEIDTABLE(36, 6), new LIFEIDTABLE(42, 135), new LIFEIDTABLE(48, 7), new LIFEIDTABLE(60, 9), new LIFEIDTABLE(72, 10), new LIFEIDTABLE(78, 136),
                new LIFEIDTABLE(84, 12), new LIFEIDTABLE(90, 137), new LIFEIDTABLE(96, 138), new LIFEIDTABLE(102, 139), new LIFEIDTABLE(108, 140), new LIFEIDTABLE(114, 141), new LIFEIDTABLE(120, 14),
                new LIFEIDTABLE(126, 142), new LIFEIDTABLE(132, 143), new LIFEIDTABLE(138, 144), new LIFEIDTABLE(144, 15), new LIFEIDTABLE(150, 145), new LIFEIDTABLE(156, 146), new LIFEIDTABLE(162, 147),
                new LIFEIDTABLE(168, 148), new LIFEIDTABLE(180, 16), new LIFEIDTABLE(192, 149), new LIFEIDTABLE(198, 150), new LIFEIDTABLE(204, 151), new LIFEIDTABLE(216, 152), new LIFEIDTABLE(228, 153),
                new LIFEIDTABLE(240, 17), new LIFEIDTABLE(264, 154), new LIFEIDTABLE(288, 155), new LIFEIDTABLE(300, 156), new LIFEIDTABLE(318, 157), new LIFEIDTABLE(336, 158), new LIFEIDTABLE(360, 159),
                new LIFEIDTABLE(420, 160), new LIFEIDTABLE(480, 18), new LIFEIDTABLE(540, 161), new LIFEIDTABLE(600, 162)
            };

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

            m_Table             = null;
            deprPercent         = schedule.DeprPercent;
            deprLife            = schedule.DeprLife;
            Salvage             = schedule.SalvageDeduction;
            adjCost             = schedule.AdjustedCost;
            PostUse             = schedule.PostUsageDeduction;
            PlacedInServiceDate = schedule.PlacedInServiceDate;
            AvgConvention       = schedule.AvgConvention;

            DBPercent          = deprPercent;
            YearElapsed        = 0;
            Life               = deprLife;
            SalvageDeduction   = Salvage;
            AdjustedCost       = adjCost;
            PostUsageDeduction = PostUse;

            //
            // Now we need to determine the ACRS table number and load the table into the system.
            //
            m_tableId = 0;

            if (deprPercent == 200)
            {
                if (string.Compare(AvgConvention, "MQ") != 0)    // is not mid quarter
                {
                    m_tableId = FindID((short)(deprLife + 0.01), HY200, 6);
                }
                else
                {
                    m_tableId = FindID((short)(deprLife + 0.01), MQ200, 6);
                }
            }
            else if (deprPercent == 150)
            {
                if (string.Compare(AvgConvention, "MQ") != 0)    // is not mid quarter
                {
                    m_tableId = FindID((short)(deprLife * 12 + 0.01), HY150, 39);
                }
                else
                {
                    m_tableId = FindID((short)(deprLife * 12 + 0.01), MQ150, 39);
                }
            }
            else if (deprPercent == 100)
            {
                if (string.Compare(AvgConvention, "MM") == 0 || string.Compare(AvgConvention, "MMM") == 0)
                {
                    m_tableId = FindID((short)(deprLife + 0.01), MM100, 3);
                }
            }

            if (m_tableId == 0)
            {
                return(true);
            }
            //
            // Load the table interface
            //
            //if ( FAILED(hr = CComObject<CBAUSDeprTable>::CreateInstance(&obj)) ||
            //     FAILED(hr = obj->QueryInterface(IID_IBADeprTable, (void**)&m_Table)) )
            //{
            //    delete obj;
            //    return hr;
            //}
            obj     = new BAUSDeprTable();
            m_Table = (IBADeprTable)obj;
            //
            // Load the appropriate table into the interface
            //
            if (m_tableId < 100)
            {
                obj.LoadTable(m_macrsTable, m_tableId);
                tablePeriodCount = m_Table.PeriodCount;
            }
            else
            {
                obj.LoadTable(m_apolloMacrsTable, m_tableId);
                tablePeriodCount = m_Table.PeriodCount;
            }
            //
            // Now we need to determine the period that the asset was placed in service.
            // This will be used to look up the appropriate information in the table.
            //
            if (tablePeriodCount == 1)
            {
                m_sPlacedInServicePeriod = 1;
            }
            else
            {
                if (tablePeriodCount == 4)
                {
                    m_sPlacedInServicePeriod = convention.DetermineTablePeriod;
                }
                else if (tablePeriodCount == 12 && deprPercent == 100 &&
                         (string.Compare(AvgConvention, "MM") == 0 || string.Compare(AvgConvention, "MMM") == 0))
                {
                    DateTime yearEnd;
                    int      monthCount;

                    Calendar = schedule.Calendar;
                    Calendar.GetFiscalYear(PlacedInServiceDate, out FY);
                    yearEnd = FY.YREndDate;

                    if (yearEnd.Day < 8)
                    {
                        // If the day is less than 8, then we need to "TRUE" it up to the proper month
                        yearEnd = yearEnd.AddDays(-yearEnd.Day);
                        if (PlacedInServiceDate > yearEnd)                              // KENT
                        {
                            PlacedInServiceDate = yearEnd;
                        }
                    }
                    if (PlacedInServiceDate.Year < yearEnd.Year)
                    {
                        monthCount = yearEnd.Month - PlacedInServiceDate.Month + 13;
                    }
                    else
                    {
                        monthCount = yearEnd.Month - PlacedInServiceDate.Month + 1;
                    }
                    if (monthCount > 12)
                    {
                        monthCount = 12;
                    }
                    m_sPlacedInServicePeriod = (short)(13 - monthCount);
                }
                else
                {
                    throw new Exception("Invalid MACRS table definition.");
                }
            }
            m_iSwitchYearNum = FindSwitchYearNumber(schedule, convention);

            if (m_pObjSwitchMethod != null)
            {
                m_pObjSwitchMethod.Initialize(schedule, convention);
                m_pObjSwitchMethod.SalvageDeduction = 0;
            }

            //
            // All done
            //
            return(true);
        }