Avoid rounding issues with float

This commit is contained in:
Georg Sauthoff 2021-01-23 16:38:10 +01:00
parent 4e3818723c
commit 6c1f9bb1f5
1 changed files with 3 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import pkg_resources
import requests, zipfile import requests, zipfile
import io import io
import logging import logging
import decimal
__version__ = pkg_resources.get_distribution(__package__).version __version__ = pkg_resources.get_distribution(__package__).version
@ -93,8 +94,8 @@ class Internetmarke(object):
return [p, t, k, s] return [p, t, k, s]
def get_product_price_by_id(self, ext_prod_id): def get_product_price_by_id(self, ext_prod_id):
price_float_str = marke_products[str(ext_prod_id)]['cost_price'] price_str = marke_products[str(ext_prod_id)]['cost_price']
return int(round(float(price_float_str) * 100)) return int(decimal.Decimal(price_str) * 100)
def __init__(self, partner_id, key, key_phase="1"): def __init__(self, partner_id, key, key_phase="1"):
self.client = Client(self.wsdl_url) self.client = Client(self.wsdl_url)