public void Test_03_ForeignCurrencyAccountingWithWrongForeignValue() { string strAccountStart = "6001"; // Use an foreign currency account in GBP only string strAccountEnd = "9800"; // Use a base currency account only string strCostCentre = "4300"; PrepareTestCaseData(); TCommonAccountingTool commonAccountingTool = new TCommonAccountingTool(LedgerNumber, "NUNIT"); try { commonAccountingTool.AddForeignCurrencyJournal("JPY", 0.3m); commonAccountingTool.AddForeignCurrencyTransaction( strAccountStart, strCostCentre, "Credit GBP 100", "NUNIT", MFinanceConstants.IS_DEBIT, 100, 333.33m); commonAccountingTool.AddForeignCurrencyTransaction( strAccountEnd, strCostCentre, "Debit GBP 100", "NUNIT", MFinanceConstants.IS_CREDIT, 100, 333.33m); Assert.Fail("Exception does not appear!"); } catch (EVerificationException) { // Exception was thrown, which is expected // Assert.Pass will throw an exception NUnit.Framework.SuccessException and fail the test??? } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.ToString()); Assert.Fail("Wrong exception thrown"); } }
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"); }
public void Test_02_ForeignCurrencyAccounting() { string strAccountStart = "6001"; // Use an foreign currency account in GBP only string strAccountEnd = "9800"; // Use a base currency account only string strCostCentre = "4300"; PrepareTestCaseData(); // Get the glm-values before and after the test and taking the differences enables // to run the test several times // ** NOTE! Both of these initially return empty data because the GLMInfo line doesn't exist. // When they are later used in a comparison, 0 is returned for the non-existant rows. // And the test succeeds by a fortunate accident! TGet_GLM_Info getGLM_InfoBeforeStart = new TGet_GLM_Info(LedgerNumber, strAccountStart, strCostCentre); TGet_GLM_Info getGLM_InfoBeforeEnd = new TGet_GLM_Info(LedgerNumber, strAccountEnd, strCostCentre); TCommonAccountingTool commonAccountingTool = new TCommonAccountingTool(LedgerNumber, "NUNIT"); decimal ExchangeRateEurToGBP = 0.85m; decimal AmountInGBP = 100.0m; decimal AmountInEUR = (1.0m / ExchangeRateEurToGBP) * AmountInGBP; commonAccountingTool.AddForeignCurrencyJournal("GBP", ExchangeRateEurToGBP); commonAccountingTool.AddForeignCurrencyTransaction( strAccountStart, strCostCentre, "Debit GBP 100", "NUNIT", MFinanceConstants.IS_DEBIT, AmountInEUR, AmountInGBP); commonAccountingTool.AddForeignCurrencyTransaction( strAccountEnd, strCostCentre, "Credit GBP 100", "NUNIT", MFinanceConstants.IS_CREDIT, AmountInEUR, AmountInGBP); commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work TGet_GLM_Info getGLM_InfoAfterStart = new TGet_GLM_Info(LedgerNumber, strAccountStart, strCostCentre); TGet_GLM_Info getGLM_InfoAfterEnd = new TGet_GLM_Info(LedgerNumber, strAccountEnd, strCostCentre); Assert.AreEqual(Math.Round(getGLM_InfoBeforeStart.YtdActual + AmountInEUR, 2), Math.Round(getGLM_InfoAfterStart.YtdActual, 2), "Check if base currency has been accounted to " + strAccountStart); Assert.AreEqual(Math.Round(getGLM_InfoBeforeEnd.YtdActual + AmountInEUR, 2), Math.Round(getGLM_InfoAfterEnd.YtdActual, 2), "Check if base currency has been accounted to " + strAccountEnd); Assert.AreEqual(getGLM_InfoBeforeStart.YtdForeign + AmountInGBP, getGLM_InfoAfterStart.YtdForeign, "Check if foreign currency has been accounted"); Assert.AreEqual(getGLM_InfoBeforeEnd.YtdForeign, getGLM_InfoAfterEnd.YtdForeign, "Check if nothing foreign has been accounted on the non foreign currency account"); }
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"); }