Exemplo n.º 1
0
        /// <summary>
        /// Used for the validation of Analysis Attributes
        /// </summary>
        /// <param name="ATransactionNumber"></param>
        /// <param name="AAccountCode"></param>
        /// <param name="AGLBatchDS"></param>
        /// <param name="AValueRequiredForType"></param>
        /// <returns></returns>
        public bool AccountRecurringAnalysisAttributesValuesExist(int ATransactionNumber,
                                                                  string AAccountCode,
                                                                  GLBatchTDS AGLBatchDS,
                                                                  out String AValueRequiredForType)
        {
            AValueRequiredForType = string.Empty;

            if (string.IsNullOrEmpty(AAccountCode) || (AGLBatchDS.ATransAnalAttrib.DefaultView.Count == 0))
            {
                return(true);
            }

            StringCollection RequiredAnalAttrCodes = TRemote.MFinance.Setup.WebConnectors.RequiredAnalysisAttributesForAccount(FLedgerNumber,
                                                                                                                               AAccountCode, false);

            string AnalysisCodeFilterValues = TAnalysisAttributes.ConvertStringCollectionToCSV(RequiredAnalAttrCodes, "'");

            DataView analAttrib = new DataView(AGLBatchDS.ARecurringTransAnalAttrib);

            analAttrib.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6} IN ({7})",
                                                 ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                 FBatchNumber,
                                                 ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                 FJournalNumber,
                                                 ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                 ATransactionNumber,
                                                 ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName(),
                                                 AnalysisCodeFilterValues);

            foreach (DataRowView drv in analAttrib)
            {
                ARecurringTransAnalAttribRow rw = (ARecurringTransAnalAttribRow)drv.Row;

                string analysisCode = rw.AnalysisTypeCode;

                if (TRemote.MFinance.Setup.WebConnectors.AccountAnalysisAttributeRequiresValues(FLedgerNumber, analysisCode, false))
                {
                    if (rw.IsAnalysisAttributeValueNull() || (rw.AnalysisAttributeValue == string.Empty))
                    {
                        AValueRequiredForType = rw.AnalysisTypeCode;
                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Undo all changes to the specified batch ready to cancel it.
        ///  This avoids unecessary validation errors when cancelling.
        /// </summary>
        /// <param name="ACurrentBatch"></param>
        /// <param name="AJournalToDelete"></param>
        /// <param name="ARedisplay"></param>
        public void PrepareJournalDataForDeleting(Int32 ACurrentBatch, Int32 AJournalToDelete, Boolean ARedisplay)
        {
            //This code will only be called when the Batch tab is active.

            DataView JournalDV   = new DataView(FMainDS.ARecurringJournal);
            DataView TransDV     = new DataView(FMainDS.ARecurringTransaction);
            DataView TransAnalDV = new DataView(FMainDS.ARecurringTransAnalAttrib);

            JournalDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                ARecurringJournalTable.GetBatchNumberDBName(),
                                                ACurrentBatch,
                                                ARecurringJournalTable.GetJournalNumberDBName(),
                                                AJournalToDelete);

            TransDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                              ARecurringTransactionTable.GetBatchNumberDBName(),
                                              ACurrentBatch,
                                              ARecurringTransactionTable.GetJournalNumberDBName(),
                                              AJournalToDelete);

            TransAnalDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                                  ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                  ACurrentBatch,
                                                  ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                  AJournalToDelete);

            //Work from lowest level up
            if (TransAnalDV.Count > 0)
            {
                TransAnalDV.Sort = String.Format("{0}, {1}, {2}",
                                                 ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                 ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                 ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName());

                foreach (DataRowView drv in TransAnalDV)
                {
                    ARecurringTransAnalAttribRow transAnalRow = (ARecurringTransAnalAttribRow)drv.Row;

                    if (transAnalRow.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (transAnalRow.RowState != DataRowState.Unchanged)
                    {
                        transAnalRow.RejectChanges();
                    }
                }
            }

            if (TransDV.Count > 0)
            {
                TransDV.Sort = String.Format("{0}, {1}",
                                             ARecurringTransactionTable.GetJournalNumberDBName(),
                                             ARecurringTransactionTable.GetTransactionNumberDBName());

                foreach (DataRowView drv in TransDV)
                {
                    ARecurringTransactionRow transRow = (ARecurringTransactionRow)drv.Row;

                    if (transRow.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (transRow.RowState != DataRowState.Unchanged)
                    {
                        transRow.RejectChanges();
                    }
                }
            }

            if (JournalDV.Count > 0)
            {
                GLBatchTDSARecurringJournalRow journalRow = (GLBatchTDSARecurringJournalRow)JournalDV[0].Row;

                //No need to check for Added state as new batches are always saved
                // on creation

                if (journalRow.RowState != DataRowState.Unchanged)
                {
                    journalRow.RejectChanges();
                }

                if (ARedisplay)
                {
                    ShowDetails(journalRow);
                }
            }

            if (TransDV.Count == 0)
            {
                //Load all related data for batch ready to delete/cancel
                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringTransactionAndRelatedTablesForJournal(FLedgerNumber, ACurrentBatch,
                                                                                                                    AJournalToDelete));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// load the transactions into the grid
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <param name="AJournalNumber"></param>
        /// <param name="ATransactionNumber"></param>
        public void LoadAttributes(Int32 ALedgerNumber, Int32 ABatchNumber, Int32 AJournalNumber, Int32 ATransactionNumber)
        {
            //Check if the same batch and journal is selected, so no need to apply filter
            if ((FLedgerNumber == ALedgerNumber) && (FBatchNumber == ABatchNumber) && (FJournalNumber == AJournalNumber) &&
                (FTransactionNumber == ATransactionNumber) && (FMainDS.ATransAnalAttrib.DefaultView.Count > 0))
            {
                GetDataFromControls();
                return;
            }

            FLedgerNumber                = ALedgerNumber;
            FBatchNumber                 = ABatchNumber;
            FJournalNumber               = AJournalNumber;
            FTransactionNumber           = ATransactionNumber;
            FPreviouslySelectedDetailRow = null;

            //This is always false for recurring batches, as need to allow the showing of old data.
            FActiveOnly = false;

            if (!cmbDetailAnalysisAttributeValue.Enabled)
            {
                cmbDetailAnalysisAttributeValue.Enabled = true;
            }

            // only load from server if there are no attributes loaded yet for this journal
            // otherwise we would overwrite attributes that have already been modified

            FMainDS.ARecurringTransAnalAttrib.DefaultView.RowFilter = string.Empty;
            FMainDS.ARecurringTransAnalAttrib.DefaultView.Sort      = StringHelper.StrMerge(TTypedDataTable.GetPrimaryKeyColumnStringList(
                                                                                                ARecurringTransactionTable.TableId), ',');

            if (FMainDS.ARecurringTransAnalAttrib.DefaultView.Find(new object[] { FLedgerNumber, FBatchNumber, FJournalNumber,
                                                                                  FTransactionNumber }) == -1)
            {
                FMainDS.ARecurringTransAnalAttrib.Clear();
                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringTransAnalAttrib(ALedgerNumber, ABatchNumber, AJournalNumber,
                                                                                              ATransactionNumber));
            }

            CheckFCacheInitialised();

            FMainDS.ARecurringTransAnalAttrib.DefaultView.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5}",
                                                                                    ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                                                    FBatchNumber,
                                                                                    ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                                                    FJournalNumber,
                                                                                    ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                                                    FTransactionNumber);

            FMainDS.ARecurringTransAnalAttrib.DefaultView.Sort = String.Format("{0} ASC",
                                                                               ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName()
                                                                               );

            grdDetails.DataSource = null;
            grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ARecurringTransAnalAttrib.DefaultView);

            FMainDS.ARecurringTransAnalAttrib.DefaultView.AllowNew = false;

            if (FMainDS.ARecurringTransAnalAttrib.DefaultView.Count > 0)
            {
                SelectRowInGrid(1);
                pnlDetails.Enabled = !FPetraUtilsObject.DetailProtectedMode && !pnlDetailsProtected;
                UpdateLabels();
            }
            else
            {
                ClearControls();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AGLBatchDS"></param>
        /// <param name="ATransactionNumber"></param>
        /// <param name="AAnalysisCodeFilterValues"></param>
        public void SetRecurringTransAnalAttributeDefaultView(GLBatchTDS AGLBatchDS,
                                                              Int32 ATransactionNumber         = 0,
                                                              String AAnalysisCodeFilterValues = "")
        {
            if (FBatchNumber != -1)
            {
                if (ATransactionNumber > 0)
                {
                    if (AAnalysisCodeFilterValues.Length > 0)
                    {
                        AGLBatchDS.ARecurringTransAnalAttrib.DefaultView.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6} IN ({7})",
                                                                                                   ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                                                                   FBatchNumber,
                                                                                                   ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                                                                   FJournalNumber,
                                                                                                   ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                                                                   ATransactionNumber,
                                                                                                   ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName(),
                                                                                                   AAnalysisCodeFilterValues);
                    }
                    else
                    {
                        AGLBatchDS.ARecurringTransAnalAttrib.DefaultView.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5}",
                                                                                                   ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                                                                   FBatchNumber,
                                                                                                   ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                                                                   FJournalNumber,
                                                                                                   ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                                                                   ATransactionNumber);
                    }
                }
                else
                {
                    AGLBatchDS.ARecurringTransAnalAttrib.DefaultView.RowFilter = String.Format("{0}={1} AND {2}={3}",
                                                                                               ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                                                               FBatchNumber,
                                                                                               ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                                                                               FJournalNumber);
                }

                AGLBatchDS.ARecurringTransAnalAttrib.DefaultView.Sort = String.Format("{0} ASC, {1} ASC",
                                                                                      ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                                                                      ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName()
                                                                                      );
            }
        }
Exemplo n.º 5
0
        private bool AllowInactiveFieldValues(int ABatchNumber)
        {
            bool RetVal = false;

            TVerificationResultCollection VerificationResult = new TVerificationResultCollection();
            string VerificationMessage = string.Empty;

            DataView TransDV  = new DataView(FMainDS.ARecurringTransaction);
            DataView AttribDV = new DataView(FMainDS.ARecurringTransAnalAttrib);

            int TotalNumInactiveValues   = 0;
            int NumInactiveAccounts      = 0;
            int NumInactiveCostCentres   = 0;
            int NumInactiveAccountTypes  = 0;
            int NumInactiveAccountValues = 0;

            try
            {
                //Check for inactive account or cost centre codes
                TransDV.RowFilter = String.Format("{0}={1}",
                                                  ARecurringTransactionTable.GetBatchNumberDBName(),
                                                  ABatchNumber);
                TransDV.Sort = String.Format("{0} ASC, {1} ASC",
                                             ARecurringTransactionTable.GetJournalNumberDBName(),
                                             ARecurringTransactionTable.GetTransactionNumberDBName());

                foreach (DataRowView drv in TransDV)
                {
                    ARecurringTransactionRow transRow = (ARecurringTransactionRow)drv.Row;

                    if (!AccountIsActive(transRow.AccountCode))
                    {
                        VerificationMessage += String.Format(" Account '{0}' in Journal:{1} Transaction:{2}.{3}",
                                                             transRow.AccountCode,
                                                             transRow.JournalNumber,
                                                             transRow.TransactionNumber,
                                                             Environment.NewLine);

                        NumInactiveAccounts++;
                    }

                    if (!CostCentreIsActive(transRow.CostCentreCode))
                    {
                        VerificationMessage += String.Format(" Cost Centre '{0}' in Journal:{1} Transaction:{2}.{3}",
                                                             transRow.CostCentreCode,
                                                             transRow.JournalNumber,
                                                             transRow.TransactionNumber,
                                                             Environment.NewLine);

                        NumInactiveCostCentres++;
                    }
                }

                //Check anlysis attributes
                AttribDV.RowFilter = String.Format("{0}={1}",
                                                   ARecurringTransAnalAttribTable.GetBatchNumberDBName(),
                                                   ABatchNumber);
                AttribDV.Sort = String.Format("{0} ASC, {1} ASC, {2} ASC",
                                              ARecurringTransAnalAttribTable.GetJournalNumberDBName(),
                                              ARecurringTransAnalAttribTable.GetTransactionNumberDBName(),
                                              ARecurringTransAnalAttribTable.GetAnalysisTypeCodeDBName());

                foreach (DataRowView drv2 in AttribDV)
                {
                    ARecurringTransAnalAttribRow analAttribRow = (ARecurringTransAnalAttribRow)drv2.Row;

                    if (!AnalysisCodeIsActive(analAttribRow.AccountCode, analAttribRow.AnalysisTypeCode))
                    {
                        VerificationMessage += String.Format(" Analysis Code '{0}' in Journal:{1} Transaction:{2}.{3}",
                                                             analAttribRow.AnalysisTypeCode,
                                                             analAttribRow.JournalNumber,
                                                             analAttribRow.TransactionNumber,
                                                             Environment.NewLine);

                        NumInactiveAccountTypes++;
                    }

                    if (!AnalysisAttributeValueIsActive(analAttribRow.AnalysisTypeCode, analAttribRow.AnalysisAttributeValue))
                    {
                        VerificationMessage += String.Format(" Analysis Value '{0}' in Journal:{1} Transaction:{2}.{3}",
                                                             analAttribRow.AnalysisAttributeValue,
                                                             analAttribRow.JournalNumber,
                                                             analAttribRow.TransactionNumber,
                                                             Environment.NewLine);

                        NumInactiveAccountValues++;
                    }
                }
            }
            catch (Exception ex)
            {
                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }

            TotalNumInactiveValues = (NumInactiveAccounts + NumInactiveCostCentres + NumInactiveAccountTypes + NumInactiveAccountValues);

            if (TotalNumInactiveValues > 0)
            {
                VerificationResult.Add(new TVerificationResult(string.Format(Catalog.GetString("Inactive Values:{0}"), Environment.NewLine),
                                                               VerificationMessage,
                                                               TResultSeverity.Resv_Noncritical));

                StringBuilder errorMessages = new StringBuilder();

                errorMessages.AppendFormat(Catalog.GetString("{0} inactive value(s) found in Recurring GL Batch {1}. Do you still want to submit?{2}"),
                                           TotalNumInactiveValues,
                                           ABatchNumber,
                                           Environment.NewLine);

                foreach (TVerificationResult message in VerificationResult)
                {
                    errorMessages.AppendFormat("{0}{1}",
                                               Environment.NewLine,
                                               message.ResultText);
                }

                TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm());

                RetVal = (extendedMessageBox.ShowDialog(errorMessages.ToString(),
                                                        Catalog.GetString("Submit Batch"), string.Empty,
                                                        TFrmExtendedMessageBox.TButtons.embbYesNo,
                                                        TFrmExtendedMessageBox.TIcon.embiQuestion) == TFrmExtendedMessageBox.TResult.embrYes);
            }
            else
            {
                RetVal = true;
            }

            return(RetVal);
        }