Fixed retreiving of exchange rates [0000057]
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 18 Sep 2008 22:39:00 +0000 (22:39 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 18 Sep 2008 22:39:00 +0000 (22:39 +0000)
CHANGELOG.txt
gl/manage/exchange_rates.php
includes/banking.inc
includes/ui/ui_view.inc

index d491a6c11bbd3d1fb4ea2d0023484b84cdb8d2fa..0400ed9c6073baa3223815b62d39fc039c33490e 100644 (file)
@@ -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.
index 669895b14863e539ada9ab9aff00c35775899694..5cd3ed217fff4a9c8348c679e7ce177be36f8b9e 100644 (file)
@@ -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, '',
index d3ca75bd5c4295992b88f4b270a21e47ece046a3..5e5f346e0fe3f009d2732bda43101cb78a7edbc3 100644 (file)
@@ -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;
        }
        
index c1364786608d52b4c08b636ec818a561e3196f14..4b23e03059d274a7e8b32a6a1cc9cc010f025db4 100644 (file)
@@ -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 . " = <span id='_ex_rate'>" . $rate . "</span> " . $to_currency .
                ($buttons?"  " . submit('get_rate',_("Get"), false, $hint, true):""));