public void TestPostGLBatchesArgumentValidation() { TVerificationResultCollection VerificationResult = null; List <Int32> BatchNumbers = new List <int>(); string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatches(-1, BatchNumbers, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Ledger number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch without any batch numbers."; // Post a GL Batch without any batch numbers try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); if ((!VerificationResult.HasCriticalOrNonCriticalErrors) || (!VerificationResult.BuildVerificationResultString().Contains("No GL Batches to post"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; BatchNumbers.Add(-1); // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Batch number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } }
public void TestPrepareGLBatchForPostingArgumentValidation() { TVerificationResultCollection VerificationResult = null; TDBTransaction Transaction = null; GLBatchTDS MainDS = null; int BatchPeriod = -1; string Message = "Validation failed for PrepareGLBatchForPosting with ledger number less than 1."; // Prepare GL Batch For Posting with ledger number less than 1 try { TGLPosting.PrepareGLBatchForPosting(out MainDS, -1, 1, ref Transaction, out VerificationResult, null, ref BatchPeriod); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for PrepareGLBatchForPosting with batch number less than 1."; // Prepare GL Batch For Posting with batch number less than 1 try { TGLPosting.PrepareGLBatchForPosting(out MainDS, 1, -1, ref Transaction, out VerificationResult, null, ref BatchPeriod); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(1, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for PrepareGLBatchForPosting with null transaction."; // Prepare GL Batch For Posting with null transaction try { TGLPosting.PrepareGLBatchForPosting(out MainDS, 1, 1, ref Transaction, out VerificationResult, null, ref BatchPeriod); Assert.Fail(Message); } catch (EFinanceSystemDBTransactionNullException e) { Assert.AreEqual("Function:Prepare GL Batch For Posting - Database Transaction must not be NULL!", e.Message, Message); } catch { Assert.Fail(Message); } }
public void TestPostGLBatchesArgumentValidation() { TVerificationResultCollection VerificationResult = null; List <Int32> BatchNumbers = new List <int>(); string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatches(-1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch without any batch numbers."; // Post a GL Batch without any batch numbers try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (ArgumentException e) { Assert.AreEqual("Function:Post GL Batches - The list of GL Batch numbers to post is empty!", e.Message, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; BatchNumbers.Add(-1); // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatches(1, BatchNumbers, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(1, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } }
private void InitBatchAndJournal() { F_GLDataset = TGLPosting.CreateABatch(F_LedgerNum); F_batch = F_GLDataset.ABatch[0]; F_batch.BatchDescription = Catalog.GetString("Period end revaluations"); TAccountPeriodInfo accountingPeriodInfo = new TAccountPeriodInfo(F_LedgerNum); accountingPeriodInfo.AccountingPeriodNumber = F_batch.BatchPeriod; F_batch.DateEffective = accountingPeriodInfo.PeriodEndDate; F_batch.BatchStatus = MFinanceConstants.BATCH_UNPOSTED; F_journal = F_GLDataset.AJournal.NewRowTyped(); F_journal.LedgerNumber = F_batch.LedgerNumber; F_journal.BatchNumber = F_batch.BatchNumber; F_journal.JournalNumber = 1; F_journal.DateEffective = F_batch.DateEffective; F_journal.JournalPeriod = F_batch.BatchPeriod; F_journal.TransactionCurrency = F_BaseCurrency; F_journal.JournalDescription = F_batch.BatchDescription; F_journal.TransactionTypeCode = CommonAccountingTransactionTypesEnum.REVAL.ToString(); F_journal.SubSystemCode = CommonAccountingSubSystemsEnum.GL.ToString(); F_journal.LastTransactionNumber = 0; F_journal.DateOfEntry = DateTime.Now; F_journal.ExchangeRateToBase = 1.0M; F_GLDataset.AJournal.Rows.Add(F_journal); }
/// Returns true if it seems to be OK. private Boolean CloseRevaluationAccountingBatch(out Int32 glBatchNumber) { Boolean blnReturnValue = false; glBatchNumber = -1; if (F_GLDataset != null) { F_batch.BatchCreditTotal = F_journal.JournalCreditTotal; F_batch.BatchDebitTotal = F_journal.JournalDebitTotal; TVerificationResultCollection AVerifications; blnReturnValue = (TGLTransactionWebConnector.SaveGLBatchTDS( ref F_GLDataset, out AVerifications, FDataBase) == TSubmitChangesResult.scrOK); if (!blnReturnValue) { return(false); } F_GLDataset.AcceptChanges(); blnReturnValue = (TGLPosting.PostGLBatch( F_batch.LedgerNumber, F_batch.BatchNumber, out AVerifications, FDataBase)); if (blnReturnValue) { glBatchNumber = F_batch.BatchNumber; } } return(blnReturnValue); } // Close Revaluation Accounting Batch
public void TestLoadGLBatchDataArgumentValidation() { TVerificationResultCollection VerificationResult = null; TDataBase db = DBAccess.Connect("TestLoadGLBatchDataArgumentValidation"); TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.ReadCommitted); // Load GL Batch with ledger number less than 1 string Message = "Validation failed for LoadGLBatchData with ledger number less than 1."; try { TGLPosting.LoadGLBatchData(-1, 1, ref Transaction, ref VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } // Load GL Batch with batch number less than 1 Message = "Validation failed for LoadGLBatchData with batch number less than 1."; try { TGLPosting.LoadGLBatchData(43, -1, ref Transaction, ref VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(43, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } // Load GL Batch with null VerificationResult Message = "Validation failed for LoadGLBatchData with null VerificationResult."; VerificationResult = null; try { TGLPosting.LoadGLBatchData(1, 1, ref Transaction, ref VerificationResult); Assert.Fail(Message); } catch (ArgumentException e) { Assert.AreEqual("Function:Load GL Batch Data - Verifications collection must not be NULL!", e.Message, Message); } catch { Assert.Fail(Message); } }
private void TCommonAccountingTool_(string ABatchDescription) { FBatchTDS = TGLPosting.CreateABatch(FLedgerInfo.LedgerNumber); FBaseCurrencyInfo = new TCurrencyInfo(FLedgerInfo.BaseCurrency); FBatchRow = FBatchTDS.ABatch[0]; FBatchRow.BatchDescription = ABatchDescription; FBatchRow.BatchStatus = MFinanceConstants.BATCH_UNPOSTED; FBatchNumber = FBatchRow.BatchNumber; FJournalCount = 0; blnReadyForTransaction = false; blnInitBatchDate = true; }
public void TestPrepareGLBatchForPostingArgumentValidation() { TVerificationResultCollection VerificationResult = new TVerificationResultCollection(); TDataBase db = DBAccess.Connect("TestPrepareGLBatchForPostingArgumentValidation"); TDBTransaction Transaction = db.BeginTransaction(IsolationLevel.ReadCommitted); GLBatchTDS MainDS = null; int BatchPeriod = -1; string Message = "Validation failed for PrepareGLBatchForPosting with ledger number less than 1."; // Prepare GL Batch For Posting with ledger number less than 1 try { TGLPosting.PrepareGLBatchForPosting(out MainDS, -1, 1, ref Transaction, out VerificationResult, null, ref BatchPeriod); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } // Prepare GL Batch For Posting with batch number less than 1 Message = "Validation failed for PrepareGLBatchForPosting with batch number less than 1."; try { TGLPosting.PrepareGLBatchForPosting(out MainDS, 43, -1, ref Transaction, out VerificationResult, null, ref BatchPeriod); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(43, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } }
private Boolean CloseSaveAndPost_(TVerificationResultCollection AVerifications) { if (FJournalCount != 0) { // The checksum of the "last journal" is used to update the checksum of the batch. FBatchRow.BatchControlTotal += FJournalRow.JournalDebitTotal - FJournalRow.JournalCreditTotal; } FBatchTDS.ThrowAwayAfterSubmitChanges = true; GLBatchTDSAccess.SubmitChanges(FBatchTDS); Boolean PostedOk = TGLPosting.PostGLBatch( FLedgerInfo.LedgerNumber, FBatchNumber, out AVerifications); // Make sure that this object cannot be used for another posting ... FBatchTDS = null; FBatchRow = null; FJournalRow = null; return(PostedOk); }
public void TestPostGLBatchArgumentValidation() { TVerificationResultCollection VerificationResult = null; string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatch(-1, 1, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Ledger number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatch(1, -1, out VerificationResult); if ((VerificationResult.CountCriticalErrors != 1) || (!VerificationResult.BuildVerificationResultString().Contains("The Batch number must be greater than 0"))) { Assert.Fail(Message); } } catch { Assert.Fail(Message); } }
public void TestPostGLBatchArgumentValidation() { TVerificationResultCollection VerificationResult = null; string Message = "Validation failed for posting a GL Batch with ledger number less than 1."; // Post a GL Batch with ledger number less than 1 try { TGLPosting.PostGLBatch(-1, 1, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidLedgerNumberException e) { Assert.AreEqual(-1, e.LedgerNumber, Message); } catch { Assert.Fail(Message); } Message = "Validation failed for posting a GL Batch with batch number less than 1."; // Post a GL Batch with batch number less than 1 try { TGLPosting.PostGLBatch(1, -1, out VerificationResult); Assert.Fail(Message); } catch (EFinanceSystemInvalidBatchNumberException e) { Assert.AreEqual(1, e.LedgerNumber, Message); Assert.AreEqual(-1, e.BatchNumber, Message); } catch { Assert.Fail(Message); } }
private void InitBatchAndJournal(decimal AExchangeRate, string ACurrencyCode) { F_GLDataset = TGLPosting.CreateABatch(F_LedgerNum, false, true); F_batch = F_GLDataset.ABatch[0]; F_batch.BatchDescription = Catalog.GetString("Period end revaluations"); TAccountPeriodInfo accountingPeriodInfo = new TAccountPeriodInfo(F_LedgerNum); accountingPeriodInfo.AccountingPeriodNumber = F_batch.BatchPeriod; F_batch.DateEffective = accountingPeriodInfo.PeriodEndDate; F_batch.BatchStatus = MFinanceConstants.BATCH_UNPOSTED; F_journal = F_GLDataset.AJournal.NewRowTyped(); F_journal.LedgerNumber = F_batch.LedgerNumber; F_journal.BatchNumber = F_batch.BatchNumber; F_journal.JournalNumber = 1; F_journal.DateEffective = F_batch.DateEffective; F_journal.ExchangeRateTime = 14400; // revaluations are typically later than 'new rates' F_journal.JournalPeriod = F_batch.BatchPeriod; F_journal.TransactionCurrency = F_BaseCurrency; F_journal.JournalDescription = F_batch.BatchDescription; F_journal.TransactionTypeCode = CommonAccountingTransactionTypesEnum.REVAL.ToString(); F_journal.SubSystemCode = CommonAccountingSubSystemsEnum.GL.ToString(); F_journal.LastTransactionNumber = 0; F_journal.DateOfEntry = DateTime.Now; F_journal.ExchangeRateToBase = 1.0M; F_GLDataset.AJournal.Rows.Add(F_journal); ARevaluationRow revalRow = F_GLDataset.ARevaluation.NewRowTyped(); revalRow.LedgerNumber = F_journal.LedgerNumber; revalRow.BatchNumber = F_journal.BatchNumber; revalRow.JournalNumber = F_journal.JournalNumber; revalRow.ExchangeRateToBase = AExchangeRate; revalRow.RevaluationCurrency = ACurrencyCode; F_GLDataset.ARevaluation.Rows.Add(revalRow); }
/// <summary> /// Post a budget /// </summary> private static void PostBudget(int ALedgerNumber, ABudgetRow ABudgetRow, List <ABudgetPeriodRow> ABudgetPeriodRows) { GLPostingDS.AGeneralLedgerMaster.DefaultView.Sort = String.Format("{0},{1},{2},{3}", AGeneralLedgerMasterTable.GetLedgerNumberDBName(), AGeneralLedgerMasterTable.GetYearDBName(), AGeneralLedgerMasterTable.GetAccountCodeDBName(), AGeneralLedgerMasterTable.GetCostCentreCodeDBName()); int glmRowIndex = GLPostingDS.AGeneralLedgerMaster.DefaultView.Find(new object[] { ALedgerNumber, ABudgetRow.Year, ABudgetRow.AccountCode, ABudgetRow.CostCentreCode }); if (glmRowIndex == -1) { TGLPosting.CreateGLMYear(ref GLPostingDS, ALedgerNumber, ABudgetRow.Year, ABudgetRow.AccountCode, ABudgetRow.CostCentreCode); glmRowIndex = GLPostingDS.AGeneralLedgerMaster.DefaultView.Find(new object[] { ALedgerNumber, ABudgetRow.Year, ABudgetRow.AccountCode, ABudgetRow.CostCentreCode }); } int GLMSequence = ((AGeneralLedgerMasterRow)GLPostingDS.AGeneralLedgerMaster.DefaultView[glmRowIndex].Row).GlmSequence; /* Update totals for the General Ledger Master period record. */ foreach (ABudgetPeriodRow BPR in ABudgetPeriodRows) { AddBudgetValue(GLMSequence, BPR.PeriodNumber, BPR.BudgetBase); } }
/// <summary> /// Process the account code parent codes /// </summary> private static void ProcessAccountParent( int ALedgerNumber, string CurrAccountCode, bool ADebitCreditIndicator, string ACostCentreList, ABudgetRow ABudgetRow, List <ABudgetPeriodRow> ABudgetPeriods) { AAccountRow AccountRow = (AAccountRow)GLPostingDS.AAccount.Rows.Find(new object[] { ALedgerNumber, CurrAccountCode }); AAccountHierarchyDetailRow AccountHierarchyDetailRow = (AAccountHierarchyDetailRow)GLPostingDS.AAccountHierarchyDetail.Rows.Find( new object[] { ALedgerNumber, MFinanceConstants.ACCOUNT_HIERARCHY_STANDARD, CurrAccountCode }); if (AccountHierarchyDetailRow != null) { string AccountCodeToReportTo = AccountHierarchyDetailRow.AccountCodeToReportTo; if ((AccountCodeToReportTo != null) && (AccountCodeToReportTo != string.Empty)) { /* Recursively call this procedure. */ ProcessAccountParent( ALedgerNumber, AccountCodeToReportTo, ADebitCreditIndicator, ACostCentreList, ABudgetRow, ABudgetPeriods); } } int DebitCreditMultiply = 1; /* needed if the debit credit indicator is not the same */ /* If the account has the same db/cr indicator as the original * account for which the budget was created, add the budget amount. * Otherwise, subtract. */ if (AccountRow.DebitCreditIndicator != ADebitCreditIndicator) { DebitCreditMultiply = -1; } string[] CostCentres = ACostCentreList.Split(':'); string AccCode = AccountRow.AccountCode; /* For each associated Cost Centre, update the General Ledger Master. */ foreach (string CostCentreCode in CostCentres) { int glmRowIndex = GLPostingDS.AGeneralLedgerMaster.DefaultView.Find(new object[] { ALedgerNumber, ABudgetRow.Year, AccCode, CostCentreCode }); if (glmRowIndex == -1) { TGLPosting.CreateGLMYear(ref GLPostingDS, ALedgerNumber, ABudgetRow.Year, AccCode, CostCentreCode); glmRowIndex = GLPostingDS.AGeneralLedgerMaster.DefaultView.Find(new object[] { ALedgerNumber, ABudgetRow.Year, AccCode, CostCentreCode }); } int GLMSequence = ((AGeneralLedgerMasterRow)GLPostingDS.AGeneralLedgerMaster.DefaultView[glmRowIndex].Row).GlmSequence; /* Update totals for the General Ledger Master period record. */ foreach (ABudgetPeriodRow BPR in ABudgetPeriods) { AddBudgetValue(GLMSequence, BPR.PeriodNumber, DebitCreditMultiply * BPR.BudgetBase); } } }