/// <summary> /// update the journal header fields from a batch /// </summary> /// <param name="ABatch"></param> public void UpdateHeaderTotals(ABatchRow ABatch) { decimal SumDebits = 0.0M; decimal SumCredits = 0.0M; DataView JournalDV = new DataView(FMainDS.AJournal); JournalDV.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), ABatch.BatchNumber); foreach (DataRowView v in JournalDV) { AJournalRow r = (AJournalRow)v.Row; SumCredits += r.JournalCreditTotal; SumDebits += r.JournalDebitTotal; } FPetraUtilsObject.DisableDataChangedEvent(); txtDebit.NumberValueDecimal = SumDebits; txtCredit.NumberValueDecimal = SumCredits; txtControl.NumberValueDecimal = ABatch.BatchControlTotal; txtCurrentPeriod.Text = ABatch.BatchPeriod.ToString(); FPetraUtilsObject.EnableDataChangedEvent(); }
/// <summary> /// Calculate the base amount for the transactions, and update the totals for the journals and the current batch /// </summary> /// <param name="AMainDS"></param> /// <param name="ACurrentBatch"></param> public static void UpdateTotalsOfBatch(ref GLBatchTDS AMainDS, ABatchRow ACurrentBatch) { decimal BatchDebitTotal = 0.0m; decimal BatchCreditTotal = 0.0m; DataView jnlDataView = new DataView(AMainDS.AJournal); jnlDataView.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), ACurrentBatch.BatchNumber); foreach (DataRowView journalView in jnlDataView) { GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row; UpdateTotalsOfJournal(ref AMainDS, ref journalRow); BatchDebitTotal += journalRow.JournalDebitTotal; BatchCreditTotal += journalRow.JournalCreditTotal; } if ((ACurrentBatch.BatchDebitTotal != BatchDebitTotal) || (ACurrentBatch.BatchCreditTotal != BatchCreditTotal)) { ACurrentBatch.BatchDebitTotal = BatchDebitTotal; ACurrentBatch.BatchCreditTotal = BatchCreditTotal; } }
private void SetJournalDefaultView() { string DVRowFilter = string.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), FBatchNumber); FMainDS.AJournal.DefaultView.RowFilter = DVRowFilter; FMainDS.AJournal.DefaultView.Sort = String.Format("{0} DESC", AJournalTable.GetJournalNumberDBName() ); FFilterAndFindObject.FilterPanelControls.SetBaseFilter(DVRowFilter, true); FFilterAndFindObject.CurrentActiveFilter = DVRowFilter; }
/// <summary> /// Cancel any changes made to this form /// </summary> public void CancelChangesToFixedBatches() { if ((GetBatchRow() != null) && (GetBatchRow().BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { DataView journalDV = new DataView(FMainDS.AJournal); journalDV.RowFilter = string.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), GetBatchRow().BatchNumber); foreach (DataRowView drv in journalDV) { AJournalRow jr = (AJournalRow)drv.Row; jr.RejectChanges(); } } }
private void LoadJournalsForCurrentBatch() { if (FPreviouslySelectedDetailRow == null) { return; } //Current Batch number int BatchNumber = FPreviouslySelectedDetailRow.BatchNumber; string BatchStatus = FPreviouslySelectedDetailRow.BatchStatus; if (FMainDS.AJournal != null) { FMainDS.AJournal.DefaultView.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), BatchNumber); if (FMainDS.AJournal.DefaultView.Count == 0) { ((TFrmGLBatch)this.ParentForm).LoadJournals(FPreviouslySelectedDetailRow); } } }
/// <summary> /// Re-show the specified row /// </summary> /// <param name="ACurrentBatch"></param> /// <param name="AJournalToCancel"></param> /// <param name="ARedisplay"></param> public void PrepareJournalDataForCancelling(Int32 ACurrentBatch, Int32 AJournalToCancel, Boolean ARedisplay) { //This code will only be called when the Journal tab is active. DataView JournalDV = new DataView(FMainDS.AJournal); DataView TransDV = new DataView(FMainDS.ATransaction); DataView TransAnalDV = new DataView(FMainDS.ATransAnalAttrib); JournalDV.RowFilter = String.Format("{0}={1} And {2}={3}", AJournalTable.GetBatchNumberDBName(), ACurrentBatch, AJournalTable.GetJournalNumberDBName(), AJournalToCancel); TransDV.RowFilter = String.Format("{0}={1} And {2}={3}", ATransactionTable.GetBatchNumberDBName(), ACurrentBatch, ATransactionTable.GetJournalNumberDBName(), AJournalToCancel); TransAnalDV.RowFilter = String.Format("{0}={1} And {2}={3}", ATransAnalAttribTable.GetBatchNumberDBName(), ACurrentBatch, ATransAnalAttribTable.GetJournalNumberDBName(), AJournalToCancel); //Work from lowest level up if (TransAnalDV.Count > 0) { TransAnalDV.Sort = String.Format("{0}, {1}", ATransAnalAttribTable.GetTransactionNumberDBName(), ATransAnalAttribTable.GetAnalysisTypeCodeDBName()); foreach (DataRowView drv in TransAnalDV) { ATransAnalAttribRow transAnalRow = (ATransAnalAttribRow)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}", ATransactionTable.GetTransactionNumberDBName()); foreach (DataRowView drv in TransDV) { ATransactionRow transRow = (ATransactionRow)drv.Row; if (transRow.RowState == DataRowState.Added) { //Do nothing } else if (transRow.RowState != DataRowState.Unchanged) { transRow.RejectChanges(); } } } if (JournalDV.Count > 0) { GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)JournalDV[0].Row; //No need to check for Added state as new journals 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 journal ready to delete/cancel FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransactionAndRelatedTablesForJournal(FLedgerNumber, ACurrentBatch, AJournalToCancel)); } }
/// <summary> /// Update the specified Batch's LastJournal number. Assumes all necessary data is loaded for Batch /// </summary> /// <param name="AMainDS"></param> /// <param name="ACurrentBatchRow"></param> /// <returns>false if no change to batch totals</returns> public static bool UpdateBatchLastJournal(ref GLBatchTDS AMainDS, ref ABatchRow ACurrentBatchRow) { #region Validate Arguments if (AMainDS == null) { throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString("Function:{0} - The GL Batch dataset is null!"), Utilities.GetMethodName(true))); } else if (ACurrentBatchRow == null) { throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString( "Function:{0} - The GL Batch data row is null!"), Utilities.GetMethodName(true))); } else if (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED) { TLogging.Log(String.Format("Function:{0} - Tried to update totals for non-Unposted Batch:{1}", Utilities.GetMethodName(true), ACurrentBatchRow.BatchNumber)); return(false); } #endregion Validate Arguments bool RowUpdated = false; int ActualLastJournalNumber = 0; DataView JournalDV = new DataView(AMainDS.AJournal); JournalDV.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), ACurrentBatchRow.BatchNumber); //Highest Journal number first JournalDV.Sort = String.Format("{0} DESC", AJournalTable.GetJournalNumberDBName()); foreach (DataRowView journalView in JournalDV) { GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row; //Run once only if (ActualLastJournalNumber == 0) { ActualLastJournalNumber = journalRow.JournalNumber; } if (UpdateJournalLastTransaction(ref AMainDS, ref journalRow)) { RowUpdated = true; } } if (ACurrentBatchRow.LastJournal != ActualLastJournalNumber) { ACurrentBatchRow.LastJournal = ActualLastJournalNumber; RowUpdated = true; } return(RowUpdated); }
/// <summary> /// Calculate the base amount for the transactions, and update the totals for the journals and the current batch /// This assumes that all relevant data has already been loaded /// </summary> /// <param name="AMainDS"></param> /// <param name="ACurrentBatchRow"></param> /// <param name="ACurrentJournalNumber"></param> /// <returns>false if no change to batch totals</returns> public static bool UpdateBatchTotals(ref GLBatchTDS AMainDS, ref ABatchRow ACurrentBatchRow, Int32 ACurrentJournalNumber = 0) { #region Validate Arguments if (AMainDS == null) { throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString("Function:{0} - The GL Batch dataset is null!"), Utilities.GetMethodName(true))); } else if (ACurrentBatchRow == null) { throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString( "Function:{0} - The GL Batch data row is null!"), Utilities.GetMethodName(true))); } else if (ACurrentBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED) { TLogging.Log(String.Format("Function:{0} - Tried to update totals for non-Unposted Batch:{1}", Utilities.GetMethodName(true), ACurrentBatchRow.BatchNumber)); return(false); } #endregion Validate Arguments bool AmountsUpdated = false; decimal BatchDebitTotal = 0.0m; decimal BatchCreditTotal = 0.0m; DataView JournalDV = new DataView(AMainDS.AJournal); JournalDV.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), ACurrentBatchRow.BatchNumber); foreach (DataRowView journalView in JournalDV) { GLBatchTDSAJournalRow journalRow = (GLBatchTDSAJournalRow)journalView.Row; if (((ACurrentJournalNumber > 0) && (ACurrentJournalNumber == journalRow.JournalNumber)) || (ACurrentJournalNumber == 0)) { if ((UpdateJournalTotals(ref AMainDS, ref journalRow))) { AmountsUpdated = true; } } BatchDebitTotal += journalRow.JournalDebitTotal; BatchCreditTotal += journalRow.JournalCreditTotal; } if ((ACurrentBatchRow.BatchDebitTotal != BatchDebitTotal) || (ACurrentBatchRow.BatchCreditTotal != BatchCreditTotal)) { ACurrentBatchRow.BatchDebitTotal = BatchDebitTotal; ACurrentBatchRow.BatchCreditTotal = BatchCreditTotal; AmountsUpdated = true; } return(AmountsUpdated); }