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
|
|
@ -19,6 +19,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from decimal import Decimal
|
||||
from datetime import date
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
|
@ -55,9 +56,9 @@ class AccountHistory(BasePage):
|
|||
amount = tds[4].text
|
||||
amount = amount.strip(u' \n\t\x80').replace(' ', '').replace(',', '.')
|
||||
|
||||
# if we don't have exactly one '.', this is not a floatm try the next
|
||||
# if we don't have exactly one '.', this is not a Decimal try the next
|
||||
operation = Transaction(len(self.operations))
|
||||
operation.amount = float(amount)
|
||||
operation.amount = Decimal(amount)
|
||||
|
||||
operation.date = d
|
||||
operation.label = label
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from weboob.capabilities.bank import Account
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -55,9 +57,9 @@ class AccountsList(BasePage):
|
|||
balance = span.text
|
||||
balance = balance.strip(u' \n\t€+').replace(',', '.').replace(' ', '')
|
||||
if balance != "":
|
||||
account.balance = float(balance)
|
||||
account.balance = Decimal(balance)
|
||||
else:
|
||||
account.balance = 0.0
|
||||
account.balance = Decimal(0.0)
|
||||
|
||||
else:
|
||||
# because of some weird useless <tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue