Commit f27d9966 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

same as r37156 (when calculating the diff of a quantity, it is necessary to...

same as r37156 (when calculating the diff of a quantity, it is necessary to use real values instead of recorded ones).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37304 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1a1ba807
...@@ -284,14 +284,17 @@ class RuleMixin: ...@@ -284,14 +284,17 @@ class RuleMixin:
updatable_compensation_movement = None updatable_compensation_movement = None
prevision_quantity = prevision_movement.getQuantity() prevision_quantity = prevision_movement.getQuantity()
decision_quantity = 0.0 decision_quantity = 0.0
real_quantity = 0.0
# First, we update all properties (exc. quantity) which could be divergent # First, we update all properties (exc. quantity) which could be divergent
# and if we can not, we compensate them # and if we can not, we compensate them
for decision_movement in decision_movement_list: for decision_movement in decision_movement_list:
real_movement_quantity = decision_movement.getQuantity()
if decision_movement.isPropertyRecorded('quantity'): if decision_movement.isPropertyRecorded('quantity'):
decision_movement_quantity = decision_movement.getRecordedProperty('quantity') decision_movement_quantity = decision_movement.getRecordedProperty('quantity')
else: else:
decision_movement_quantity = decision_movement.getQuantity() decision_movement_quantity = real_movement_quantity
decision_quantity += decision_movement_quantity decision_quantity += decision_movement_quantity
real_quantity += real_movement_quantity
if self._isProfitAndLossMovement(decision_movement): if self._isProfitAndLossMovement(decision_movement):
if decision_movement.isFrozen(): if decision_movement.isFrozen():
# Record not completed movements # Record not completed movements
...@@ -332,10 +335,11 @@ class RuleMixin: ...@@ -332,10 +335,11 @@ class RuleMixin:
# after compensation # after compensation
quantity_movement = prevision_movement.asContext(quantity=decision_quantity-compensated_quantity) quantity_movement = prevision_movement.asContext(quantity=decision_quantity-compensated_quantity)
if not _compare(quantity_tester_list, prevision_movement, quantity_movement): if not _compare(quantity_tester_list, prevision_movement, quantity_movement):
missing_quantity = prevision_quantity - decision_quantity + compensated_quantity missing_quantity = prevision_quantity - real_quantity + compensated_quantity
if updatable_movement is not None: if updatable_movement is not None:
# If an updatable movement still exists, we update it # If an updatable movement still exists, we update it
updatable_movement.setQuantity(updatable_movement.getQuantity() + missing_quantity) updatable_movement.setQuantity(updatable_movement.getQuantity() + missing_quantity)
updatable_movement.clearRecordedProperty('quantity')
elif not_completed_movement is not None: elif not_completed_movement is not None:
# It is still possible to add a new movement some movements are not completed # It is still possible to add a new movement some movements are not completed
new_movement = prevision_movement.asContext(quantity=missing_quantity) new_movement = prevision_movement.asContext(quantity=missing_quantity)
...@@ -345,6 +349,7 @@ class RuleMixin: ...@@ -345,6 +349,7 @@ class RuleMixin:
# but we can still update a profit and loss movement_collection_diff # but we can still update a profit and loss movement_collection_diff
updatable_compensation_movement.setQuantity(updatable_compensation_movement.getQuantity() updatable_compensation_movement.setQuantity(updatable_compensation_movement.getQuantity()
+ missing_quantity) + missing_quantity)
updatable_compensation_movement.clearRecordedProperty('quantity')
else: else:
# We must create a profit and loss movement # We must create a profit and loss movement
new_movement = self._newProfitAndLossMovement(prevision_movement) new_movement = self._newProfitAndLossMovement(prevision_movement)
......
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