Skip to content

Commit

Permalink
Change amount calculation to avoid rounding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilien Tantin committed Mar 8, 2019
1 parent 2356282 commit 90fbcbb
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-

from odoo import api, fields, models, _
from odoo.tools import float_round

from datetime import datetime
import hashlib
import urlparse
Expand Down Expand Up @@ -102,6 +104,7 @@ def paybox_form_generate_values(self, values):
paybox_tx_values = dict((k, v) for k, v in values.items() if v)

base_url = self.env['ir.config_parameter'].get_param('web.base.url')
prec = self.env['decimal.precision'].precision_get('Product Price')

key = self.paybox_get_authentication_key()

Expand All @@ -111,7 +114,7 @@ def paybox_form_generate_values(self, values):
('PBX_SITE', self.paybox_site),
('PBX_RANG', self.paybox_rank),
('PBX_IDENTIFIANT', self.paybox_id),
('PBX_TOTAL', int(values['amount'] * 100)),
('PBX_TOTAL', int(float_round(values['amount'] * 100, prec))),
('PBX_DEVISE', values.get('currency').number),
('PBX_CMD', values.get('reference').replace('/', ' ')),
('PBX_PORTEUR', values.get('partner_email')),
Expand Down

0 comments on commit 90fbcbb

Please sign in to comment.