/// <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); }
/// <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); }
/// <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); }
private int ImportAndPostGiftBatch() { 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}", FLedgerNumber.ToString()); FileContent = FileContent.Replace("{thisyear}", DateTime.Today.Year.ToString()); sr.Close(); 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 = null; 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, "Should have imported the gift batch and returned a valid batch number"); Int32 generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult)) { Assert.Fail("Gift Batch was not posted: " + VerificationResult.BuildVerificationResultString()); } return(BatchNumber); }
public void TestBatchPostingRecalculations() { TVerificationResultCollection VerificationResult; Int64 RecipientKey; Int64 RealRecipientLedgerNumber; Int64 FalseRecipientLedgerNumber; const string REALCOSTCENTRECODE = "4300"; const string FALSECOSTCENTRECODE = "3500"; const string ACCOUNTCODE = "0100"; Int32 GiftBatchNumber; // // Arrange: Create all data needed for this test (Gift Details have 'fake' RecipientLedgerNumber and CostCentreCode) // TestBatchPostingRecalculations_Arrange(out RecipientKey, out RealRecipientLedgerNumber, out FalseRecipientLedgerNumber, REALCOSTCENTRECODE, FALSECOSTCENTRECODE, out GiftBatchNumber); // // Act: Post the batch // bool result = TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, GiftBatchNumber, out VerificationResult); // // Assert // // Initial Assert: Tests that the post returns positive Assert.AreEqual(true, result, "TestBatchPostingRecalculations fail: Posting GiftBatch failed: " + VerificationResult.BuildVerificationResultString()); // Primary Assert: Chaeck that the gifts have the correct RecipientLedgerNumber, CostCentreCode and Account TDBTransaction Transaction = null; AGiftDetailRow PositiveGiftDetailRow = null; AGiftDetailRow NegativeGiftDetailRow = null; ATransactionRow TransactionRow = null; Int32 GLBatchNumber = -1; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { PositiveGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 1, 1, Transaction)[0]; NegativeGiftDetailRow = AGiftDetailAccess.LoadByPrimaryKey(FLedgerNumber, GiftBatchNumber, 2, 1, Transaction)[0]; GLBatchNumber = ALedgerAccess.LoadByPrimaryKey(FLedgerNumber, Transaction)[0].LastBatchNumber; TransactionRow = ATransactionAccess.LoadByPrimaryKey(FLedgerNumber, GLBatchNumber, 1, 1, Transaction)[0]; }); Assert.IsNotNull(PositiveGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining PositiveGiftDetailRow from database failed"); Assert.IsNotNull(NegativeGiftDetailRow, "TestBatchPostingRecalculations fail: Obtaining NegativeGiftDetailRow from database failed"); Assert.IsNotNull(TransactionRow, "TestBatchPostingRecalculations fail: Obtaining Transaction from database failed"); Assert.AreEqual(RealRecipientLedgerNumber, PositiveGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FalseRecipientLedgerNumber, NegativeGiftDetailRow.RecipientLedgerNumber, "TestBatchPostingRecalculations fail: RecipientLedgerNumber for NegativeGiftDetailRow is incorrect"); Assert.AreEqual(REALCOSTCENTRECODE, PositiveGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for PositiveGiftDetailRow is incorrect"); Assert.AreEqual(FALSECOSTCENTRECODE, NegativeGiftDetailRow.CostCentreCode, "TestBatchPostingRecalculations fail: CostCentreCode for NegativeGiftDetailRow is incorrect"); Assert.AreEqual(ACCOUNTCODE, TransactionRow.AccountCode, "TestBatchPostingRecalculations fail: AccountCode for PositiveGiftDetailRow is incorrect"); // Cleanup: Delete test records bool SubmissionOK = true; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { AProcessedFeeAccess.DeleteUsingTemplate( new TSearchCriteria[] { new TSearchCriteria("a_ledger_number_i", FLedgerNumber), new TSearchCriteria("a_batch_number_i", GiftBatchNumber) }, Transaction); AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, PositiveGiftDetailRow, Transaction); AGiftDetailAccess.DeleteRow(AGiftDetailTable.TableId, NegativeGiftDetailRow, Transaction); }); TPartnerWebConnector.DeletePartner(RecipientKey, out VerificationResult); TPartnerWebConnector.DeletePartner(RealRecipientLedgerNumber, out VerificationResult); TPartnerWebConnector.DeletePartner(FalseRecipientLedgerNumber, out VerificationResult); }
public void TestAdjustGiftBatch() { int GiftBatchNumber = ImportAndPostGiftBatch(); TGet_GLM_Info getGLM_InfoBeforeTest73 = new TGet_GLM_Info(FLedgerNumber, "0200", "7300"); TGet_GLM_Info getGLM_InfoBeforeTest35 = new TGet_GLM_Info(FLedgerNumber, "0200", "3500"); string formletterTemplateFile = TAppSettingsManager.GetValue("ReceiptTemplate.file", "../../csharp/ICT/Testing/lib/MFinance/SampleData/AnnualReceiptTemplate.html"); Encoding encodingOfHTMLfile = TTextFile.GetFileEncoding(formletterTemplateFile); StreamReader sr = new StreamReader(formletterTemplateFile, encodingOfHTMLfile, false); string FileContent = sr.ReadToEnd(); sr.Close(); string receiptsBefore; string receiptsPDF; TReceiptingWebConnector.CreateAnnualGiftReceipts(FLedgerNumber, "Annual", new DateTime(DateTime.Today.Year, 1, 1), new DateTime(DateTime.Today.Year, 12, 31), FileContent, null, String.Empty, null, String.Empty, "de-DE", out receiptsPDF, out receiptsBefore); Assert.AreNotEqual(0, receiptsBefore.Trim().Length, "old receipt must not be empty"); int AdjustBatchNumber; TAdjustmentWebConnector.GiftRevertAdjust(FLedgerNumber, GiftBatchNumber, -1, false, -1, DateTime.Today, GiftAdjustmentFunctionEnum.AdjustGift, false, -1.0m, out AdjustBatchNumber); bool BatchIsUnposted; string CurrencyCode; GiftBatchTDS BatchTDS = TGiftTransactionWebConnector.LoadGiftTransactionsForBatch( FLedgerNumber, AdjustBatchNumber, out BatchIsUnposted, out CurrencyCode); // find the transaction to modify Int32 ToModify = (BatchTDS.AGiftDetail[1].GiftTransactionNumber == 2)?1:0; // change the amount from 20 to 25 BatchTDS.AGiftDetail[ToModify].GiftTransactionAmount = 25; // the money should go to field 35 instead of field 73 BatchTDS.AGiftDetail[ToModify].RecipientKey = 35000000; // TODO change of donor // BatchTDS.Gift[1].DonorKey = TVerificationResultCollection VerificationResult; if (TGiftTransactionWebConnector.SaveGiftBatchTDS(ref BatchTDS, out VerificationResult) != TSubmitChangesResult.scrOK) { Assert.Fail("Adjustment Gift Batch was not saved: " + VerificationResult.BuildVerificationResultString()); } int generatedGlBatchNumber; if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, AdjustBatchNumber, out generatedGlBatchNumber, out VerificationResult)) { Assert.Fail("Adjustment Gift Batch was not posted: " + VerificationResult.BuildVerificationResultString()); } TGet_GLM_Info getGLM_InfoAfterTest73 = new TGet_GLM_Info(FLedgerNumber, "0200", "7300"); TGet_GLM_Info getGLM_InfoAfterTest35 = new TGet_GLM_Info(FLedgerNumber, "0200", "3500"); // Test balance on the related account/Costcentre Assert.AreEqual(getGLM_InfoBeforeTest73.YtdActual - 20, getGLM_InfoAfterTest73.YtdActual, "The amount of 20 should be derived from the 73 costcentre"); Assert.AreEqual(getGLM_InfoBeforeTest35.YtdActual + 25, getGLM_InfoAfterTest35.YtdActual, "The amount of 25 should be added to the 35 costcentre"); // Test the number of rows on the gift receipt. // the difference should be 3 lines removed, 3 lines added. no double donations. string receiptsAfter; TReceiptingWebConnector.CreateAnnualGiftReceipts(FLedgerNumber, "Annual", new DateTime(DateTime.Today.Year, 1, 1), new DateTime(DateTime.Today.Year, 12, 31), FileContent, null, String.Empty, null, String.Empty, "de-DE", out receiptsPDF, out receiptsAfter); receiptsBefore = THttpBinarySerializer.DeserializeFromBase64(receiptsBefore); receiptsAfter = THttpBinarySerializer.DeserializeFromBase64(receiptsAfter); TLogging.Log("TestAdjustGiftBatch Diff:"); TLogging.Log(TTextFile.Diff(receiptsBefore, receiptsAfter)); string[] diff = TTextFile.Diff(receiptsBefore, receiptsAfter).Trim().Split(Environment.NewLine); Assert.AreEqual(6, diff.Length, "difference on receipts are 6 lines"); }
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 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"); }