use decimal.Decimal instead of float to store amounts of money

This commit is contained in:
Romain Bignon 2012-03-29 16:14:32 +02:00
commit b157e92d5b
28 changed files with 111 additions and 69 deletions

View file

@ -19,6 +19,8 @@
from __future__ import with_statement
from decimal import Decimal
from weboob.capabilities.bank import ICapBank, AccountNotFound, Recipient, Account
from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.value import ValueBackendPassword
@ -78,7 +80,7 @@ class CreditMutuelBackend(BaseBackend, ICapBank):
try:
assert account.isdigit()
assert to.isdigit()
amount = float(amount)
amount = Decimal(amount)
except (AssertionError, ValueError):
raise AccountNotFound()

View file

@ -18,6 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from decimal import Decimal
import re
from weboob.tools.browser import BasePage
@ -70,7 +71,7 @@ class AccountsPage(BasePage):
balance += c
if c == ',':
balance += '.'
account.balance = float(balance)
account.balance = Decimal(balance)
l.append(account)
#raise NotImplementedError()
return l
@ -135,7 +136,7 @@ class OperationsPage(BasePage):
balance += c
if c == ',':
balance += '.'
operation.amount = float(balance)
operation.amount = Decimal(balance)
yield operation
def next_page_url(self):