Commit a3b7be60 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

add NetConvertedQuantityDivergenceTester that inherits from FloatDivergenceTester.

* tested_property should be 'quantity'
* but quantity should be calculated by getNetConvertedQuantity not getQuantity.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31513 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 09fb8cb7
...@@ -71,8 +71,8 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin): ...@@ -71,8 +71,8 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin):
lambda x:False)(tested_property): lambda x:False)(tested_property):
decision_value = decision_movement.getRecordedProperty(tested_property) decision_value = decision_movement.getRecordedProperty(tested_property)
else: else:
decision_value = decision_movement.getProperty(tested_property) decision_value = self._getPropertyValue(decision_movement, tested_property)
prevision_value = prevision_movement.getProperty(tested_property) prevision_value = self._getPropertyValue(prevision_movement, tested_property)
# use delivery_ratio if specified # use delivery_ratio if specified
if self.getProperty('use_delivery_ratio') and \ if self.getProperty('use_delivery_ratio') and \
...@@ -165,7 +165,7 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin): ...@@ -165,7 +165,7 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin):
decision_movement -- a delivery movement (decision) decision_movement -- a delivery movement (decision)
""" """
tested_property = self.getTestedProperty() tested_property = self.getTestedProperty()
prevision_value = prevision_movement.getProperty(tested_property) prevision_value = self._getPropertyValue(prevision_movement, tested_property)
return {tested_property:prevision_value} return {tested_property:prevision_value}
def accept(self, simulation_movement): def accept(self, simulation_movement):
...@@ -189,3 +189,6 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin): ...@@ -189,3 +189,6 @@ class FloatDivergenceTester(Predicate, DivergenceTesterMixin):
instead. instead.
""" """
raise NotImplementedError raise NotImplementedError
def _getPropertyValue(self, document, property):
return document.getProperty(property)
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo
from Products.ERP5.Document.FloatDivergenceTester import FloatDivergenceTester
from Products.ERP5Type import Permissions, PropertySheet, interfaces
class NetConvertedQuantityDivergenceTester(FloatDivergenceTester):
"""
The purpose of this divergence tester is to check the
consistency between delivery movement and simulation movement
for some specific properties.
"""
meta_type = 'ERP5 Net Converted Quantity Divergence Tester'
portal_type = 'Net Converted Quantity Divergence Tester'
add_permission = Permissions.AddPortalContent
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
def getUpdatablePropertyDict(self, prevision_movement, decision_movement):
"""
Returns a list of properties to update on decision_movement
prevision_movement so that next call to compare returns True.
prevision_movement -- a simulation movement (prevision)
decision_movement -- a delivery movement (decision)
"""
tested_property = 'net_converted_quantity'
prevision_value = self._getPropertyValue(prevision_movement, tested_property)
return {tested_property:prevision_value}
def _getPropertyValue(self, document, property):
return document.getNetConvertedQuantity()
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