Created
May 28, 2014 12:51
-
-
Save spookylukey/589f9d3f05be56351fec to your computer and use it in GitHub Desktop.
How not to do currncy exchange...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exchange(self, price): | |
#default = Currency.objects.get(iso4217=DEFAULT_CURRENCY) | |
try: | |
rate = self.exchangerate_set.all()[0] | |
return Decimal(str(float(rate.denominator) * float(price))) | |
except IndexError: | |
return price |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment