public void TestSaveNewPartnerWithLocation() { TDataBase db = DBAccess.Connect("TestSaveNewPartnerWithLocation"); TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.Serializable); TPartnerEditUIConnector connector = new TPartnerEditUIConnector(db); PartnerEditTDS MainDS = new PartnerEditTDS(); PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS, db); TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS); DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Transaction.Commit(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "TPartnerEditUIConnector SubmitChanges return value"); // check the location key for this partner. should not be negative Assert.AreEqual(1, MainDS.PPartnerLocation.Rows.Count, "TPartnerEditUIConnector SubmitChanges returns one location"); Assert.Greater(MainDS.PPartnerLocation[0].LocationKey, 0, "TPartnerEditUIConnector SubmitChanges returns valid location key"); }
public void TestGenerateHOSAFiles() { int LedgerNumber = FLedgerNumber; int PeriodNumber = 4; int IchNumber = 1; string CostCentre = "73"; String CurrencySelect = MFinanceConstants.CURRENCY_BASE; string FileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenHOSAFile.csv"; TVerificationResultCollection VerificationResults; TGenHOSAFilesReportsWebConnector.GenerateHOSAFiles(LedgerNumber, PeriodNumber, IchNumber, CostCentre, CurrencySelect, FileName, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "HOSA File Generation Failed!"); Assert.IsTrue(File.Exists(FileName), "HOSA File did not create!"); File.Delete(FileName); }
public void TestFileHeaderReplace() { string fileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenHOSAFileHeaderReplace.csv"; int PeriodNumber = 4; string StandardCostCentre = "4300"; string CostCentre = "78"; string Currency = "USD"; StreamWriter sw = new StreamWriter(fileName); sw.WriteLine("/** Header **,4,4300,78,18/01/2013,USD"); sw.Close(); TVerificationResultCollection VerificationResults = new TVerificationResultCollection(); string TableForExportHeader = "/** Header **" + "," + PeriodNumber.ToString() + "," + StandardCostCentre + "," + CostCentre + "," + DateTime.Today.ToShortDateString() + "," + Currency; TGenHOSAFilesReportsWebConnector.ReplaceHeaderInFile(fileName, TableForExportHeader, ref VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Header Replacement in File Failed!"); File.Delete(fileName); }
/// <summary> /// This will import a test gift batch, and post it. /// </summary> public static int ImportAndPostGiftBatch(DateTime AGiftDateEffective, TDataBase ADataBase) { TGiftImporting importer = new TGiftImporting(); string testFile = TAppSettingsManager.GetValue("GiftBatch.file", CommonNUnitFunctions.rootPath + "/csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv"); TLogging.Log(testFile); StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); sr.Close(); FileContent = FileContent.Replace("{ledgernumber}", FLedgerNumber.ToString()); FileContent = FileContent.Replace("{thisyear}-01-01", AGiftDateEffective.ToString("yyyy-MM-dd")); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", FLedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("DatesMayBeIntegers", false); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); TVerificationResultCollection VerificationResult; GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber; bool refreshRequired; importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult, ADataBase); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "error when importing gift batch:"); int BatchNumber = importer.GetLastGiftBatchNumber(); Assert.AreNotEqual(-1, BatchNumber, "Should have imported the gift batch and return a valid batch number"); Int32 generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult, ADataBase)) { string VerifResStr; if (VerificationResult != null) { VerifResStr = ": " + VerificationResult.BuildVerificationResultString(); } else { VerifResStr = String.Empty; } Assert.Fail("Gift Batch was not posted" + VerifResStr); } return(BatchNumber); }
public void TestSaveNewPartnerWithExistingLocation() { TDataBase db = DBAccess.Connect("TestSaveNewPartnerWithExistingLocation"); TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.Serializable); TPartnerEditUIConnector connector = new TPartnerEditUIConnector(db); PartnerEditTDS MainDS = new PartnerEditTDS(); PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS, db); TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS); DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Transaction.Commit(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "saving the first partner with a location"); Int32 LocationKey = MainDS.PLocation[0].LocationKey; MainDS = new PartnerEditTDS(); Transaction = db.BeginTransaction(IsolationLevel.Serializable); PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS, db); PPartnerLocationRow PartnerLocationRow = MainDS.PPartnerLocation.NewRowTyped(); PartnerLocationRow.SiteKey = DomainManager.GSiteKey; PartnerLocationRow.PartnerKey = PartnerRow.PartnerKey; PartnerLocationRow.LocationKey = LocationKey; MainDS.PPartnerLocation.Rows.Add(PartnerLocationRow); ResponseDS = new PartnerEditTDS(); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Transaction.Commit(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); TDBTransaction ReadTransaction = new TDBTransaction(); db.ReadTransaction( ref ReadTransaction, delegate { PPartnerTable PartnerAtAddress = PPartnerAccess.LoadViaPLocation( DomainManager.GSiteKey, LocationKey, ReadTransaction); Assert.AreEqual(2, PartnerAtAddress.Rows.Count, "there should be two partners at this location"); }); }
public void TestGenerateICHEmail() { TVerificationResultCollection VerificationResults = new TVerificationResultCollection(); int PeriodNumber = 5; int ICHProcessingNumber = 1; int CurrencyType = 1; //base string FileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenerateICHEmail.csv"; bool SendEmail = true; // make sure there is a valid email destination if (TGenFilesReports.GetICHEmailAddress(null).Length == 0) { string sqlStatement = String.Format("INSERT INTO PUB_{0}({1},{2},{3},{4}) VALUES (?,?,?,?)", AEmailDestinationTable.GetTableDBName(), AEmailDestinationTable.GetFileCodeDBName(), AEmailDestinationTable.GetConditionalValueDBName(), AEmailDestinationTable.GetPartnerKeyDBName(), AEmailDestinationTable.GetEmailAddressDBName()); OdbcParameter parameter; List <OdbcParameter> parameters = new List <OdbcParameter>(); parameter = new OdbcParameter("name", OdbcType.VarChar); parameter.Value = MFinanceConstants.EMAIL_FILE_CODE_STEWARDSHIP; parameters.Add(parameter); parameter = new OdbcParameter("condition", OdbcType.VarChar); parameter.Value = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) / 100; parameters.Add(parameter); parameter = new OdbcParameter("partnerkey", OdbcType.Int); parameter.Value = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) * 10000; parameters.Add(parameter); parameter = new OdbcParameter("email", OdbcType.VarChar); parameter.Value = TAppSettingsManager.GetValue("ClearingHouse.EmailAddress"); parameters.Add(parameter); bool SubmissionOK = true; TDBTransaction DBTransaction = null; DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref DBTransaction, ref SubmissionOK, delegate { DBAccess.GDBAccessObj.ExecuteNonQuery(sqlStatement, DBTransaction, parameters.ToArray()); DBAccess.GDBAccessObj.CommitTransaction(); }); } TGenFilesReports.GenerateStewardshipFile(FLedgerNumber, PeriodNumber, ICHProcessingNumber, CurrencyType, FileName, SendEmail, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Performing ICH Email File Generation Failed!"); }
/// <summary> /// /// </summary> public void SaveChanges() { DataSet ResponseDS = new PartnerEditTDS(); TPartnerEditUIConnector UIConnector = new TPartnerEditUIConnector(); TVerificationResultCollection VerificationResult; TSubmitChangesResult Result = UIConnector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); }
/// <summary> /// prepare the test case /// </summary> public static bool ImportAndPostGiftBatch(int ALedgerNumber, out TVerificationResultCollection VerificationResult) { TGiftImporting importer = new TGiftImporting(); string testFile = TAppSettingsManager.GetValue("GiftBatch.file", "../../csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv"); StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); FileContent = FileContent.Replace("{ledgernumber}", ALedgerNumber.ToString()); FileContent = FileContent.Replace("{thisyear}", DateTime.Today.Year.ToString()); sr.Close(); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", ALedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("DatesMayBeIntegers", false); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber; bool refreshRequired; if (!importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult)) { return(false); } int BatchNumber = importer.GetLastGiftBatchNumber(); Int32 generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(ALedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult)) { CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult); return(false); } TDataBase db = DBAccess.Connect("FixSendMailPartnerLocation"); TDBTransaction t = new TDBTransaction(); bool SubmissionOK = false; db.WriteTransaction(ref t, ref SubmissionOK, delegate { // need to set sendmail = true for the donor with partner key 43005001 string sql = "UPDATE p_partner_location SET p_send_mail_l = true WHERE p_partner_key_n = 43005001"; db.ExecuteNonQuery(sql, t); SubmissionOK = true; }); return(true); }
public void TestGenerateHOSAReports() { int LedgerNumber = FLedgerNumber; int PeriodNumber = 4; int IchNumber = 1; string Currency = "USD"; TVerificationResultCollection VerificationResults; TGenHOSAFilesReportsWebConnector.GenerateHOSAReports(LedgerNumber, PeriodNumber, IchNumber, Currency, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Performing HOSA Report Generation Failed!"); }
/// <summary> /// prepare the test case /// </summary> public static bool ImportAndPostGiftBatch(int ALedgerNumber, out TVerificationResultCollection VerificationResult) { TGiftImporting importer = new TGiftImporting(); string testFile = TAppSettingsManager.GetValue("GiftBatch.file", "../../csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv"); StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); FileContent = FileContent.Replace("{ledgernumber}", ALedgerNumber.ToString()); FileContent = FileContent.Replace("{thisyear}", DateTime.Today.Year.ToString()); sr.Close(); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", ALedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("DatesMayBeIntegers", false); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber; bool refreshRequired; if (!importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult)) { return(false); } int BatchNumber = importer.GetLastGiftBatchNumber(); Int32 generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(ALedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult)) { CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult); return(false); } return(true); }
public void TestFamilyPropagateNewLocation() { TDataBase db = DBAccess.Connect("TestFamilyPropagateNewLocation"); TPartnerEditUIConnector connector = new TPartnerEditUIConnector(db); PartnerEditTDS MainDS = new PartnerEditTDS(); TCreateTestPartnerData.CreateFamilyWithTwoPersonRecords(MainDS, db); DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); // now change on partner location. should ask about everyone else // it seems, the change must be to PLocation. In Petra 2.3, changes to the PartnerLocation are not propagated // MainDS.PPartnerLocation[0].DateGoodUntil = new DateTime(2011, 01, 01); Assert.AreEqual(1, MainDS.PLocation.Rows.Count, "there should be only one address for the whole family"); MainDS.PLocation[0].County = "different"; ResponseDS = new PartnerEditTDS(); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); // we currently return scrOK Assert.AreEqual(TSubmitChangesResult.scrInfoNeeded, result, "should ask if the partner locations of the other members of the family should be changed as well"); // TODO: simulate the dialog where the user selects which people to propagate the address change for. // TODO: what about replacing the whole address? // TODO: adding a new location for all members of the family? }
public void TestImportFamily() { string testFile = TAppSettingsManager.GetValue("ExtractTest.file", "../../csharp/ICT/Testing/lib/MPartner/SampleData/sampleExtract.ext"); string SelectedEventCode = TAppSettingsManager.GetValue("ImportPartnerForEventCode", String.Empty); StreamReader reader = new StreamReader(testFile, System.Text.Encoding.GetEncoding(1252)); string[] lines = reader.ReadToEnd().Replace("\r\n", "\n").Replace("\r", "\n").Split(new char[] { '\n' }); reader.Close(); TVerificationResultCollection VerificationResult; TPartnerFileImport importer = new TPartnerFileImport(); PartnerImportExportTDS MainDS = importer.ImportAllData(lines, SelectedEventCode, false, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult); foreach (PPartnerRow PartnerRow in MainDS.PPartner.Rows) { TLogging.Log(PartnerRow.PartnerKey.ToString() + " " + PartnerRow.PartnerShortName); } // TODO: check if the partners have been imported previously already foreach (PPartnerRow PartnerRow in MainDS.PPartner.Rows) { TLogging.Log(PartnerRow.PartnerKey.ToString() + " " + PartnerRow.PartnerShortName); } try { PartnerImportExportTDSAccess.SubmitChanges(MainDS); } catch (Exception e) { TLogging.Log(e.Message); TLogging.Log(e.StackTrace); Assert.Fail("See log messages"); } Assert.AreEqual(2, MainDS.PPartner.Rows.Count); }
public void TestGenerateStewardshipFile() { ImportAdminFees(); TVerificationResultCollection VerificationResults = new TVerificationResultCollection(); int PeriodNumber = 5; int ICHProcessingNumber = 1; int CurrencyType = 1; //base string FileName = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "Test.csv"; bool SendEmail = false; TGenFilesReports.GenerateStewardshipFile(FLedgerNumber, PeriodNumber, ICHProcessingNumber, CurrencyType, FileName, SendEmail, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Performing Stewardship File Generation Failed!"); }
public void TestMultipleGifts() { // import the test gift batch, and post it TGiftImporting importer = new TGiftImporting(); string dirTestData = "../../csharp/ICT/Testing/lib/MFinance/server/BankImport/"; string testFile = dirTestData + "GiftBatch.csv"; StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); sr.Close(); FileContent = FileContent.Replace("2010-09-30", DateTime.Now.Year.ToString("0000") + "-09-30"); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", FLedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); parameters.Add("DatesMayBeIntegers", false); TVerificationResultCollection VerificationResult; GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber; bool refreshRequired; if (!importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult)) { Assert.Fail("Gift Batch was not imported: " + VerificationResult.BuildVerificationResultString()); } int BatchNumber = importer.GetLastGiftBatchNumber(); Assert.AreNotEqual(-1, BatchNumber, "Failed to import gift batch: " + VerificationResult.BuildVerificationResultString()); Int32 generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult)) { Assert.Fail("Gift Batch was not posted: " + VerificationResult.BuildVerificationResultString()); } // import the test csv file, will already do the training testFile = dirTestData + "BankStatement.csv"; sr = new StreamReader(testFile); FileContent = sr.ReadToEnd(); sr.Close(); FileContent = FileContent.Replace("30.09.2010", "30.09." + DateTime.Now.Year.ToString("0000")); Int32 StatementKey; BankImportTDS BankImportDS = TBankStatementImportCSV.ImportBankStatementHelper( FLedgerNumber, "6200", ";", "DMY", "European", "EUR", "unused,DateEffective,Description,Amount,Currency", "", "BankStatementSeptember.csv", FileContent); Assert.AreNotEqual(null, BankImportDS, "valid bank import dataset september"); Assert.AreEqual(TSubmitChangesResult.scrOK, TBankStatementImport.StoreNewBankStatement( BankImportDS, out StatementKey), "save statement September"); // revert the gift batch, so that the training does not get confused if the test is run again; // the training needs only one gift batch for that date Hashtable requestParams = new Hashtable(); requestParams.Add("Function", GiftAdjustmentFunctionEnum.ReverseGiftBatch); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("BatchNumber", BatchNumber); requestParams.Add("GiftDetailNumber", -1); requestParams.Add("GiftNumber", -1); requestParams.Add("NewBatchSelected", false); requestParams.Add("NoReceipt", true); requestParams.Add("NewPct", 0.0m); requestParams.Add("UpdateTaxDeductiblePct", new System.Collections.Generic.List <string[]>()); requestParams.Add("GlEffectiveDate", new DateTime(DateTime.Now.Year, 09, 30)); requestParams.Add("AutoCompleteComments", false); requestParams.Add("ReversalCommentOne", String.Empty); requestParams.Add("ReversalCommentTwo", String.Empty); requestParams.Add("ReversalCommentThree", String.Empty); requestParams.Add("ReversalCommentOneType", String.Empty); requestParams.Add("ReversalCommentTwoType", String.Empty); requestParams.Add("ReversalCommentThreeType", String.Empty); int AdjustmentBatchNumber; bool BatchIsUnposted; GiftBatchTDS GiftReverseDS = TGiftTransactionWebConnector.LoadGiftTransactionsForBatch(FLedgerNumber, BatchNumber, out BatchIsUnposted); Assert.AreEqual(true, TAdjustmentWebConnector.GiftRevertAdjust(requestParams, out AdjustmentBatchNumber, GiftReverseDS), "reversing the gift batch"); if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, AdjustmentBatchNumber, out generatedGlBatchNumber, out VerificationResult)) { Assert.Fail("Gift Reverse Batch was not posted: " + VerificationResult.BuildVerificationResultString()); } // duplicate the bank import file, for the next month FileContent = FileContent.Replace("30.09." + DateTime.Now.Year.ToString("0000"), "30.10." + DateTime.Now.Year.ToString("0000")); BankImportDS = TBankStatementImportCSV.ImportBankStatementHelper( FLedgerNumber, "6200", ";", "DMY", "European", "EUR", "unused,DateEffective,Description,Amount,Currency", "", "BankStatementOctober.csv", FileContent); Assert.AreNotEqual(null, BankImportDS, "valid bank import dataset october"); Assert.AreEqual(TSubmitChangesResult.scrOK, TBankStatementImport.StoreNewBankStatement( BankImportDS, out StatementKey), "save statement October"); // create gift batch from imported statement Int32 GiftBatchNumber; TBankImportWebConnector.CreateGiftBatch( FLedgerNumber, StatementKey, out VerificationResult, out GiftBatchNumber); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "cannot create gift batch from bank statement:"); // check if the gift batch is correct GiftBatchTDS GiftDS = TGiftTransactionWebConnector.LoadAGiftBatchAndRelatedData(FLedgerNumber, GiftBatchNumber); // since we are not able to match the split gifts, only 1 donation should be matched. // TODO: allow 2 gifts to be merged in OpenPetra, even when they come separate on the bank statement. // then 4 gifts could be matched. Assert.AreEqual(1, GiftDS.AGift.Rows.Count, "expected two matched gifts"); }
public void TestPerformStewardshipCalculation() { TVerificationResultCollection VerificationResults = new TVerificationResultCollection(); Int32 PeriodNumber = 5; const string CostCentreGIF = "9500"; const string CostCentreReceivingField = "7300"; // run possibly empty stewardship calculation, to process all gifts that do not belong to this test TStewardshipCalculationWebConnector.PerformStewardshipCalculation(FLedgerNumber, PeriodNumber, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Performing initial Stewardship Calculation Failed!"); // make sure we have some admin fees ImportAdminFees(); decimal AdminGrantIncomeBefore = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ADMIN_FEE_INCOME_ACCT, (FLedgerNumber * 100).ToString("0000")).YtdActual; decimal GIFBefore = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_SETTLEMENT, CostCentreGIF).YtdActual; decimal RecipientBefore = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_SETTLEMENT, CostCentreReceivingField).YtdActual; decimal ClearingHouseBefore = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_ICH, (FLedgerNumber * 100).ToString("0000")).YtdActual; // import new gift batch. use proper period and date effective DateTime PeriodStartDate, PeriodEndDate; TFinancialYear.GetStartAndEndDateOfPeriod(FLedgerNumber, PeriodNumber, out PeriodStartDate, out PeriodEndDate, null); ImportAndPostGiftBatch(PeriodStartDate); TStewardshipCalculationWebConnector.PerformStewardshipCalculation(FLedgerNumber, PeriodNumber, out VerificationResults); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "Performing Stewardship Calculation Failed!"); // Home office keeps 1.40 => 4300/3400 Admin Grant income decimal AdminGrantIncomeAfter = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ADMIN_FEE_INCOME_ACCT, (FLedgerNumber * 100).ToString("0000")).YtdActual; Assert.AreEqual(20.0m * 7.0m / 100.0m, AdminGrantIncomeAfter - AdminGrantIncomeBefore, "Home office keeps 7% of 20 Euro gift"); // GIF should get 0.20 => 9500/5601 decimal GIFAfter = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_SETTLEMENT, CostCentreGIF).YtdActual; Assert.AreEqual(20.0m / 100.0m, GIFAfter - GIFBefore, "GIF should get 1% of 20 Euro gift. Before: " + GIFBefore + ", After: " + GIFAfter); // Receiving field should get 20-1.60 = 18.40 => 7300/5601 decimal RecipientAfter = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_SETTLEMENT, CostCentreReceivingField).YtdActual; Assert.AreEqual(20.0m * (100.0m - 1.0m - 7.0m) / 100.0m, RecipientAfter - RecipientBefore, "Receiving field should get 92% of 20 Euro gift"); // Clearing House (4300/8500) should receive the money for GIF and receiving field decimal ClearingHouseAfter = new TGet_GLM_Info(FLedgerNumber, MFinanceConstants.ICH_ACCT_ICH, (FLedgerNumber * 100).ToString("0000")).YtdActual; Assert.AreEqual(20.0m * (100.0m - 7.0m) / 100.0m, ClearingHouseAfter - ClearingHouseBefore, "We have to give everything apart from our 7% to ICH"); }
public void TestDeleteChurch() { DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; String TextMessage; Boolean CanDeletePartner; PPartnerRow ChurchPartnerRow; PPartnerRow PartnerRow; TSubmitChangesResult result; Int64 PartnerKey; TPartnerEditUIConnector connector = new TPartnerEditUIConnector(); PartnerEditTDS MainDS = new PartnerEditTDS(); ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record"); // check if church partner can be deleted (still needs to be possible at this point) CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage); if (TextMessage.Length > 0) { TLogging.Log(TextMessage); } Assert.IsTrue(CanDeletePartner); // create family partner and relationship to church partner PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); PPartnerRelationshipRow RelationshipRow = MainDS.PPartnerRelationship.NewRowTyped(); RelationshipRow.PartnerKey = ChurchPartnerRow.PartnerKey; RelationshipRow.RelationName = "SUPPCHURCH"; RelationshipRow.RelationKey = PartnerRow.PartnerKey; MainDS.PPartnerRelationship.Rows.Add(RelationshipRow); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add relationship record to church record"); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); // now deletion must not be possible since relationship as SUPPCHURCH exists CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(ChurchPartnerRow.PartnerKey, out TextMessage); if (TextMessage.Length > 0) { TLogging.Log(TextMessage); } Assert.IsTrue(!CanDeletePartner); // now test actual deletion of church partner ChurchPartnerRow = TCreateTestPartnerData.CreateNewChurchPartner(MainDS); PartnerKey = ChurchPartnerRow.PartnerKey; result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create church record for deletion"); // check if church record is being deleted Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult)); // check that church record is really deleted Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey)); }
public void TestBankingDetails() { TPartnerEditUIConnector connector = new TPartnerEditUIConnector(); PartnerEditTDS MainDS = new PartnerEditTDS(); PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS); DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "TPartnerEditUIConnector SubmitChanges return value"); connector = new TPartnerEditUIConnector(PartnerRow.PartnerKey); // add a banking detail PartnerEditTDSPBankingDetailsRow bankingDetailsRow = MainDS.PBankingDetails.NewRowTyped(true); bankingDetailsRow.AccountName = "account of " + PartnerRow.PartnerShortName; bankingDetailsRow.BankAccountNumber = new Random().Next().ToString(); bankingDetailsRow.BankingDetailsKey = (MainDS.PBankingDetails.Count + 1) * -1; bankingDetailsRow.BankKey = 43005004; bankingDetailsRow.MainAccount = true; bankingDetailsRow.BankingType = MPartnerConstants.BANKINGTYPE_BANKACCOUNT; MainDS.PBankingDetails.Rows.Add(bankingDetailsRow); PPartnerBankingDetailsRow partnerBankingDetails = MainDS.PPartnerBankingDetails.NewRowTyped(true); partnerBankingDetails.PartnerKey = PartnerRow.PartnerKey; partnerBankingDetails.BankingDetailsKey = bankingDetailsRow.BankingDetailsKey; MainDS.PPartnerBankingDetails.Rows.Add(partnerBankingDetails); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving 2:"); foreach (DataTable t in MainDS.Tables) { if ((t == MainDS.PBankingDetails) || (t == MainDS.PPartnerBankingDetails) || (t == MainDS.PDataLabelValuePartner)) { int NumRows = t.Rows.Count; for (int RowIndex = NumRows - 1; RowIndex >= 0; RowIndex -= 1) { DataRow InspectDR = t.Rows[RowIndex]; // delete all added Rows. if (InspectDR.RowState == DataRowState.Added) { InspectDR.Delete(); } } } } MainDS.AcceptChanges(); Assert.AreEqual(1, PBankingDetailsUsageAccess.CountViaPPartner(PartnerRow.PartnerKey, null), "count of main accounts for partner"); // add another account bankingDetailsRow = MainDS.PBankingDetails.NewRowTyped(true); bankingDetailsRow.AccountName = "2nd account of " + PartnerRow.PartnerShortName; bankingDetailsRow.BankAccountNumber = new Random().Next().ToString(); bankingDetailsRow.BankingDetailsKey = (MainDS.PBankingDetails.Count + 1) * -1; bankingDetailsRow.BankKey = 43005004; bankingDetailsRow.MainAccount = false; bankingDetailsRow.BankingType = MPartnerConstants.BANKINGTYPE_BANKACCOUNT; MainDS.PBankingDetails.Rows.Add(bankingDetailsRow); partnerBankingDetails = MainDS.PPartnerBankingDetails.NewRowTyped(true); partnerBankingDetails.PartnerKey = PartnerRow.PartnerKey; partnerBankingDetails.BankingDetailsKey = bankingDetailsRow.BankingDetailsKey; MainDS.PPartnerBankingDetails.Rows.Add(partnerBankingDetails); PartnerEditTDS ChangedDS = MainDS.GetChangesTyped(true); result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult); MainDS.Merge(ChangedDS); foreach (DataTable t in MainDS.Tables) { if ((t == MainDS.PBankingDetails) || (t == MainDS.PPartnerBankingDetails) || (t == MainDS.PDataLabelValuePartner)) { int NumRows = t.Rows.Count; for (int RowIndex = NumRows - 1; RowIndex >= 0; RowIndex -= 1) { DataRow InspectDR = t.Rows[RowIndex]; // delete all added Rows. if (InspectDR.RowState == DataRowState.Added) { InspectDR.Delete(); } } } } MainDS.AcceptChanges(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving 3:"); // now delete the main bank account PartnerEditTDSPBankingDetailsRow toDelete = null; foreach (PartnerEditTDSPBankingDetailsRow row in MainDS.PBankingDetails.Rows) { if (row.MainAccount) { toDelete = row; break; } } Assert.IsNotNull(toDelete, "cannot find main account"); Assert.AreEqual(true, toDelete.MainAccount, "should be the main account"); MainDS.PPartnerBankingDetails.Rows.Find(new object[] { PartnerRow.PartnerKey, toDelete.BankingDetailsKey }).Delete(); toDelete.Delete(); ChangedDS = MainDS.GetChangesTyped(true); result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult); Assert.AreEqual(1, VerificationResult.Count, "should fail because we have no main account anymore"); Assert.AreEqual( "One Bank Account of a Partner must be set as the 'Main Account'. Please select the record that should become the 'Main Account' and choose 'Set Main Account'.", VerificationResult[0].ResultText, "should fail because we have no main account anymore"); PartnerEditTDSPBankingDetailsRow otherAccount = null; foreach (PartnerEditTDSPBankingDetailsRow row in MainDS.PBankingDetails.Rows) { if ((row.RowState != DataRowState.Deleted) && !row.MainAccount) { otherAccount = row; break; } } otherAccount.MainAccount = true; ChangedDS = MainDS.GetChangesTyped(true); result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult); MainDS.Merge(ChangedDS); MainDS.AcceptChanges(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving 4:"); // now delete the last remaining bank account toDelete = MainDS.PBankingDetails[0]; Assert.AreEqual(true, toDelete.MainAccount); MainDS.PPartnerBankingDetails.Rows.Find(new object[] { PartnerRow.PartnerKey, toDelete.BankingDetailsKey }).Delete(); toDelete.Delete(); ChangedDS = MainDS.GetChangesTyped(true); result = connector.SubmitChanges(ref ChangedDS, ref ResponseDS, out VerificationResult); MainDS.Merge(ChangedDS); MainDS.AcceptChanges(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving 5:"); }
public void TestNewPartnerWithLocation0() { TPartnerEditUIConnector connector = new TPartnerEditUIConnector(); PartnerEditTDS MainDS = new PartnerEditTDS(); PPartnerRow PartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS); PPartnerLocationRow PartnerLocationRow = MainDS.PPartnerLocation.NewRowTyped(); PartnerLocationRow.SiteKey = DomainManager.GSiteKey; PartnerLocationRow.PartnerKey = PartnerRow.PartnerKey; PartnerLocationRow.LocationKey = 0; MainDS.PPartnerLocation.Rows.Add(PartnerLocationRow); DataSet ResponseDS = new PartnerEditTDS(); TVerificationResultCollection VerificationResult; TSubmitChangesResult result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create a partner with location 0"); TCreateTestPartnerData.CreateNewLocation(PartnerRow.PartnerKey, MainDS); // remove location 0, same is done in csharp\ICT\Petra\Client\MCommon\logic\UC_PartnerAddresses.cs TUCPartnerAddressesLogic::AddRecord // Check if record with PartnerLocation.LocationKey = 0 is around > delete it DataRow PartnerLocationRecordZero = MainDS.PPartnerLocation.Rows.Find(new object[] { PartnerRow.PartnerKey, DomainManager.GSiteKey, 0 }); if (PartnerLocationRecordZero != null) { DataRow LocationRecordZero = MainDS.PLocation.Rows.Find(new object[] { DomainManager.GSiteKey, 0 }); if (LocationRecordZero != null) { LocationRecordZero.Delete(); } PartnerLocationRecordZero.Delete(); } ResponseDS = new PartnerEditTDS(); result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "There was a critical error when saving:"); Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Replace location 0 of partner"); Assert.AreEqual(1, MainDS.PPartnerLocation.Rows.Count, "the partner should only have one location in the dataset"); // get all addresses of the partner TDBTransaction ReadTransaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref ReadTransaction, delegate { PPartnerLocationTable testPartnerLocations = PPartnerLocationAccess.LoadViaPPartner(PartnerRow.PartnerKey, ReadTransaction); Assert.AreEqual(1, testPartnerLocations.Rows.Count, "the partner should only have one location"); Assert.Greater(testPartnerLocations[0].LocationKey, 0, "TPartnerEditUIConnector SubmitChanges returns valid location key"); }); }
public void Test_YearEnd() { intLedgerNumber = CommonNUnitFunctions.CreateNewLedger(); TLedgerInfo LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(0, LedgerInfo.CurrentFinancialYear, "Before YearEnd, we should be in year 0"); TAccountPeriodInfo periodInfo = new TAccountPeriodInfo(intLedgerNumber, 1); Assert.AreEqual(new DateTime(DateTime.Now.Year, 1, 1), periodInfo.PeriodStartDate, "Calendar from base database should start with January 1st of this year"); CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\test-sql\\gl-test-year-end.sql", intLedgerNumber); CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\test-sql\\gl-test-year-end-account-property.sql", intLedgerNumber); TCommonAccountingTool commonAccountingTool = new TCommonAccountingTool(intLedgerNumber, "NUNIT"); commonAccountingTool.AddBaseCurrencyJournal(); commonAccountingTool.JournalDescription = "Test Data accounts"; string strAccountGift = "0200"; string strAccountBank = "6200"; string strAccountExpense = "4100"; // Accounting of some gifts ... commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4301", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 100); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4302", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4303", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 300); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4301", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 100); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4302", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4303", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 300); // Accounting of some expenses ... commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4301", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4302", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4303", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4301", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4302", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4303", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 200); commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work TVerificationResultCollection verificationResult = new TVerificationResultCollection(); bool blnLoop = true; while (blnLoop) { if (LedgerInfo.ProvisionalYearEndFlag) { blnLoop = false; } else { TVerificationResultCollection VerificationResult; TPeriodIntervalConnector.TPeriodMonthEnd(intLedgerNumber, false, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "Running MonthEnd gave critical error"); } } // check before year end that income and expense accounts are not 0 int intYear = 0; CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 150, 0, 150, 0, 200, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 100, 0, 200, 0, 300, 0); // test that we cannot post to period 12 anymore, all periods are closed? LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(true, LedgerInfo.ProvisionalYearEndFlag, "Provisional YearEnd flag should be set"); Assert.AreEqual(TYearEndProcessStatus.RESET_STATUS, (TYearEndProcessStatus)LedgerInfo.YearEndProcessStatus, "YearEnd process status should be still on RESET"); TReallocation reallocation = new TReallocation(LedgerInfo); reallocation.VerificationResultCollection = verificationResult; reallocation.IsInInfoMode = false; Assert.AreEqual(6, reallocation.GetJobSize(), "Six reallocation jobs expected"); reallocation.RunOperation(); // // Now if I try to do the same thing again, it should find there's nothing to do: reallocation = new TReallocation(LedgerInfo); reallocation.VerificationResultCollection = verificationResult; reallocation.IsInInfoMode = true; Assert.AreEqual(0, reallocation.GetJobSize(), "After TReallocation, all reallocation jobs should be clear"); // check amounts after reallocation CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 0, -150, 0, -150, 0, -200); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 0, -100, 0, -200, 0, -300); // first run in info mode TPeriodIntervalConnector.TPeriodYearEnd(intLedgerNumber, true, out verificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(verificationResult, "YearEnd test should not have critical errors"); // now run for real TPeriodIntervalConnector.TPeriodYearEnd(intLedgerNumber, false, out verificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(verificationResult, "YearEnd should not have critical errors"); ++intYear; // check after year end that income and expense accounts are 0, bank account remains CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 0, 0, 0, 0, 0, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 0, 0, 0, 0, 0, 0); // also check the glm period records CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountBank, -50, 50, 100); CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountExpense, 0, 0, 0); CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountGift, 0, 0, 0); // 8200 is the account that the expenses and income from last year is moved to TGlmInfo glmInfo = new TGlmInfo(intLedgerNumber, intYear, "8200"); glmInfo.Reset(); glmInfo.MoveNext(); Assert.AreEqual(100, glmInfo.YtdActualBase); Assert.AreEqual(0, glmInfo.ClosingPeriodActualBase); LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(1, LedgerInfo.CurrentFinancialYear, "After YearEnd, we are in a new financial year"); Assert.AreEqual(1, LedgerInfo.CurrentPeriod, "After YearEnd, we are in Period 1"); Assert.AreEqual(false, LedgerInfo.ProvisionalYearEndFlag, "After YearEnd, ProvisionalYearEnd flag should not be set"); Assert.AreEqual(TYearEndProcessStatus.RESET_STATUS, (TYearEndProcessStatus)LedgerInfo.YearEndProcessStatus, "after year end, year end process status should be RESET"); periodInfo = new TAccountPeriodInfo(intLedgerNumber, 1); Assert.AreEqual(new DateTime(DateTime.Now.Year + 1, 1, 1), periodInfo.PeriodStartDate, "new Calendar should start with January 1st of next year"); }
public void T0_Consolidation() { // reset the database, so that there is no consolidated budget CommonNUnitFunctions.ResetDatabase(); string budgetTestFile = TAppSettingsManager.GetValue("GiftBatch.file", CommonNUnitFunctions.rootPath + "/csharp/ICT/Testing/lib/MFinance/SampleData/BudgetImport-All.csv"); int NumBudgetsUpdated; int NumFailedRows; TVerificationResultCollection VerificationResult; BudgetTDS ImportDS = new BudgetTDS(); string ImportString = File.ReadAllText(budgetTestFile); // import budget from CSV decimal RowsImported = TBudgetMaintainWebConnector.ImportBudgets( FLedgerNumber, 0, ImportString, budgetTestFile, new string[] { ",", "dmy", "American" }, ref ImportDS, out NumBudgetsUpdated, out NumFailedRows, out VerificationResult); Assert.AreNotEqual(0, RowsImported, "expect to import several rows"); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "ImportBudgets has critical errors:"); BudgetTDSAccess.SubmitChanges(ImportDS); // check for value in budget table string sqlQueryBudget = String.Format( "SELECT {0} FROM PUB_{1}, PUB_{2} WHERE {1}.a_budget_sequence_i = {2}.a_budget_sequence_i AND a_period_number_i = 1 AND " + "a_ledger_number_i = {3} AND a_revision_i = 0 AND a_year_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300'", ABudgetPeriodTable.GetBudgetBaseDBName(), ABudgetTable.GetTableDBName(), ABudgetPeriodTable.GetTableDBName(), FLedgerNumber); decimal budgetValue = Convert.ToDecimal(DBAccess.GDBAccessObj.ExecuteScalar(sqlQueryBudget, IsolationLevel.ReadCommitted)); Assert.AreEqual(250m, budgetValue, "problem with importing budget from CSV"); // check for zero in glmperiod budget: that row does not even exist yet, so check that it does not exist string sqlQueryCheckEmptyConsolidatedBudget = String.Format( "SELECT COUNT(*) FROM PUB_{0}, PUB_{1} WHERE {0}.a_glm_sequence_i = {1}.a_glm_sequence_i AND a_period_number_i = 1 AND " + "a_ledger_number_i = {2} AND a_year_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300'", AGeneralLedgerMasterPeriodTable.GetTableDBName(), AGeneralLedgerMasterTable.GetTableDBName(), FLedgerNumber); Assert.AreEqual(0, DBAccess.GDBAccessObj.ExecuteScalar(sqlQueryCheckEmptyConsolidatedBudget, IsolationLevel.ReadCommitted), "budget should not be consolidated yet"); // consolidate the budget TBudgetConsolidateWebConnector.LoadBudgetForConsolidate(FLedgerNumber); TBudgetConsolidateWebConnector.ConsolidateBudgets(FLedgerNumber, true); // check for correct value in glmperiod budget string sqlQueryConsolidatedBudget = String.Format( "SELECT {0} FROM PUB_{1}, PUB_{2} WHERE {1}.a_glm_sequence_i = {2}.a_glm_sequence_i AND a_period_number_i = 1 AND " + "a_ledger_number_i = {3} AND a_year_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300'", AGeneralLedgerMasterPeriodTable.GetBudgetBaseDBName(), AGeneralLedgerMasterPeriodTable.GetTableDBName(), AGeneralLedgerMasterTable.GetTableDBName(), FLedgerNumber); decimal consolidatedBudgetValue = Convert.ToDecimal(DBAccess.GDBAccessObj.ExecuteScalar(sqlQueryConsolidatedBudget, IsolationLevel.ReadCommitted)); Assert.AreEqual(250m, consolidatedBudgetValue, "budget should now be consolidated"); // TODO: also check some summary account and cost centre for summed up budget values // check how reposting a budget works string sqlChangeBudget = String.Format("UPDATE PUB_{0} SET {1} = 44 WHERE a_period_number_i = 1 AND " + "EXISTS (SELECT * FROM PUB_{2} WHERE {0}.a_budget_sequence_i = {2}.a_budget_sequence_i AND a_ledger_number_i = {3} " + "AND a_year_i = 0 AND a_revision_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300')", ABudgetPeriodTable.GetTableDBName(), ABudgetPeriodTable.GetBudgetBaseDBName(), ABudgetTable.GetTableDBName(), FLedgerNumber); bool SubmissionOK = true; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { DBAccess.GDBAccessObj.ExecuteNonQuery(sqlChangeBudget, Transaction); }); // post all budgets again TBudgetConsolidateWebConnector.LoadBudgetForConsolidate(FLedgerNumber); TBudgetConsolidateWebConnector.ConsolidateBudgets(FLedgerNumber, true); consolidatedBudgetValue = Convert.ToDecimal(DBAccess.GDBAccessObj.ExecuteScalar(sqlQueryConsolidatedBudget, IsolationLevel.ReadCommitted)); Assert.AreEqual(44.0m, consolidatedBudgetValue, "budget should be consolidated with the new value"); // post only a modified budget (testing UnPostBudget) sqlChangeBudget = String.Format("UPDATE PUB_{0} SET {1} = 65 WHERE a_period_number_i = 1 AND " + "EXISTS (SELECT * FROM PUB_{2} WHERE {0}.a_budget_sequence_i = {2}.a_budget_sequence_i AND a_ledger_number_i = {3} " + "AND a_year_i = 0 AND a_revision_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300')", ABudgetPeriodTable.GetTableDBName(), ABudgetPeriodTable.GetBudgetBaseDBName(), ABudgetTable.GetTableDBName(), FLedgerNumber); string sqlMarkBudgetForConsolidation = String.Format("UPDATE PUB_{0} SET {1} = false WHERE " + "a_ledger_number_i = {2} " + "AND a_year_i = 0 AND a_revision_i = 0 AND a_account_code_c = '0300' AND a_cost_centre_code_c = '4300'", ABudgetTable.GetTableDBName(), ABudgetTable.GetBudgetStatusDBName(), FLedgerNumber); SubmissionOK = true; Transaction = null; DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { DBAccess.GDBAccessObj.ExecuteNonQuery(sqlChangeBudget, Transaction); DBAccess.GDBAccessObj.ExecuteNonQuery(sqlMarkBudgetForConsolidation, Transaction); }); // post only modified budget again TBudgetConsolidateWebConnector.LoadBudgetForConsolidate(FLedgerNumber); TBudgetConsolidateWebConnector.ConsolidateBudgets(FLedgerNumber, false); consolidatedBudgetValue = Convert.ToDecimal(DBAccess.GDBAccessObj.ExecuteScalar(sqlQueryConsolidatedBudget, IsolationLevel.ReadCommitted)); Assert.AreEqual(65.0m, consolidatedBudgetValue, "budget should be consolidated with the new value, after UnPostBudget"); // TODO: test forwarding periods. what happens to next year values, when there is no next year glm record yet? }
public void Test_YearEnd() { intLedgerNumber = CommonNUnitFunctions.CreateNewLedger(); TLedgerInfo LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(0, LedgerInfo.CurrentFinancialYear, "Before YearEnd, we should be in year 0"); TAccountPeriodInfo periodInfo = new TAccountPeriodInfo(intLedgerNumber, 1); Assert.AreEqual(new DateTime(DateTime.Now.Year, 1, 1), periodInfo.PeriodStartDate, "Calendar from base database should start with January 1st of this year"); CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\server\\GL\\test-sql\\gl-test-year-end.sql", intLedgerNumber); TCommonAccountingTool commonAccountingTool = new TCommonAccountingTool(intLedgerNumber, "NUNIT"); commonAccountingTool.AddBaseCurrencyJournal(); commonAccountingTool.JournalDescription = "Test Data accounts"; string strAccountGift = "0200"; string strAccountBank = "6200"; string strAccountExpense = "4100"; // Accounting of some gifts ... commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4301", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 100); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4302", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4303", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 300); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4301", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 100); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4302", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4303", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 300); // Accounting of some expenses ... commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4301", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4302", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountExpense, "4303", "Expense Example", "Debit", MFinanceConstants.IS_DEBIT, 200); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4301", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4302", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 150); commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4303", "Expense Example", "Credit", MFinanceConstants.IS_CREDIT, 200); commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work TVerificationResultCollection verificationResult = new TVerificationResultCollection(); bool blnLoop = true; while (blnLoop) { if (LedgerInfo.ProvisionalYearEndFlag) { blnLoop = false; } else { TVerificationResultCollection VerificationResult; List <Int32> glBatchNumbers; Boolean stewardshipBatch; TPeriodIntervalConnector.PeriodMonthEnd( intLedgerNumber, false, out glBatchNumbers, out stewardshipBatch, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "Running MonthEnd gave critical error"); } } // check before year end that income and expense accounts are not 0 int intYear = 0; CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 150, 0, 150, 0, 200, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 100, 0, 200, 0, 300, 0); // test that we cannot post to period 12 anymore, all periods are closed? LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(true, LedgerInfo.ProvisionalYearEndFlag, "Provisional YearEnd flag should be set"); List <Int32> glBatches = new List <int>(); TDBTransaction transaction = null; bool SubmissionOK = false; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction( IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref transaction, ref SubmissionOK, delegate { // // Reallocation is never called explicitly like this - it's not really appropriate // because I'm about to call it again as part of YearEnd, below. // But a tweak in the reallocation code means that it should now cope with being called twice. TReallocation reallocation = new TReallocation(LedgerInfo, glBatches, transaction); reallocation.VerificationResultCollection = verificationResult; reallocation.IsInInfoMode = false; reallocation.RunOperation(); SubmissionOK = true; }); // check amounts after reallocation CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 0, -150, 0, -150, 0, -200); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 0, -100, 0, -200, 0, -300); // first run in info mode TPeriodIntervalConnector.PeriodYearEnd(intLedgerNumber, true, out glBatches, out verificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(verificationResult, "YearEnd test should not have critical errors"); // now run for real TPeriodIntervalConnector.PeriodYearEnd(intLedgerNumber, false, out glBatches, out verificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(verificationResult, "YearEnd should not have critical errors"); ++intYear; // check after year end that income and expense accounts are 0, bank account remains CheckGLMEntry(intLedgerNumber, intYear, strAccountBank, -50, 0, 50, 0, 100, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountExpense, 0, 0, 0, 0, 0, 0); CheckGLMEntry(intLedgerNumber, intYear, strAccountGift, 0, 0, 0, 0, 0, 0); // also check the glm period records CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountBank, -50, 50, 100); CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountExpense, 0, 0, 0); CheckGLMPeriodEntry(intLedgerNumber, intYear, 1, strAccountGift, 0, 0, 0); // 9700 is the account that the expenses and income from last year is moved to TGlmInfo glmInfo = new TGlmInfo(intLedgerNumber, intYear, "9700"); glmInfo.Reset(); Assert.IsTrue(glmInfo.MoveNext(), "9700 account not found"); Assert.AreEqual(100, glmInfo.YtdActualBase); Assert.AreEqual(0, glmInfo.ClosingPeriodActualBase); LedgerInfo = new TLedgerInfo(intLedgerNumber); Assert.AreEqual(1, LedgerInfo.CurrentFinancialYear, "After YearEnd, we are in a new financial year"); Assert.AreEqual(1, LedgerInfo.CurrentPeriod, "After YearEnd, we are in Period 1"); Assert.AreEqual(false, LedgerInfo.ProvisionalYearEndFlag, "After YearEnd, ProvisionalYearEnd flag should not be set"); periodInfo = new TAccountPeriodInfo(intLedgerNumber, 1); Assert.AreEqual(new DateTime(DateTime.Now.Year + 1, 1, 1), periodInfo.PeriodStartDate, "new Calendar should start with January 1st of next year"); }
public void TestExportGifts() { int LedgerNumber = FLedgerNumber; string CostCentre = "7300"; string AcctCode = "0200"; string MonthName = "January"; int PeriodNumber = 1; DateTime PeriodStartDate = new DateTime(DateTime.Today.Year, 1, 1); DateTime PeriodEndDate = new DateTime(DateTime.Today.Year, 1, 31); string Base = MFinanceConstants.CURRENCY_BASE; int IchNumber = 0; DataTable TableForExport = new DataTable(); bool NewTransaction = false; // otherwise period 1 might have been closed already CommonNUnitFunctions.ResetDatabase(); // need to create gifts first TStewardshipCalculationTest.ImportAndPostGiftBatch(PeriodEndDate); //Perform stewardship calculation TVerificationResultCollection VerificationResults; TStewardshipCalculationWebConnector.PerformStewardshipCalculation(FLedgerNumber, PeriodNumber, out VerificationResults); VerificationResults = new TVerificationResultCollection(); //Create DataTable to receive exported transactions TableForExport.Columns.Add("CostCentre", typeof(string)); TableForExport.Columns.Add("Account", typeof(string)); TableForExport.Columns.Add("LedgerMonth", typeof(string)); TableForExport.Columns.Add("ICHPeriod", typeof(string)); TableForExport.Columns.Add("Date", typeof(DateTime)); TableForExport.Columns.Add("IndividualDebitTotal", typeof(decimal)); TableForExport.Columns.Add("IndividualCreditTotal", typeof(decimal)); TGenHOSAFilesReportsWebConnector.ExportGifts(LedgerNumber, CostCentre, AcctCode, MonthName, PeriodNumber, PeriodStartDate, PeriodEndDate, Base, IchNumber, TableForExport, VerificationResults); TableForExport.AcceptChanges(); DataRow[] DR = TableForExport.Select(); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults, "HOSA - Performing Export of gifts Failed!"); Assert.IsTrue((DR.Length > 0), "HOSA - Performing Export of gifts Failed to return any rows!"); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } }
public void Test_2YearEnds() { intLedgerNumber = CommonNUnitFunctions.CreateNewLedger(); CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\server\\GL\\test-sql\\gl-test-year-end.sql", intLedgerNumber); TLedgerInfo LedgerInfo = new TLedgerInfo(intLedgerNumber); for (int countYear = 0; countYear < 2; countYear++) { TLogging.Log("preparing year number " + countYear.ToString()); // accounting one gift string strAccountGift = "0200"; string strAccountBank = "6200"; TCommonAccountingTool commonAccountingTool = new TCommonAccountingTool(intLedgerNumber, "NUNIT"); commonAccountingTool.AddBaseCurrencyJournal(); commonAccountingTool.JournalDescription = "Test Data accounts"; commonAccountingTool.AddBaseCurrencyTransaction( strAccountBank, "4301", "Gift Example", "Debit", MFinanceConstants.IS_DEBIT, 100); commonAccountingTool.AddBaseCurrencyTransaction( strAccountGift, "4301", "Gift Example", "Credit", MFinanceConstants.IS_CREDIT, 100); Boolean PostedOk = commonAccountingTool.CloseSaveAndPost(); // returns true if posting seemed to work Assert.AreEqual(true, PostedOk, "Test batch can't be posted"); bool blnLoop = true; while (blnLoop) { // System.Windows.Forms.MessageBox.Show(LedgerInfo.CurrentPeriod.ToString(), "MonthEnd Period"); if (LedgerInfo.ProvisionalYearEndFlag) { blnLoop = false; } else { List <Int32> glBatchNumbers; Boolean stewardshipBatch; TVerificationResultCollection VerificationResult; TPeriodIntervalConnector.PeriodMonthEnd( intLedgerNumber, false, out glBatchNumbers, out stewardshipBatch, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "MonthEnd gave critical error at Period" + LedgerInfo.CurrentPeriod + ":\r\n"); } } TDBTransaction transaction = null; bool SubmissionOK = false; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction( IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref transaction, ref SubmissionOK, delegate { TLogging.Log("Closing year number " + countYear.ToString()); List <Int32> glBatches = new List <int>(); TReallocation reallocation = new TReallocation(LedgerInfo, glBatches, transaction); TVerificationResultCollection verificationResult = new TVerificationResultCollection(); reallocation.VerificationResultCollection = verificationResult; reallocation.IsInInfoMode = false; // Assert.AreEqual(1, reallocation.GetJobSize(), "Check 1 reallocation job is required"); // No job size is published by Reallocation reallocation.RunOperation(); TYearEnd YearEndOperator = new TYearEnd(LedgerInfo); TGlmNewYearInit glmNewYearInit = new TGlmNewYearInit(LedgerInfo, countYear, YearEndOperator, transaction); glmNewYearInit.VerificationResultCollection = verificationResult; glmNewYearInit.IsInInfoMode = false; // Assert.Greater(glmNewYearInit.GetJobSize(), 0, "Check that NewYearInit has work to do"); // in this version, GetJobSize returns 0 glmNewYearInit.RunOperation(); YearEndOperator.SetNextPeriod(transaction); SubmissionOK = true; }); } Assert.AreEqual(2, LedgerInfo.CurrentFinancialYear, "After YearEnd, Ledger is in year 2"); TAccountPeriodInfo periodInfo = new TAccountPeriodInfo(intLedgerNumber, 1); Assert.AreEqual(new DateTime(DateTime.Now.Year + 2, 1, 1), periodInfo.PeriodStartDate, "new Calendar should start with January 1st of next year"); } // Test_2YearEnds
public void TestMultipleGifts() { // import the test gift batch, and post it TGiftImporting importer = new TGiftImporting(); string dirTestData = "../../csharp/ICT/Testing/lib/MFinance/server/BankImport/TestData/"; string testFile = dirTestData + "GiftBatch.csv"; StreamReader sr = new StreamReader(testFile); string FileContent = sr.ReadToEnd(); sr.Close(); FileContent = FileContent.Replace("2010-09-30", DateTime.Now.Year.ToString("0000") + "-09-30"); Hashtable parameters = new Hashtable(); parameters.Add("Delimiter", ","); parameters.Add("ALedgerNumber", FLedgerNumber); parameters.Add("DateFormatString", "yyyy-MM-dd"); parameters.Add("NumberFormat", "American"); parameters.Add("NewLine", Environment.NewLine); TVerificationResultCollection VerificationResult; importer.ImportGiftBatches(parameters, FileContent, out VerificationResult); int BatchNumber = importer.GetLastGiftBatchNumber(); Assert.AreNotEqual(-1, BatchNumber, "Failed to import gift batch: " + VerificationResult.BuildVerificationResultString()); if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, BatchNumber, out VerificationResult)) { Assert.Fail("Gift Batch was not posted: " + VerificationResult.BuildVerificationResultString()); } // import the test csv file, will already do the training TBankStatementImport import = new TBankStatementImport(); testFile = dirTestData + "BankStatement.csv"; sr = new StreamReader(testFile); FileContent = sr.ReadToEnd(); sr.Close(); FileContent = FileContent.Replace("30.09.2010", "30.09." + DateTime.Now.Year.ToString("0000")); Int32 StatementKey; BankImportTDS BankImportDS = import.ImportBankStatementNonInteractive( FLedgerNumber, "6200", ";", "DMY", TDlgSelectCSVSeparator.NUMBERFORMAT_EUROPEAN, "unused,DateEffective,Description,Amount,Currency", "BankStatementSeptember.csv", FileContent); Assert.AreNotEqual(null, BankImportDS, "valid bank import dataset september"); Assert.AreEqual(TSubmitChangesResult.scrOK, TBankImportWebConnector.StoreNewBankStatement( BankImportDS, out StatementKey), "save statement September"); // revert the gift batch, so that the training does not get confused if the test is run again; // the training needs only one gift batch for that date Hashtable requestParams = new Hashtable(); requestParams.Add("Function", "ReverseGiftBatch"); requestParams.Add("ALedgerNumber", FLedgerNumber); requestParams.Add("BatchNumber", BatchNumber); requestParams.Add("GiftDetailNumber", -1); requestParams.Add("GiftNumber", -1); requestParams.Add("NewBatchSelected", false); requestParams.Add("GlEffectiveDate", new DateTime(DateTime.Now.Year, 09, 30)); Assert.AreEqual(true, TAdjustmentWebConnector.GiftRevertAdjust(requestParams, out VerificationResult), "reversing the gift batch"); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "Gift Batch was not reverted:"); // duplicate the bank import file, for the next month FileContent = FileContent.Replace("30.09." + DateTime.Now.Year.ToString("0000"), "30.10." + DateTime.Now.Year.ToString("0000")); BankImportDS = import.ImportBankStatementNonInteractive( FLedgerNumber, "6200", ";", "DMY", TDlgSelectCSVSeparator.NUMBERFORMAT_EUROPEAN, "unused,DateEffective,Description,Amount,Currency", "BankStatementOcotober.csv", FileContent); Assert.AreNotEqual(null, BankImportDS, "valid bank import dataset october"); Assert.AreEqual(TSubmitChangesResult.scrOK, TBankImportWebConnector.StoreNewBankStatement( BankImportDS, out StatementKey), "save statement October"); // create gift batch from imported statement Int32 GiftBatchNumber = TBankImportWebConnector.CreateGiftBatch( FLedgerNumber, StatementKey, -1, out VerificationResult); CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult, "cannot create gift batch from bank statement:"); // check if the gift batch is correct GiftBatchTDS GiftDS = TGiftTransactionWebConnector.LoadGiftBatchData(FLedgerNumber, GiftBatchNumber); // since we are not able to match the split gift, only 2 gifts should be matched. // TODO: allow 2 gifts to be merged in OpenPetra, even when they come separate on the bank statement. // then 4 gifts could be matched. Assert.AreEqual(2, GiftDS.AGift.Rows.Count, "expected two matched gifts"); }