Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
fix float to decimal conversion in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Jul 19, 2012
1 parent ce270de commit d70c4f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mkt/stats/search.py
Expand Up @@ -203,7 +203,7 @@ def cut(revenue):
"""
Takes away Marketplace's cut from developers' revenue.
"""
return Decimal(round(Decimal(revenue) * Decimal(MKT_CUT), 2))
return Decimal(str(round(revenue * MKT_CUT, 2)))


def handle_kwargs(q, field, kwargs, join_field=None):
Expand Down
9 changes: 5 additions & 4 deletions mkt/stats/tests/test_tasks.py
@@ -1,4 +1,5 @@
import datetime
from decimal import Decimal
import random

from django.utils import unittest
Expand Down Expand Up @@ -428,7 +429,7 @@ def test_basic(self):
class TestCut(unittest.TestCase):

def test_basic(self):
eq_(cut(0), 0)
eq_(cut(1), .7)
eq_(cut(10), 7)
eq_(cut(33), 23.10)
eq_(cut(0), Decimal(str(0)))
eq_(cut(1), Decimal(str(.7)))
eq_(cut(10), Decimal(str(7)))
eq_(cut(33), Decimal(str(23.10)))

0 comments on commit d70c4f4

Please sign in to comment.