DevTreks.Extensions/NPVCalculators/BIs/BICalculator.cs
/// <summary>
/// Amortizes each type of beneift separately. Makes display of benefit 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 beneift separately. Makes display of benefit 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 beneift separately . Makes display of benefit data more understandable . Adds this annuity as a line item to future time periods . Reference year is used to adjust salvage values .
public void CalculateOutcomeAmortizedBen(CalculatorParameters calcParameters)
        {
            double dbSalvVal = 0;
            double dbCRF = 0;
            double dbROutcomeAmortBen = 0;
            double dbIncentOutcomeAmortBen = 0;
            double dbRTotal = 0;
            double dbIncentTotal = 0;
            double dbLastTimeDays = 0;
            double dbRemovePrincipal = 0;
            if ((calcParameters.ParentOutcome.EffectiveLife == 1)
                && (calcParameters.ParentBudgetInvestment.PreProdPeriods == 0))
            {
                calcParameters.ParentOutcome.TotalAMR = calcParameters.ParentOutcome.TotalR;
                calcParameters.ParentOutcome.TotalAMR_INT = calcParameters.ParentOutcome.TotalR_INT;
                calcParameters.ParentOutcome.TotalAMRINCENT = calcParameters.ParentOutcome.TotalRINCENT;
            }
            else if ((calcParameters.ParentOutcome.EffectiveLife == 1)
                && (calcParameters.ParentBudgetInvestment.PreProdPeriods != 0))
            {
                if ((calcParameters.ParentBudgetInvestment.ProdPeriods >= 1)
                    && (calcParameters.ParentTimePeriod.Date < calcParameters.ParentBudgetInvestment.InitEOPDate))
                {
                    calcParameters.ParentOutcome.TotalAMR = 0;
                    calcParameters.ParentOutcome.TotalAMR_INT = 0;
                    calcParameters.ParentOutcome.TotalAMRINCENT = 0;
                }
                else
                {
                    calcParameters.ParentOutcome.TotalAMR = calcParameters.ParentOutcome.TotalR;
                    calcParameters.ParentOutcome.TotalAMRINCENT = calcParameters.ParentOutcome.TotalRINCENT;
                }
            }
            else if ((calcParameters.ParentOutcome.EffectiveLife != 1))
            {
                if (calcParameters.ParentOutcome.EffectiveLife < 1)
                {
                    dbCRF = GeneralRules.CalculateFractionalPaymentFactor(
                        calcParameters.ParentBudgetInvestment.Local.RealRate,
                        calcParameters.ParentOutcome.EffectiveLife,
                        CalculatorHelpers.ConvertStringToInt(calcParameters.ParentOutcome.EffectiveLife.ToString()),
                        DOUBLE_YEAR, ref dbLastTimeDays);
                }
                else
                {
                    dbCRF = GeneralRules.CalculateCapitalRecoveryFactor(
                        calcParameters.ParentOutcome.EffectiveLife, 0,
                        calcParameters.ParentBudgetInvestment.Local.RealRate);
                }
                if (calcParameters.ParentBudgetInvestment.AnnEquivalents != null)
                {
                    dbSalvVal = calcParameters.ParentOutcome.SalvageValue /
                        (System.Math.Pow((1 + calcParameters.ParentBudgetInvestment.Local.RealRate),
                        calcParameters.ParentOutcome.EffectiveLife));
                    dbRTotal = calcParameters.ParentOutcome.TotalR;
                    dbROutcomeAmortBen = ((dbRTotal - dbSalvVal) * dbCRF);
                     handled separately
                    dbIncentTotal = calcParameters.ParentOutcome.TotalRINCENT;
                    if (dbIncentTotal != 0)
                    {
                        dbIncentOutcomeAmortBen = ((dbIncentTotal - dbSalvVal) * dbCRF);
                    }
                }
                else
                {
                    dbSalvVal = calcParameters.ParentOutcome.SalvageValue /
                        (System.Math.Pow((1 + calcParameters.ParentBudgetInvestment.Local.RealRate),
                        calcParameters.ParentOutcome.EffectiveLife));
                    dbRTotal = calcParameters.ParentOutcome.TotalR;
                    dbROutcomeAmortBen = (((dbRTotal - dbSalvVal) * dbCRF));
                    dbIncentTotal = calcParameters.ParentOutcome.TotalRINCENT;
                    if (dbIncentTotal != 0)
                    {
                        dbIncentOutcomeAmortBen = ((dbIncentTotal - dbSalvVal) * dbCRF);
                    }
                }
                calcParameters.ParentOutcome.TotalAMR = dbROutcomeAmortBen;
                calcParameters.ParentOutcome.TotalAMR_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, dbRTotal, dbROutcomeAmortBen,
                            dbIncentTotal, dbIncentOutcomeAmortBen);
                    }
                    if (calcParameters.ParentBudgetInvestment.PreProdPeriods != 0)
                    {
                        dbRemovePrincipal = dbRTotal;
                        RemoveAnnualEquivalents(dbRemovePrincipal, calcParameters);
                    }
                }
                calcParameters.ParentOutcome.TotalAMRINCENT = dbIncentOutcomeAmortBen;
            }
        }
public void CalculateOutcomeAmortizedBen ( CalculatorParameters calcParameters ) { double dbSalvVal = 0 ; double dbCRF = 0 ; double dbROutcomeAmortBen = 0 ; double dbIncentOutcomeAmortBen = 0 ; double dbRTotal = 0 ; double dbIncentTotal = 0 ; double dbLastTimeDays = 0 ; double dbRemovePrincipal = 0 ; if ( ( calcParameters . ParentOutcome . EffectiveLife == 1 ) && ( calcParameters . ParentBudgetInvestment . PreProdPeriods == 0 ) ) { calcParameters . ParentOutcome . TotalAMR = calcParameters . ParentOutcome . TotalR ; calcParameters . ParentOutcome . TotalAMR_INT = calcParameters . ParentOutcome . TotalR_INT ; calcParameters . ParentOutcome . TotalAMRINCENT = calcParameters . ParentOutcome . TotalRINCENT ; } else if ( ( calcParameters . ParentOutcome . EffectiveLife == 1 ) && ( calcParameters . ParentBudgetInvestment . PreProdPeriods != 0 ) ) { if ( ( calcParameters . ParentBudgetInvestment . ProdPeriods >= 1 ) && ( calcParameters . ParentTimePeriod . Date < calcParameters . ParentBudgetInvestment . InitEOPDate ) ) { calcParameters . ParentOutcome . TotalAMR = 0 ; calcParameters . ParentOutcome . TotalAMR_INT = 0 ; calcParameters . ParentOutcome . TotalAMRINCENT = 0 ; } else { calcParameters . ParentOutcome . TotalAMR = calcParameters . ParentOutcome . TotalR ; calcParameters . ParentOutcome . TotalAMRINCENT = calcParameters . ParentOutcome . TotalRINCENT ; } } else if ( ( calcParameters . ParentOutcome . EffectiveLife != 1 ) ) { if ( calcParameters . ParentOutcome . EffectiveLife < 1 ) { dbCRF = GeneralRules . CalculateFractionalPaymentFactor ( calcParameters . ParentBudgetInvestment . Local . RealRate , calcParameters . ParentOutcome . EffectiveLife , CalculatorHelpers . ConvertStringToInt ( calcParameters . ParentOutcome . EffectiveLife . ToString ( ) ) , DOUBLE_YEAR , ref dbLastTimeDays ) ; } else { dbCRF = GeneralRules . CalculateCapitalRecoveryFactor ( calcParameters . ParentOutcome . EffectiveLife , 0 , calcParameters . ParentBudgetInvestment . Local . RealRate ) ; } if ( calcParameters . ParentBudgetInvestment . AnnEquivalents != null ) { dbSalvVal = calcParameters . ParentOutcome . SalvageValue / ( System . Math . Pow ( ( 1 + calcParameters . ParentBudgetInvestment . Local . RealRate ) , calcParameters . ParentOutcome . EffectiveLife ) ) ; dbRTotal = calcParameters . ParentOutcome . TotalR ; dbROutcomeAmortBen = ( ( dbRTotal - dbSalvVal ) * dbCRF ) ; dbIncentTotal = calcParameters . ParentOutcome . TotalRINCENT ; if ( dbIncentTotal != 0 ) { dbIncentOutcomeAmortBen = ( ( dbIncentTotal - dbSalvVal ) * dbCRF ) ; } } else { dbSalvVal = calcParameters . ParentOutcome . SalvageValue / ( System . Math . Pow ( ( 1 + calcParameters . ParentBudgetInvestment . Local . RealRate ) , calcParameters . ParentOutcome . EffectiveLife ) ) ; dbRTotal = calcParameters . ParentOutcome . TotalR ; dbROutcomeAmortBen = ( ( ( dbRTotal - dbSalvVal ) * dbCRF ) ) ; dbIncentTotal = calcParameters . ParentOutcome . TotalRINCENT ; if ( dbIncentTotal != 0 ) { dbIncentOutcomeAmortBen = ( ( dbIncentTotal - dbSalvVal ) * dbCRF ) ; } } calcParameters . ParentOutcome . TotalAMR = dbROutcomeAmortBen ; calcParameters . ParentOutcome . TotalAMR_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 , dbRTotal , dbROutcomeAmortBen , dbIncentTotal , dbIncentOutcomeAmortBen ) ; } if ( calcParameters . ParentBudgetInvestment . PreProdPeriods != 0 ) { dbRemovePrincipal = dbRTotal ; RemoveAnnualEquivalents ( dbRemovePrincipal , calcParameters ) ; } } calcParameters . ParentOutcome . TotalAMRINCENT = dbIncentOutcomeAmortBen ; } }
Amortizes each type of beneift separately.
Amortizes each type of beneift 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 net annuity is already in the opcomp collection //incentives //amortize and set each cost //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 //now remove this principal from preproduction annuity total //regular annuities are not included in the sum of the preproduction costs //incentives
calcParameters
CalculatorParameters