private static Int32 FindFinancialYearByDate(Int32 ALedgerNumber, DateTime ADate) { Int32 yearDateBelongsTo = 99; DateTime yearStartDate = DateTime.Today; TDBTransaction transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.Serializable, ref transaction, delegate { ALedgerTable LedgerTable = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, transaction); if (LedgerTable.Count == 0) { return; } ALedgerRow LedgerRow = (ALedgerRow)LedgerTable.Rows[0]; yearDateBelongsTo = LedgerRow.CurrentFinancialYear; AAccountingPeriodTable AccPeriodTable = AAccountingPeriodAccess.LoadViaALedger(ALedgerNumber, transaction); if (AccPeriodTable.Count == 0) { return; } //Find earliest start date (don't assume PK order) AAccountingPeriodRow AccPeriodRow = null; for (int i = 0; i < AccPeriodTable.Count; i++) { DateTime currentStartDate; AccPeriodRow = (AAccountingPeriodRow)AccPeriodTable.Rows[i]; currentStartDate = AccPeriodRow.PeriodStartDate; if (i > 0) { if (yearStartDate > currentStartDate) { yearStartDate = currentStartDate; } } else { yearStartDate = currentStartDate; } } //Find the correct year while (ADate < yearStartDate) { ADate = ADate.AddYears(1); yearDateBelongsTo--; } }); // Get NewOrExisting AutoReadTransaction //Set the year to return return(yearDateBelongsTo); } // Find FinancialYear ByDate
/// <summary> /// Called after MonthEnd. No GUI will be displayed. /// </summary> public void PrintPeriodEndReport(Int32 ALedgerNumber, Boolean AMonthMode) { LedgerNumber = ALedgerNumber; TRptCalculator Calc = new TRptCalculator(); ALedgerRow Ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; int currentPeriod = Ledger.CurrentPeriod; Calc.AddParameter("param_ledger_number_i", ALedgerNumber); Calc.AddParameter("param_year_i", Ledger.CurrentFinancialYear); Calc.AddParameter("param_end_period_i", currentPeriod - 1); DateTime endDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate( ALedgerNumber, Ledger.CurrentFinancialYear, -1, currentPeriod); Calc.AddParameter("param_end_date", new TVariant(endDate)); Calc.AddStringParameter("param_account_hierarchy_c", "STANDARD"); Calc.AddStringParameter("param_currency", "Base"); Calc.AddStringParameter("param_currency_name", Ledger.BaseCurrency); Calc.AddParameter("param_cost_centre_breakdown", false); Calc.AddParameter("param_cost_centre_summary", false); Calc.AddParameter("param_cost_centre_codes", ""); Calc.AddParameter("param_costcentreoptions", "AccountLevel"); Calc.AddParameter("param_current_period", currentPeriod); Calc.AddParameter("param_period", true); Calc.AddParameter("param_current_financial_year", true); Calc.AddStringParameter("param_depth", "standard"); FPetraUtilsObject.FFastReportsPlugin.GenerateReport(Calc); }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { String RootCostCentre = "[" + FLedgerNumber + "]"; ACalc.AddParameter("param_cost_centre_code", new TVariant(RootCostCentre)); // I need to get the name of the current ledger.. ALedgerTable LedgerTbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber); Boolean IsClosed = false; if (LedgerTbl.Rows.Count > 0) { ALedgerRow LedgerRow = LedgerTbl[0]; // // I want to tell the user whether the selected period is closed // (although they probably know already...) Int32 SelPeriod = ACalc.GetParameters().GetParameter("param_end_period_i").value.ToInt32(); Int32 SelYear = ACalc.GetParameters().GetParameter("param_year_i").value.ToInt32(); if ((SelYear < LedgerRow.CurrentFinancialYear) || (SelPeriod < LedgerRow.CurrentPeriod)) { IsClosed = true; } } String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber); ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddParameter("param_period_closed", IsClosed); return(FPetraUtilsObject.FFastReportsPlugin.LoadReportData("TrialBalance", false, new string[] { "TrialBalance" }, ACalc, this, false)); }
/// <summary> /// Print or reprint the posting report for this batch. /// </summary> public static void PrintPostingRegister(Int32 ALedgerNumber, Int32 ABatchNumber, Boolean AEditTemplate = false) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Batch Posting Register"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } GLBatchTDS BatchTDS = TRemote.MFinance.GL.WebConnectors.LoadABatchAndContent(ALedgerNumber, ABatchNumber); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = BatchTDS.ALedger[0]; //Call RegisterData to give the data to the template ReportingEngine.RegisterData(BatchTDS.ABatch, "ABatch"); ReportingEngine.RegisterData(BatchTDS.AJournal, "AJournal"); ReportingEngine.RegisterData(BatchTDS.ATransaction, "ATransaction"); Calc.AddParameter("param_batch_number_i", ABatchNumber); Calc.AddParameter("param_ledger_number_i", ALedgerNumber); String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(ALedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerName); if (AEditTemplate) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary> /// Print out the Motivation Details using FastReports template. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilePrint(object sender, EventArgs e) { FastReportsWrapper ReportingEngine = new FastReportsWrapper("Motivation Details"); if (!ReportingEngine.LoadedOK) { ReportingEngine.ShowErrorPopup(); return; } ReportingEngine.RegisterData(FMainDS.AMotivationDetail, "MotivationDetail"); TRptCalculator Calc = new TRptCalculator(); ALedgerRow LedgerRow = FMainDS.ALedger[0]; Calc.AddParameter("param_ledger_number_i", LedgerRow.LedgerNumber); Calc.AddStringParameter("param_ledger_name", LedgerRow.LedgerName); if (ModifierKeys.HasFlag(Keys.Control)) { ReportingEngine.DesignReport(Calc); } else { ReportingEngine.GenerateReport(Calc); } }
/// <summary> /// /// </summary> /// <param name="ALedgerNumber"></param> public void InitialiseLedger(int ALedgerNumber) { FLedgerNumber = ALedgerNumber; FLedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; txtLedger.Text = TFinanceControls.GetLedgerNumberAndName(FLedgerNumber); TFinanceControls.InitialiseAvailableEndOfYearsList(ref cmbPeriodYear, FLedgerNumber); cmbPeriodYear.SelectedIndex = 0; TFinanceControls.InitialiseAvailableEndOfYearsList(ref cmbQuarterYear, FLedgerNumber); cmbQuarterYear.SelectedIndex = 0; TFinanceControls.InitialiseAvailableEndOfYearsList(ref cmbBreakdownYear, FLedgerNumber); cmbBreakdownYear.SelectedIndex = 0; TFinanceControls.InitialiseAccountHierarchyList(ref cmbAccountHierarchy, FLedgerNumber); cmbAccountHierarchy.SelectedIndex = 0; // if there is only one hierarchy, disable the control // cmbAccountHierarchy.Enabled = (cmbAccountHierarchy.Count > 1); /* select the latest year TODO ??? */ // if (this.CbB_AvailableYears.Items.Count > 0) // { // this.CbB_AvailableYears.SelectedIndex = 0; /// first item is the most current year // } }
private void InitialiseLedgerControls() { //Set the valid date range label TLedgerSelection.GetCurrentPostingRangeDates(FLedgerNumber, out FStartDateCurrentPeriod, out FEndDateLastForwardingPeriod, out FDefaultDate); lblValidDateRange.Text = String.Format(Catalog.GetString("Valid between {0} and {1}"), StringHelper.DateToLocalizedString(FStartDateCurrentPeriod, false, false), StringHelper.DateToLocalizedString(FEndDateLastForwardingPeriod, false, false)); // Get the current year/period and pass on to the filter logic object ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; FCurrentLedgerYear = LedgerRow.CurrentFinancialYear; FCurrentLedgerPeriod = LedgerRow.CurrentPeriod; FLoadAndFilterLogicObject.CurrentLedgerYear = FCurrentLedgerYear; FLoadAndFilterLogicObject.CurrentLedgerPeriod = FCurrentLedgerPeriod; TFrmGLBatch myParentForm = (TFrmGLBatch)this.ParentForm; myParentForm.GetJournalsControl().LedgerBaseCurrency = LedgerRow.BaseCurrency; }
private void UpdateSubsystemLinkStatus(int ALedgerNumber, TTaskList ATaskList, XmlNode ATaskListNode) { if ((ATaskListNode != null) && (ATaskListNode.ParentNode != null) && (ATaskListNode.ParentNode.Name == "Finance")) { ALedgerRow ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; XmlNode TempNode = ATaskListNode.ParentNode.FirstChild; while (TempNode != null) { if (TempNode.Name == "GiftProcessing") { ATaskList.EnableDisableTaskItem(TempNode, TRemote.MFinance.Setup.WebConnectors.IsGiftProcessingSubsystemActivated(ALedgerNumber)); } else if (TempNode.Name == "AccountsPayable") { ATaskList.EnableDisableTaskItem(TempNode, TRemote.MFinance.Setup.WebConnectors.IsAccountsPayableSubsystemActivated(ALedgerNumber)); } TempNode = TempNode.NextSibling; } // while EnableDisableChildOption(ATaskList, "SuspenseAccounts", ledger.SuspenseAccountFlag, ATaskListNode.ParentNode); } // if }
/// <summary> /// make sure the correct journal number is assigned and the batch.lastJournal is updated /// </summary> /// <param name="ANewRow"></param> public void NewRowManual(ref GLBatchTDSARecurringJournalRow ANewRow) { if ((ANewRow == null) || (FLedgerNumber == -1)) { return; } ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; ANewRow.LedgerNumber = FBatchRow.LedgerNumber; ANewRow.BatchNumber = FBatchRow.BatchNumber; ANewRow.JournalNumber = ++FBatchRow.LastJournal; // manually created journals are all GL ANewRow.SubSystemCode = MFinanceConstants.SUB_SYSTEM_GL; ANewRow.TransactionTypeCode = MFinanceConstants.STANDARD_JOURNAL; ANewRow.TransactionCurrency = LedgerRow.BaseCurrency; ANewRow.ExchangeRateToBase = 1; ANewRow.DateEffective = FBatchRow.DateEffective; ANewRow.JournalPeriod = FBatchRow.BatchPeriod; ANewRow.JournalDebitTotalBase = 0.0M; ANewRow.JournalCreditTotalBase = 0.0M; }
/// <summary> /// Called after MonthEnd. No GUI is displayed - last month's Summary is shown. /// </summary> public void PrintPeriodEndReport(Int32 ALedgerNumber, Boolean AMonthMode) { LedgerNumber = ALedgerNumber; ALedgerRow Ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; int currentPeriod = Ledger.CurrentPeriod; TRptCalculator Calc = new TRptCalculator(); Calc.AddParameter("param_ledger_number_i", new TVariant(ALedgerNumber)); Calc.AddParameter("param_year_i", Ledger.CurrentFinancialYear); Calc.AddParameter("param_current_financial_year", true); Calc.AddParameter("param_end_period_i", new TVariant(currentPeriod - 1)); Calc.AddParameter("param_current_period", new TVariant(currentPeriod)); DateTime startDate = TRemote.MFinance.GL.WebConnectors.GetPeriodStartDate( ALedgerNumber, Ledger.CurrentFinancialYear, -1, currentPeriod); Calc.AddParameter("param_start_date", new TVariant(startDate)); DateTime endDate = TRemote.MFinance.GL.WebConnectors.GetPeriodEndDate( ALedgerNumber, Ledger.CurrentFinancialYear, -1, currentPeriod); Calc.AddParameter("param_end_date", new TVariant(endDate)); FPetraUtilsObject.FFastReportsPlugin.GenerateReport(Calc); }
private Boolean LoadReportData(TRptCalculator ACalc) { ArrayList reportParam = ACalc.GetParameters().Elems; Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); foreach (Shared.MReporting.TParameter p in reportParam) { if (p.name.StartsWith("param") && (p.name != "param_calculation") && !paramsDictionary.ContainsKey(p.name)) { paramsDictionary.Add(p.name, p.value); } } // get data for this report DataSet ReportDataSet = TRemote.MReporting.WebConnectors.GetOneYearMonthGivingDataSet(paramsDictionary); if (TRemote.MReporting.WebConnectors.DataTableGenerationWasCancelled() || this.IsDisposed) { return(false); } // if no recipients if (ReportDataSet.Tables["Recipients"] == null) { FPetraUtilsObject.WriteToStatusBar("No recipients found for this report period."); return(false); } // register datatables with the report FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["Recipients"], "Recipients"); FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportDataSet.Tables["Donors"], "Donors"); // // My report doesn't need a ledger row - only the name of the ledger. And I need the currency formatter.. String LedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber); ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber); ALedgerRow Row = LedgerDetailsTable[0]; ACalc.AddStringParameter("param_ledger_name", LedgerName); String CurrencyName = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency; ACalc.AddStringParameter("param_currency_name", CurrencyName); ACalc.AddStringParameter("param_currency_formatter", "0,0.000"); Boolean HasData = ReportDataSet.Tables["Recipients"].Rows.Count > 0; if (!HasData) { MessageBox.Show(Catalog.GetString( "No Recipients found."), "Recipient Gift Statement"); } return(HasData); }
/// <summary> /// /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="APaymentNumber"></param> public void ReloadPayment(Int32 ALedgerNumber, Int32 APaymentNumber) { FMainDS = TRemote.MFinance.AP.WebConnectors.LoadAPPayment(ALedgerNumber, APaymentNumber); FLedgerNumber = FMainDS.AApPayment[0].LedgerNumber; ALedgerTable Tbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber); FLedgerRow = Tbl[0]; ShowData(FMainDS.AApSupplier[0]); }
/// <summary> /// Show ledger settings data from given data set /// This will be called after the ledger has been set but before the screen's Show() method has been called. /// </summary> /// <param name="ARow">The ledger row for which details will be shown</param> private void ShowDataManual(ALedgerRow ARow) { // Someone at some time must have thought that this table might be useful... // It does contain a lot of this info as well //AAccountingSystemParameterRow ParameterRow = (AAccountingSystemParameterRow)FMainDS.AAccountingSystemParameter.Rows[0]; // In these steps we 'force' the data to be within specified limits. Then we are free to set the max/min of the spin buttons. int currentPeriodMax = 13; int currentPeriodMin = 1; nudCurrentPeriod.Value = Math.Max(Math.Min(ARow.CurrentPeriod, currentPeriodMax), currentPeriodMin); nudCurrentPeriod.Minimum = currentPeriodMin; nudCurrentPeriod.Maximum = currentPeriodMax; int accountingPeriodsMax = 13; int accountingPeriodsMin = 12; nudNumberOfAccountingPeriods.Value = Math.Max(Math.Min(ARow.NumberOfAccountingPeriods, accountingPeriodsMax), accountingPeriodsMin); nudNumberOfAccountingPeriods.Minimum = accountingPeriodsMin; nudNumberOfAccountingPeriods.Maximum = accountingPeriodsMax; int fwdPostingPeriodsMax = 8; nudNumberFwdPostingPeriods.Value = Math.Max(Math.Min(ARow.NumberFwdPostingPeriods, fwdPostingPeriodsMax), 0); nudNumberFwdPostingPeriods.Maximum = fwdPostingPeriodsMax; int actualsDataRetentionMin = 1; nudActualsDataRetention.Value = Math.Max(Math.Min(ARow.ActualsDataRetention, 100), actualsDataRetentionMin); nudActualsDataRetention.Minimum = actualsDataRetentionMin; int giftDataRetentionMin = 1; nudGiftDataRetention.Value = Math.Max(Math.Min(ARow.GiftDataRetention, 100), giftDataRetentionMin); nudGiftDataRetention.Minimum = giftDataRetentionMin; // comment out budget data retention settings for now until they are properly used in OpenPetra //int budgetDataRetentionMin = 1; //nudBudgetDataRetention.Value = Math.Max(Math.Min(ARow.BudgetDataRetention, 100), budgetDataRetentionMin); //nudBudgetDataRetention.Minimum = budgetDataRetentionMin; if (ARow.CalendarMode) { rbtMonthly.Checked = true; } else { rbtNonMonthly.Checked = true; } CalendarModeChanged(null, null); if (FMainForm.CalendarStartDate != DateTime.MinValue) { dtpFinancialYearStartDate.Date = FMainForm.CalendarStartDate; } }
private void GetLedgerInfo(Int32 ALedgerNumber, out String ALedgerName, out String ALedgerBaseCurrency) { ALedgerRow ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0]; ALedgerBaseCurrency = ledger.BaseCurrency; ALedgerName = TRemote.MFinance.Reporting.WebConnectors.GetLedgerName(FLedgerNumber); }
// // This will be called if the Fast Reports Wrapper loaded OK. // Returns True if the data apparently loaded OK and the report should be printed. private bool LoadReportData(TRptCalculator ACalc) { ArrayList reportParam = ACalc.GetParameters().Elems; Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); foreach (Shared.MReporting.TParameter p in reportParam) { if (p.name.StartsWith("param") && (p.name != "param_calculation") && (!paramsDictionary.ContainsKey(p.name))) { paramsDictionary.Add(p.name, p.value); } } String RootCostCentre = "[" + FLedgerNumber + "]"; paramsDictionary.Add("param_cost_centre_code", new TVariant(RootCostCentre)); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("TrialBalance", paramsDictionary); if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "TrialBalance"); // // I need to get the name of the current ledger.. ALedgerTable LedgerTbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber); String LedgerName = ""; Boolean IsClosed = false; if (LedgerTbl.Rows.Count > 0) { ALedgerRow LedgerRow = LedgerTbl[0]; LedgerName = LedgerRow.LedgerName; // // I want to tell the user whether the selected period is closed // (although they probably know already...) Int32 SelPeriod = ACalc.GetParameters().GetParameter("param_end_period_i").value.ToInt32(); Int32 SelYear = ACalc.GetParameters().GetParameter("param_year_i").value.ToInt32(); if ((SelYear < LedgerRow.CurrentFinancialYear) || (SelPeriod < LedgerRow.CurrentPeriod)) { IsClosed = true; } } ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddParameter("param_period_closed", IsClosed); return(true); }
private Boolean LoadReportData(TRptCalculator ACalc) { Shared.MReporting.TParameterList pm = ACalc.GetParameters(); pm.Add("param_start_period_i", 1); ArrayList reportParam = ACalc.GetParameters().Elems; Dictionary <String, TVariant> paramsDictionary = new Dictionary <string, TVariant>(); foreach (Shared.MReporting.TParameter p in reportParam) { if (p.name.StartsWith("param") && (p.name != "param_calculation")) { paramsDictionary.Add(p.name, p.value); } } DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Executive Summary", paramsDictionary); if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } FPetraUtilsObject.FFastReportsPlugin.RegisterData(ReportTable, "Accounts"); // // My report doesn't need a ledger row - only the name of the ledger. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } ACalc.AddStringParameter("param_ledger_name", LedgerName); ALedgerRow Ledger = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; ACalc.AddStringParameter("param_currency_name", Ledger.BaseCurrency); Boolean HasData = ReportTable.Rows.Count > 0; if (!HasData) { MessageBox.Show(Catalog.GetString("No Executive Summary data found for current Ledger."), "Executive Summary"); } return(HasData); }
private void RunOnceOnParentActivationManual() { ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; FLedgerBaseCurrency = LedgerRow.BaseCurrency; txtControl.CurrencyCode = TTxtCurrencyTextBox.CURRENCY_STANDARD_2_DP; txtCredit.CurrencyCode = FLedgerBaseCurrency; txtDebit.CurrencyCode = FLedgerBaseCurrency; }
// Normally this would be in the generated code, but this screen does not have any controls that are bound to this table (yet?) // If something changes and ShowData moves to generated code, this will become ShowDataManual private void ShowData(ALedgerRow ARow) { if ((FMainDS != null) && (FMainDS.ALedgerInitFlag != null)) { FRequireApprovalDataRow = (ALedgerInitFlagRow)FMainDS.ALedgerInitFlag.Rows.Find(new object[] { FLedgerNumber, "AP_APPROVE_BLOCK" }); chkRequireApproval.Checked = (FRequireApprovalDataRow != null); } else { throw new NullReferenceException("The GLSetupTDS dataset has not been initialised correctly"); } }
/// <summary> /// Get Data Row /// </summary> private void GetDataRow() { TDBTransaction Transaction = new TDBTransaction(); try { TDataBase db = DBAccess.Connect("LedgerInfo.GetDataRow", FDataBase); db.ReadTransaction( ref Transaction, delegate { //Reload all ledgers each time FLedgerTbl = ALedgerAccess.LoadAll(Transaction); // FLedgerTbl is static - this refreshes *any and all* TLedgerInfo objects. #region Validate Data 1 if ((FLedgerTbl == null) || (FLedgerTbl.Count == 0)) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "Function:{0} - The Ledger table is empty or could not be accessed!"), Utilities.GetMethodName(true))); } #endregion Validate Data 1 FMyDataView = new DataView(FLedgerTbl); FMyDataView.RowFilter = String.Format("{0} = {1}", ALedgerTable.GetLedgerNumberDBName(), FLedgerNumber); //a_ledger_number_i #region Validate Data 2 if (FMyDataView.Count == 0) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"), Utilities.GetMethodName(true), FLedgerNumber)); } #endregion Validate Data 2 FLedgerRow = (FMyDataView.Count == 0?null:(ALedgerRow)FMyDataView[0].Row); }); if (FDataBase == null) { db.CloseDBConnection(); } } catch (Exception ex) { TLogging.LogException(ex, Utilities.GetMethodSignature()); throw; } }
/// <summary> /// Set which payments should be paid; initialises the data of this screen /// </summary> /// <param name="ADataset"></param> /// <param name="ALedgerNumber"></param> /// <param name="ADocumentsToPay"></param> /// <returns>true if there's something to pay</returns> public bool AddDocumentsToPayment(AccountsPayableTDS ADataset, Int32 ALedgerNumber, List <Int32> ADocumentsToPay) { FMainDS = ADataset; FLedgerNumber = ALedgerNumber; ALedgerTable Tbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber); FLedgerRow = Tbl[0]; if (FMainDS.AApPayment == null) { FMainDS.Merge(new AccountsPayableTDSAApPaymentTable()); // Because of these lines, AddDocumentsToPayment may only be called once per payment. } else { FMainDS.AApPayment.Clear(); } if (FMainDS.AApDocumentPayment == null) { FMainDS.Merge(new AccountsPayableTDSAApDocumentPaymentTable()); } else { FMainDS.AApDocumentPayment.Clear(); } // I want to check that it'll be OK to pay these documents: for (Int32 Idx = ADocumentsToPay.Count - 1; Idx >= 0; Idx--) { Int32 DocId = ADocumentsToPay[Idx]; AccountsPayableTDS tempDs = TRemote.MFinance.AP.WebConnectors.LoadAApDocument(ALedgerNumber, DocId); if (!ApDocumentCanPay(tempDs, tempDs.AApDocument[0])) { ADocumentsToPay.Remove(DocId); } } if (ADocumentsToPay.Count == 0) { return(false); } TRemote.MFinance.AP.WebConnectors.CreatePaymentTableEntries(ref FMainDS, ALedgerNumber, ADocumentsToPay); chkPrintRemittance.Checked = true; chkClaimDiscount.Enabled = false; chkPrintCheque.Enabled = false; chkPrintLabel.Enabled = false; ShowDataManual(); return(true); }
private void GetDataRow() { TDBTransaction Transaction = null; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadUncommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { FLedgerTbl = ALedgerAccess.LoadAll(Transaction); // FLedgerTbl is static - this refreshes *any and all* TLedgerInfo objects. #region Validate Data 1 if ((FLedgerTbl == null) || (FLedgerTbl.Count == 0)) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "Function:{0} - The Ledger table is empty or could not be accessed!"), Utilities.GetMethodName(true))); } #endregion Validate Data 1 FMyDataView = new DataView(FLedgerTbl); FMyDataView.RowFilter = String.Format("{0} = {1}", ALedgerTable.GetLedgerNumberDBName(), FLedgerNumber); //a_ledger_number_i #region Validate Data 2 if (FMyDataView.Count == 0) { throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString( "Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"), Utilities.GetMethodName(true), FLedgerNumber)); } #endregion Validate Data 2 FLedgerRow = (ALedgerRow)FMyDataView[0].Row; // More than one TLedgerInfo object may point to this same row. }); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } }
private void RunOnceOnParentActivationManual() { // On a screen with no batches we cannot use FLedgerNumber because that is set by LoadJournals int batchFormLedger = ((TFrmRecurringGLBatch)ParentForm).LedgerNumber; ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, batchFormLedger))[0]; FLedgerBaseCurrency = LedgerRow.BaseCurrency; txtControl.CurrencyCode = TTxtCurrencyTextBox.CURRENCY_STANDARD_2_DP; txtCredit.CurrencyCode = FLedgerBaseCurrency; txtDebit.CurrencyCode = FLedgerBaseCurrency; }
private void GetDataFromControlsManual(ALedgerRow ARow) { if ((FRequireApprovalDataRow != null) && !chkRequireApproval.Checked) { // Turn off the requirement for AP approval FRequireApprovalDataRow.Delete(); } if (chkRequireApproval.Checked && (FRequireApprovalDataRow == null)) { // Turn on requirement for AP approval FRequireApprovalDataRow = FMainDS.ALedgerInitFlag.NewRowTyped(); FRequireApprovalDataRow.LedgerNumber = FLedgerNumber; FRequireApprovalDataRow.InitOptionName = "AP_APPROVE_BLOCK"; FMainDS.ALedgerInitFlag.Rows.Add(FRequireApprovalDataRow); } }
private void ShowDataManual() { AccountsPayableTDSAApDocumentRow DocumentRow = FMainDS.AApDocument[0]; FDocumentLedgerNumber = DocumentRow.LedgerNumber; // This will involve a trip to the server to access GLSetupTDS TFrmLedgerSettingsDialog settings = new TFrmLedgerSettingsDialog(this, FDocumentLedgerNumber); FRequireApprovalBeforePosting = settings.APRequiresApprovalBeforePosting; txtTotalAmount.CurrencyCode = DocumentRow.CurrencyCode; txtDetailAmount.CurrencyCode = DocumentRow.CurrencyCode; dtpDateDue.Date = DocumentRow.DateIssued.AddDays(Convert.ToDouble(nudCreditTerms.Value)); this.Text += " - " + TFinanceControls.GetLedgerNumberAndName(FDocumentLedgerNumber); FLedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FDocumentLedgerNumber))[0]; txtDetailBaseAmount.CurrencyCode = FLedgerRow.BaseCurrency; //txtExchangeRateToBase.SetControlProperties(10); // // If this document's currency is that of my own ledger, // I need to disable the rate of exchange field. if (DocumentRow.CurrencyCode == FLedgerRow.BaseCurrency) { txtExchangeRateToBase.Enabled = false; btnLookupExchangeRate.Enabled = false; } if ((FMainDS.AApDocumentDetail == null) || (FMainDS.AApDocumentDetail.Rows.Count == 0)) // When the document is new, I need to create the first detail line. { NewDetail(null, null); } FMainDS.AApDocumentDetail.DefaultView.Sort = AApDocumentDetailTable.GetDetailNumberDBName(); // Create Text description of Anal Attribs for each DetailRow.. foreach (AccountsPayableTDSAApDocumentDetailRow DetailRow in FMainDS.AApDocumentDetail.Rows) { UpdateAttributeLabel(DetailRow); } EnableControls(); }
private void RunOnceOnActivationManual() { rbtPayFullOutstandingAmount.CheckedChanged += new EventHandler(EnablePartialPayment); chkClaimDiscount.Visible = false; txtExchangeRate.TextChanged += new EventHandler(UpdateTotalAmount); ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; FCurrencyTable = (ACurrencyTable)TDataCache.TMCommon.GetCacheableCommonTable(TCacheableCommonTablesEnum.CurrencyCodeList); //txtExchangeRate.SetControlProperties(10); txtBaseAmount.CurrencyCode = LedgerRow.BaseCurrency; TExchangeRateCache.ResetCache(); FocusedRowChanged(null, null); }
/// <summary> /// The screen has been shown /// </summary> private void RunOnceOnActivationManual() { FActiveTab = tpgLedger; // See if we were launched with an initial tab set?? if (FInitialTab == "AP") { tabAllSettings.SelectedTab = tpgAccountsPayable; FActiveTab = tpgAccountsPayable; } ALedgerRow ledgerRow = (ALedgerRow)FMainDS.ALedger.Rows[0]; this.Text = this.Text + String.Format(" - {0}", TFinanceControls.GetLedgerNumberAndName(ledgerRow.LedgerNumber)); FPetraUtilsObject.DataSaved += new TDataSavedHandler(FPetraUtilsObject_DataSaved); }
private void ReadControlsManual(TRptCalculator ACalc, TReportActionEnum AReportAction) { int detailYears = Convert.ToInt16(txtYearsDetail.Text); int summaryYears = Convert.ToInt16(txtYearsSummary.Text); if ((AReportAction == TReportActionEnum.raGenerate) && ((detailYears > 99) || (detailYears < 0) || (summaryYears > 99) || (summaryYears < 0))) { TVerificationResult VerificationMessage = new TVerificationResult( Catalog.GetString("Report Years"), Catalog.GetString("Set the year range between 1 and 99"), TResultSeverity.Resv_Critical); FPetraUtilsObject.AddVerificationResult(VerificationMessage); } ACalc.AddParameter("param_ledger_number_i", FLedgerNumber); // // I need to get the name of the current ledger.. DataTable LedgerNameTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerNameList); DataView LedgerView = new DataView(LedgerNameTable); LedgerView.RowFilter = "LedgerNumber=" + FLedgerNumber; String LedgerName = ""; if (LedgerView.Count > 0) { LedgerName = LedgerView[0].Row["LedgerName"].ToString(); } ALedgerTable LedgerDetailsTable = (ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber); ALedgerRow Row = LedgerDetailsTable[0]; String CurrencyName = (cmbCurrency.SelectedItem.ToString() == "Base") ? Row.BaseCurrency : Row.IntlCurrency; ACalc.AddStringParameter("param_ledger_name", LedgerName); ACalc.AddStringParameter("param_currency_name", CurrencyName); Int32 Years = Math.Max(detailYears, summaryYears); DateTime StartDate = new DateTime(DateTime.Now.Year - Years, 1, 1); ACalc.AddParameter("param_StartDate", StartDate); ACalc.AddParameter("param_DetailYears", detailYears); ACalc.AddParameter("param_SummaryYears", summaryYears); ACalc.AddParameter("param_TD", FTaxDeductiblePercentageEnabled); }
private void RunOnceOnActivationManual() { FPetraUtilsObject.DataSaved += new TDataSavedHandler(FPetraUtilsObject_DataSaved); // Load the data from the Fees Payable cached table Type DataTableType; DataTable CacheDT = TDataCache.GetCacheableDataTableFromPetraServer("FeesPayableList", String.Empty, FFilter, out DataTableType); FExtraDS.AFeesPayable.Merge(CacheDT); FExtraDS.AFeesPayable.DefaultView.Sort = String.Format("{0}, {1} ASC", AFeesPayableTable.GetLedgerNumberDBName(), AFeesPayableTable.GetFeeCodeDBName()); ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; txtDetailChargeAmount.CurrencyCode = LedgerRow.BaseCurrency; SelectRowInGrid(1); UpdateRecordNumberDisplay(); }
/// <summary> /// add a new journal /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void NewRow(System.Object sender, EventArgs e) { if ((FPreviouslySelectedDetailRow == null) || (grdDetails.Rows.Count == 1)) { ALedgerRow LedgerRow = ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable( TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0]; FCurrencyCodeForJournals = LedgerRow.BaseCurrency; } FPetraUtilsObject.VerificationResultCollection.Clear(); this.CreateNewARecurringJournal(); if (grdDetails.Rows.Count > 1) { ((TFrmRecurringGLBatch)this.ParentForm).EnableTransactions(); } }
private void AddTestRow(Int32 ALedgerNumber, String ALedgerName, Boolean ALedgerStatus, String ALedgerCurrency = null) { // Create a new row and specify the column values that are part of our test ALedgerRow newRow = FMainDS.ALedger.NewRowTyped(); newRow.LedgerNumber = ALedgerNumber; newRow.LedgerName = ALedgerName; newRow.LedgerStatus = ALedgerStatus; if (ALedgerCurrency != null) { newRow.BaseCurrency = ALedgerCurrency; } // These columns are also required newRow.PartnerKey = ALedgerNumber * 10000; // unique index for table newRow.ForexGainsLossesAccount = "NUnitForex"; // Not NULL and no default specified FMainDS.ALedger.Rows.Add(newRow); }
private void GetDataRow() { bool NewTransaction = false; try { TDBTransaction transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadUncommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); FLedgerTbl = ALedgerAccess.LoadAll(transaction); // FLedgerTbl is static - this refreshes *any and all* TLedgerInfo objects. MyView = new DataView(FLedgerTbl); MyView.RowFilter = "a_ledger_number_i = " + ledgerNumber; FLedgerRow = (ALedgerRow)MyView[0].Row; // More than one TLedgerInfo object may point to this same row. } finally { if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } } }
/// <summary> /// This ensures that whenever SaveChanges is called we get the data from the controls and that it is valid data. /// Save will fail if there are validation errors /// </summary> private void ValidateDataManual(ALedgerRow ARow) { if (FSpecificControlToValidate == null) { ucoGeneralLedgerSettings.GetValidatedData(); ucoAPLedgerSettings.GetValidatedData(); } else if (FSpecificControlToValidate is TUC_GeneralLedgerSettings) { ucoGeneralLedgerSettings.GetValidatedData(); } else if (FSpecificControlToValidate is TUC_APLedgerSettings) { ucoAPLedgerSettings.GetValidatedData(); } else { throw new ArgumentException("Unknown control to validate"); } // Reset our variable FSpecificControlToValidate = null; }
/// <summary> /// Set which payments should be paid; initialises the data of this screen /// </summary> /// <param name="ADataset"></param> /// <param name="ALedgerNumber"></param> /// <param name="ADocumentsToPay"></param> /// <returns>true if there's something to pay</returns> public bool AddDocumentsToPayment(AccountsPayableTDS ADataset, Int32 ALedgerNumber, List <Int32>ADocumentsToPay) { FMainDS = ADataset; FLedgerNumber = ALedgerNumber; ALedgerTable Tbl = TRemote.MFinance.AP.WebConnectors.GetLedgerInfo(FLedgerNumber); FLedgerRow = Tbl[0]; if (FMainDS.AApPayment == null) { FMainDS.Merge(new AccountsPayableTDSAApPaymentTable()); // Because of these lines, AddDocumentsToPayment may only be called once per payment. } else { FMainDS.AApPayment.Clear(); } if (FMainDS.AApDocumentPayment == null) { FMainDS.Merge(new AccountsPayableTDSAApDocumentPaymentTable()); } else { FMainDS.AApDocumentPayment.Clear(); } // I want to check that it'll be OK to pay these documents: for (Int32 Idx = ADocumentsToPay.Count - 1; Idx >= 0; Idx--) { Int32 DocId = ADocumentsToPay[Idx]; AccountsPayableTDS tempDs = TRemote.MFinance.AP.WebConnectors.LoadAApDocument(ALedgerNumber, DocId); if (!ApDocumentCanPay(tempDs, tempDs.AApDocument[0])) { ADocumentsToPay.Remove(DocId); } } if (ADocumentsToPay.Count == 0) { return false; } TRemote.MFinance.AP.WebConnectors.CreatePaymentTableEntries(ref FMainDS, ALedgerNumber, ADocumentsToPay); chkPrintRemittance.Checked = true; chkClaimDiscount.Enabled = false; chkPrintCheque.Enabled = false; chkPrintLabel.Enabled = false; ShowDataManual(); return true; }
// get Actuals for this month, YTD and Prior YTD and Budget YTD private static Decimal[] GetActualsAndBudget( ALedgerRow ALedger, string AAccountCode, string ACostCentreCode, int APeriodNumber, int AYear) { decimal[] Results = new decimal[4]; int GLMSeqLastYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear - 1); int GLMSeqThisYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear); int GLMSeqNextYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear + 1); Results[0] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, GLMSeqThisYear, -1, APeriodNumber, ALedger.NumberOfAccountingPeriods, ALedger.CurrentFinancialYear, AYear, false, MFinanceConstants.CURRENCY_BASE); Results[1] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, GLMSeqLastYear, GLMSeqThisYear, APeriodNumber, ALedger.NumberOfAccountingPeriods, ALedger.CurrentFinancialYear, AYear - 1, true, MFinanceConstants.CURRENCY_BASE); Results[2] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, GLMSeqThisYear, -1, APeriodNumber, ALedger.NumberOfAccountingPeriods, ALedger.CurrentFinancialYear, AYear, true, MFinanceConstants.CURRENCY_BASE); Results[3] = TCommonBudgetMaintain.GetBudget(GLMSeqThisYear, GLMSeqNextYear, APeriodNumber, ALedger.NumberOfAccountingPeriods, true, MFinanceConstants.CURRENCY_BASE); return Results; }
} // Total Gifts Through Field // get Actuals for this month, YTD and Prior YTD and Budget YTD private static Decimal[] GetActualsAndBudget(TReportingDbAdapter DbAdapter, ALedgerRow ALedger, string AAccountCode, string ACostCentreCode, int APeriodNumber, int AYear) { decimal[] Results = new decimal[4]; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref Transaction, delegate { String YearFilter = String.Format(" AND glm.a_year_i in({0},{1})", AYear - 1, AYear); String PeriodFilter = (APeriodNumber > 1) ? String.Format(" AND glmp.a_period_number_i IN ({0},{1})", APeriodNumber - 1, APeriodNumber) : " AND glmp.a_period_number_i=1"; AAccountRow AccountRow = (AAccountRow)AAccountAccess.LoadByPrimaryKey(ALedger.LedgerNumber, AAccountCode, Transaction).Rows[0]; String AccountFilter = GetReportingAccounts(ALedger.LedgerNumber, AAccountCode, ""); AccountFilter = " AND glm.a_account_code_c IN ('" + AccountFilter.Replace(",", "','") + "')"; String CostCentreFilter = GetReportingCostCentres(ALedger.LedgerNumber, ACostCentreCode, ""); CostCentreFilter = " AND glm.a_cost_centre_code_c in ('" + CostCentreFilter.Replace(",", "','") + "') "; String subtractOrAddBase = (AccountRow.DebitCreditIndicator) ? "CASE WHEN debit=TRUE THEN Base ELSE 0-Base END" : "CASE WHEN debit=TRUE THEN 0-Base ELSE Base END"; String subtractOrAddLastMonth = (APeriodNumber == 1) ? "CASE WHEN Year=" + AYear + " THEN " + ( (AccountRow.DebitCreditIndicator) ? "CASE WHEN debit=TRUE THEN YearStart ELSE 0-YearStart END" : "CASE WHEN debit=TRUE THEN 0-YearStart ELSE YearStart END") + " END" : "CASE WHEN Year=" + AYear + " AND Period=" + (APeriodNumber - 1) + " THEN " + subtractOrAddBase + " END"; String subtractOrAddThisYear = "CASE WHEN Year=" + AYear + " AND Period=" + APeriodNumber + " THEN " + subtractOrAddBase + " END"; String subtractOrAddLastYear = "CASE WHEN Year=" + (AYear - 1) + " AND Period=" + APeriodNumber + " THEN " + subtractOrAddBase + " END"; String subtractOrAddBudget = "CASE WHEN Year=" + AYear + " AND Period=" + APeriodNumber + " THEN " + ( (AccountRow.DebitCreditIndicator) ? "CASE WHEN debit=TRUE THEN Budget ELSE 0-Budget END" : "CASE WHEN debit=TRUE THEN 0-Budget ELSE Budget END") + " END"; String Query = "SELECT sum(" + subtractOrAddLastMonth + ") AS SumLastMonthYtd," + " sum(" + subtractOrAddThisYear + ") AS SumYtd," + " sum(" + subtractOrAddLastYear + ") AS SumLastYear," + " sum(" + subtractOrAddBudget + ") AS SumBudget" + " FROM" + " (SELECT DISTINCT a_account.a_account_code_c AS AccountCode, glm.a_cost_centre_code_c AS CostCentreCode, a_account.a_debit_credit_indicator_l AS debit," + " glm.a_year_i AS Year," + " glm.a_start_balance_base_n AS YearStart," + " glmp.a_period_number_i AS Period," + " glmp.a_actual_base_n AS Base, glmp.a_budget_base_n AS Budget" + " FROM a_general_ledger_master AS glm, a_general_ledger_master_period AS glmp, a_account" + " WHERE glm.a_glm_sequence_i=glmp.a_glm_sequence_i" + " AND glm.a_account_code_c=a_account.a_account_code_c" + " AND a_account.a_ledger_number_i=" + ALedger.LedgerNumber + " AND glm.a_ledger_number_i=" + ALedger.LedgerNumber + YearFilter + PeriodFilter + AccountFilter + CostCentreFilter + ") AS AllGlm"; DataTable tempTable = DbAdapter.RunQuery(Query, "ExecSummary", Transaction); if (tempTable.Rows.Count > 0) { Results[0] = Convert.ToDecimal(tempTable.Rows[0]["SumYtd"]) - Convert.ToDecimal(tempTable.Rows[0]["SumLastMonthYtd"]); Results[1] = Convert.ToDecimal(tempTable.Rows[0]["SumLastYear"]); Results[2] = Convert.ToDecimal(tempTable.Rows[0]["SumYtd"]); Results[3] = Convert.ToDecimal(tempTable.Rows[0]["SumBudget"]); } /* * int GLMSeqLastYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( * ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear - 1); * int GLMSeqThisYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( * ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear); * int GLMSeqNextYear = TCommonBudgetMaintain.GetGLMSequenceForBudget( * ALedger.LedgerNumber, AAccountCode, ACostCentreCode, AYear + 1); * * Results[0] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, * GLMSeqThisYear, * -1, * APeriodNumber, * ALedger.NumberOfAccountingPeriods, * ALedger.CurrentFinancialYear, * AYear, * false, * MFinanceConstants.CURRENCY_BASE); * Results[1] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, * GLMSeqLastYear, * GLMSeqThisYear, * APeriodNumber, * ALedger.NumberOfAccountingPeriods, * ALedger.CurrentFinancialYear, * AYear - 1, * true, * MFinanceConstants.CURRENCY_BASE); * Results[2] = TCommonBudgetMaintain.GetActual(ALedger.LedgerNumber, * GLMSeqThisYear, * -1, * APeriodNumber, * ALedger.NumberOfAccountingPeriods, * ALedger.CurrentFinancialYear, * AYear, * true, * MFinanceConstants.CURRENCY_BASE); * Results[3] = TCommonBudgetMaintain.GetBudget(GLMSeqThisYear, * GLMSeqNextYear, * APeriodNumber, * ALedger.NumberOfAccountingPeriods, * true, * MFinanceConstants.CURRENCY_BASE); */ }); return Results; }
// The main validation method for the controls on this tab page private void ValidateDataManual(ALedgerRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult = null; // make sure that Financial Year Start Date is no later than 28th of a month // (this field is not part of a_ledger but will be stored in period 1 of a_accounting_period) if (rbtMonthly.Checked) { // make sure that Financial Year Start Date is not empty // (this field is not part of a_ledger but will be stored in period 1 of a_accounting_period) if (dtpFinancialYearStartDate.Date == null) { VerificationResult = new TScreenVerificationResult( TDateChecks.IsNotUndefinedDateTime( dtpFinancialYearStartDate.Date, lblFinancialYearStartDate.Text.Trim(':'), true, this), null, dtpFinancialYearStartDate); } else if (dtpFinancialYearStartDate.Date.Value.Day > 28) { VerificationResult = new TScreenVerificationResult( this, new DataColumn(), ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_PERIOD_START_DAY_AFTER_28).ErrorMessageText, PetraErrorCodes.ERR_PERIOD_START_DAY_AFTER_28, dtpFinancialYearStartDate, TResultSeverity.Resv_Critical); } else { VerificationResult = null; } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, null); } // check that there no suspense accounts for this ledger if box is unticked ValidationColumn = ARow.Table.Columns[ALedgerTable.ColumnSuspenseAccountFlagId]; if (FValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (!ARow.SuspenseAccountFlag) { if (TRemote.MFinance.Common.ServerLookups.WebConnectors.HasSuspenseAccounts(FLedgerNumber)) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_NO_SUSPENSE_ACCOUNTS_ALLOWED)), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = null; } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } } // check that the number of forwarding periods is not less than the already used ones ValidationColumn = ARow.Table.Columns[ALedgerTable.ColumnNumberFwdPostingPeriodsId]; if (FValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.NumberFwdPostingPeriods < FMainForm.CurrentForwardPostingPeriods) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_NUMBER_FWD_PERIODS_TOO_SMALL, new string[] { FMainForm.CurrentForwardPostingPeriods.ToString(), FMainForm.CurrentForwardPostingPeriods.ToString() })), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = null; } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } // check that current period is not greater than number of ledger periods ValidationColumn = ARow.Table.Columns[ALedgerTable.ColumnNumberOfAccountingPeriodsId]; if (FValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { if (ARow.CurrentPeriod > ARow.NumberOfAccountingPeriods) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(this, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_CURRENT_PERIOD_TOO_LATE)), ValidationColumn, ValidationControlsData.ValidationControl); } else { VerificationResult = null; } // Handle addition/removal to/from TVerificationResultCollection VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn); } }
/// <summary> /// Additional tasks in addition to those defined by the auto-generator /// </summary> private void GetDataFromControlsManual(ALedgerRow ARow) { ARow.CalendarMode = rbtMonthly.Checked; if (dtpFinancialYearStartDate.Text.Trim() == "") { FMainForm.CalendarStartDate = DateTime.MinValue; } else { // set ledger row to modified if calendar date has changed (this is necessary as otherwise SaveChanges() would // not call StoreManualCode(...) if there was no other change on that screen and then the calendar change // would not get triggered on server if (FMainForm.CalendarStartDate != dtpFinancialYearStartDate.Date.Value) { ARow.SetModified(); } FMainForm.CalendarStartDate = dtpFinancialYearStartDate.Date.Value; } }