From 072aa83479f051d0582b4b2972023e1ba300b252 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 28 Sep 2012 21:52:52 +0200 Subject: [PATCH] brmbar.Currency.convert(): Use _latest_ exchange rate, not earliest --- brmbar3/brmbar/Currency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brmbar3/brmbar/Currency.py b/brmbar3/brmbar/Currency.py index c197bf1..8acd260 100644 --- a/brmbar3/brmbar/Currency.py +++ b/brmbar3/brmbar/Currency.py @@ -63,7 +63,7 @@ class Currency: def convert(self, amount, target): with closing(self.db.cursor()) as cur: - cur.execute("SELECT rate, rate_dir FROM exchange_rates WHERE target = %s AND source = %s AND valid_since <= NOW() ORDER BY valid_since ASC LIMIT 1", [target.id, self.id]) + cur.execute("SELECT rate, rate_dir FROM exchange_rates WHERE target = %s AND source = %s AND valid_since <= NOW() ORDER BY valid_since DESC LIMIT 1", [target.id, self.id]) res = cur.fetchone() if res is None: raise NameError("Currency.convert(): Unknown conversion " + self.name() + " to " + other.name())