Commit 68b4823c authored by Arnaud Fontaine's avatar Arnaud Fontaine Committed by Sebastien Robin

Implement delivery.getQuantity() == 0.

When RSPL/RPPL Invoice Lines are on the same SIT TML as its
corresponding SO/PO IL movements, the sum may be 0 and there is nothing
wrong about it. This was implemented in Legacy Simulation.
parent 83da8bae
......@@ -79,6 +79,15 @@ class FloatEquivalenceTester(Predicate, EquivalenceTesterMixin):
prevision_value = self._getTestedPropertyValue(prevision_movement,
tested_property) or 0.0
return self._comparePrevisionDecisionValue(prevision_movement,
prevision_value,
decision_movement,
decision_value)
def _comparePrevisionDecisionValue(self,
prevision_movement, prevision_value,
decision_movement, decision_value):
tested_property = self.getTestedProperty()
if prevision_movement.getDelivery() == decision_movement.getRelativeUrl():
# use delivery_ratio if specified
if self.getProperty('use_delivery_ratio'):
......
......@@ -45,6 +45,32 @@ class NetConvertedQuantityEquivalenceTester(FloatEquivalenceTester):
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _compare(self, prevision_movement, decision_movement):
tested_property = self.getTestedProperty()
if getattr(decision_movement, 'isPropertyRecorded',
lambda x:False)(tested_property):
decision_value = decision_movement.getRecordedProperty(tested_property) or 0.0
else:
decision_value = self._getTestedPropertyValue(decision_movement,
tested_property) or 0.0
# XXX: QuantityDivergenceTester from Legacy Simulation: A delivery
# quantity of 0 is an exceptional case that we cannot really handle with
# the current approach of delivery ratio.
if decision_value == 0.0:
prevision_value = sum([
sm.getMappedProperty('corrected_quantity')
for sm in decision_movement.getDeliveryRelatedValueList(
portal_type='Simulation Movement')])
else:
prevision_value = self._getTestedPropertyValue(prevision_movement,
tested_property) or 0.0
return self._comparePrevisionDecisionValue(prevision_movement,
prevision_value,
decision_movement,
decision_value)
def getUpdatablePropertyDict(self, prevision_movement, decision_movement):
"""
Returns a list of properties to update on decision_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