Commit e56cb1c3 authored by Jérome Perrin's avatar Jérome Perrin

calculateSeparatePrice should not simply compare floats for equality, for now

we'll compare with an arbitrary precision, untill we have a good way of
specifying this.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30065 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0015825
...@@ -228,13 +228,22 @@ class MovementGroupNode: ...@@ -228,13 +228,22 @@ class MovementGroupNode:
def calculateSeparatePrice(self, movement, added_movement=None): def calculateSeparatePrice(self, movement, added_movement=None):
""" Separate movements which have different price """ Separate movements which have different price
""" """
if added_movement is not None and \ if added_movement is not None:
movement.getPrice() == added_movement.getPrice() : # XXX To prevent float rounding issue, we round the price with an
new_movement = self._genericCalculation(movement, # arbirary precision before comparision.
added_movement=added_movement) movement_price = movement.getPrice()
new_movement.setPriceMethod('getAveragePrice') if movement_price is not None:
new_movement.setQuantityMethod("getAddQuantity") movement_price = round(movement_price, 5)
return new_movement, None added_movement_price = added_movement.getPrice()
if added_movement_price is not None:
added_movement_price = round(added_movement_price, 5)
if movement_price == added_movement_price:
new_movement = self._genericCalculation(movement,
added_movement=added_movement)
new_movement.setPriceMethod('getAveragePrice')
new_movement.setQuantityMethod("getAddQuantity")
return new_movement, None
return movement, added_movement return movement, added_movement
def calculateAddQuantity(self, movement, added_movement=None): def calculateAddQuantity(self, movement, added_movement=None):
......
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