mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-06 13:01:50 +02:00
added currency conversion to the CurrencyConversion class
This commit is contained in:
parent
71caae03f9
commit
f1a4a93a41
1 changed files with 8 additions and 0 deletions
|
@ -26,6 +26,14 @@ class CurrencyConverter(object):
|
|||
for rate in self.response["rates"]:
|
||||
currencies.append((rate,rate))
|
||||
return currencies
|
||||
|
||||
def echange_currency(self,amount,currency1,currency2):
|
||||
base = self.response["base"]
|
||||
conversion_rate1 = self.response["rates"][currency1]
|
||||
conversion_rate2 = self.response["rates"][currency2]
|
||||
new_amount = (amount / conversion_rate1) * conversion_rate2
|
||||
# round to two digits because we are dealing with money
|
||||
return round(new_amount,2)
|
||||
|
||||
def slugify(value):
|
||||
"""Normalizes string, converts to lowercase, removes non-alpha characters,
|
||||
|
|
Loading…
Reference in a new issue