示例#1
0
        public bool GetCurrentMethod(string flags, out IBADeprMethod pVal)
        {
            pVal = null;
            string        switchFlag;
            IBASwitchDepr swIface;
            bool          hr;

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

            switchFlag = SwitchFlag;

            if (flags.Contains(switchFlag))
            {
                if (m_pObjSwitchMethod == null)
                {
                    throw new Exception("Flags indicate that a switch is needed, but the switch interface is not initialized.");
                }

                //
                // Now set up the method that we are switching to.
                //
                m_pObjSwitchMethod.AdjustedCost       = (m_dAdjustedCost);
                m_pObjSwitchMethod.PostUsageDeduction = (m_dPostUsedDeduction);
                m_pObjSwitchMethod.SalvageDeduction   = (m_dSalvageDeduction);
                m_pObjSwitchMethod.PriorAccum         = (m_dPriorAccum);
                m_pObjSwitchMethod.Life               = (m_dLife);
                m_pObjSwitchMethod.YearElapsed        = (m_dYearElapsed);
                m_pObjSwitchMethod.DeemedStartDate    = (m_dtDeemedStartDate);
                m_pObjSwitchMethod.DeemedEndDate      = (m_dtDeemedEndDate);
                m_pObjSwitchMethod.YearNum            = (m_iYearNum);
                m_pObjSwitchMethod.DBPercent          = (m_dDBPercent);
                m_pObjSwitchMethod.FiscalYearFraction = (m_dFiscalYearFraction);

                swIface = m_pObjSwitchMethod as IBASwitchDepr;
                if (swIface == null)
                {
                    pVal = m_pObjSwitchMethod as IBADeprMethod;
                    return(true);
                }
                return(swIface.GetCurrentMethod(flags, out pVal));
            }
            else
            {
                pVal = this as IBADeprMethod;
                return(true);
            }
        }
示例#2
0
 public DecliningBalanceMethod()
 {
     m_dAdjustedCost      = 0;
     m_dPostUsedDeduction = 0;
     m_dSalvageDeduction  = 0;
     m_dPriorAccum        = 0;
     m_dYearElapsed       = 0;
     m_dLife               = 0;
     m_dDBPercent          = 0;
     m_dFiscalYearFraction = 0;
     m_dtDeemedStartDate   = DateTime.MinValue;
     m_dtDeemedEndDate     = DateTime.MinValue;
     m_iYearNum            = 0;
     m_dAnuualRate         = 0;
     m_iSwitchYearNum      = 0;
     m_bSwitchRequired     = true;
     m_bIsShortYear        = false;
     m_pObjSwitchMethod    = null;
     m_parentFlags         = "";
 }
示例#3
0
        public AltMACRSTable()
        {
            string tmp = @"SFACalcEngine.DeprMethods.altMACRPCTS.TBL";

            try
            {
                Assembly a         = Assembly.GetEntryAssembly();
                string[] resources = a.GetManifestResourceNames();

                System.IO.Stream s = a.GetManifestResourceStream(tmp);
                var memoryStream   = new MemoryStream();
                s.CopyTo(memoryStream);
                m_altMacrsTable = memoryStream.ToArray();
            }
            catch (Exception e)
            {
                string t = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                //string s = AppDomain.CurrentDomain.BaseDirectory;
                //s = e.Message;
            }
            m_altMacrsTableCount = m_altMacrsTable[0];

            m_dAdjustedCost      = 0;
            m_dPostUsedDeduction = 0;
            m_dSalvageDeduction  = 0;
            m_dPriorAccum        = 0;
            m_dYearElapsed       = 0;
            m_dLife               = 0;
            m_dDBPercent          = 0;
            m_dFiscalYearFraction = 0;
            m_dtDeemedStartDate   = DateTime.MinValue;
            m_dtDeemedEndDate     = DateTime.MinValue;
            m_iYearNum            = 0;

            m_iSwitchYearNum   = 0;
            m_bSwitchRequired  = true;
            m_bIsShortYear     = false;
            m_pObjSwitchMethod = null;
            m_parentFlags      = "";
        }
示例#4
0
 public DecliningBalanceMethodNoSwitch()
 {
     m_ddbMethod = new DecliningBalanceMethod();
     m_ddbSwitch = m_ddbMethod as IBASwitchDepr;
     m_ddbSwitch.SwitchRequired = false;
 }
示例#5
0
        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);
        }
示例#6
0
        public bool InitializeACEDeprMethod(short iCurrentYearNumber, string flags, double dYearElapsed, double priorAccum, IBADeprMethod pObjDeprMethod)
        {
            bool hr;

            if (pObjDeprMethod == null || flags == null)
            {
                throw new Exception("Error in InitializeACEDeprMethod.");
            }
            //
            // Now we need to adjust the depr values for ACE.
            //
            if (m_bUseACEHandling &&
                (iCurrentYearNumber > m_iAceTransitionYear + 1 ||
                 string.Compare(flags, "v") != 0))
            {
                double ADSLife;
                ADSLife                         = m_pObjSchedule.ADSLife; // by KENT	fix MS MC-00037
                pObjDeprMethod.Life             = ADSLife;                // by KENT  fix MS MC-00037
                pObjDeprMethod.YearElapsed      = dYearElapsed;
                pObjDeprMethod.SalvageDeduction = 0;
                pObjDeprMethod.PriorAccum       = priorAccum;
            }
            return(true);
        }
示例#7
0
 public bool GetCurrentMethod(string flags, out IBADeprMethod pVal)
 {
     return(m_ddbSwitch.GetCurrentMethod(flags, out pVal));
 }
示例#8
0
 public MACRSFormula()
 {
     m_ddbMethod = new DecliningBalanceMethod();
     m_ddbSwitch = m_ddbMethod as IBASwitchDepr;
     m_ddbSwitch.SwitchRequired = true;
 }