/// <summary> /// if withExchangeRatesGLM is false, it /// will only set the correct values for realPeriod and realYear, /// </summary> /// <returns></returns> public TFinancialPeriod(TDataBase databaseConnection, int period, int year, TParameterList parameters, int column) { diffPeriod = 0; FCurrentFinancialYear = parameters.Get("param_current_financial_year_i", column).ToInt(); FNumberAccountingPeriods = parameters.Get("param_number_of_accounting_periods_i", column).ToInt(); FCurrentPeriod = parameters.Get("param_current_period_i", column).ToInt(); FNumberForwardingPeriods = parameters.Get("param_number_fwd_posting_periods_i", column).ToInt(); Int32 glmSequenceNumber = parameters.Get("glm_sequence_i", column).ToInt(); LedgerStatus myLedgerStatus = new LedgerStatus(); realGlmSequence = myLedgerStatus.GlmSequencesCache.GetGlmSequence(glmSequenceNumber); if ((realGlmSequence != null) && (realGlmSequence.year != year)) { realGlmSequence = myLedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, year); } if (parameters.Exists("param_diff_period_i", column, -1)) { diffPeriod = parameters.Get("param_diff_period_i", column).ToInt(); } MainConstructor(databaseConnection, period, year, diffPeriod, FCurrentFinancialYear, FCurrentPeriod, FNumberAccountingPeriods, FNumberForwardingPeriods, realGlmSequence, myLedgerStatus); }
/// <summary> /// called by the constructors /// </summary> /// <param name="databaseConnection"></param> /// <param name="period"></param> /// <param name="year">the selected year that the report should be on</param> /// <param name="diffPeriod"></param> /// <param name="ACurrentFinancialYear"></param> /// <param name="ACurrentPeriod"></param> /// <param name="ANumberAccountingPeriods"></param> /// <param name="ANumberForwardingPeriods"></param> /// <param name="glmSequence">in relation to year, not currentFinancialYear</param> /// <param name="myLedgerStatus"></param> public void MainConstructor(TDataBase databaseConnection, int period, int year, int diffPeriod, System.Int32 ACurrentFinancialYear, System.Int32 ACurrentPeriod, System.Int32 ANumberAccountingPeriods, System.Int32 ANumberForwardingPeriods, TGlmSequence glmSequence, LedgerStatus myLedgerStatus) { this.diffPeriod = diffPeriod; FCurrentFinancialYear = ACurrentFinancialYear; FNumberAccountingPeriods = ANumberAccountingPeriods; FCurrentPeriod = ACurrentPeriod; FNumberForwardingPeriods = ANumberForwardingPeriods; realPeriod = period + diffPeriod; realYear = year; if (glmSequence == null) { realGlmSequence = null; } else { realGlmSequence = myLedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, glmSequence, realYear); } // the period is in the last year // this treatment only applies to situations with different financial years. // in a financial year equals to the glm year, the period 0 represents the start balance if ((diffPeriod == 0) && (realPeriod == 0)) { // leave it, period 0 represents the start balance } else if (realPeriod < 1) { realPeriod = FNumberAccountingPeriods + realPeriod; realYear = realYear - 1; realGlmSequence = myLedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, realYear); } // forwarding periods are only allowed in the current year if ((realPeriod > FNumberAccountingPeriods) && (realYear != FCurrentFinancialYear)) { realPeriod = realPeriod - FNumberAccountingPeriods; realYear = realYear + 1; realGlmSequence = myLedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, realYear); } if (realGlmSequence != null) { exchangeRateToIntl = myLedgerStatus.ExchangeRateCache.GetCorporateExchangeRate(databaseConnection, realGlmSequence.ledger_number, realYear, realPeriod, FCurrentFinancialYear); } }
/// <summary> /// copy constructor /// </summary> /// <param name="APeriod"></param> public TFinancialPeriod(TFinancialPeriod APeriod) { diffPeriod = APeriod.diffPeriod; realYear = APeriod.realYear; realPeriod = APeriod.realPeriod; realGlmSequence = new TGlmSequence(APeriod.realGlmSequence); exchangeRateToIntl = APeriod.exchangeRateToIntl; FCurrentFinancialYear = APeriod.FCurrentFinancialYear; FNumberAccountingPeriods = APeriod.FNumberAccountingPeriods; FCurrentPeriod = APeriod.FCurrentPeriod; FNumberForwardingPeriods = APeriod.FNumberForwardingPeriods; }
/// <summary> /// copy constructor /// </summary> /// <param name="glmSequence"></param> public TGlmSequence(TGlmSequence glmSequence) { this.account_code = glmSequence.account_code; this.cost_centre_code = glmSequence.cost_centre_code; this.incExpAccount = glmSequence.incExpAccount; this.postingAccount = glmSequence.postingAccount; this.DebitCreditIndicator = glmSequence.DebitCreditIndicator; this.ledger_number = glmSequence.ledger_number; this.currentFinancialYearSequence = glmSequence.currentFinancialYearSequence; this.currentFinancialYear = glmSequence.currentFinancialYear; this.glmSequence = glmSequence.glmSequence; this.year = glmSequence.year; }
/// <summary> /// Get the sequence number of another year, using a known sequence number /// </summary> /// <param name="databaseConnection"></param> /// <param name="glmSequence">The known sequence number of a general_ledger_master year</param> /// <param name="year">The year of the required sequence</param> /// <returns>the glm sequence System.Object of the a_general_ledger_master row of the another year; null if there is no available a_general_ledger_master row /// </returns> /// public TGlmSequence GetOtherYearGlmSequence(TDataBase databaseConnection, TGlmSequence glmSequence, int year) { TGlmSequence ReturnValue; int sequenceNumber; if (glmSequence == null) { return(null); } // first check the local cache ReturnValue = null; foreach (TGlmSequence glmSequenceElement in glmSequences) { if ((glmSequenceElement.currentFinancialYearSequence == glmSequence.currentFinancialYearSequence) && (glmSequenceElement.year == year)) { ReturnValue = glmSequenceElement; break; } } if ((ReturnValue == null) && (glmSequence != null)) { sequenceNumber = GetGlmSequenceFromDB(databaseConnection, glmSequence.ledger_number, glmSequence.cost_centre_code, glmSequence.account_code, year); if (sequenceNumber == -1) { // for the summary accounts from alternative account hierarchies, // which don't have glm records. sequenceNumber = NextNegativeSequence; NextNegativeSequence--; } TGlmSequence glmSequenceElement = new TGlmSequence(glmSequence, sequenceNumber, year); glmSequences.Add(glmSequenceElement); ReturnValue = glmSequenceElement; } return(ReturnValue); }
/// the given period should not be changed with diffPeriod public TFinancialPeriod(TDataBase databaseConnection, int realPeriod, int year, TParameterList parameters, int column, bool real) { diffPeriod = 0; FCurrentFinancialYear = parameters.Get("param_current_financial_year_i", column).ToInt(); FNumberAccountingPeriods = parameters.Get("param_number_of_accounting_periods_i", column).ToInt(); FCurrentPeriod = parameters.Get("param_current_period_i", column).ToInt(); FNumberForwardingPeriods = parameters.Get("param_number_of_accounting_periods_i", column).ToInt(); Int32 glmSequenceNumber = parameters.Get("glm_sequence_i", column).ToInt(); realGlmSequence = LedgerStatus.GlmSequencesCache.GetGlmSequence(glmSequenceNumber); MainConstructor(databaseConnection, realPeriod, year, diffPeriod, FCurrentFinancialYear, FCurrentPeriod, FNumberAccountingPeriods, FNumberForwardingPeriods, realGlmSequence); }
/// <summary> /// constructor /// </summary> /// <param name="databaseConnection"></param> /// <param name="period"></param> /// <param name="year"></param> /// <param name="diffPeriod"></param> /// <param name="ACurrentFinancialYear"></param> /// <param name="ACurrentPeriod"></param> /// <param name="ANumberAccountingPeriods"></param> /// <param name="ANumberForwardingPeriods"></param> /// <param name="glmSequence"></param> public TFinancialPeriod(TDataBase databaseConnection, int period, int year, int diffPeriod, System.Int32 ACurrentFinancialYear, System.Int32 ACurrentPeriod, System.Int32 ANumberAccountingPeriods, System.Int32 ANumberForwardingPeriods, TGlmSequence glmSequence) { MainConstructor(databaseConnection, period, year, diffPeriod, ACurrentFinancialYear, ACurrentPeriod, ANumberAccountingPeriods, ANumberForwardingPeriods, glmSequence); }
/// <summary> /// Get the sequence System.Object of a a_general_ledger_master /// </summary> /// <returns>the glm sequence System.Object of the a_general_ledger_master row of the given year; nil if there is no available a_general_ledger_master row /// </returns> public TGlmSequence GetGlmSequenceCurrentYear(TDataBase databaseConnection, int pv_ledger_number_i, String pv_cost_centre_code_c, String pv_account_code_c, int pv_current_financial_year_i) { TGlmSequence ReturnValue; int sequenceNumber; String accountType; bool postingAccount; bool debitCreditIndicator; // first check the local cache ReturnValue = null; foreach (TGlmSequence glmSequenceElement in glmSequences) { if ((glmSequenceElement.ledger_number == pv_ledger_number_i) && (glmSequenceElement.account_code == pv_account_code_c) && (glmSequenceElement.cost_centre_code == pv_cost_centre_code_c) && (glmSequenceElement.year == pv_current_financial_year_i)) { ReturnValue = glmSequenceElement; break; } } if (ReturnValue == null) { sequenceNumber = GetGlmSequenceFromDB(databaseConnection, pv_ledger_number_i, pv_cost_centre_code_c, pv_account_code_c, pv_current_financial_year_i); if (sequenceNumber == -1) { // for the summary accounts from alternative account hierarchies, // which don't have glm records. sequenceNumber = NextNegativeSequence; NextNegativeSequence = NextNegativeSequence - 1; } if (TAccountInfo(databaseConnection, pv_ledger_number_i, pv_account_code_c, out accountType, out postingAccount, out debitCreditIndicator)) { TGlmSequence glmSequenceElement = new TGlmSequence(pv_ledger_number_i, pv_account_code_c, pv_cost_centre_code_c, StringHelper.IsSame(accountType, "income") || StringHelper.IsSame(accountType, "expense"), postingAccount, debitCreditIndicator, sequenceNumber, pv_current_financial_year_i); glmSequences.Add(glmSequenceElement); ReturnValue = glmSequenceElement; } else { // account could not be found ReturnValue = null; } } return(ReturnValue); }
/// <summary> /// Get the sequence number of another year, using a known sequence number /// </summary> /// <param name="databaseConnection"></param> /// <param name="glmSequence">The known sequence number of a general_ledger_master year</param> /// <param name="year">The year of the required sequence</param> /// <returns>the glm sequence System.Object of the a_general_ledger_master row of the another year; null if there is no available a_general_ledger_master row /// </returns> /// public TGlmSequence GetOtherYearGlmSequence(TDataBase databaseConnection, TGlmSequence glmSequence, int year) { TGlmSequence ReturnValue; int sequenceNumber; if (glmSequence == null) { return null; } // first check the local cache ReturnValue = null; foreach (TGlmSequence glmSequenceElement in glmSequences) { if ((glmSequenceElement.currentFinancialYearSequence == glmSequence.currentFinancialYearSequence) && (glmSequenceElement.year == year)) { ReturnValue = glmSequenceElement; break; } } if ((ReturnValue == null) && (glmSequence != null)) { sequenceNumber = GetGlmSequenceFromDB(databaseConnection, glmSequence.ledger_number, glmSequence.cost_centre_code, glmSequence.account_code, year); if (sequenceNumber == -1) { // for the summary accounts from alternative account hierarchies, // which don't have glm records. sequenceNumber = NextNegativeSequence; NextNegativeSequence--; } TGlmSequence glmSequenceElement = new TGlmSequence(glmSequence, sequenceNumber, year); glmSequences.Add(glmSequenceElement); ReturnValue = glmSequenceElement; } return ReturnValue; }
/// <summary> /// Get the sequence System.Object of a a_general_ledger_master /// </summary> /// <returns>the glm sequence System.Object of the a_general_ledger_master row of the given year; nil if there is no available a_general_ledger_master row /// </returns> public TGlmSequence GetGlmSequenceCurrentYear(TDataBase databaseConnection, int pv_ledger_number_i, String pv_cost_centre_code_c, String pv_account_code_c, int pv_current_financial_year_i) { TGlmSequence ReturnValue; int sequenceNumber; String accountType; bool postingAccount; bool debitCreditIndicator; // first check the local cache ReturnValue = null; foreach (TGlmSequence glmSequenceElement in glmSequences) { if ((glmSequenceElement.ledger_number == pv_ledger_number_i) && (glmSequenceElement.account_code == pv_account_code_c) && (glmSequenceElement.cost_centre_code == pv_cost_centre_code_c) && (glmSequenceElement.year == pv_current_financial_year_i)) { ReturnValue = glmSequenceElement; break; } } if (ReturnValue == null) { sequenceNumber = GetGlmSequenceFromDB(databaseConnection, pv_ledger_number_i, pv_cost_centre_code_c, pv_account_code_c, pv_current_financial_year_i); if (sequenceNumber == -1) { // for the summary accounts from alternative account hierarchies, // which don't have glm records. sequenceNumber = NextNegativeSequence; NextNegativeSequence = NextNegativeSequence - 1; } if (TAccountInfo(databaseConnection, pv_ledger_number_i, pv_account_code_c, out accountType, out postingAccount, out debitCreditIndicator)) { TGlmSequence glmSequenceElement = new TGlmSequence(pv_ledger_number_i, pv_account_code_c, pv_cost_centre_code_c, StringHelper.IsSame(accountType, "income") || StringHelper.IsSame(accountType, "expense"), postingAccount, debitCreditIndicator, sequenceNumber, pv_current_financial_year_i); glmSequences.Add(glmSequenceElement); ReturnValue = glmSequenceElement; } else { // account could not be found ReturnValue = null; } } return ReturnValue; }
/// <summary> /// if withExchangeRatesGLM is false, it /// will only set the correct values for realPeriod and realYear, /// </summary> /// <returns></returns> public TFinancialPeriod(TDataBase databaseConnection, int period, int year, TParameterList parameters, int column) { diffPeriod = 0; FCurrentFinancialYear = parameters.Get("param_current_financial_year_i", column).ToInt(); FNumberAccountingPeriods = parameters.Get("param_number_of_accounting_periods_i", column).ToInt(); FCurrentPeriod = parameters.Get("param_current_period_i", column).ToInt(); FNumberForwardingPeriods = parameters.Get("param_number_fwd_posting_periods_i", column).ToInt(); Int32 glmSequenceNumber = parameters.Get("glm_sequence_i", column).ToInt(); realGlmSequence = LedgerStatus.GlmSequencesCache.GetGlmSequence(glmSequenceNumber); if ((realGlmSequence != null) && (realGlmSequence.year != year)) { realGlmSequence = LedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, year); } if (parameters.Exists("param_diff_period_i", column, -1)) { diffPeriod = parameters.Get("param_diff_period_i", column).ToInt(); } MainConstructor(databaseConnection, period, year, diffPeriod, FCurrentFinancialYear, FCurrentPeriod, FNumberAccountingPeriods, FNumberForwardingPeriods, realGlmSequence); }
/// <summary> /// called by the constructors /// </summary> /// <param name="databaseConnection"></param> /// <param name="period"></param> /// <param name="year">the selected year that the report should be on</param> /// <param name="diffPeriod"></param> /// <param name="ACurrentFinancialYear"></param> /// <param name="ACurrentPeriod"></param> /// <param name="ANumberAccountingPeriods"></param> /// <param name="ANumberForwardingPeriods"></param> /// <param name="glmSequence">in relation to year, not currentFinancialYear</param> public void MainConstructor(TDataBase databaseConnection, int period, int year, int diffPeriod, System.Int32 ACurrentFinancialYear, System.Int32 ACurrentPeriod, System.Int32 ANumberAccountingPeriods, System.Int32 ANumberForwardingPeriods, TGlmSequence glmSequence) { this.diffPeriod = diffPeriod; FCurrentFinancialYear = ACurrentFinancialYear; FNumberAccountingPeriods = ANumberAccountingPeriods; FCurrentPeriod = ACurrentPeriod; FNumberForwardingPeriods = ANumberForwardingPeriods; realPeriod = period + diffPeriod; realYear = year; if (glmSequence == null) { realGlmSequence = null; } else { realGlmSequence = LedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, glmSequence, realYear); } // the period is in the last year // this treatment only applies to situations with different financial years. // in a financial year equals to the glm year, the period 0 represents the start balance if ((diffPeriod == 0) && (realPeriod == 0)) { // leave it, period 0 represents the start balance } else if (realPeriod < 1) { realPeriod = FNumberAccountingPeriods + realPeriod; realYear = realYear - 1; realGlmSequence = LedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, realYear); } // forwarding periods are only allowed in the current year if ((realPeriod > FNumberAccountingPeriods) && (realYear != FCurrentFinancialYear)) { realPeriod = realPeriod - FNumberAccountingPeriods; realYear = realYear + 1; realGlmSequence = LedgerStatus.GlmSequencesCache.GetOtherYearGlmSequence(databaseConnection, realGlmSequence, realYear); } if (realGlmSequence != null) { exchangeRateToIntl = LedgerStatus.ExchangeRateCache.GetCorporateExchangeRate(databaseConnection, realGlmSequence.ledger_number, realYear, realPeriod, FCurrentFinancialYear); } }