[FIX] point_of_sale: round taxes as in amount_tax

amount_tax compute method uses `price * (1 - (discount or 0.0) / 100.0)`
_create_account_move_line method used `price * (100.0 - discount) / 100.0`

with price = 9.95 and discount = 0.1 it makes a difference
>>> 9.95 * 0.9
8.955
>>> 9.95 * 90.0 / 100.0
8.954999999999998

Cumulative errors makes a 1 cent difference between totals of the orders and
computed amounts.

The session could not be closed as debit != credit

opw-743188
This commit is contained in:
Martin Trigaux
2017-05-17 15:22:07 +02:00
parent 6de2990f8d
commit ae1aec32c2
+2 -1
View File
@@ -292,7 +292,8 @@ class PosOrder(models.Model):
taxes = line.tax_ids_after_fiscal_position.filtered(lambda t: t.company_id.id == current_company.id)
if not taxes:
continue
for tax in taxes.compute_all(line.price_unit * (100.0 - line.discount) / 100.0, cur, line.qty)['taxes']:
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
for tax in taxes.compute_all(price, cur, line.qty)['taxes']:
insert_data('tax', {
'name': _('Tax') + ' ' + tax['name'],
'product_id': line.product_id.id,