Commit 95bc3a83 authored by Arnaud Fontaine's avatar Arnaud Fontaine

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 178e2673
......@@ -78,6 +78,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,33 @@ 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_movement.getPortalType() != 'Simulation Movement' and
decision_value == 0.0):
prevision_value = sum([
sm.getCorrectedQuantity()
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)
security.declareProtected(Permissions.AccessContentsInformation,
'getUpdatablePropertyDict')
def getUpdatablePropertyDict(self, prevision_movement, 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