Use python's Decimal module to handle prices
authorGu1 <gu1@cafai.fr>
Wed, 17 Apr 2013 23:45:28 +0000 (01:45 +0200)
committerGu1 <gu1@cafai.fr>
Wed, 17 Apr 2013 23:45:28 +0000 (01:45 +0200)
fdneligibility/views.py

index 8a41dd0..a5a4bff 100644 (file)
@@ -7,6 +7,7 @@ from utils import VerifiedHTTPSConnection, APP_ROOT
 from httplib import HTTPException
 from ssl import SSLError
 import re
+from decimal import Decimal
 
 
 ELIGIBILITY_FORMS=[EligibilityForm1, EligibilityForm2]
@@ -90,8 +91,8 @@ class EligibilityWizard(SessionWizardView):
                                                                           "at a later time. If the problem persist, contact us.")])
                     return self.render(form)
                 for o in si_res['offres']:
-                    o['fas']=float(o['fas'].replace('E TTC', u''))
-                    o['abo']=float(o['abo'].replace('E TTC', u''))
+                    o['fas']=Decimal(o['fas'].replace('E TTC', u''))
+                    o['abo']=Decimal(o['abo'].replace('E TTC', u''))
                     plan_id=o['code_offre']
                     del o['code_offre']
                     o['plan_id']=plan_id