From 325d2efa089c2a294162238b6830482e6cfd556c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 25 Oct 2016 14:56:02 +0200 Subject: [PATCH] use round() to avoid truncation errros when doing int(5.1 * 100) = 5.09 Before this commit, a postage of 5.10 EUR would actually be reported as postage of 5.09 EUR and subsequently rejected by DPAG. --- inema/inema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inema/inema.py b/inema/inema.py index a611e25..0f6ca7a 100644 --- a/inema/inema.py +++ b/inema/inema.py @@ -21,7 +21,7 @@ formats = json.loads(formats_json) def get_product_price_by_id(ext_prod_id): price_float_str = marke_products[str(ext_prod_id)]['cost_price'] - return int(float(price_float_str) * 100) + return int(round(float(price_float_str) * 100)) # generate a 1C4A SOAP header def gen_1c4a_hdr(partner_id, key_phase, key): @@ -127,7 +127,7 @@ class Internetmarke(object): def checkoutPDF(self, page_format): s = self.client.service # FIXME: convert ShoppingCartPosition to ShoppingCartPDFPosition - _logger.info("Submitting basket with %u positions", len(self.positions)) + _logger.info("Submitting basket with %u positions, total=%f", len(self.positions), self.compute_total()) r = s.checkoutShoppingCartPDF(_soapheaders = self.soapheader, userToken = self.user_token, pageFormatId = page_format, @@ -145,7 +145,7 @@ class Internetmarke(object): def checkoutPNG(self): s = self.client.service - _logger.info("Submitting basket with %u positions", len(self.positions)) + _logger.info("Submitting basket with %u positions, total=%f", len(self.positions), self.compute_total()) r = s.checkoutShoppingCartPNG(_soapheaders = self.soapheader, userToken = self.user_token, positions = self.positions,