use decimal.Decimal instead of float to store amounts of money
This commit is contained in:
parent
32b87b47f5
commit
b157e92d5b
28 changed files with 111 additions and 69 deletions
|
|
@ -18,6 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from decimal import Decimal
|
||||
from datetime import date
|
||||
import re
|
||||
|
||||
|
|
@ -56,9 +57,9 @@ class AccountHistory(BasePage):
|
|||
amount = t.text
|
||||
amount = ''.join(amount.replace('.', '').replace(',', '.').split())
|
||||
if amount[0] == "-":
|
||||
operation.amount = -float(amount[1:])
|
||||
operation.amount = - Decimal(amount[1:])
|
||||
else:
|
||||
operation.amount = float(amount)
|
||||
operation.amount = Decimal(amount)
|
||||
|
||||
operations.append(operation)
|
||||
return operations
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.bank import Account, AccountNotFound
|
||||
from decimal import Decimal
|
||||
|
||||
from weboob.capabilities.bank import Account, AccountNotFound
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ class AccountList(BasePage):
|
|||
tmp_balance = tmp[0].text
|
||||
|
||||
account.id = tmp_id
|
||||
account.balance = float(''.join(tmp_balance.replace('.','').replace(',','.').split()))
|
||||
account.balance = Decimal(''.join(tmp_balance.replace('.','').replace(',','.').split()))
|
||||
self.account_list.append(account)
|
||||
|
||||
def get_account(self, id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue