//        /// <summary>
//        /// Test that the valid posting period code works
//        /// </summary>
//        [Test]
//        public void TestIsValidPostingPeriod()
//        {
//              int DateEffectivePeriodNumber;
//              int DateEffectiveYearNumber;
//
//              bool NewTransaction = false;
//
//              TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);
//
//			Assert.IsTrue(TFinancialYear.IsValidPostingPeriod(FLedgerNumber, Convert.ToDateTime("15-Sep-2011"), out DateEffectivePeriodNumber, out DateEffectiveYearNumber, Transaction),"Period is not valid");
//
//              if (NewTransaction)
//              {
//                      DBAccess.GDBAccessObj.RollbackTransaction();
//              }
//        }

        /// <summary>
        /// this function will import admin fees if there are no admin fees in the database yet
        /// </summary>
        private void ImportAdminFees()
        {
            AFeesPayableTable    FeesPayableTable    = null;
            AFeesReceivableTable FeesReceivableTable = null;

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction,
                                                                      delegate
            {
                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);
            });

            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);
            }
        }
Пример #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");
        }