/// <summary> /// todoComment /// </summary> /// <param name="databaseConnection">The database connection.</param> /// <param name="pv_ledger_number_i">The pv_ledger_number_i.</param> /// <param name="pv_year_i">The pv_year_i.</param> /// <param name="pv_period_i">The pv_period_i.</param> /// <param name="currentFinancialYear">The current financial year.</param> /// <returns></returns> public decimal GetCorporateExchangeRate(TDataBase databaseConnection, int pv_ledger_number_i, int pv_year_i, int pv_period_i, int currentFinancialYear) { if (pv_period_i == 0) // I sometimes get asked for this. There's no period 0. { //TODO: Calendar vs Financial Date Handling - Need to confirm this below pv_period_i = 12; // Perhaps I should look up this value from number of periods? pv_year_i--; } foreach (TExchangeRate exchangeRateElement in exchangeRates) { if ((exchangeRateElement.ledger_number_i == pv_ledger_number_i) && (exchangeRateElement.year_i == pv_year_i) && (exchangeRateElement.period_i == pv_period_i)) { return(exchangeRateElement.rate_n); } } decimal ReturnValue = GetCorporateExchangeRateFromDB(databaseConnection, pv_ledger_number_i, pv_year_i, pv_period_i, currentFinancialYear); // // Cache this for the next time I'm asked... TExchangeRate exchangeRateElement2 = new TExchangeRate(); exchangeRateElement2.ledger_number_i = pv_ledger_number_i; exchangeRateElement2.year_i = pv_year_i; exchangeRateElement2.period_i = pv_period_i; exchangeRateElement2.rate_n = ReturnValue; exchangeRates.Add(exchangeRateElement2); return(ReturnValue); }
/// <summary> /// todoComment /// </summary> /// <param name="databaseConnection">The database connection.</param> /// <param name="pv_ledger_number_i">The pv_ledger_number_i.</param> /// <param name="pv_year_i">The pv_year_i.</param> /// <param name="pv_period_i">The pv_period_i.</param> /// <param name="currentFinancialYear">The current financial year.</param> /// <returns></returns> public decimal GetCorporateExchangeRate(TDataBase databaseConnection, int pv_ledger_number_i, int pv_year_i, int pv_period_i, int currentFinancialYear) { if (pv_period_i == 0) // I sometimes get asked for this. There's no period 0. { //TODO: Calendar vs Financial Date Handling - Need to confirm this below pv_period_i = 12; // Perhaps I should look up this value from number of periods? pv_year_i--; } foreach (TExchangeRate exchangeRateElement in exchangeRates) { if ((exchangeRateElement.ledger_number_i == pv_ledger_number_i) && (exchangeRateElement.year_i == pv_year_i) && (exchangeRateElement.period_i == pv_period_i)) { return exchangeRateElement.rate_n; } } decimal ReturnValue = GetCorporateExchangeRateFromDB(databaseConnection, pv_ledger_number_i, pv_year_i, pv_period_i, currentFinancialYear); // // Cache this for the next time I'm asked... TExchangeRate exchangeRateElement2 = new TExchangeRate(); exchangeRateElement2.ledger_number_i = pv_ledger_number_i; exchangeRateElement2.year_i = pv_year_i; exchangeRateElement2.period_i = pv_period_i; exchangeRateElement2.rate_n = ReturnValue; exchangeRates.Add(exchangeRateElement2); return ReturnValue; }