Exemplo n.º 1
0
        public static void GetLedgerPeriodDetails(
            int ALedgerNumber,
            out int ANumberAccountingPeriods,
            out int ANumberForwardingPeriods,
            out int ACurrentPeriod,
            out int ACurrentYear)
        {
            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            ALedgerTable CachedDataTable = (ALedgerTable)CachePopulator.GetCacheableTable(
                TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out typeofTable);

            if (CachedDataTable.Rows.Count > 0)
            {
                ANumberAccountingPeriods = CachedDataTable[0].NumberOfAccountingPeriods;
                ANumberForwardingPeriods = CachedDataTable[0].NumberFwdPostingPeriods;
                ACurrentPeriod = CachedDataTable[0].CurrentPeriod;
                ACurrentYear = CachedDataTable[0].CurrentFinancialYear;
            }
            else
            {
                ANumberAccountingPeriods = -1;
                ANumberForwardingPeriods = -1;
                ACurrentPeriod = -1;
                ACurrentYear = -1;
            }
        }
        void CheckGLMPeriodEntry(int ALedgerNumber, int AYear, int APeriodNr, string AAccount,
                                 decimal cc1Base,
                                 decimal cc2Base,
                                 decimal cc3Base)
        {
            TGlmInfo glmInfo = new TGlmInfo(ALedgerNumber, AYear, AAccount);

            glmInfo.Reset();
            int  intCnt  = 0;
            bool blnFnd1 = false;
            bool blnFnd2 = false;
            bool blnFnd3 = false;

            TCacheable       cache = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            Type             dummy;
            ACostCentreTable costcentres = (ACostCentreTable)cache.GetCacheableTable(TCacheableFinanceTablesEnum.CostCentreList,
                                                                                     string.Empty,
                                                                                     false,
                                                                                     ALedgerNumber,
                                                                                     out dummy);

            while (glmInfo.MoveNext())
            {
//              TLogging.Log("glmInfo.CostCentreCode: " + glmInfo.CostCentreCode);

                TGlmpInfo glmpInfo = new TGlmpInfo(-1, -1, glmInfo.GlmSequence, APeriodNr);

                Assert.AreEqual(true,
                                glmpInfo.RowExists,
                                "we cannot find a glm period record for " + glmInfo.AccountCode + " / " + glmInfo.CostCentreCode);

                if (glmInfo.CostCentreCode.Equals("4301"))
                {
                    Assert.AreEqual(cc1Base, glmpInfo.ActualBase);
                    blnFnd1 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4302"))
                {
                    Assert.AreEqual(cc2Base, glmpInfo.ActualBase);
                    blnFnd2 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4303"))
                {
                    Assert.AreEqual(cc3Base, glmpInfo.ActualBase);
                    blnFnd3 = true;
                }

                if (((ACostCentreRow)costcentres.Rows.Find(new object[] { ALedgerNumber, glmInfo.CostCentreCode })).PostingCostCentreFlag)
                {
                    ++intCnt;
                }
            }

            Assert.AreEqual(3, intCnt, "3 posting cost centres ...");
            Assert.IsTrue(blnFnd1);
            Assert.IsTrue(blnFnd2);
            Assert.IsTrue(blnFnd3);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize the static variables.
        /// Set up Error Codes and Data Validation Delegates for a Web Request.
        /// This setting-up makes use of the fact that this Method is called only once,
        /// at the start of each Web Request in TOpenPetraOrgSessionManager.Init()
        /// </summary>
        public static void Init()
        {
            TSharedValidationHelper.SharedGetDataDelegate                           = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TPartnerServerLookups.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TPartnerServerLookups.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TPartnerServerLookups.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TPartnerServerLookups.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TPartnerServerLookups.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TFinanceServerLookupWebConnector.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate              = @TAccountingPeriodsWebConnector.GetPeriodDates;
            TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriodDelegate    = @TAccountingPeriodsWebConnector.GetFirstDayOfAccountingPeriod;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            Ict.Petra.Server.MCommon.Cacheable.WebConnectors.TCommonCacheableWebConnector.Init();
            Ict.Petra.Server.MConference.Cacheable.WebConnectors.TConferenceCacheableWebConnector.Init();
            Ict.Petra.Server.MFinance.Cacheable.WebConnectors.TFinanceCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Mailing.Cacheable.WebConnectors.TMailingCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Partner.Cacheable.WebConnectors.TPartnerCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Subscriptions.Cacheable.WebConnectors.TSubscriptionsCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Person.Cacheable.WebConnectors.TPersonCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Unit.Cacheable.WebConnectors.TUnitCacheableWebConnector.Init();
            Ict.Petra.Server.MSysMan.Cacheable.WebConnectors.TSysManCacheableWebConnector.Init();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate         = @CachePopulatorCommon.GetCacheableTable;
            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate       = @CachePopulatorFinance.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate   = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate       = @CachePopulatorUnits.GetCacheableTable;
            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;
            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate         = @CachePopulatorSysMan.GetCacheableTable;

            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

            TCacheableTablesManager.Init();
            TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask));

            TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
        }
Exemplo n.º 4
0
        /// <summary>
        /// init the static variables
        /// </summary>
        public static void Init()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate                           = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TPartnerServerLookups.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TPartnerServerLookups.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TPartnerServerLookups.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TPartnerServerLookups.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TPartnerServerLookups.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TFinanceServerLookupWebConnector.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriodDelegate    = @TAccountingPeriodsWebConnector.GetFirstDayOfAccountingPeriod;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate   = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;
            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;

            TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        static TCallForwarding()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate                   = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate            = @TPartnerServerLookups.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TFinanceServerLookups.GetCurrentPostingRangeDates;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate   = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;
        }
Exemplo n.º 6
0
        void CheckGLMPeriodEntry(int ALedgerNumber, int AYear, int APeriodNr, string AAccount,
            decimal cc1Base,
            decimal cc2Base,
            decimal cc3Base)
        {
            TGlmInfo glmInfo = new TGlmInfo(ALedgerNumber, AYear, AAccount);

            glmInfo.Reset();
            int intCnt = 0;
            bool blnFnd1 = false;
            bool blnFnd2 = false;
            bool blnFnd3 = false;

            TCacheable cache = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            Type dummy;
            ACostCentreTable costcentres = (ACostCentreTable)cache.GetCacheableTable(TCacheableFinanceTablesEnum.CostCentreList,
                string.Empty,
                false,
                ALedgerNumber,
                out dummy);

            while (glmInfo.MoveNext())
            {
//              TLogging.Log("glmInfo.CostCentreCode: " + glmInfo.CostCentreCode);

                TGlmpInfo glmpInfo = new TGlmpInfo(ALedgerNumber);
                glmpInfo.LoadBySequence(glmInfo.GlmSequence, APeriodNr);

                Assert.AreEqual(true,
                    glmpInfo.RowExists,
                    "we cannot find a glm period record for " + glmInfo.AccountCode + " / " + glmInfo.CostCentreCode);

                if (glmInfo.CostCentreCode.Equals("4301"))
                {
                    Assert.AreEqual(cc1Base, glmpInfo.ActualBase);
                    blnFnd1 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4302"))
                {
                    Assert.AreEqual(cc2Base, glmpInfo.ActualBase);
                    blnFnd2 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4303"))
                {
                    Assert.AreEqual(cc3Base, glmpInfo.ActualBase);
                    blnFnd3 = true;
                }

                if (((ACostCentreRow)costcentres.Rows.Find(new object[] { ALedgerNumber, glmInfo.CostCentreCode })).PostingCostCentreFlag)
                {
                    ++intCnt;
                }
            }

            Assert.AreEqual(3, intCnt, "3 posting cost centres ...");
            Assert.IsTrue(blnFnd1);
            Assert.IsTrue(blnFnd2);
            Assert.IsTrue(blnFnd3);
        }
Exemplo n.º 7
0
        } // Test_2YearEnds

        void CheckGLMEntry(int ALedgerNumber, int AYear, string AAccount,
                           decimal cc1Base, decimal cc1Closing,
                           decimal cc2Base, decimal cc2Closing,
                           decimal cc3Base, decimal cc3Closing)
        {
            TGlmInfo glmInfo = new TGlmInfo(ALedgerNumber, AYear, AAccount);

            glmInfo.Reset();
            int  intCnt  = 0;
            bool blnFnd1 = false;
            bool blnFnd2 = false;
            bool blnFnd3 = false;

            TCacheable       cache = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            Type             dummy;
            ACostCentreTable costcentres = (ACostCentreTable)cache.GetCacheableTable(TCacheableFinanceTablesEnum.CostCentreList,
                                                                                     string.Empty,
                                                                                     false,
                                                                                     ALedgerNumber,
                                                                                     out dummy);

            while (glmInfo.MoveNext())
            {
//              TLogging.Log("glmInfo.CostCentreCode: " + glmInfo.CostCentreCode);

                if (glmInfo.CostCentreCode.Equals("4301"))
                {
                    Assert.AreEqual(cc1Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
                    Assert.AreEqual(cc1Closing,
                                    glmInfo.ClosingPeriodActualBase,
                                    "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
                    blnFnd1 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4302"))
                {
                    Assert.AreEqual(cc2Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
                    Assert.AreEqual(cc2Closing,
                                    glmInfo.ClosingPeriodActualBase,
                                    "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
                    blnFnd2 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4303"))
                {
                    Assert.AreEqual(cc3Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");
                    Assert.AreEqual(cc3Closing,
                                    glmInfo.ClosingPeriodActualBase,
                                    "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");
                    blnFnd3 = true;
                }

                if (((ACostCentreRow)costcentres.Rows.Find(new object[] { ALedgerNumber, glmInfo.CostCentreCode })).PostingCostCentreFlag)
                {
                    ++intCnt;
                }
            }

            Assert.IsTrue(blnFnd1, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
            Assert.IsTrue(blnFnd2, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
            Assert.IsTrue(blnFnd3, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");

            Assert.AreEqual(3, intCnt, "CheckGLMEntry expects 3 posting cost centres ...");
        }
Exemplo n.º 8
0
        void CheckGLMEntry(int ALedgerNumber, int AYear, string AAccount,
            decimal cc1Base, decimal cc1Closing,
            decimal cc2Base, decimal cc2Closing,
            decimal cc3Base, decimal cc3Closing)
        {
            TGlmInfo glmInfo = new TGlmInfo(ALedgerNumber, AYear, AAccount);

            glmInfo.Reset();
            int intCnt = 0;
            bool blnFnd1 = false;
            bool blnFnd2 = false;
            bool blnFnd3 = false;

            TCacheable cache = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            Type dummy;
            ACostCentreTable costcentres = (ACostCentreTable)cache.GetCacheableTable(TCacheableFinanceTablesEnum.CostCentreList,
                string.Empty,
                false,
                ALedgerNumber,
                out dummy);

            while (glmInfo.MoveNext())
            {
//              TLogging.Log("glmInfo.CostCentreCode: " + glmInfo.CostCentreCode);

                if (glmInfo.CostCentreCode.Equals("4301"))
                {
                    Assert.AreEqual(cc1Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
                    Assert.AreEqual(cc1Closing,
                        glmInfo.ClosingPeriodActualBase,
                        "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
                    blnFnd1 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4302"))
                {
                    Assert.AreEqual(cc2Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
                    Assert.AreEqual(cc2Closing,
                        glmInfo.ClosingPeriodActualBase,
                        "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
                    blnFnd2 = true;
                }

                if (glmInfo.CostCentreCode.Equals("4303"))
                {
                    Assert.AreEqual(cc3Base, glmInfo.YtdActualBase, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");
                    Assert.AreEqual(cc3Closing,
                        glmInfo.ClosingPeriodActualBase,
                        "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");
                    blnFnd3 = true;
                }

                if (((ACostCentreRow)costcentres.Rows.Find(new object[] { ALedgerNumber, glmInfo.CostCentreCode })).PostingCostCentreFlag)
                {
                    ++intCnt;
                }
            }

            Assert.IsTrue(blnFnd1, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4301, " + AAccount + ")");
            Assert.IsTrue(blnFnd2, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4302, " + AAccount + ")");
            Assert.IsTrue(blnFnd3, "CheckGLMEntry (" + ALedgerNumber + ", " + AYear + ", 4303, " + AAccount + ")");

            Assert.AreEqual(3, intCnt, "CheckGLMEntry expects 3 posting cost centres ...");
        }
Exemplo n.º 9
0
        public static System.DateTime GetPeriodEndDate(Int32 ALedgerNumber, System.Int32 AYear, System.Int32 ADiffPeriod, System.Int32 APeriod)
        {
            System.Int32 RealYear = 0;
            System.Int32 RealPeriod = 0;
            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            DateTime ReturnValue = DateTime.Now;
            GetRealPeriod(ALedgerNumber, ADiffPeriod, AYear, APeriod, out RealPeriod, out RealYear);
            DataTable UntypedTable = CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.AccountingPeriodList,
                "",
                false,
                ALedgerNumber,
                out typeofTable);
            AAccountingPeriodTable CachedDataTable = (AAccountingPeriodTable)UntypedTable;
            CachedDataTable.DefaultView.RowFilter = AAccountingPeriodTable.GetAccountingPeriodNumberDBName() + " = " + RealPeriod;

            if (CachedDataTable.DefaultView.Count > 0)
            {
                ReturnValue = ((AAccountingPeriodRow)CachedDataTable.DefaultView[0].Row).PeriodEndDate;

                ALedgerTable Ledger = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                    "",
                    false,
                    ALedgerNumber,
                    out typeofTable);

                ReturnValue = ReturnValue.AddYears(RealYear - Ledger[0].CurrentFinancialYear);
            }

            return ReturnValue;
        }
Exemplo n.º 10
0
        public static DataTable GetAvailableGLYears(Int32 ALedgerNumber,
            System.Int32 ADiffPeriod,
            bool AIncludeNextYear,
            out String ADisplayMember, out String AValueMember)
        {
            ADisplayMember = "YearDate";
            AValueMember = "YearNumber";
            String YearEnd = "YearEnd";
            DataTable DatTable = new DataTable();
            DatTable.Columns.Add(AValueMember, typeof(System.Int32));
            DatTable.Columns.Add(ADisplayMember, typeof(String));
            DatTable.Columns.Add(YearEnd, typeof(String));
            DatTable.PrimaryKey = new DataColumn[] {
                DatTable.Columns[0]
            };

            System.Type TypeOfTable = null;
            TCacheable CachePopulator = new TCacheable();
            ALedgerTable LedgerTable = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out TypeOfTable);

            DateTime CurrentYearEnd = GetPeriodEndDate(
                ALedgerNumber,
                LedgerTable[0].CurrentFinancialYear,
                ADiffPeriod,
                LedgerTable[0].NumberOfAccountingPeriods);

            TDBTransaction ReadTransaction = null;
            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                ref ReadTransaction,
                delegate
                {
                    // add the years, which are retrieved by reading from the GL batch tables
                    string sql =
                        String.Format("SELECT DISTINCT {0} AS availYear " + " FROM PUB_{1} " + " WHERE {2} = " +
                            ALedgerNumber.ToString() + " ORDER BY 1 DESC",
                            ABatchTable.GetBatchYearDBName(),
                            ABatchTable.GetTableDBName(),
                            ABatchTable.GetLedgerNumberDBName());

                    DataTable BatchYearTable = DBAccess.GDBAccessObj.SelectDT(sql, "BatchYearTable", ReadTransaction);

                    foreach (DataRow row in BatchYearTable.Rows)
                    {
                        DataRow resultRow = DatTable.NewRow();
                        DateTime SelectableYear = CurrentYearEnd.AddYears(-1 * (LedgerTable[0].CurrentFinancialYear - Convert.ToInt32(row[0])));
                        resultRow[0] = row[0];
                        resultRow[1] = SelectableYear.ToString("yyyy");
                        resultRow[2] = SelectableYear.ToString("dd-MMM-yyyy");
                        DatTable.Rows.Add(resultRow);
                    }
                });

            // we should also check if the current year has been added, in case there are no batches yet
            if (DatTable.Rows.Find(LedgerTable[0].CurrentFinancialYear) == null)
            {
                DataRow resultRow = DatTable.NewRow();
                resultRow[0] = LedgerTable[0].CurrentFinancialYear;
                resultRow[1] = CurrentYearEnd.ToString("yyyy");
                resultRow[2] = CurrentYearEnd.ToString("dd-MMM-yyyy");
                DatTable.Rows.InsertAt(resultRow, 0);
            }

            if (AIncludeNextYear && (DatTable.Rows.Find(LedgerTable[0].CurrentFinancialYear + 1) == null))
            {
                DataRow resultRow = DatTable.NewRow();
                resultRow[0] = LedgerTable[0].CurrentFinancialYear + 1;
                resultRow[1] = CurrentYearEnd.AddYears(1).ToString("yyyy");
                resultRow[2] = CurrentYearEnd.ToString("dd-MMM-yyyy");
                DatTable.Rows.InsertAt(resultRow, 0);
            }

            return DatTable;
        }
Exemplo n.º 11
0
        public static bool GetRealPeriod(
            System.Int32 ALedgerNumber,
            System.Int32 ADiffPeriod,
            System.Int32 AYear,
            System.Int32 APeriod,
            out System.Int32 ARealPeriod,
            out System.Int32 ARealYear)
        {
            ARealPeriod = APeriod + ADiffPeriod;
            ARealYear = AYear;

            if (ADiffPeriod == 0)
            {
                return true;
            }

            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            ALedgerTable Ledger = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out typeofTable);

            // the period is in the last year
            // this treatment only applies to situations with different financial years.
            // in a financial year equals to the glm year, the period 0 represents the start balance
            if ((ADiffPeriod == 0) && (ARealPeriod == 0))
            {
                //do nothing
            }
            else if (ARealPeriod < 1)
            {
                ARealPeriod = Ledger[0].NumberOfAccountingPeriods + ARealPeriod;
                ARealYear = ARealYear - 1;
            }

            // forwarding periods are only allowed in the current year
            if ((ARealPeriod > Ledger[0].NumberOfAccountingPeriods) && (ARealYear != Ledger[0].CurrentFinancialYear))
            {
                ARealPeriod = ARealPeriod - Ledger[0].NumberOfAccountingPeriods;
                ARealYear = ARealYear + 1;
            }

            return true;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        static TCallForwarding()
        {
            // Set up Error Codes and Data Validation Delegates for a Client's AppDomain.
            // This setting-up makes use of the fact that this Method is called only once,
            // namely directly after the Client logged in successfully.
            ErrorCodeInventory.RegisteredTypes.Add(new Ict.Petra.Shared.PetraErrorCodes().GetType());

            TSharedValidationHelper.SharedGetDataDelegate = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate = @TPartnerServerLookups.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TFinanceServerLookups.GetCurrentPostingRangeDates;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;
            TGLPosting.PrintReportOnClientDelegate = @TReportingWebConnector.GenerateReportOnClient;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @CachePopulatorCommon.GetCacheableTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @CachePopulatorFinance.GetCacheableTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate = @CachePopulatorUnits.GetCacheableTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @CachePopulatorSysMan.GetCacheableTable;
        }
Exemplo n.º 13
0
        public static DataTable GetAvailableGiftYears(Int32 ALedgerNumber, out String ADisplayMember, out String AValueMember)
        {
            #region Validate Arguments

            if (ALedgerNumber <= 0)
            {
                throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
                            "Function:{0} - The Ledger number must be greater than 0!"),
                        Utilities.GetMethodName(true)), ALedgerNumber);
            }

            #endregion Validate Arguments

            ADisplayMember = "YearDate";
            AValueMember = "YearNumber";

            DataTable ReturnTable = new DataTable();
            ReturnTable.Columns.Add(AValueMember, typeof(System.Int32));
            ReturnTable.Columns.Add(ADisplayMember, typeof(String));
            ReturnTable.PrimaryKey = new DataColumn[] {
                ReturnTable.Columns[0]
            };

            System.Type TypeofTable = null;
            TCacheable CachePopulator = new TCacheable();

            ALedgerTable LedgerTable = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out TypeofTable);

            AAccountingPeriodTable AccountingPeriods = (AAccountingPeriodTable)CachePopulator.GetCacheableTable(
                TCacheableFinanceTablesEnum.AccountingPeriodList,
                "",
                false,
                ALedgerNumber,
                out TypeofTable);

            #region Validate Data

            if ((LedgerTable == null) || (LedgerTable.Count == 0))
            {
                throw new EFinanceSystemCacheableTableReturnedNoDataException(String.Format(Catalog.GetString(
                            "Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"),
                        Utilities.GetMethodName(true),
                        ALedgerNumber));
            }
            else if ((AccountingPeriods == null) || (AccountingPeriods.Count == 0))
            {
                throw new EFinanceSystemCacheableTableReturnedNoDataException(String.Format(Catalog.GetString(
                            "Function:{0} - Accounting Periods data for Ledger number {1} does not exist or could not be accessed!"),
                        Utilities.GetMethodName(true),
                        ALedgerNumber));
            }

            #endregion Validate Data

            AAccountingPeriodRow CurrentYearEndPeriod =
                (AAccountingPeriodRow)AccountingPeriods.Rows.Find(new object[] { ALedgerNumber, LedgerTable[0].NumberOfAccountingPeriods });
            DateTime CurrentYearEnd = CurrentYearEndPeriod.PeriodEndDate;

            TDBTransaction ReadTransaction = null;

            try
            {
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum,
                    ref ReadTransaction,
                    delegate
                    {
                        // add the years, which are retrieved by reading from the gift batch tables
                        string Sql =
                            String.Format("SELECT DISTINCT {0} AS availYear FROM PUB_{1} WHERE {2}={3} ORDER BY 1 DESC",
                                AGiftBatchTable.GetBatchYearDBName(),
                                AGiftBatchTable.GetTableDBName(),
                                AGiftBatchTable.GetLedgerNumberDBName(),
                                ALedgerNumber);

                        DataTable BatchYearTable = DBAccess.GDBAccessObj.SelectDT(Sql, "BatchYearTable", ReadTransaction);

                        foreach (DataRow row in BatchYearTable.Rows)
                        {
                            DataRow resultRow = ReturnTable.NewRow();
                            resultRow[0] = row[0];
                            resultRow[1] = CurrentYearEnd.AddYears(-1 * (LedgerTable[0].CurrentFinancialYear - Convert.ToInt32(
                                                                             row[0]))).ToShortDateString();
                            ReturnTable.Rows.Add(resultRow);
                        }
                    });

                // we should also check if the current year has been added, in case there are no gift batches yet
                if (ReturnTable.Rows.Find(LedgerTable[0].CurrentFinancialYear) == null)
                {
                    DataRow resultRow = ReturnTable.NewRow();
                    resultRow[0] = LedgerTable[0].CurrentFinancialYear;
                    resultRow[1] = CurrentYearEnd.ToShortDateString();
                    ReturnTable.Rows.InsertAt(resultRow, 0);
                }
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return ReturnTable;
        }
Exemplo n.º 14
0
        public static DataTable GetAvailableGiftYears(Int32 ALedgerNumber, out String ADisplayMember, out String AValueMember)
        {
            ADisplayMember = "YearDate";
            AValueMember = "YearNumber";

            DataTable ReturnTable = new DataTable();
            ReturnTable.Columns.Add(AValueMember, typeof(System.Int32));
            ReturnTable.Columns.Add(ADisplayMember, typeof(String));
            ReturnTable.PrimaryKey = new DataColumn[] {
                ReturnTable.Columns[0]
            };

            System.Type TypeofTable = null;
            TCacheable CachePopulator = new TCacheable();

            ALedgerTable LedgerTable = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out TypeofTable);

            AAccountingPeriodTable AccountingPeriods = (AAccountingPeriodTable)CachePopulator.GetCacheableTable(
                TCacheableFinanceTablesEnum.AccountingPeriodList,
                "",
                false,
                ALedgerNumber,
                out TypeofTable);

            AAccountingPeriodRow CurrentYearEndPeriod =
                (AAccountingPeriodRow)AccountingPeriods.Rows.Find(new object[] { ALedgerNumber, LedgerTable[0].NumberOfAccountingPeriods });
            DateTime CurrentYearEnd = CurrentYearEndPeriod.PeriodEndDate;

            TDBTransaction ReadTransaction = null;
            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref ReadTransaction,
                delegate
                {
                    // add the years, which are retrieved by reading from the gift batch tables
                    string Sql =
                        String.Format("SELECT DISTINCT {0} AS availYear FROM PUB_{1} WHERE {2}={3} ORDER BY 1 DESC",
                            AGiftBatchTable.GetBatchYearDBName(),
                            AGiftBatchTable.GetTableDBName(),
                            AGiftBatchTable.GetLedgerNumberDBName(),
                            ALedgerNumber);

                    DataTable BatchYearTable = DBAccess.GDBAccessObj.SelectDT(Sql, "BatchYearTable", ReadTransaction);

                    foreach (DataRow row in BatchYearTable.Rows)
                    {
                        DataRow resultRow = ReturnTable.NewRow();
                        resultRow[0] = row[0];
                        resultRow[1] = CurrentYearEnd.AddYears(-1 * (LedgerTable[0].CurrentFinancialYear - Convert.ToInt32(
                                                                         row[0]))).ToShortDateString();
                        ReturnTable.Rows.Add(resultRow);
                    }
                });

            // we should also check if the current year has been added, in case there are no gift batches yet
            if (ReturnTable.Rows.Find(LedgerTable[0].CurrentFinancialYear) == null)
            {
                DataRow resultRow = ReturnTable.NewRow();
                resultRow[0] = LedgerTable[0].CurrentFinancialYear;
                resultRow[1] = CurrentYearEnd.ToShortDateString();
                ReturnTable.Rows.InsertAt(resultRow, 0);
            }

            return ReturnTable;
        }
Exemplo n.º 15
0
        public static string IdentifyPartnerCostCentre(Int32 ALedgerNumber, Int64 AFieldNumber)
        {
            #region Validate Arguments

            if (ALedgerNumber <= 0)
            {
                throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
                            "Function:{0} - The Ledger number must be greater than 0!"),
                        Utilities.GetMethodName(true)), ALedgerNumber);
            }
            else if (AFieldNumber < 0)
            {
                throw new ArgumentException(String.Format(Catalog.GetString("Function:{0} - The Field number cannot be negative!"),
                        Utilities.GetMethodName(true)));
            }

            #endregion Validate Arguments

            TCacheable CachePopulator = new TCacheable();
            Type typeOfTable;

            AValidLedgerNumberTable ValidLedgerNumbers = (AValidLedgerNumberTable)
                                                         CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.ValidLedgerNumberList,
                "",
                false,
                out typeOfTable);

            AValidLedgerNumberRow ValidLedgerNumberRow = null;

            if (ValidLedgerNumbers != null)
            {
                ValidLedgerNumberRow = (AValidLedgerNumberRow)ValidLedgerNumbers.Rows.Find(new object[] { ALedgerNumber, AFieldNumber });
            }

            if (ValidLedgerNumberRow != null)
            {
                return ValidLedgerNumberRow.CostCentreCode;
            }
            else
            {
                return TGLTransactionWebConnector.GetStandardCostCentre(ALedgerNumber);
            }
        }
Exemplo n.º 16
0
        public static string GetReportingCostCentres(int ALedgerNumber, String ASummaryCostCentreCode, string ARemoveCostCentresFromList)
        {
            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            ACostCentreTable CachedDataTable = (ACostCentreTable)CachePopulator.GetCacheableTable(
                TCacheableFinanceTablesEnum.CostCentreList,
                "",
                false,
                ALedgerNumber,
                out typeofTable);

            CachedDataTable.DefaultView.Sort = ACostCentreTable.GetCostCentreToReportToDBName();

            List <string>Result = new List <string>();

            GetReportingCostCentres(CachedDataTable, Result, ASummaryCostCentreCode);

            List <string>IgnoreCostCentres = new List <string>();

            GetReportingCostCentres(CachedDataTable, IgnoreCostCentres, ARemoveCostCentresFromList);

            foreach (string s in IgnoreCostCentres)
            {
                if (Result.Contains(s))
                {
                    Result.Remove(s);
                }
            }

            return StringHelper.StrMerge(Result.ToArray(), ',');
        }
        private static bool TrainBankStatementsLastMonthThread(String ASessionID, Int32 AClientID, Int32 ALedgerNumber, DateTime AToday)
        {
            TSession.InitThread(ASessionID);

            DomainManager.GClientID = AClientID;
            string MyClientID = DomainManager.GClientID.ToString();

            TProgressTracker.InitProgressTracker(MyClientID,
                Catalog.GetString("Training last months bank statements"),
                30);

            DateTime startDateThisMonth = new DateTime(AToday.Year, AToday.Month, 1);
            DateTime endDateLastMonth = startDateThisMonth.AddDays(-1);
            DateTime startDateLastMonth = new DateTime(endDateLastMonth.Year, endDateLastMonth.Month, 1);

            // for debugging the training:
            //startDateLastMonth = new DateTime(2015,10,5);
            //startDateThisMonth = startDateLastMonth.AddDays(1);

            // get all bank accounts
            TCacheable CachePopulator = new TCacheable();
            Type typeofTable;
            GLSetupTDSAAccountTable accounts = (GLSetupTDSAAccountTable)CachePopulator.GetCacheableTable(
                TCacheableFinanceTablesEnum.AccountList,
                "",
                false,
                ALedgerNumber,
                out typeofTable);

            foreach (GLSetupTDSAAccountRow account in accounts.Rows)
            {
                // at OM Germany we don't have the bank account flags set
                if ((!account.IsBankAccountFlagNull() && (account.BankAccountFlag == true))
                    || (!account.IsCashAccountFlagNull() && (account.CashAccountFlag == true))
                    )
                {
                    string BankAccountCode = account.AccountCode;

                    DateTime counter = startDateLastMonth;

                    while (!counter.Equals(startDateThisMonth))
                    {
                        TProgressTracker.SetCurrentState(
                            MyClientID,
                            String.Format(Catalog.GetString("Training {0} {1}"), BankAccountCode, counter.ToShortDateString()),
                            counter.Day);

                        // TODO: train only one bank statement per date and bank account?
                        TrainBankStatement(ALedgerNumber, counter, BankAccountCode);
                        counter = counter.AddDays(1);
                    }
                }
            }

            TProgressTracker.FinishJob(MyClientID);

            return true;
        }
Exemplo n.º 18
0
        public static string CreateAnnualGiftReceipts(Int32 ALedgerNumber,
            DateTime AStartDate,
            DateTime AEndDate,
            string AHTMLTemplate,
            bool ADeceasedFirst = false,
            string AExtract = null,
            Int64 ADonorKey = 0)
        {
            string ResultDocument = string.Empty;

            TLanguageCulture.LoadLanguageAndCulture();

            // get BaseCurrency
            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            ALedgerTable LedgerTable = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                "",
                false,
                ALedgerNumber,
                out typeofTable);
            string BaseCurrency = LedgerTable[0].BaseCurrency;

            TDBTransaction Transaction = null;

            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted,
                ref Transaction,
                delegate
                {
                    try
                    {
                        // get the local country code
                        string LocalCountryCode = TAddressTools.GetCountryCodeFromSiteLedger(Transaction);
                        DataTable donorkeys = new DataTable();
                        string SqlStmt = "";

                        if (ADonorKey != 0)
                        {
                            TPartnerClass Class;
                            string ShortName;
                            TPartnerServerLookups.GetPartnerShortName(ADonorKey, out ShortName, out Class);

                            donorkeys.Columns.Add(new DataColumn("DonorKey"));
                            donorkeys.Columns.Add(new DataColumn("DonorName"));
                            DataRow SingleRow = donorkeys.NewRow();
                            SingleRow[0] = ADonorKey;
                            SingleRow[1] = ShortName;

                            donorkeys.Rows.Add(SingleRow);
                        }
                        else
                        {
                            SortedList <string, string>Defines = new SortedList <string, string>();

                            if (!string.IsNullOrEmpty(AExtract))
                            {
                                Defines.Add("BYEXTRACT", string.Empty);
                            }

                            // first get all donors in the given date range
                            SqlStmt = TDataBase.ReadSqlFile("Gift.ReceiptPrinting.GetDonors.sql", Defines);

                            OdbcParameter[] parameters = new OdbcParameter[4];
                            parameters[0] = new OdbcParameter("LedgerNumber", OdbcType.Int);
                            parameters[0].Value = ALedgerNumber;
                            parameters[1] = new OdbcParameter("StartDate", OdbcType.Date);
                            parameters[1].Value = AStartDate;
                            parameters[2] = new OdbcParameter("EndDate", OdbcType.Date);
                            parameters[2].Value = AEndDate;
                            parameters[3] = new OdbcParameter("Extract", OdbcType.VarChar);
                            parameters[3].Value = AExtract;

                            donorkeys = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "DonorKeys", Transaction, parameters);

                            // put deceased partner's at the front (still sorted alphabetically)
                            if (ADeceasedFirst)
                            {
                                // create a new datatable with same structure as donorkeys
                                DataTable temp = donorkeys.Clone();
                                temp.Clear();

                                // add deceased donors to the temp table and delete from donorkeys
                                for (int i = 0; i < donorkeys.Rows.Count; i++)
                                {
                                    if (SharedTypes.StdPartnerStatusCodeStringToEnum(donorkeys.Rows[i][2].ToString()) ==
                                        TStdPartnerStatusCode.spscDIED)
                                    {
                                        temp.Rows.Add((object[])donorkeys.Rows[i].ItemArray.Clone());
                                        donorkeys.Rows[i].Delete();
                                    }
                                }

                                // add remaining partners to temp table
                                donorkeys.AcceptChanges();
                                temp.Merge(donorkeys);

                                donorkeys = temp;
                            }
                        }

                        SqlStmt = TDataBase.ReadSqlFile("Gift.ReceiptPrinting.GetDonationsOfDonor.sql");

                        foreach (DataRow donorrow in donorkeys.Rows)
                        {
                            Int64 donorKey = Convert.ToInt64(donorrow[0]);
                            string donorName = donorrow[1].ToString();

                            OdbcParameter[] parameters = new OdbcParameter[4];
                            parameters[0] = new OdbcParameter("LedgerNumber", OdbcType.Int);
                            parameters[0].Value = ALedgerNumber;
                            parameters[1] = new OdbcParameter("StartDate", OdbcType.Date);
                            parameters[1].Value = AStartDate;
                            parameters[2] = new OdbcParameter("EndDate", OdbcType.Date);
                            parameters[2].Value = AEndDate;
                            parameters[3] = new OdbcParameter("DonorKey", OdbcType.BigInt);
                            parameters[3].Value = donorKey;

                            DataTable donations = DBAccess.GDBAccessObj.SelectDT(SqlStmt, "Donations", Transaction, parameters);

                            if (donations.Rows.Count > 0)
                            {
                                string letter =
                                    FormatLetter(donorKey, donorName, donations, BaseCurrency, AHTMLTemplate, LocalCountryCode, Transaction);

                                if (TFormLettersTools.AttachNextPage(ref ResultDocument, letter))
                                {
                                    // TODO: store somewhere that the receipt has been printed?
                                    // TODO also store each receipt with the donor in document management, and in contact management?
                                }
                            }
                        }

                        TFormLettersTools.CloseDocument(ref ResultDocument);
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("Error in CreateAnnualGiftReceipts: " + e.Message);
                        throw e;
                    }
                });

            return ResultDocument;
        }
Exemplo n.º 19
0
        public static System.DateTime GetPeriodStartDate(
            System.Int32 ALedgerNumber,
            System.Int32 AYear,
            System.Int32 ADiffPeriod,
            System.Int32 APeriod)
        {
            System.Int32 RealYear = 0;
            System.Int32 RealPeriod = 0;
            System.Type typeofTable = null;
            TCacheable CachePopulator = new TCacheable();
            DateTime ReturnValue = DateTime.Now;
            GetRealPeriod(ALedgerNumber, ADiffPeriod, AYear, APeriod, out RealPeriod, out RealYear);
            DataTable CachedDataTable = CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.AccountingPeriodList,
                "",
                false,
                ALedgerNumber,
                out typeofTable);
            string whereClause = AAccountingPeriodTable.GetLedgerNumberDBName() + " = " + ALedgerNumber.ToString() + " and " +
                                 AAccountingPeriodTable.GetAccountingPeriodNumberDBName() + " = " + RealPeriod.ToString();
            DataRow[] filteredRows = CachedDataTable.Select(whereClause);

            if (filteredRows.Length > 0)
            {
                ReturnValue = ((AAccountingPeriodRow)filteredRows[0]).PeriodStartDate;

                ALedgerTable Ledger = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                    "",
                    false,
                    ALedgerNumber,
                    out typeofTable);

                ReturnValue = ReturnValue.AddYears(RealYear - Ledger[0].CurrentFinancialYear);
            }

            return ReturnValue;
        }
Exemplo n.º 20
0
        public static string IdentifyPartnerCostCentre(Int32 ALedgerNumber, Int64 AFieldNumber)
        {
            TCacheable CachePopulator = new TCacheable();
            Type typeOfTable;
            AValidLedgerNumberTable ValidLedgerNumbers = (AValidLedgerNumberTable)
                                                         CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.ValidLedgerNumberList,
                "",
                false,
                out typeOfTable);

            AValidLedgerNumberRow ValidLedgerNumberRow = (AValidLedgerNumberRow)
                                                         ValidLedgerNumbers.Rows.Find(new object[] { ALedgerNumber, AFieldNumber });

            if (ValidLedgerNumberRow != null)
            {
                return ValidLedgerNumberRow.CostCentreCode;
            }
            else
            {
                return TGLTransactionWebConnector.GetStandardCostCentre(ALedgerNumber);
            }
        }
Exemplo n.º 21
0
        public static GLSetupTDS LoadAccountHierarchies(Int32 ALedgerNumber)
        {
            #region Validate Arguments

            if (ALedgerNumber <= 0)
            {
                throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
                            "Function:{0} - The Ledger number must be greater than 0!"),
                        Utilities.GetMethodName(true)), ALedgerNumber);
            }

            #endregion Validate Arguments

            GLSetupTDS MainDS = new GLSetupTDS();

            // create template for AGeneralLedgerMaster
            TCacheable CachePopulator = new TCacheable();

            System.Type TypeofTable = null;

            TDBTransaction Transaction = null;

            try
            {
                ALedgerTable ledger = (ALedgerTable)CachePopulator.GetCacheableTable(TCacheableFinanceTablesEnum.LedgerDetails,
                    "",
                    false,
                    ALedgerNumber,
                    out TypeofTable);

                #region Validate Data

                if ((ledger == null) || (ledger.Count == 0))
                {
                    throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
                                "Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"),
                            Utilities.GetMethodName(true),
                            ALedgerNumber));
                }

                #endregion Validate Data

                int year = ledger[0].CurrentFinancialYear;
                string costCentreCode = "[" + ALedgerNumber + "]";

                AGeneralLedgerMasterRow template = new AGeneralLedgerMasterTable().NewRowTyped(false);
                template.LedgerNumber = ALedgerNumber;
                template.Year = year;
                template.CostCentreCode = costCentreCode;

                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                    TEnforceIsolationLevel.eilMinimum,
                    ref Transaction,
                    delegate
                    {
                        ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);
                        ACurrencyAccess.LoadAll(MainDS, Transaction);
                        AAccountHierarchyAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AAccountHierarchyDetailAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AAccountAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AAccountPropertyAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AAnalysisTypeAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AAnalysisAttributeAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AFreeformAnalysisAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AFeesReceivableAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AFeesPayableAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                        AGeneralLedgerMasterAccess.LoadUsingTemplate(MainDS, template, Transaction);
                        ASuspenseAccountAccess.LoadViaALedger(MainDS, ALedgerNumber, Transaction);
                    });

                // set Account BankAccountFlag if there exists a property
                foreach (AAccountPropertyRow accProp in MainDS.AAccountProperty.Rows)
                {
                    if ((accProp.PropertyCode == MFinanceConstants.ACCOUNT_PROPERTY_BANK_ACCOUNT) && (accProp.PropertyValue == "true"))
                    {
                        MainDS.AAccount.DefaultView.RowFilter = String.Format("{0}='{1}'",
                            AAccountTable.GetAccountCodeDBName(),
                            accProp.AccountCode);
                        GLSetupTDSAAccountRow acc = (GLSetupTDSAAccountRow)MainDS.AAccount.DefaultView[0].Row;
                        acc.BankAccountFlag = true;
                        MainDS.AAccount.DefaultView.RowFilter = "";
                    }
                }

                // set Account SuspenseAccountFlag if there exists a property
                foreach (ASuspenseAccountRow suspenseAccountRow in MainDS.ASuspenseAccount.Rows)
                {
                    GLSetupTDSAAccountRow AccountRow =
                        (GLSetupTDSAAccountRow)MainDS.AAccount.Rows.Find(new object[] { ALedgerNumber, suspenseAccountRow.SuspenseAccountCode });
                    AccountRow.SuspenseAccountFlag = true;
                }

                // Don't include any AnalysisType for which there are no values set
                MainDS.AFreeformAnalysis.DefaultView.Sort = AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(); // "a_analysis_type_code_c";

                foreach (AAnalysisTypeRow typeRow in MainDS.AAnalysisType.Rows)
                {
                    Int32 Idx = MainDS.AFreeformAnalysis.DefaultView.Find(typeRow.AnalysisTypeCode);

                    if (Idx < 0)
                    {
                        typeRow.Delete();
                    }
                }

                // add the YTD Actuals to each account
                foreach (AGeneralLedgerMasterRow generalLedgerMasterRow in MainDS.AGeneralLedgerMaster.Rows)
                {
                    GLSetupTDSAAccountRow AccountRow =
                        (GLSetupTDSAAccountRow)MainDS.AAccount.Rows.Find(new object[] { ALedgerNumber, generalLedgerMasterRow.AccountCode });
                    AccountRow.YtdActualBase = generalLedgerMasterRow.YtdActualBase;

                    if (AccountRow.ForeignCurrencyFlag)
                    {
                        AccountRow.YtdActualForeign = generalLedgerMasterRow.YtdActualForeign;
                    }
                }

                // Accept row changes here so that the Client gets 'unmodified' rows
                MainDS.AcceptChanges();

                // Remove all Tables that were not filled with data before remoting them.
                MainDS.RemoveEmptyTables();
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return MainDS;
        }