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); }
/// <summary> /// TReallocation.RunOperation /// </summary> public override Int32 RunOperation() { Int32 CountJobs = 0; if (FAccountList == null) { CalculateAccountInfo(); } TCommonAccountingTool YearEndBatch = null; if (DoExecuteableCode) { YearEndBatch = new TCommonAccountingTool(FledgerInfo, Catalog.GetString("Financial year end processing")); YearEndBatch.AddBaseCurrencyJournal(); YearEndBatch.JournalDescription = Catalog.GetString("YearEnd revaluations"); YearEndBatch.SubSystemCode = CommonAccountingSubSystemsEnum.GL; } // tCommonAccountingTool.DateEffective =""; Default is "End of actual period ..." // Loop with all account codes foreach (string strAccountCode in FAccountList) { FglmInfo = new TGlmInfo(FledgerInfo.LedgerNumber, FledgerInfo.CurrentFinancialYear, strAccountCode); while (FglmInfo.MoveNext()) { Int32 CostCentreRowIdx = FCostCentreTbl.DefaultView.Find(FglmInfo.CostCentreCode); ACostCentreRow currentCostCentre = (ACostCentreRow)FCostCentreTbl.DefaultView[CostCentreRowIdx].Row; if (currentCostCentre.PostingCostCentreFlag) { TGlmpInfo glmpInfo = new TGlmpInfo(-1, -1, FglmInfo.GlmSequence, FledgerInfo.NumberOfAccountingPeriods); if (glmpInfo.ActualBase + FglmInfo.ClosingPeriodActualBase != 0) { if (DoExecuteableCode) { ReallocationLoop(glmpInfo, YearEndBatch, strAccountCode, FglmInfo.CostCentreCode); } CountJobs++; } } } } if (DoExecuteableCode) { YearEndBatch.CloseSaveAndPost(FverificationResults); } return CountJobs; }
private void ReallocationLoop(TGlmpInfo AGlmpInfo, TCommonAccountingTool YearEndBatch, String AAccountFrom, String ACostCentreFrom) { string strCostCentreTo = TLedgerInfo.GetStandardCostCentre(FledgerInfo.LedgerNumber); string strAccountTo; FaccountInfo.AccountCode = AAccountFrom; Boolean blnDebitCredit = FaccountInfo.DebitCreditIndicator; String narrativeMessage = FstrNarrativeToMessage; string strCCAccoutCode = FaccountInfo.SetCarryForwardAccount(); // Move FaccountInfo to the Carry Forward Account - if there is one. if (FaccountInfo.IsValid) // The CarryForward account exists.. { strAccountTo = FaccountInfo.AccountCode; if (strCCAccoutCode == "SAMECC") { strCostCentreTo = ACostCentreFrom; narrativeMessage = FstrNarrativeFromToMessage; } } else // If there's no Carry Forward account, use EARNINGS_BF_ACCT { FaccountInfo.SetSpecialAccountCode(TAccountPropertyEnum.EARNINGS_BF_ACCT); strAccountTo = FaccountInfo.AccountCode; } if (FledgerInfo.IltAccountFlag) // In either case, change that if ICH_ACCT is set { FaccountInfo.SetSpecialAccountCode(TAccountPropertyEnum.ICH_ACCT); strAccountTo = FaccountInfo.AccountCode; } if (FledgerInfo.BranchProcessing) // Keep the original Cost Centres - don't roll up { strCostCentreTo = ACostCentreFrom; narrativeMessage = FstrNarrativeFromToMessage; } if (FglmInfo.YtdActualBase < 0) { blnDebitCredit = !blnDebitCredit; } Decimal TransactionAmount = Math.Abs(AGlmpInfo.ActualBase); YearEndBatch.AddBaseCurrencyTransaction( AAccountFrom, ACostCentreFrom, String.Format(narrativeMessage, ACostCentreFrom, AAccountFrom, strCostCentreTo, strAccountTo), FstrYearEnd, !blnDebitCredit, TransactionAmount); YearEndBatch.AddBaseCurrencyTransaction( strAccountTo, strCostCentreTo, String.Format(narrativeMessage, ACostCentreFrom, AAccountFrom, strCostCentreTo, strAccountTo), FstrYearEnd, blnDebitCredit, TransactionAmount); }
private void CheckForSuspenseAccountsZero() { if (FledgerInfo.CurrentPeriod == FledgerInfo.NumberOfAccountingPeriods) { // This means: The last accounting period of the year is running! if (getSuspenseAccountInfo == null) { getSuspenseAccountInfo = new GetSuspenseAccountInfo(FledgerInfo.LedgerNumber); } if (getSuspenseAccountInfo.RowCount > 0) { ASuspenseAccountRow aSuspenseAccountRow; for (int i = 0; i < getSuspenseAccountInfo.RowCount; ++i) { aSuspenseAccountRow = getSuspenseAccountInfo.Row(i); TGet_GLM_Info get_GLM_Info = new TGet_GLM_Info(FledgerInfo.LedgerNumber, aSuspenseAccountRow.SuspenseAccountCode, FledgerInfo.CurrentFinancialYear); if (get_GLM_Info.GLMExists) { TGlmpInfo get_GLMp_Info = new TGlmpInfo(FledgerInfo.LedgerNumber); get_GLMp_Info.LoadBySequence(get_GLM_Info.Sequence, FledgerInfo.CurrentPeriod); if (get_GLMp_Info.RowExists && (get_GLMp_Info.ActualBase != 0)) { TVerificationResult tvr = new TVerificationResult( Catalog.GetString("Non Zero Suspense Account found"), String.Format(Catalog.GetString("Suspense account {0} has the balance value {1}. It is required to be zero."), getSuspenseAccountInfo.ToString(), get_GLMp_Info.ActualBase), "", TPeriodEndErrorAndStatusCodes.PEEC_07.ToString(), TResultSeverity.Resv_Critical); FverificationResults.Add(tvr); FHasCriticalErrors = true; FverificationResults.Add(tvr); } } } } } } // CheckFor SuspenseAccountsZero