changeset 5151:754d911a0ebf

Fix bug #62555: Too many decimals error when generating the invoice with certain discounts
author Luis Falcon <falcon@gnuhealth.org>
date Wed, 01 Jun 2022 12:12:37 +0100
parents dddacbe73a88
children ceddfbb042af
files tryton/health_insurance/wizard/wizard_health_insurance.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_insurance/wizard/wizard_health_insurance.py
+++ b/tryton/health_insurance/wizard/wizard_health_insurance.py
@@ -168,9 +168,11 @@
                             if 'value' in list(discount.keys()):
                                 if discount['value']:
                                     if (discount['type'] == 'pct'):
-                                        unit_price *= (
-                                            1 - decimal.Decimal(
-                                                discount['value'])/100)
+                                        unit_price *= decimal.Decimal(
+                                            1 - discount['value']/100)
+                                        # Round to avoid error on sig figs
+                                        # at invoice.
+                                        unit_price = round(unit_price, 2)
 
                                         # Add remark on description discount
                                         str_disc = str(discount['value']) + '%'