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_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 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"); }