Commit 4e1cdcf4 authored by Yoshinori Okuji's avatar Yoshinori Okuji

getCorrectedQuantity must not use a mapped quantity, as any mapping must not...

getCorrectedQuantity must not use a mapped quantity, as any mapping must not be enabled in the simulation world. Instead, every caller must specify which is wanted very explicitly. This change also fixes that delivery error and profit quantity were not handled correctly when quantity was inversed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37274 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3e09122b
......@@ -453,7 +453,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
Look are invocations of _isProfitAndLossMovement in
ERP5.mixin.rule to understand how.
"""
quantity = self.getMappedProperty('quantity')
quantity = self.getQuantity()
profit_quantity = self.getProfitQuantity() or 0
delivery_error = self.getDeliveryError() or 0
return quantity - profit_quantity + delivery_error
......@@ -608,6 +608,21 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
def getMappedProperty(self, property):
mapping = self.getPropertyMappingValue()
if mapping is not None:
# Special case: corrected quantity is difficult to handle,
# because, if quantity is negatated in the mapping, other
# parameters, profit quantity (deprecated) and delivery error,
# must be negatated as well.
if property == 'corrected_quantity':
mapped_quantity_id = mapping.getMappedPropertyId('quantity')
quantity = mapping.getMappedProperty(self, 'quantity')
profit_quantity = self.getProfitQuantity() or 0
delivery_error = self.getDeliveryError() or 0
if mapped_quantity_id[:1] == '-':
# XXX what about if "quantity | -something_different" is
# specified?
return quantity + profit_quantity - delivery_error
else:
return quantity - profit_quantity + delivery_error
return mapping.getMappedProperty(self, property)
else:
return self.getProperty(property)
......
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