private bool GetDetailDataFromControlsManual(ABudgetRow ARow)
        {
            if (ARow != null)
            {
                ARow.BeginEdit();

                if (rbtAdHoc.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeAdhoc(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_ADHOC);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_ADHOC;
                }
                else if (rbtSame.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeSame(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_SAME);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_SAME;
                }
                else if (rbtSplit.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeSplit(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_SPLIT);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_SPLIT;
                }
                else if (rbtInflateN.Checked)
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeInflateN(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_INFLATE_N);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_INFLATE_N;
                }
                else      //rbtInflateBase.Checked
                {
                    if (FPetraUtilsObject.HasChanges)
                    {
                        ProcessBudgetTypeInflateBase(null, null);
                        ClearBudgetTypeTextboxesExcept(MFinanceConstants.BUDGET_INFLATE_BASE);
                    }

                    ARow.BudgetTypeCode = MFinanceConstants.BUDGET_INFLATE_BASE;
                }

                //TODO switch to using Ledger financial year
                ARow.Year = Convert.ToInt16(cmbSelectBudgetYear.GetSelectedString());
                ARow.Revision = CreateBudgetRevisionRow(FLedgerNumber, ARow.Year);
                ARow.EndEdit();
            }

            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Import the budget from a CSV file
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ACurrentBudgetYear"></param>
        /// <param name="ACSVFileName"></param>
        /// <param name="AFdlgSeparator"></param>
        /// <param name="AImportDS"></param>
        /// <param name="AVerificationResult"></param>
        /// <returns>Total number of records imported and number of which updated as the fractional part</returns>
        private static decimal ImportBudgetFromCSV(Int32 ALedgerNumber,
                                                   Int32 ACurrentBudgetYear,
                                                   string ACSVFileName,
                                                   string[] AFdlgSeparator,
                                                   ref BudgetTDS AImportDS,
                                                   ref TVerificationResultCollection AVerificationResult)
        {
            StreamReader DataFile = new StreamReader(ACSVFileName, System.Text.Encoding.Default);

            string Separator    = AFdlgSeparator[0];
            string DateFormat   = AFdlgSeparator[1];
            string NumberFormat = AFdlgSeparator[2];

            FCultureInfoNumberFormat = new CultureInfo(NumberFormat.Equals("American") ? "en-US" : "de-DE");
            CultureInfo MyCultureInfoDate = new CultureInfo("en-GB");

            MyCultureInfoDate.DateTimeFormat.ShortDatePattern = DateFormat;

            // To store the From and To currencies
            // Use an array to store these to make for easy
            //   inverting of the two currencies when calculating
            //   the inverse value.

            //string currentBudgetVal = string.Empty;
            //string mess = string.Empty;
            string CostCentre       = string.Empty;
            string Account          = string.Empty;
            string budgetType       = string.Empty;
            string budgetYearString = string.Empty;
            int    budgetYear       = 0;

            Int32 numPeriods = TAccountingPeriodsWebConnector.GetNumberOfPeriods(ALedgerNumber);

            decimal[] BudgetPeriods         = new decimal[numPeriods];
            int       YearForBudgetRevision = 0;
            int       BdgRevision           = 0; //not currently implementing versioning so always zero

            decimal rowNumber          = 0;
            decimal duplicateRowNumber = 0;

            while (!DataFile.EndOfStream)
            {
                decimal totalBudgetRowAmount = 0;

                try
                {
                    string Line = DataFile.ReadLine();

                    CostCentre = StringHelper.GetNextCSV(ref Line, Separator, false).ToString();

                    if (CostCentre == "Cost Centre")
                    {
                        //Read the next line
                        Line       = DataFile.ReadLine();
                        CostCentre = StringHelper.GetNextCSV(ref Line, Separator, false).ToString();
                    }

                    //Increment row number
                    rowNumber++;

                    //Convert separator to a char
                    // char Sep = Separator[0];
                    //Turn current line into string array of column values
                    // string[] CsvColumns = Line.Split(Sep);

                    //int NumCols = CsvColumns.Length;

                    //If number of columns is not 4 then import csv file is wrongly formed.
//                if (NumCols != 24)
//                {
//                    AVerificationResult. MessageBox.Show(Catalog.GetString("Failed to import the CSV budget file:\r\n\r\n" +
//                            "   " + ADataFilename + "\r\n\r\n" +
//                            "It contains " + NumCols.ToString() + " columns. " +
//                            ), AImportMode + " Exchange Rates Import Error");
//                    return;
//                }

                    //Read the values for the current line
                    Account    = StringHelper.GetNextCSV(ref Line, Separator, false).ToString();
                    budgetType = StringHelper.GetNextCSV(ref Line, Separator, false).ToString().ToUpper();
                    budgetType = budgetType.Replace(" ", ""); //Ad hoc will become ADHOC

                    //Allow for variations on Inf.Base and Inf.N
                    if (budgetType.Contains("INF"))
                    {
                        if (budgetType.Contains("BASE"))
                        {
                            if (budgetType != MFinanceConstants.BUDGET_INFLATE_BASE)
                            {
                                budgetType = MFinanceConstants.BUDGET_INFLATE_BASE;
                            }
                        }
                        else if (budgetType != MFinanceConstants.BUDGET_INFLATE_N)
                        {
                            budgetType = MFinanceConstants.BUDGET_INFLATE_N;
                        }
                    }

                    if ((budgetType != MFinanceConstants.BUDGET_ADHOC) &&
                        (budgetType != MFinanceConstants.BUDGET_SAME) &&
                        (budgetType != MFinanceConstants.BUDGET_INFLATE_N) &&
                        (budgetType != MFinanceConstants.BUDGET_SPLIT) &&
                        (budgetType != MFinanceConstants.BUDGET_INFLATE_BASE)
                        )
                    {
                        throw new InvalidOperationException("Budget Type: " + budgetType + " in row: " + rowNumber.ToString() + " does not exist.");
                    }

                    //Calculate the budget Year
                    budgetYearString = StringHelper.GetNextCSV(ref Line, Separator, false);

                    YearForBudgetRevision = BudgetRevisionYearNumber(ALedgerNumber, budgetYearString);

                    //Add budget revision record if there's not one already.
                    if (AImportDS.ABudgetRevision.Rows.Find(new object[] { ALedgerNumber, YearForBudgetRevision, BdgRevision }) == null)
                    {
                        ABudgetRevisionRow BudgetRevisionRow = (ABudgetRevisionRow)AImportDS.ABudgetRevision.NewRowTyped();
                        BudgetRevisionRow.LedgerNumber = ALedgerNumber;
                        BudgetRevisionRow.Year         = YearForBudgetRevision;
                        BudgetRevisionRow.Revision     = BdgRevision;
                        BudgetRevisionRow.Description  = "Budget Import from: " + ACSVFileName;
                        AImportDS.ABudgetRevision.Rows.Add(BudgetRevisionRow);
                    }

                    //Read the budgetperiod values to check if valid according to type
                    Array.Clear(BudgetPeriods, 0, numPeriods);

                    bool successfulBudgetRowProcessing = ProcessBudgetTypeImportDetails(ref Line, Separator, budgetType, ref BudgetPeriods);

                    for (int i = 0; i < numPeriods; i++)
                    {
                        totalBudgetRowAmount += BudgetPeriods[i];
                    }

                    if (!successfulBudgetRowProcessing)
                    {
                        throw new InvalidOperationException(String.Format(
                                                                "The budget in row {0} for Ledger: {1}, Year: {2}, Cost Centre: {3} and Account: {4}, does not have values consistent with Budget Type: {5}.",
                                                                rowNumber,
                                                                ALedgerNumber,
                                                                budgetYear,
                                                                CostCentre,
                                                                Account,
                                                                budgetType));
                    }

                    BudgetTDS MainDS = new BudgetTDS();

                    TDBTransaction transaction = null;
                    DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                              TEnforceIsolationLevel.eilMinimum,
                                                                              ref transaction,
                                                                              delegate
                    {
                        ABudgetAccess.LoadByUniqueKey(MainDS, ALedgerNumber, YearForBudgetRevision, BdgRevision, CostCentre, Account, transaction);
                        //TODO: need to filter on ABudgetPeriod using LoadViaBudget or LoadViaUniqueKey
                    });

                    //Check to see if the budget combination already exists:
                    if (MainDS.ABudget.Count > 0)
                    {
                        ABudgetRow BR2 = (ABudgetRow)MainDS.ABudget.Rows[0];

                        int BTSeq = BR2.BudgetSequence;

                        ABudgetRow BdgTRow = (ABudgetRow)AImportDS.ABudget.Rows.Find(new object[] { BTSeq });

                        if (BdgTRow != null)
                        {
                            duplicateRowNumber++;

                            BdgTRow.BeginEdit();
                            //Edit the new budget row
                            BdgTRow.BudgetTypeCode = budgetType;
                            BdgTRow.EndEdit();

                            ABudgetPeriodRow BPRow = null;

                            for (int i = 0; i < numPeriods; i++)
                            {
                                BPRow = (ABudgetPeriodRow)AImportDS.ABudgetPeriod.Rows.Find(new object[] { BTSeq, i + 1 });

                                if (BPRow != null)
                                {
                                    BPRow.BeginEdit();
                                    BPRow.BudgetBase = BudgetPeriods[i];
                                    BPRow.EndEdit();
                                }

                                BPRow = null;
                            }
                        }
                    }
                    else
                    {
                        //Add the new budget row
                        ABudgetRow BudgetRow   = (ABudgetRow)AImportDS.ABudget.NewRowTyped();
                        int        newSequence = -1 * (AImportDS.ABudget.Rows.Count + 1);

                        BudgetRow.BudgetSequence = newSequence;
                        BudgetRow.LedgerNumber   = ALedgerNumber;
                        BudgetRow.Year           = YearForBudgetRevision;
                        BudgetRow.Revision       = BdgRevision;
                        BudgetRow.CostCentreCode = CostCentre;
                        BudgetRow.AccountCode    = Account;
                        BudgetRow.BudgetTypeCode = budgetType;
                        AImportDS.ABudget.Rows.Add(BudgetRow);

                        //Add the budget periods
                        for (int i = 0; i < numPeriods; i++)
                        {
                            ABudgetPeriodRow BudgetPeriodRow = (ABudgetPeriodRow)AImportDS.ABudgetPeriod.NewRowTyped();
                            BudgetPeriodRow.BudgetSequence = newSequence;
                            BudgetPeriodRow.PeriodNumber   = i + 1;
                            BudgetPeriodRow.BudgetBase     = BudgetPeriods[i];
                            AImportDS.ABudgetPeriod.Rows.Add(BudgetPeriodRow);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            DataFile.Close();

            if (duplicateRowNumber > 0)
            {
                //fractional part is the number of updates divided by 10000
                if (duplicateRowNumber < 10000)
                {
                    rowNumber += (duplicateRowNumber / 10000);
                }
            }

            return(rowNumber);
        }
Exemplo n.º 3
0
        public static bool GenBudgetForNextYear(int ALedgerNumber, int ABudgetSeq, string AForecastType)
        {
            bool retVal = false;

            decimal budgetSum;
            decimal priorAmount         = 0;
            decimal afterAmount         = 0;
            int     periodOfChange      = 0;
            int     gLMSequenceThisYear = 0;
            int     gLMSequenceLastYear = 0;

            ALedgerTable ledgerTable          = FMainDS.ALedger;
            ALedgerRow   ledgerRow            = (ALedgerRow)ledgerTable.Rows[0];
            int          currentFinancialYear = ledgerRow.CurrentFinancialYear;
            int          currentPeriod        = ledgerRow.CurrentPeriod;
            int          numAccPeriods        = ledgerRow.NumberOfAccountingPeriods;

            ABudgetTable budgetTable = FMainDS.ABudget;
            ABudgetRow   budgetRow   = (ABudgetRow)budgetTable.Rows.Find(new object[] { ABudgetSeq });

            #region  Validate Method Parameters

            if ((budgetRow == null) || (budgetRow.LedgerNumber != ledgerRow.LedgerNumber) || (budgetRow.Year != currentFinancialYear))
            {
                TLogging.Log("GenBudgetForNextYear: either could not find budget sequence " + ABudgetSeq.ToString() +
                             "or the sequence does not apply to ledger " + ledgerRow.LedgerNumber.ToString() +
                             "or to ledger current year " + currentFinancialYear.ToString());
                return(retVal);
            }

            if (ALedgerNumber != ledgerRow.LedgerNumber)
            {
                TLogging.Log("GenBudgetForNextYear: method parameter ALedgerNumber is " + ALedgerNumber.ToString() +
                             " but the data set expected the ledger to be " + ledgerRow.LedgerNumber.ToString());
            }

            #endregion

            string accountCode    = budgetRow.AccountCode;
            string costCentreCode = budgetRow.CostCentreCode;

            gLMSequenceThisYear = TCommonBudgetMaintain.GetGLMSequenceForBudget(ALedgerNumber,
                                                                                accountCode,
                                                                                costCentreCode,
                                                                                currentFinancialYear);

            gLMSequenceLastYear = TCommonBudgetMaintain.GetGLMSequenceForBudget(ALedgerNumber,
                                                                                accountCode,
                                                                                costCentreCode,
                                                                                (currentFinancialYear - 1));
            try
            {
                //Update the budget status
                budgetRow.BeginEdit();
                budgetRow.BudgetStatus = false;
                budgetRow.EndEdit();

                string budgetType = budgetRow.BudgetTypeCode;

                decimal budgetAmount    = 0;
                decimal actualAmount    = 0;
                bool    validBudgetType = true;

                switch (budgetType)
                {
                case MFinanceConstants.BUDGET_ADHOC:
                case MFinanceConstants.BUDGET_INFLATE_BASE:

                    for (int i = 1; i < currentPeriod; i++)
                    {
                        //Set budget period
                        actualAmount = TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                       gLMSequenceLastYear,
                                                                       gLMSequenceThisYear,
                                                                       i,
                                                                       numAccPeriods,
                                                                       currentFinancialYear,
                                                                       (currentFinancialYear - 1),
                                                                       false,
                                                                       MFinanceConstants.CURRENCY_BASE);
                        SetBudgetPeriodBaseAmount(ABudgetSeq, i, actualAmount);
                    }

                    for (int j = currentPeriod; j <= MFinanceConstants.MAX_PERIODS; j++)
                    {
                        if (AForecastType == MFinanceConstants.FORECAST_TYPE_BUDGET)
                        {
                            budgetAmount =
                                Math.Round(TCommonBudgetMaintain.GetBudget(gLMSequenceThisYear, -1, j, numAccPeriods,
                                                                           false,
                                                                           MFinanceConstants.CURRENCY_BASE));
                            SetBudgetPeriodBaseAmount(ABudgetSeq, j, budgetAmount);
                        }
                        else
                        {
                            actualAmount = TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                           gLMSequenceLastYear,
                                                                           gLMSequenceThisYear,
                                                                           j,
                                                                           numAccPeriods,
                                                                           currentFinancialYear,
                                                                           (currentFinancialYear - 1),
                                                                           false,
                                                                           MFinanceConstants.CURRENCY_BASE);
                            SetBudgetPeriodBaseAmount(ABudgetSeq, j, actualAmount);
                        }
                    }

                    break;

                case MFinanceConstants.BUDGET_SAME:                          //because this case has no code it will fall through to the next case until it finds code.
                case MFinanceConstants.BUDGET_SPLIT:

                    if ((currentPeriod - 1) != 0)
                    {
                        budgetSum =
                            TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                            gLMSequenceThisYear,
                                                            -1,
                                                            (currentPeriod - 1),
                                                            numAccPeriods,
                                                            currentFinancialYear,
                                                            currentFinancialYear,
                                                            true,
                                                            MFinanceConstants.CURRENCY_BASE);
                    }
                    else
                    {
                        budgetSum = 0;
                    }

                    if (AForecastType == MFinanceConstants.FORECAST_TYPE_BUDGET)
                    {
                        for (int i = currentPeriod; i <= numAccPeriods; i++)
                        {
                            budgetSum += TCommonBudgetMaintain.GetBudget(gLMSequenceThisYear,
                                                                         -1,
                                                                         i,
                                                                         numAccPeriods,
                                                                         false,
                                                                         MFinanceConstants.CURRENCY_BASE);
                        }
                    }
                    else
                    {
                        if (currentPeriod > 1)
                        {
                            budgetSum += TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                         gLMSequenceLastYear,
                                                                         gLMSequenceThisYear,
                                                                         numAccPeriods,
                                                                         numAccPeriods,
                                                                         currentFinancialYear,
                                                                         (currentFinancialYear - 1),
                                                                         true,
                                                                         MFinanceConstants.CURRENCY_BASE) -
                                         TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                         gLMSequenceLastYear,
                                                                         gLMSequenceThisYear,
                                                                         (currentPeriod - 1),
                                                                         numAccPeriods,
                                                                         currentFinancialYear,
                                                                         (currentFinancialYear - 1),
                                                                         true,
                                                                         MFinanceConstants.CURRENCY_BASE);
                        }
                        else
                        {
                            budgetSum += TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                         gLMSequenceLastYear,
                                                                         gLMSequenceThisYear,
                                                                         numAccPeriods,
                                                                         numAccPeriods,
                                                                         currentFinancialYear,
                                                                         (currentFinancialYear - 1),
                                                                         true,
                                                                         MFinanceConstants.CURRENCY_BASE);
                        }
                    }

                    budgetSum = budgetSum / numAccPeriods;

                    for (int i = 1; i <= numAccPeriods; i++)
                    {
                        SetBudgetPeriodBaseAmount(ABudgetSeq, i, Math.Round(budgetSum));
                    }

                    break;

                case MFinanceConstants.BUDGET_INFLATE_N:

                    for (int i = 1; i <= numAccPeriods; i++)
                    {
                        if (GetBudgetPeriodAmount(ABudgetSeq, i) != GetBudgetPeriodAmount(ABudgetSeq, 1))
                        {
                            periodOfChange = i - 1;
                            break;
                        }
                    }

                    /* Calculate average prior to change and after change. */
                    if (periodOfChange < (currentPeriod - 1))
                    {
                        priorAmount = TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                      gLMSequenceThisYear,
                                                                      -1,
                                                                      periodOfChange,
                                                                      numAccPeriods,
                                                                      currentFinancialYear,
                                                                      currentFinancialYear,
                                                                      true,
                                                                      MFinanceConstants.CURRENCY_BASE);

                        afterAmount =
                            TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                            gLMSequenceThisYear,
                                                            -1,
                                                            (currentPeriod - 1),
                                                            numAccPeriods,
                                                            currentFinancialYear,
                                                            currentFinancialYear,
                                                            true,
                                                            MFinanceConstants.CURRENCY_BASE) -
                            TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                            gLMSequenceThisYear,
                                                            -1,
                                                            periodOfChange + 1,
                                                            numAccPeriods,
                                                            currentFinancialYear,
                                                            currentFinancialYear,
                                                            true,
                                                            MFinanceConstants.CURRENCY_BASE);

                        if (AForecastType == MFinanceConstants.FORECAST_TYPE_BUDGET)
                        {
                            for (int i = currentPeriod; i <= numAccPeriods; i++)
                            {
                                afterAmount += TCommonBudgetMaintain.GetBudget(gLMSequenceThisYear,
                                                                               -1,
                                                                               i,
                                                                               numAccPeriods,
                                                                               false,
                                                                               MFinanceConstants.CURRENCY_BASE);
                            }
                        }
                        else
                        {
                            afterAmount += TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                           gLMSequenceLastYear,
                                                                           gLMSequenceThisYear,
                                                                           numAccPeriods,
                                                                           numAccPeriods,
                                                                           currentFinancialYear,
                                                                           (currentFinancialYear - 1),
                                                                           true,
                                                                           MFinanceConstants.CURRENCY_BASE) -
                                           TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                           gLMSequenceLastYear,
                                                                           gLMSequenceThisYear,
                                                                           currentPeriod,
                                                                           numAccPeriods,
                                                                           currentFinancialYear,
                                                                           (currentFinancialYear - 1),
                                                                           true,
                                                                           MFinanceConstants.CURRENCY_BASE);
                        }
                    }
                    else                              /* Period of change HAS NOT taken place. */
                    {
                        if ((currentPeriod - 1) != 0)
                        {
                            priorAmount =
                                TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                gLMSequenceThisYear,
                                                                -1,
                                                                (currentPeriod - 1),
                                                                numAccPeriods,
                                                                currentFinancialYear,
                                                                currentFinancialYear,
                                                                true,
                                                                MFinanceConstants.CURRENCY_BASE);
                        }
                        else
                        {
                            priorAmount = 0;
                        }

                        if (AForecastType == MFinanceConstants.FORECAST_TYPE_BUDGET)
                        {
                            for (int i = currentPeriod; i <= periodOfChange; i++)
                            {
                                priorAmount += TCommonBudgetMaintain.GetBudget(gLMSequenceThisYear,
                                                                               -1,
                                                                               i,
                                                                               numAccPeriods,
                                                                               false,
                                                                               MFinanceConstants.CURRENCY_BASE);
                            }
                        }
                        else
                        {
                            priorAmount = TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                          gLMSequenceLastYear,
                                                                          gLMSequenceThisYear,
                                                                          periodOfChange,
                                                                          numAccPeriods,
                                                                          currentFinancialYear,
                                                                          (currentFinancialYear - 1),
                                                                          true,
                                                                          MFinanceConstants.CURRENCY_BASE) -
                                          TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                          gLMSequenceLastYear,
                                                                          gLMSequenceThisYear,
                                                                          currentPeriod,
                                                                          numAccPeriods,
                                                                          currentFinancialYear,
                                                                          (currentFinancialYear - 1),
                                                                          true,
                                                                          MFinanceConstants.CURRENCY_BASE);
                        }

                        if (AForecastType == MFinanceConstants.FORECAST_TYPE_BUDGET)
                        {
                            for (int i = (periodOfChange + 1); i <= numAccPeriods; i++)
                            {
                                afterAmount += TCommonBudgetMaintain.GetBudget(gLMSequenceThisYear,
                                                                               -1,
                                                                               i,
                                                                               numAccPeriods,
                                                                               false,
                                                                               MFinanceConstants.CURRENCY_BASE);
                            }
                        }
                        else
                        {
                            afterAmount = TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                          gLMSequenceLastYear,
                                                                          gLMSequenceThisYear,
                                                                          numAccPeriods,
                                                                          numAccPeriods,
                                                                          currentFinancialYear,
                                                                          (currentFinancialYear - 1),
                                                                          true,
                                                                          MFinanceConstants.CURRENCY_BASE) -
                                          TCommonBudgetMaintain.GetActual(ALedgerNumber,
                                                                          gLMSequenceLastYear,
                                                                          gLMSequenceThisYear,
                                                                          (periodOfChange + 1),
                                                                          numAccPeriods,
                                                                          currentFinancialYear,
                                                                          (currentFinancialYear - 1),
                                                                          true,
                                                                          MFinanceConstants.CURRENCY_BASE);
                        }

                        /* Dividing after sum by prior sum gives rate of inflation. */
                        priorAmount = priorAmount / periodOfChange;
                        afterAmount = afterAmount / (numAccPeriods - periodOfChange);

                        for (int i = 1; i <= periodOfChange; i++)
                        {
                            SetBudgetPeriodBaseAmount(ABudgetSeq, i, Math.Round(priorAmount, 0));
                        }

                        for (int i = (periodOfChange + 1); i <= numAccPeriods; i++)
                        {
                            SetBudgetPeriodBaseAmount(ABudgetSeq, i, Math.Round(afterAmount, 0));
                        }
                    }

                    break;

                default:
                    validBudgetType = false;
                    break;
                }

                if (!validBudgetType)
                {
                    throw new InvalidOperationException(String.Format("Invalid budget type of: {0} for Budget Seq.: {1}",
                                                                      budgetType,
                                                                      budgetRow.BudgetSequence));
                }

                retVal = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(retVal);
        }