Commit cb274231 authored by Romain Courteaud's avatar Romain Courteaud

No need to calculate average price.

If prices are identical, no need to do average calculation each time.
It also prevent returning a price of 0 if all quantity values equal 0.
parent f26f2fa3
......@@ -244,7 +244,7 @@ class MovementGroupNode:
if movement_price == added_movement_price:
new_movement = self._genericCalculation(movement,
added_movement=added_movement)
new_movement.setPriceMethod('getAveragePrice')
new_movement.setPriceMethod('getFirstPrice')
new_movement.setQuantityMethod("getAddQuantity")
return new_movement, None
return movement, added_movement
......@@ -396,6 +396,12 @@ class FakeMovement:
"""
self.__quantity_method = method
def getFirstPrice(self):
"""
Get price defined on the first movement
"""
return self.getMovementList()[0].getPrice(0)
def getAveragePrice(self):
"""
Return average price
......
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