public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention) { IBACalendar pObjCalendar; IBAFiscalYear pObjIFY; IBACalcPeriod pObjIPd; DateTime dtFYStartDate; DateTime dtPeriodStart; DateTime dtPeriodEnd; DateTime dtPISDate; if (schedule == null) { return(false); } pObjCalendar = schedule.Calendar; dtPISDate = schedule.PlacedInServiceDate; if (pObjCalendar.GetFiscalYear(dtPISDate, out pObjIFY)) { dtFYStartDate = pObjIFY.YRStartDate; if (pObjCalendar.GetPeriod(dtFYStartDate, out pObjIPd)) { dtPeriodStart = pObjIPd.PeriodStart; dtPeriodEnd = pObjIPd.PeriodEnd; if (dtPeriodStart <= dtPISDate && dtPISDate <= dtPeriodEnd) { m_PisFys = true; } } } DBPercent = schedule.DeprPercent; YearElapsed = 0; Life = schedule.DeprLife; SalvageDeduction = schedule.SalvageDeduction; AdjustedCost = schedule.AdjustedCost; PostUsageDeduction = schedule.PostUsageDeduction; m_VintageAccount = schedule.VintageAccountFlag; return(true); }
public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention) { DateTime PlacedInServiceDate; bool LowIncomeHousing; bool PersonalProperty; bool PublicUtility; bool OutsideUS; if (schedule == null) { return(false); } DBPercent = schedule.DeprPercent; YearElapsed = 0; Life = schedule.DeprLife; SalvageDeduction = schedule.SalvageDeduction; AdjustedCost = schedule.AdjustedCost; PostUsageDeduction = schedule.PostUsageDeduction; LowIncomeHousing = schedule.LowIncomeHousingFlag; PersonalProperty = schedule.PersonalPropertyFlag; PublicUtility = schedule.PublicUtilityFlag; OutsideUS = schedule.UsedOutsideTheUS; PlacedInServiceDate = schedule.PlacedInServiceDate; m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_Normal; m_bUseFirstYearFactor = false; if (LowIncomeHousing) { // nothing special here } else if ((PersonalProperty || PublicUtility)) { m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_NoneInYear; m_bUseFirstYearFactor = true; } return(true); }
public short FindSwitchYearNumber(IBADeprScheduleItem schedule, IBAAvgConvention convention) { DateTime dtPISDate; DateTime dtDeemedEnd; DateTime dtYrStart; DateTime dtYrEnd; short iFYNum; short iStartYearNum; IBAFiscalYear pObjFY; bool bShortYear; IBACalendar Calendar; dtPISDate = schedule.PlacedInServiceDate; Calendar = schedule.Calendar; dtDeemedEnd = convention.DeemedEndDate; Calendar.GetFiscalYear(dtPISDate, out pObjFY); iStartYearNum = pObjFY.FYNum; dtYrStart = pObjFY.YRStartDate; dtYrEnd = pObjFY.YREndDate; do { bShortYear = pObjFY.IsShortYear; iFYNum = pObjFY.FYNum; if (bShortYear) { return((short)(iFYNum - iStartYearNum + 1)); } else { pObjFY = null; Calendar.GetFiscalYear(dtYrEnd.AddDays(+1), out pObjFY); dtYrStart = pObjFY.YRStartDate; dtYrEnd = pObjFY.YREndDate; } } while (!bShortYear && dtYrStart <= dtDeemedEnd); return(32767); }
public bool CalculateACEYearInformation(CalcEngine calcEngine, IBAAvgConvention pObjAvgConvetion) { if (calcEngine == null || pObjAvgConvetion == null) { throw new Exception("Error in CalculateACEYearInformation."); } if (m_pObjSchedule == null || m_pObjCalendar == null) { throw new Exception("Error in CalculateACEYearInformation."); } if (m_bUseACEHandling && m_iAceTransitionYear > 0) { m_dACETransitionYearElapsed = calcEngine.CalculateYearElapsed(m_pObjSchedule, pObjAvgConvetion, m_pObjCalendar, m_dtACEStart); } else { m_dACETransitionYearElapsed = 0; } 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); }
public bool Initialize(IBADeprScheduleItem schedule, IBAAvgConvention convention) { BAUSDeprTable obj; IBACalendar Calendar; IBAFiscalYear FY; short deprPercent; long tablePeriodCount; DateTime PlacedInServiceDate; double deprLife; double adjCost; double PostUse; double Salvage; bool LowIncomeHousing; bool PersonalProperty; bool PublicUtility; bool OutsideUS; LIFEIDTABLE[] ATSLlih = new LIFEIDTABLE[] { new LIFEIDTABLE(15, 11), new LIFEIDTABLE(35, 15), new LIFEIDTABLE(45, 16) }; LIFEIDTABLE[] ATSLPers = new LIFEIDTABLE[] { new LIFEIDTABLE(3, 17), new LIFEIDTABLE(5, 18), new LIFEIDTABLE(10, 19), new LIFEIDTABLE(12, 20), new LIFEIDTABLE(15, 21), new LIFEIDTABLE(25, 22), new LIFEIDTABLE(35, 23), new LIFEIDTABLE(45, 24) }; 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; LowIncomeHousing = schedule.LowIncomeHousingFlag; PersonalProperty = schedule.PersonalPropertyFlag; PublicUtility = schedule.PublicUtilityFlag; OutsideUS = schedule.UsedOutsideTheUS; DBPercent = deprPercent; YearElapsed = 0; Life = deprLife; SalvageDeduction = Salvage; AdjustedCost = adjCost; PostUsageDeduction = PostUse; m_tableId = 0; m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_Normal; m_bUseFirstYearFactor = false; //RDBJ if ( OutsideUS ) //RDBJ { //RDBJ // Currently we are not supporting outside the US so return an error //RDBJ return Error("Property predominantly outside the US is currently not supported."); //RDBJ } //RDBJ else { if (LowIncomeHousing) { if ((int)(deprLife + 0.01) == 35 && PlacedInServiceDate > new DateTime(1985, 5, 8)) { m_tableId = 14; } else { m_tableId = FindID((short)(deprLife + 0.01), ATSLlih, 3); } } else if ((PersonalProperty || PublicUtility)) { m_tableId = FindID((short)(deprLife + 0.01), ATSLPers, 8); m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_NoneInYear; m_bUseFirstYearFactor = true; } else if ((int)(deprLife + 0.01) == 18) { if (PlacedInServiceDate < new DateTime(1984, 6, 23)) { m_tableId = 26; } else { m_tableId = 27; } } else if ((int)(deprLife + 0.01) == 19) { m_tableId = 28; } else if ((int)(deprLife + 0.01) == 35) { if (PlacedInServiceDate > new DateTime(1985, 5, 8)) { m_tableId = 29; } else if (PlacedInServiceDate > new DateTime(1984, 6, 22)) { m_tableId = 30; } else { m_tableId = 15; } } else if ((int)(deprLife + 0.01) == 45) { if (PlacedInServiceDate > new DateTime(1984, 6, 22)) { m_tableId = 31; } else { m_tableId = 16; } } else if ((int)(deprLife + 0.01) == 15) { m_tableId = 25; } // // We could not find the table number, so return with error. // if (m_tableId == 0) { throw new Exception("Unable to determine ACRS Table Number."); } } obj = new BAUSDeprTable(); m_Table = (IBADeprTable)obj; // // Load the appropriate table into the interface // obj.LoadTable(m_acrsTable, 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 == 12) { 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 Alternate ACRS table definition."); } } // // All done // 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; bool LowIncomeHousing; bool PersonalProperty; bool PublicUtility; bool OutsideUS; LIFEIDTABLE[] ATLives = new LIFEIDTABLE[] { new LIFEIDTABLE(3, 1), new LIFEIDTABLE(5, 2), new LIFEIDTABLE(10, 3), new LIFEIDTABLE(15, 5), new LIFEIDTABLE(18, 7), new LIFEIDTABLE(19, 8) }; LIFEIDTABLE[] HY100 = new LIFEIDTABLE[] { new LIFEIDTABLE(30, 104), new LIFEIDTABLE(36, 105), new LIFEIDTABLE(42, 106), new LIFEIDTABLE(48, 107), new LIFEIDTABLE(60, 108), new LIFEIDTABLE(72, 109), new LIFEIDTABLE(78, 110), new LIFEIDTABLE(84, 111), new LIFEIDTABLE(90, 112), new LIFEIDTABLE(96, 113), new LIFEIDTABLE(102, 114), new LIFEIDTABLE(108, 115), new LIFEIDTABLE(114, 116), new LIFEIDTABLE(120, 117), new LIFEIDTABLE(126, 118), new LIFEIDTABLE(132, 119), new LIFEIDTABLE(138, 120), new LIFEIDTABLE(144, 121), new LIFEIDTABLE(150, 122), new LIFEIDTABLE(156, 123), new LIFEIDTABLE(162, 124), new LIFEIDTABLE(168, 125), new LIFEIDTABLE(180, 126), new LIFEIDTABLE(192, 127), new LIFEIDTABLE(198, 128), new LIFEIDTABLE(204, 129), new LIFEIDTABLE(216, 130), new LIFEIDTABLE(228, 131), new LIFEIDTABLE(240, 132), new LIFEIDTABLE(264, 133), new LIFEIDTABLE(300, 134), new LIFEIDTABLE(318, 135), new LIFEIDTABLE(336, 136), new LIFEIDTABLE(360, 137), new LIFEIDTABLE(420, 138), new LIFEIDTABLE(540, 139), new LIFEIDTABLE(600, 140) }; 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; LowIncomeHousing = schedule.LowIncomeHousingFlag; PersonalProperty = schedule.PersonalPropertyFlag; PublicUtility = schedule.PublicUtilityFlag; OutsideUS = schedule.UsedOutsideTheUS; DBPercent = deprPercent; YearElapsed = 0; Life = deprLife; SalvageDeduction = Salvage; AdjustedCost = adjCost; PostUsageDeduction = PostUse; m_tableId = 0; m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_Normal; if (OutsideUS) { if (LowIncomeHousing) { if (PlacedInServiceDate > new DateTime(1985, 8, 5) && PlacedInServiceDate < new DateTime(1987, 1, 1)) { m_tableId = 102; } } if ((int)(deprLife) == 35 && string.Compare(AvgConvention, "MM") == 0 && deprPercent == 150) { if (PlacedInServiceDate < new DateTime(1984, 6, 23)) { m_tableId = 141; } else if (PlacedInServiceDate > new DateTime(1984, 6, 22) && PlacedInServiceDate < new DateTime(1985, 5, 9)) { m_tableId = 103; } else if (PlacedInServiceDate > new DateTime(1985, 8, 5) && PlacedInServiceDate < new DateTime(1987, 1, 1)) { m_tableId = 101; } } else if (string.Compare(AvgConvention, "HY") == 0) { m_tableId = FindID((short)((deprLife * 12) + 0.01), HY100, 39); } } else { if (LowIncomeHousing) { if (PlacedInServiceDate < new DateTime(1985, 5, 9)) { m_tableId = 9; } else { m_tableId = 10; } } else if ((int)(deprLife) == 15 && (PersonalProperty || PublicUtility)) { m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_NoneInYear; m_tableId = 4; } else if ((int)(deprLife) == 18 && PlacedInServiceDate < new DateTime(1984, 6, 23)) { m_tableId = 6; } else { m_tableId = FindID((short)(deprLife), ATLives, 6); } } // // We could not find the table number, so return with error. // if (m_tableId == 0) { throw new Exception("Unable to determine ACRS Table Number."); } if ((PersonalProperty || PublicUtility)) { m_disposalOverride = DISPOSALOVERRIDETYPE.disposaloverride_NoneInYear; } // // 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_acrsTable, m_tableId); tablePeriodCount = m_Table.PeriodCount; } else { obj.LoadTable(m_acrsNonUSTable, 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 == 12) { 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; } if (monthCount < 1) { monthCount = 1; } m_sPlacedInServicePeriod = (short)(13 - monthCount); } else { throw new Exception("Invalid ACRS table definition."); } } // // All done // return(true); }
public bool ProcessACEForYear(short iFYNum, IBADeprMethod pObjDeprMethod, double dActualPriorAccum, CalcEngine calcEngine, IBAAvgConvention pObjAvgConvetion, double dYearElapsed, out IBADeprMethod outMethod) { bool hr; outMethod = null; if (m_pObjSchedule == null || m_pObjCalendar == null) { throw new Exception("Error in ProcessACEForYear."); } if (outMethod != null) { outMethod = null; } if (pObjDeprMethod == null || calcEngine == null || pObjAvgConvetion == null) { throw new Exception("Error in ProcessACEForYear."); } outMethod = pObjDeprMethod; if (m_bUseACEHandling && iFYNum == m_iAceTransitionYear + 1) { double ACEBasis; double ACELife; double basis; double yearElapsed = 0; double ADSLife; string deprmethod; decimal curTmp; short yearNum = 0; basis = pObjDeprMethod.Basis; ACELife = pObjDeprMethod.Life; deprmethod = m_pObjSchedule.DeprMethod; ADSLife = m_pObjSchedule.ADSLife; ACEBasis = basis - dActualPriorAccum; if (String.Compare(deprmethod, "MT") == 0 || String.Compare(deprmethod, "MF") == 0 || String.Compare(deprmethod, "MAT") == 0 || String.Compare(deprmethod, "MAF") == 0 || String.Compare(deprmethod, "MST") == 0 || String.Compare(deprmethod, "MSF") == 0 || String.Compare(deprmethod, "AT") == 0 || String.Compare(deprmethod, "AST") == 0 || String.Compare(deprmethod, "ASF") == 0) { if (m_pObjACEInfo == null) { ACELife = m_curACELife; ACEBasis = m_curACEBasis; } else { if (m_PISDate >= m_dtACEStart) { ACEBasis = basis; } else { ACEBasis = basis - dActualPriorAccum; ACELife = ADSLife - yearElapsed; } CurrencyHelper.DoubleToCurrency(ACEBasis, out curTmp); m_pObjACEInfo.ACELife = ACELife; m_pObjACEInfo.ACEBasis = curTmp; } // // Now we need to create the RV method and initialize it. // outMethod = null; dYearElapsed = yearElapsed; if (!(hr = calcEngine.CreateDeprMethod("RV", false, out outMethod)) || !(hr = calcEngine.InitializeDeprMethod(m_pObjSchedule, pObjAvgConvetion, outMethod))) { return(hr); } outMethod.Life = ACELife + m_dACETransitionYearElapsed; outMethod.SalvageDeduction = 0; outMethod.YearElapsed = dYearElapsed; outMethod.YearNum = yearNum; outMethod.PriorAccum = dActualPriorAccum; } else { } } return(true); }
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); }