예제 #1
0
        public void Test_PEMM_05_Revaluation()
        {
            FLedgerNumber = CommonNUnitFunctions.CreateNewLedger();
            // load foreign currency account 6001
            CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\" +
                                                  "test-sql\\gl-test-account-data.sql", FLedgerNumber);

            // post a batch for foreign currency account 6001
            TCommonAccountingTool commonAccountingTool =
                new TCommonAccountingTool(FLedgerNumber, "NUNIT");

            commonAccountingTool.AddForeignCurrencyJournal("GBP", 1.1m);
            commonAccountingTool.JournalDescription = "Test foreign currency account";
            string strAccountGift = "0200";
            string strAccountBank = "6001";

            // Accounting of some gifts ...
            commonAccountingTool.AddBaseCurrencyTransaction(
                strAccountBank, (FLedgerNumber * 100).ToString(), "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 100);

            commonAccountingTool.AddBaseCurrencyTransaction(
                strAccountGift, (FLedgerNumber * 100).ToString(), "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 100);

            commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work


            TVerificationResultCollection verificationResult;
            bool blnHasErrors = TPeriodIntervalConnector.TPeriodMonthEnd(
                FLedgerNumber, true, out verificationResult);
            bool blnStatusArrived = false;

            for (int i = 0; i < verificationResult.Count; ++i)
            {
                if (verificationResult[i].ResultCode.Equals(
                        TPeriodEndErrorAndStatusCodes.PEEC_05.ToString()))
                {
                    blnStatusArrived = true;
                    Assert.IsTrue(verificationResult[i].ResultSeverity == TResultSeverity.Resv_Critical,
                                  "we need a critical error: need to run revaluation first ...");
                }
            }

            Assert.IsTrue(blnStatusArrived, "Status message has been shown");
            Assert.IsTrue(blnHasErrors, "should fail because revaluation needs to be run first");

            // run revaluation
            blnHasErrors = TRevaluationWebConnector.Revaluate(FLedgerNumber, new TLedgerInfo(
                                                                  FLedgerNumber).CurrentPeriod, new string[] { "GBP" }, new decimal[] { 1.2m }, out verificationResult);

            TLogging.Log(verificationResult.BuildVerificationResultString());
            Assert.IsFalse(blnHasErrors, "Problem running the revaluation");

            blnHasErrors = TPeriodIntervalConnector.TPeriodMonthEnd(
                FLedgerNumber, true, out verificationResult);
            Assert.IsFalse(blnHasErrors, "should now be able to close the month now that the revaluation has been run");
        }
예제 #2
0
        public void Test_PEMM_05_Revaluation()
        {
            FLedgerNumber = CommonNUnitFunctions.CreateNewLedger();
            // load foreign currency account 6001
            CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\" +
                                                  "test-sql\\gl-test-account-data.sql", FLedgerNumber);

            // post a batch for foreign currency account 6001
            TCommonAccountingTool commonAccountingTool =
                new TCommonAccountingTool(FLedgerNumber, "NUNIT");

            commonAccountingTool.AddForeignCurrencyJournal("GBP", 1.1m);
            commonAccountingTool.JournalDescription = "Test foreign currency account";
            string strAccountGift = "0200";
            string strAccountBank = "6001";

            // Accounting of some gifts ...
            commonAccountingTool.AddBaseCurrencyTransaction(
                strAccountBank, (FLedgerNumber * 100).ToString(), "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 100);

            commonAccountingTool.AddBaseCurrencyTransaction(
                strAccountGift, (FLedgerNumber * 100).ToString(), "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 100);

            Boolean PostedOk = commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work

            Assert.IsTrue(PostedOk, "Post foreign gift batch");


            TVerificationResultCollection verificationResult;

/*
 * This error is no longer critical - it's OK to run month end even if a reval is required. (Mantis# 03905)
 *
 *          bool blnHasErrors = TPeriodIntervalConnector.TPeriodMonthEnd(
 *              FLedgerNumber, true, out verificationResult);
 *
 *          for (int i = 0; i < verificationResult.Count; ++i)
 *          {
 *              if (verificationResult[i].ResultCode.Equals(
 *                      TPeriodEndErrorAndStatusCodes.PEEC_05.ToString()))
 *              {
 *                  blnStatusArrived = true;
 *                  Assert.IsTrue(verificationResult[i].ResultSeverity == TResultSeverity.Resv_Critical,
 *                      "A critical error is required: need to run revaluation first ...");
 *              }
 *          }
 */

            // run revaluation
            Boolean blnHasErrors = TRevaluationWebConnector.Revaluate(FLedgerNumber, new string[] { "GBP" }, new decimal[] { 1.2m },
                                                                      TLedgerInfo.GetStandardCostCentre(FLedgerNumber),
                                                                      out verificationResult);

            if (blnHasErrors)
            {
                TLogging.Log("\n\n\nTRevaluationWebConnector.Revaluate returned false, VerificationResult follows:");
                TLogging.Log(verificationResult.BuildVerificationResultString());
            }

            Assert.IsFalse(blnHasErrors, "Problem running the revaluation");

            blnHasErrors = TPeriodIntervalConnector.PeriodMonthEnd(
                FLedgerNumber, true, out verificationResult);

            if (blnHasErrors)
            {
                TLogging.Log("\n\n\nTPeriodMonthEnd returned true, VerificationResult follows:");
                TLogging.Log(verificationResult.BuildVerificationResultString());
            }

            Assert.IsFalse(blnHasErrors, "should now be able to close the month now that the revaluation has been run");
        }