DevTreks.Extensions/NPVCalculators/BIs/BICalculator.cs
/// <summary>
/// Amortizes each type of cost separately. Makes display of cost data more understandable.
/// Adds this annuity as a line item to future time periods.
/// Reference year is used to adjust salvage values.
/// </summary>
Amortizes each type of cost separately. Makes display of cost data more understandable.
Adds this annuity as a line item to future time periods.
Reference year is used to adjust salvage values.
Amortizes each type of cost separately . Makes display of cost data more understandable . Adds this annuity as a line item to future time periods . Reference year is used to adjust salvage values .
public void CalculateComponentAmortizedCost(CalculatorParameters calcParameters)
        {
            double dbSalvVal = 0;
            double dbCRF = 0;
            double dbOCCompAmortCost = 0;
            double dbAOHCompAmortCost = 0;
            double dbCAPCompAmortCost = 0;
            double dbIncentCompAmortCost = 0;
            double dbOCTotal = 0;
            double dbAOHTotal = 0;
            double dbCAPTotal = 0;
            double dbIncentTotal = 0;
            double dbLastTimeDays = 0;
            double dbRemovePrincipal = 0;
            if ((calcParameters.ParentOperationComponent.EffectiveLife == 1) 
                && (calcParameters.ParentBudgetInvestment.PreProdPeriods == 0))
            {
                calcParameters.ParentOperationComponent.TotalAMOC = calcParameters.ParentOperationComponent.TotalOC;
                calcParameters.ParentOperationComponent.TotalAMAOH = calcParameters.ParentOperationComponent.TotalAOH;
                calcParameters.ParentOperationComponent.TotalAMCAP = calcParameters.ParentOperationComponent.TotalCAP;
                calcParameters.ParentOperationComponent.TotalAMOC_INT = calcParameters.ParentOperationComponent.TotalOC_INT;
                calcParameters.ParentOperationComponent.TotalAMAOH_INT = calcParameters.ParentOperationComponent.TotalAOH_INT;
                calcParameters.ParentOperationComponent.TotalAMCAP_INT = calcParameters.ParentOperationComponent.TotalCAP_INT;
                calcParameters.ParentOperationComponent.TotalAMINCENT = calcParameters.ParentOperationComponent.TotalINCENT;
            }
            else if ((calcParameters.ParentOperationComponent.EffectiveLife == 1) 
                && (calcParameters.ParentBudgetInvestment.PreProdPeriods != 0))
            {
                if ((calcParameters.ParentBudgetInvestment.ProdPeriods >= 1) 
                    && (calcParameters.ParentTimePeriod.Date < calcParameters.ParentBudgetInvestment.InitEOPDate))
                {
                    calcParameters.ParentOperationComponent.TotalAMOC = 0;
                    calcParameters.ParentOperationComponent.TotalAMAOH = 0;
                    calcParameters.ParentOperationComponent.TotalAMCAP = 0;
                    calcParameters.ParentOperationComponent.TotalAMOC_INT = 0;
                    calcParameters.ParentOperationComponent.TotalAMAOH_INT = 0;
                    calcParameters.ParentOperationComponent.TotalAMCAP_INT = 0;
                    calcParameters.ParentOperationComponent.TotalAMINCENT = 0;
                }
                else
                {
                    calcParameters.ParentOperationComponent.TotalAMOC = calcParameters.ParentOperationComponent.TotalOC;
                    calcParameters.ParentOperationComponent.TotalAMAOH = calcParameters.ParentOperationComponent.TotalAOH;
                    calcParameters.ParentOperationComponent.TotalAMCAP = calcParameters.ParentOperationComponent.TotalCAP;
                    calcParameters.ParentOperationComponent.TotalAMOC_INT = calcParameters.ParentOperationComponent.TotalOC_INT;
                    calcParameters.ParentOperationComponent.TotalAMAOH_INT = calcParameters.ParentOperationComponent.TotalAOH_INT;
                    calcParameters.ParentOperationComponent.TotalAMCAP_INT = calcParameters.ParentOperationComponent.TotalCAP_INT;
                    calcParameters.ParentOperationComponent.TotalAMINCENT = calcParameters.ParentOperationComponent.TotalINCENT;
                }
            }
            else if ((calcParameters.ParentOperationComponent.EffectiveLife != 1))
            {
                if (calcParameters.ParentOperationComponent.EffectiveLife < 1)
                {
                    dbCRF = GeneralRules.CalculateFractionalPaymentFactor(
                        calcParameters.ParentBudgetInvestment.Local.RealRate,
                        calcParameters.ParentOperationComponent.EffectiveLife,
                        CalculatorHelpers.ConvertStringToInt(calcParameters.ParentOperationComponent.EffectiveLife.ToString()), 
                        DOUBLE_YEAR, ref dbLastTimeDays);
                }
                else
                {
                    dbCRF = GeneralRules.CalculateCapitalRecoveryFactor(
                        calcParameters.ParentOperationComponent.EffectiveLife, 0, 
                        calcParameters.ParentBudgetInvestment.Local.RealRate);
                }
                if (calcParameters.ParentBudgetInvestment.AnnEquivalents != null)
                {
                    dbSalvVal = calcParameters.ParentOperationComponent.SalvageValue / 
                        (System.Math.Pow((1 + calcParameters.ParentBudgetInvestment.Local.RealRate), 
                        calcParameters.ParentOperationComponent.EffectiveLife));
                    dbOCTotal = calcParameters.ParentOperationComponent.TotalOC;
                    dbOCCompAmortCost = (dbOCTotal * dbCRF);
                    dbAOHTotal = calcParameters.ParentOperationComponent.TotalAOH;
                    dbAOHCompAmortCost = ((dbAOHTotal - dbSalvVal) * dbCRF);
                    dbCAPTotal = calcParameters.ParentOperationComponent.TotalCAP;
                    dbCAPCompAmortCost = (dbCAPTotal * dbCRF);
                     handled separately
                    dbIncentTotal = calcParameters.ParentOperationComponent.TotalINCENT;
                    if (dbIncentTotal != 0)
                    {
                        dbIncentCompAmortCost = ((dbIncentTotal - dbSalvVal) * dbCRF);
                    }
                }
                else
                {
                    dbSalvVal = calcParameters.ParentOperationComponent.SalvageValue / 
                        (System.Math.Pow((1 + calcParameters.ParentBudgetInvestment.Local.RealRate), 
                        calcParameters.ParentOperationComponent.EffectiveLife));
                    dbOCTotal = calcParameters.ParentOperationComponent.TotalOC;
                    dbAOHTotal = calcParameters.ParentOperationComponent.TotalAOH;
                    dbCAPTotal = calcParameters.ParentOperationComponent.TotalCAP;
                    dbAOHCompAmortCost = (((dbOCTotal + dbAOHTotal + dbCAPTotal - dbSalvVal) 
                        * dbCRF));
                    dbIncentTotal = calcParameters.ParentOperationComponent.TotalINCENT;
                    if (dbIncentTotal != 0)
                    {
                        dbIncentCompAmortCost = ((dbIncentTotal - dbSalvVal) * dbCRF);
                    }
                }
                calcParameters.ParentOperationComponent.TotalAMOC = dbOCCompAmortCost;
                calcParameters.ParentOperationComponent.TotalAMAOH = dbAOHCompAmortCost;
                calcParameters.ParentOperationComponent.TotalAMCAP = dbCAPCompAmortCost;
                calcParameters.ParentOperationComponent.TotalAMOC_INT = 0;
                calcParameters.ParentOperationComponent.TotalAMAOH_INT = 0;
                calcParameters.ParentOperationComponent.TotalAMCAP_INT = 0;
                if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.budgets
                    || calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.investments)
                {
                    if (calcParameters.ParentBudgetInvestment.AnnEquivalents != null)
                    {
                        AddAnnualEquivalents1(calcParameters,
                            TimePeriod.ANNUITY_TYPES.regular, calcParameters.CurrentElementNodeName,
                            calcParameters.ParentTimePeriod.Id, calcParameters.ParentBudgetInvestment.ProdPeriods,
                            calcParameters.ParentTimePeriod.Date, 1, (dbOCTotal + dbAOHTotal + dbCAPTotal),
                            (dbOCCompAmortCost + dbAOHCompAmortCost + dbCAPCompAmortCost),
                            dbIncentTotal, dbIncentCompAmortCost);
                    }
                    if (calcParameters.ParentBudgetInvestment.PreProdPeriods != 0)
                    {
                        dbRemovePrincipal = (dbOCTotal + dbAOHTotal + dbCAPTotal);
                        RemoveAnnualEquivalents(dbRemovePrincipal, calcParameters);
                    }
                }
                else
                {
                }
                calcParameters.ParentOperationComponent.TotalAMINCENT = dbIncentCompAmortCost;
            }
            calcParameters.ParentOperationComponent.TotalAMTOTAL
                = calcParameters.ParentOperationComponent.TotalAMOC + calcParameters.ParentOperationComponent.TotalAMAOH + calcParameters.ParentOperationComponent.TotalAMCAP;
        }
public void CalculateComponentAmortizedCost ( CalculatorParameters calcParameters ) { double dbSalvVal = 0 ; double dbCRF = 0 ; double dbOCCompAmortCost = 0 ; double dbAOHCompAmortCost = 0 ; double dbCAPCompAmortCost = 0 ; double dbIncentCompAmortCost = 0 ; double dbOCTotal = 0 ; double dbAOHTotal = 0 ; double dbCAPTotal = 0 ; double dbIncentTotal = 0 ; double dbLastTimeDays = 0 ; double dbRemovePrincipal = 0 ; if ( ( calcParameters . ParentOperationComponent . EffectiveLife == 1 ) && ( calcParameters . ParentBudgetInvestment . PreProdPeriods == 0 ) ) { calcParameters . ParentOperationComponent . TotalAMOC = calcParameters . ParentOperationComponent . TotalOC ; calcParameters . ParentOperationComponent . TotalAMAOH = calcParameters . ParentOperationComponent . TotalAOH ; calcParameters . ParentOperationComponent . TotalAMCAP = calcParameters . ParentOperationComponent . TotalCAP ; calcParameters . ParentOperationComponent . TotalAMOC_INT = calcParameters . ParentOperationComponent . TotalOC_INT ; calcParameters . ParentOperationComponent . TotalAMAOH_INT = calcParameters . ParentOperationComponent . TotalAOH_INT ; calcParameters . ParentOperationComponent . TotalAMCAP_INT = calcParameters . ParentOperationComponent . TotalCAP_INT ; calcParameters . ParentOperationComponent . TotalAMINCENT = calcParameters . ParentOperationComponent . TotalINCENT ; } else if ( ( calcParameters . ParentOperationComponent . EffectiveLife == 1 ) && ( calcParameters . ParentBudgetInvestment . PreProdPeriods != 0 ) ) { if ( ( calcParameters . ParentBudgetInvestment . ProdPeriods >= 1 ) && ( calcParameters . ParentTimePeriod . Date < calcParameters . ParentBudgetInvestment . InitEOPDate ) ) { calcParameters . ParentOperationComponent . TotalAMOC = 0 ; calcParameters . ParentOperationComponent . TotalAMAOH = 0 ; calcParameters . ParentOperationComponent . TotalAMCAP = 0 ; calcParameters . ParentOperationComponent . TotalAMOC_INT = 0 ; calcParameters . ParentOperationComponent . TotalAMAOH_INT = 0 ; calcParameters . ParentOperationComponent . TotalAMCAP_INT = 0 ; calcParameters . ParentOperationComponent . TotalAMINCENT = 0 ; } else { calcParameters . ParentOperationComponent . TotalAMOC = calcParameters . ParentOperationComponent . TotalOC ; calcParameters . ParentOperationComponent . TotalAMAOH = calcParameters . ParentOperationComponent . TotalAOH ; calcParameters . ParentOperationComponent . TotalAMCAP = calcParameters . ParentOperationComponent . TotalCAP ; calcParameters . ParentOperationComponent . TotalAMOC_INT = calcParameters . ParentOperationComponent . TotalOC_INT ; calcParameters . ParentOperationComponent . TotalAMAOH_INT = calcParameters . ParentOperationComponent . TotalAOH_INT ; calcParameters . ParentOperationComponent . TotalAMCAP_INT = calcParameters . ParentOperationComponent . TotalCAP_INT ; calcParameters . ParentOperationComponent . TotalAMINCENT = calcParameters . ParentOperationComponent . TotalINCENT ; } } else if ( ( calcParameters . ParentOperationComponent . EffectiveLife != 1 ) ) { if ( calcParameters . ParentOperationComponent . EffectiveLife < 1 ) { dbCRF = GeneralRules . CalculateFractionalPaymentFactor ( calcParameters . ParentBudgetInvestment . Local . RealRate , calcParameters . ParentOperationComponent . EffectiveLife , CalculatorHelpers . ConvertStringToInt ( calcParameters . ParentOperationComponent . EffectiveLife . ToString ( ) ) , DOUBLE_YEAR , ref dbLastTimeDays ) ; } else { dbCRF = GeneralRules . CalculateCapitalRecoveryFactor ( calcParameters . ParentOperationComponent . EffectiveLife , 0 , calcParameters . ParentBudgetInvestment . Local . RealRate ) ; } if ( calcParameters . ParentBudgetInvestment . AnnEquivalents != null ) { dbSalvVal = calcParameters . ParentOperationComponent . SalvageValue / ( System . Math . Pow ( ( 1 + calcParameters . ParentBudgetInvestment . Local . RealRate ) , calcParameters . ParentOperationComponent . EffectiveLife ) ) ; dbOCTotal = calcParameters . ParentOperationComponent . TotalOC ; dbOCCompAmortCost = ( dbOCTotal * dbCRF ) ; dbAOHTotal = calcParameters . ParentOperationComponent . TotalAOH ; dbAOHCompAmortCost = ( ( dbAOHTotal - dbSalvVal ) * dbCRF ) ; dbCAPTotal = calcParameters . ParentOperationComponent . TotalCAP ; dbCAPCompAmortCost = ( dbCAPTotal * dbCRF ) ; dbIncentTotal = calcParameters . ParentOperationComponent . TotalINCENT ; if ( dbIncentTotal != 0 ) { dbIncentCompAmortCost = ( ( dbIncentTotal - dbSalvVal ) * dbCRF ) ; } } else { dbSalvVal = calcParameters . ParentOperationComponent . SalvageValue / ( System . Math . Pow ( ( 1 + calcParameters . ParentBudgetInvestment . Local . RealRate ) , calcParameters . ParentOperationComponent . EffectiveLife ) ) ; dbOCTotal = calcParameters . ParentOperationComponent . TotalOC ; dbAOHTotal = calcParameters . ParentOperationComponent . TotalAOH ; dbCAPTotal = calcParameters . ParentOperationComponent . TotalCAP ; dbAOHCompAmortCost = ( ( ( dbOCTotal + dbAOHTotal + dbCAPTotal - dbSalvVal ) * dbCRF ) ) ; dbIncentTotal = calcParameters . ParentOperationComponent . TotalINCENT ; if ( dbIncentTotal != 0 ) { dbIncentCompAmortCost = ( ( dbIncentTotal - dbSalvVal ) * dbCRF ) ; } } calcParameters . ParentOperationComponent . TotalAMOC = dbOCCompAmortCost ; calcParameters . ParentOperationComponent . TotalAMAOH = dbAOHCompAmortCost ; calcParameters . ParentOperationComponent . TotalAMCAP = dbCAPCompAmortCost ; calcParameters . ParentOperationComponent . TotalAMOC_INT = 0 ; calcParameters . ParentOperationComponent . TotalAMAOH_INT = 0 ; calcParameters . ParentOperationComponent . TotalAMCAP_INT = 0 ; if ( calcParameters . SubApplicationType == Constants . SUBAPPLICATION_TYPES . budgets || calcParameters . SubApplicationType == Constants . SUBAPPLICATION_TYPES . investments ) { if ( calcParameters . ParentBudgetInvestment . AnnEquivalents != null ) { AddAnnualEquivalents1 ( calcParameters , TimePeriod . ANNUITY_TYPES . regular , calcParameters . CurrentElementNodeName , calcParameters . ParentTimePeriod . Id , calcParameters . ParentBudgetInvestment . ProdPeriods , calcParameters . ParentTimePeriod . Date , 1 , ( dbOCTotal + dbAOHTotal + dbCAPTotal ) , ( dbOCCompAmortCost + dbAOHCompAmortCost + dbCAPCompAmortCost ) , dbIncentTotal , dbIncentCompAmortCost ) ; } if ( calcParameters . ParentBudgetInvestment . PreProdPeriods != 0 ) { dbRemovePrincipal = ( dbOCTotal + dbAOHTotal + dbCAPTotal ) ; RemoveAnnualEquivalents ( dbRemovePrincipal , calcParameters ) ; } } else { } calcParameters . ParentOperationComponent . TotalAMINCENT = dbIncentCompAmortCost ; } calcParameters . ParentOperationComponent . TotalAMTOTAL = calcParameters . ParentOperationComponent . TotalAMOC + calcParameters . ParentOperationComponent . TotalAMAOH + calcParameters . ParentOperationComponent . TotalAMCAP ; }
Amortizes each type of cost separately.
Amortizes each type of cost separately .
//Rule1. Show regular totals in annual column for 1 year budgets //remember, these are discounted costs, interest has to be added back in to get original //incentives //Rule2. don't show preproduction costs prior to common ref point, but include totals column in ann column after //incentives //and preproduction component annuity is already in the collection //incentives //amortize and set each cost //always take the salvage value out of aoh only //incentives handled separately //different than AOH because no subsequent periods added to finish off incentive //added for operation/component price application //Rule3. Always show annuities in annual column of any budget  //or investment and handle consistently in time periods thereafter //the first year discounted real interest will actually show up in next time period //that allows the correct profit to be shown in the year the annuity ocdbs //see the dairy cow replacement examples //note annuities will only be accrued in the aoh cost section //now remove this principal from preproduction annuity total //regular annuities are not included in the sum of the preproduction costs //incentives //totals
calcParameters
CalculatorParameters