From fe73be4641ae9b204b29ff662ecd11b2cc73a846 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Thu, 18 Sep 2008 22:39:00 +0000 Subject: [PATCH] Fixed retreiving of exchange rates [0000057] --- CHANGELOG.txt | 5 +++++ gl/manage/exchange_rates.php | 3 +++ includes/banking.inc | 1 + includes/ui/ui_view.inc | 13 ++++++------- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d491a6c..0400ed9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,7 @@ Legend: ! -> Note $ -> Affected files +18-Sep-2008 Janusz Dobrowolski + Support for calling external pages during document entry (e.g. for adding customer/supplier/items). $ /index.php /includes/ui/ui_controls.inc @@ -48,6 +49,10 @@ $ /purchasing/supplier_credit.php /sales/manage/customers.php # Syntax error introduced in previous update fixed $ /inventory/prices.php +# Fixed retreiving of exchange rates [0000057] +$ /gl/manage/exchange_rates.php + /includes/banking.inc + /includes/ui/ui_view.inc 18-Sep-2008 Joe Hunt + New Report - Bank Statement. diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 669895b..5cd3ed2 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -140,6 +140,9 @@ function display_rate_edit() if (isset($_POST['get_rate'])) { $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); + if ($_POST['BuyRate'] == 0) { + display_error(_('This currency is not listed by ECB. Enter exchange rate manually.')); + } $Ajax->activate('BuyRate'); } small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', diff --git a/includes/banking.inc b/includes/banking.inc index d3ca75b..5e5f346 100644 --- a/includes/banking.inc +++ b/includes/banking.inc @@ -85,6 +85,7 @@ function get_exchange_rate_from_home_currency($currency_code, $date_) if (db_num_rows($result) == 0) { // no stored exchange rate, just return 1 + display_error(_("Cannot get exchange rate for this currency. Please add exchange rate manually on Exchange Rates page.") ); return 1.000; } diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index c136478..4b23e03 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -285,24 +285,23 @@ function exchange_rate_display($from_currency, $to_currency, $date_, $buttons=tr $currency = $to_currency; else $currency = $from_currency; + $rate = get_ecb_rate($currency); - if ($rate==0) - { - display_error(_("Cannot get exchange rate for this currency. Please add exchange rate manually on Exchange Rates page.") ); - $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_); - } else - { + if ($rate && ($date_==Today())) { if (get_date_exchange_rate($currency, $date_)) update_exchange_rate($currency, $date_, $rate, $rate); else add_exchange_rate($currency, $date_, $rate, $rate); - } + } else + $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_); + if ($from_currency == $comp_currency) $rate = 1 / $rate; $Ajax->activate('get_rate'); } else $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_); + $rate = number_format2($rate, user_exrate_dec()); label_row(_("Exchange Rate:"),"1 " . $from_currency . " = " . $rate . " " . $to_currency . ($buttons?" " . submit('get_rate',_("Get"), false, $hint, true):"")); -- 2.30.2