public void TestProcessAdminFees()
        {
            ImportAdminFees();

            GiftBatchTDS MainDS = new GiftBatchTDS();

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                                      delegate
            {
                AFeesPayableAccess.LoadViaALedger(MainDS, FLedgerNumber, Transaction);
                AFeesReceivableAccess.LoadViaALedger(MainDS, FLedgerNumber, Transaction);
            });

            TVerificationResultCollection VerificationResults = null;

            //TODO If this first one works, try different permatations for Assert.AreEqual
            // Test also for exception handling
            Assert.AreEqual(2m, TGiftTransactionWebConnector.CalculateAdminFee(MainDS,
                                                                               FLedgerNumber,
                                                                               "GIF",
                                                                               200m,
                                                                               out VerificationResults), "expect 1% of 200");
        }
示例#2
0
        public void TestProcessAdminFees()
        {
            bool NewTransaction = false;

            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);

            TVerificationResultCollection VerficationResults = null;

            AFeesPayableTable    FeesPayableTable    = null;
            AFeesReceivableTable FeesReceivableTable = null;

            try
            {
                AFeesPayableRow template = new AFeesPayableTable().NewRowTyped(false);

                template.LedgerNumber = FLedgerNumber;
                template.FeeCode      = MainFeesPayableCode;

                FeesPayableTable = AFeesPayableAccess.LoadUsingTemplate(template, Transaction);

                AFeesReceivableRow template1 = new AFeesReceivableTable().NewRowTyped(false);

                template1.LedgerNumber = FLedgerNumber;
                template1.FeeCode      = MainFeesReceivableCode;

                FeesReceivableTable = AFeesReceivableAccess.LoadUsingTemplate(template1, Transaction);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }

            if (FeesPayableTable.Count == 0)
            {
                CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\" +
                                                      "test-sql\\gl-test-feespayable-data.sql", FLedgerNumber);
            }

            if (FeesReceivableTable.Count == 0)
            {
                CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\" +
                                                      "test-sql\\gl-test-feesreceivable-data.sql", FLedgerNumber);
            }

            GiftBatchTDS MainDS = new GiftBatchTDS();

            //Reset
            NewTransaction = false;
            Transaction    = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction);

            try
            {
                AFeesPayableAccess.LoadViaALedger(MainDS, FLedgerNumber, Transaction);
                AFeesReceivableAccess.LoadViaALedger(MainDS, FLedgerNumber, Transaction);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }

            //TODO If this first one works, try different permatations for Assert.AreEqual
            // Test also for exception handling
            Assert.AreEqual(12m, TGiftTransactionWebConnector.CalculateAdminFee(MainDS,
                                                                                FLedgerNumber,
                                                                                MainFeesPayableCode,
                                                                                100m,
                                                                                out VerficationResults), "admin fee fixed 12% of 100 expect 12");
        }