Пример #1
0
        private void RunRevaluationIntern()
        {
            Boolean        NewTransaction;
            TDBTransaction DBTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTransaction);
            AAccountTable  accountTable  = new AAccountTable();

            AAccountRow accountTemplate = (AAccountRow)accountTable.NewRowTyped(false);

            accountTemplate.LedgerNumber        = F_LedgerNum;
            accountTemplate.AccountActiveFlag   = true;
            accountTemplate.ForeignCurrencyFlag = true;
            accountTable = AAccountAccess.LoadUsingTemplate(accountTemplate, DBTransaction);

            AGeneralLedgerMasterTable glmTable    = new AGeneralLedgerMasterTable();
            AGeneralLedgerMasterRow   glmTemplate = (AGeneralLedgerMasterRow)glmTable.NewRowTyped(false);

            glmTemplate.LedgerNumber = F_LedgerNum;
            glmTemplate.Year         = F_FinancialYear;
            glmTable = AGeneralLedgerMasterAccess.LoadUsingTemplate(glmTemplate, DBTransaction);

            if (NewTransaction)
            {
                DBAccess.GDBAccessObj.RollbackTransaction();
            }

            if (accountTable.Rows.Count == 0) // not using any foreign accounts?
            {
                return;
            }

            for (int iCnt = 0; iCnt < accountTable.Rows.Count; ++iCnt)
            {
                AAccountRow accountRow = (AAccountRow)accountTable[iCnt];

                for (int kCnt = 0; kCnt < F_CurrencyCode.Length; ++kCnt)
                {
                    // AForeignCurrency[] and ANewExchangeRate[] shall support a value
                    // for this account resp. for the currency of the account
                    if (accountRow.ForeignCurrencyCode.Equals(F_CurrencyCode[kCnt]))
                    {
                        glmTable.DefaultView.RowFilter = "a_account_code_c = '" + accountRow.AccountCode + "'";

                        if (glmTable.DefaultView.Count > 0)
                        {
                            RevaluateAccount(glmTable.DefaultView, F_ExchangeRate[kCnt]);
                        }
                    }
                }
            }

            CloseRevaluationAccountingBatch();
        }
Пример #2
0
        public static GLSetupTDS LoadLedgerSettings(Int32 ALedgerNumber, out DateTime ACalendarStartDate,
            out bool ACurrencyChangeAllowed, out bool ACalendarChangeAllowed)
        {
            #region Validate Arguments

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

            #endregion Validate Arguments

            ACalendarStartDate = DateTime.MinValue;
            ACurrencyChangeAllowed = false;
            ACalendarChangeAllowed = false;

            DateTime CalendarStartDate = ACalendarStartDate;
            bool CurrencyChangeAllowed = ACurrencyChangeAllowed;

            GLSetupTDS MainDS = new GLSetupTDS();

            TDBTransaction Transaction = null;

            try
            {
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                    TEnforceIsolationLevel.eilMinimum,
                    ref Transaction,
                    delegate
                    {
                        ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);
                        AAccountingSystemParameterAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);
                        ALedgerInitFlagAccess.LoadViaALedger(MainDS, ALedgerNumber, null, Transaction);

                        #region Validate Data

                        //ALedgerInitFlag is optional so no need to check
                        //TODO confirm this

                        if ((MainDS.ALedger == null) || (MainDS.ALedger.Count == 0))
                        {
                            throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
                                        "Ledger Data for Ledger number {0} does not exist!"), ALedgerNumber));
                        }
                        else if ((MainDS.AAccountingSystemParameter == null) || (MainDS.AAccountingSystemParameter.Count == 0))
                        {
                            throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
                                        "AccountingSystemParameter Data for Ledger number {0} does not exist!"), ALedgerNumber));
                        }

                        #endregion Validate Data

                        // retrieve calendar start date (start date of financial year)
                        AAccountingPeriodTable CalendarTable = AAccountingPeriodAccess.LoadByPrimaryKey(ALedgerNumber, 1, Transaction);

                        if (CalendarTable.Count > 0)
                        {
                            CalendarStartDate = ((AAccountingPeriodRow)CalendarTable.Rows[0]).PeriodStartDate;
                        }

                        // now check if currency change would be allowed
                        CurrencyChangeAllowed = true;

                        if ((AJournalAccess.CountViaALedger(ALedgerNumber, Transaction) > 0)
                            || (AGiftBatchAccess.CountViaALedger(ALedgerNumber, Transaction) > 0))
                        {
                            // don't allow currency change if journals or gift batches exist
                            CurrencyChangeAllowed = false;
                        }

                        if (AGiftBatchAccess.CountViaALedger(ALedgerNumber, Transaction) > 0)
                        {
                            // don't allow currency change if journals exist
                            CurrencyChangeAllowed = false;
                        }

                        if (CurrencyChangeAllowed)
                        {
                            // don't allow currency change if there are foreign currency accounts for this ledger
                            AAccountTable TemplateTable;
                            AAccountRow TemplateRow;
                            StringCollection TemplateOperators;

                            TemplateTable = new AAccountTable();
                            TemplateRow = TemplateTable.NewRowTyped(false);
                            TemplateRow.LedgerNumber = ALedgerNumber;
                            TemplateRow.ForeignCurrencyFlag = true;
                            TemplateOperators = new StringCollection();
                            TemplateOperators.Add("=");

                            if (AAccountAccess.CountUsingTemplate(TemplateRow, TemplateOperators, Transaction) > 0)
                            {
                                CurrencyChangeAllowed = false;
                            }
                        }
                    });

                ACalendarStartDate = CalendarStartDate;
                ACurrencyChangeAllowed = CurrencyChangeAllowed;
                // now check if calendar change would be allowed
                ACalendarChangeAllowed = IsCalendarChangeAllowed(ALedgerNumber);

                // 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 (EFinanceSystemDataTableReturnedNoDataException ex)
            {
                throw new EFinanceSystemDataTableReturnedNoDataException(String.Format("Function:{0} - {1}",
                        Utilities.GetMethodName(true),
                        ex.Message));
            }
            catch (Exception ex)
            {
                TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}",
                        Utilities.GetMethodSignature(),
                        Environment.NewLine,
                        ex.Message));
                throw ex;
            }

            return MainDS;
        }
Пример #3
0
        public static GLSetupTDS LoadLedgerSettings(Int32 ALedgerNumber, out DateTime ACalendarStartDate,
            out bool ACurrencyChangeAllowed, out bool ACalendarChangeAllowed)
        {
            ACalendarStartDate = DateTime.MinValue;
            ACurrencyChangeAllowed = false;
            ACalendarChangeAllowed = false;

            DateTime CalendarStartDate = ACalendarStartDate;
            bool CurrencyChangeAllowed = ACurrencyChangeAllowed;

            GLSetupTDS MainDS = new GLSetupTDS();

            TDBTransaction Transaction = null;
            DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                TEnforceIsolationLevel.eilMinimum,
                ref Transaction,
                delegate
                {
                    ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);
                    AAccountingSystemParameterAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, Transaction);
                    ALedgerInitFlagAccess.LoadViaALedger(MainDS, ALedgerNumber, null, Transaction);

                    // retrieve calendar start date (start date of financial year)
                    AAccountingPeriodTable CalendarTable = AAccountingPeriodAccess.LoadByPrimaryKey(ALedgerNumber, 1, Transaction);

                    if (CalendarTable.Count > 0)
                    {
                        CalendarStartDate = ((AAccountingPeriodRow)CalendarTable.Rows[0]).PeriodStartDate;
                    }

                    // now check if currency change would be allowed
                    CurrencyChangeAllowed = true;

                    if ((AJournalAccess.CountViaALedger(ALedgerNumber, Transaction) > 0)
                        || (AGiftBatchAccess.CountViaALedger(ALedgerNumber, Transaction) > 0))
                    {
                        // don't allow currency change if journals or gift batches exist
                        CurrencyChangeAllowed = false;
                    }

                    if (AGiftBatchAccess.CountViaALedger(ALedgerNumber, Transaction) > 0)
                    {
                        // don't allow currency change if journals exist
                        CurrencyChangeAllowed = false;
                    }

                    if (CurrencyChangeAllowed)
                    {
                        // don't allow currency change if there are foreign currency accounts for this ledger
                        AAccountTable TemplateTable;
                        AAccountRow TemplateRow;
                        StringCollection TemplateOperators;

                        TemplateTable = new AAccountTable();
                        TemplateRow = TemplateTable.NewRowTyped(false);
                        TemplateRow.LedgerNumber = ALedgerNumber;
                        TemplateRow.ForeignCurrencyFlag = true;
                        TemplateOperators = new StringCollection();
                        TemplateOperators.Add("=");

                        if (AAccountAccess.CountUsingTemplate(TemplateRow, TemplateOperators, Transaction) > 0)
                        {
                            CurrencyChangeAllowed = false;
                        }
                    }
                });

            ACalendarStartDate = CalendarStartDate;
            ACurrencyChangeAllowed = CurrencyChangeAllowed;
            // now check if calendar change would be allowed
            ACalendarChangeAllowed = IsCalendarChangeAllowed(ALedgerNumber);

            // 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();

            return MainDS;
        }