Commit b3ed2210 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

erp5_pdm: do not round calculated average unit_price in slice case.

otherwise it loses too much precision.
parent bfdcb738
...@@ -34,10 +34,7 @@ if result["slice_base_price"]: ...@@ -34,10 +34,7 @@ if result["slice_base_price"]:
slice_min = 1 slice_min = 1
priced_quantity = min(slice_max - 1, quantity) - (slice_min - 1) priced_quantity = min(slice_max - 1, quantity) - (slice_min - 1)
total_price += priced_quantity * slice_price total_price += priced_quantity * slice_price
if result.get('base_unit_price', None) is None:
result["base_price"] = total_price / quantity result["base_price"] = total_price / quantity
else:
result["base_price"] = round(total_price / quantity, int(round(- log(result['base_unit_price'], 10),0)))
base_price = result["base_price"] base_price = result["base_price"]
if base_price in (None, ""): if base_price in (None, ""):
......
  • @kazuhiko @Nicolas , it seems tests also needs to be adjusted, testResources started to fail with this change.

    ======================================================================
    FAIL: testGetPriceWithBasePriceDefinedPerSlice (testResource.TestResource)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/srv/slapgrid/slappart0/srv/testnode/aai/soft/ebc3bdb8c4511188df375d0f7981e02c/parts/erp5/Products/ERP5/tests/testResource.py", line 1230, in testGetPriceWithBasePriceDefinedPerSlice
        _test(**case)
      File "/srv/slapgrid/slappart0/srv/testnode/aai/soft/ebc3bdb8c4511188df375d0f7981e02c/parts/erp5/Products/ERP5/tests/testResource.py", line 1217, in _test
        self.assertEqual(price, sale_order_line.getPrice())
    AssertionError: 9.90909 != 9.909090909090908
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment