private static void GetAdminFees(Int32 ALedgerNumber, Int32 ABatchNumber, Int32 ATransactionNumber, Int32 ADetailNumber, out decimal GIFFee, out decimal ICTFee, out decimal OtherFee) { GIFFee = 0; ICTFee = 0; OtherFee = 0; AProcessedFeeTable ProcessedFeeTbl = AProcessedFeeAccess.LoadViaAGiftDetail(ALedgerNumber, ABatchNumber, ATransactionNumber, ADetailNumber, FTransaction); foreach (AProcessedFeeRow Row in ProcessedFeeTbl.Rows) { switch (Row.FeeCode) { case "ICT": { ICTFee += Row.PeriodicAmount; break; } case "GIF": { GIFFee += Row.PeriodicAmount; break; } default: { OtherFee += Row.PeriodicAmount; break; } } } }
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); }