Skip to content
This repository
Browse code

Merge branch 'releases/0.2' of github.com:tangentlabs/django-oscar in…

…to releases/0.2
  • Loading branch information...
commit 9bac51a5419f2b350d9922115cd223071e77d2a0 2 parents ada4790 + a03b96d
David Winterbottom authored May 23, 2012
4  oscar/apps/dashboard/tests.py
@@ -43,14 +43,14 @@ def test_dashboard_hourly_report_with_no_orders(self):
43 43
         self.assertEquals(len(report['y_range']), 0)
44 44
         self.assertEquals(report['max_revenue'], 0)
45 45
 
46  
-    def test_dashboard_hourly_report_with_orders(self): 
  46
+    def test_dashboard_hourly_report_with_orders(self):
47 47
         create_order(total_incl_tax=D('34.05'), total_excl_tax=D('34.05'))
48 48
         create_order(total_incl_tax=D('21.90'), total_excl_tax=D('21.90'))
49 49
         report = IndexView().get_hourly_report()
50 50
 
51 51
         self.assertEquals(len(report['order_total_hourly']), 24)
52 52
         self.assertEquals(len(report['y_range']), 11)
53  
-        self.assertEquals(report['max_revenue'], D('55.95'))
  53
+        self.assertEquals(report['max_revenue'], D('60'))
54 54
 
55 55
     def test_dashboard_index_has_stats_vars_in_context(self):
56 56
         response = self.client.get(reverse('dashboard:index'))
7  oscar/apps/dashboard/views.py
... ...
@@ -1,4 +1,4 @@
1  
-from decimal import Decimal as D
  1
+from decimal import Decimal as D, ROUND_UP
2 2
 from datetime import datetime, timedelta
3 3
 
4 4
 from django.views.generic import TemplateView
@@ -98,6 +98,11 @@ def get_hourly_report(self, hours=24, segments=10):
98 98
             start_time = end_time
99 99
 
100 100
         max_value = max([x['total_incl_tax'] for x in order_total_hourly])
  101
+        divisor = 1
  102
+        while divisor < max_value / 50:
  103
+            divisor *= 10
  104
+        max_value = (max_value / divisor).quantize(D('1'), rounding=ROUND_UP)
  105
+        max_value *= divisor
101 106
         if max_value:
102 107
             segment_size = (max_value) / D('100.0')
103 108
             for item in order_total_hourly:

0 notes on commit 9bac51a

Please sign in to comment.
Something went wrong with that request. Please try again.