Created
May 28, 2014 12:52
-
-
Save spookylukey/eb6029bc48ab8410227b to your computer and use it in GitHub Desktop.
How not to do currency 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