From f18ad53b036c453fa2fff52045e00ef8918c2dc3 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Fri, 13 Nov 2009 22:25:05 +0000 Subject: [PATCH] renamed transformation interface git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30608 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/AppliedRule.py | 6 ++ product/ERP5/Document/TradeCondition.py | 4 +- product/ERP5/Document/TradeModelCell.py | 2 +- product/ERP5/Document/TradeModelLine.py | 2 +- product/ERP5/Document/Transformation.py | 2 +- product/ERP5/Document/TransformedResource.py | 3 +- product/ERP5/interfaces/amount_generator.py | 62 +++++++++++++++ product/ERP5/interfaces/transformation.py | 80 -------------------- 8 files changed, 76 insertions(+), 85 deletions(-) create mode 100644 product/ERP5/interfaces/amount_generator.py delete mode 100644 product/ERP5/interfaces/transformation.py diff --git a/product/ERP5/Document/AppliedRule.py b/product/ERP5/Document/AppliedRule.py index 59848a2c5e..e639c408b4 100644 --- a/product/ERP5/Document/AppliedRule.py +++ b/product/ERP5/Document/AppliedRule.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. @@ -26,6 +27,8 @@ # ############################################################################## +import zope.interface + from AccessControl import ClassSecurityInfo from Products.CMFCore.utils import getToolByName from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces @@ -74,6 +77,9 @@ class AppliedRule(XMLObject): , PropertySheet.AppliedRule ) + # Declarative interfaces + zope.interface.implements(interfaces.IMovementCollection,) + def tpValues(self) : """ show the content in the left pane of the ZMI """ return self.objectValues() diff --git a/product/ERP5/Document/TradeCondition.py b/product/ERP5/Document/TradeCondition.py index 4a95530421..a9b4d82fd8 100644 --- a/product/ERP5/Document/TradeCondition.py +++ b/product/ERP5/Document/TradeCondition.py @@ -76,7 +76,9 @@ class TradeCondition(Path, Transformation, XMLMatrix): , PropertySheet.Order ) - zope.interface.implements(interfaces.ITransformation) + zope.interface.implements(interfaces.IAmountGenerator, + interfaces.IMovementGenerator, + interfaces.IMovementCollectionUpdater,) security.declareProtected(Permissions.AccessContentsInformation, 'updateAggregatedAmountList') diff --git a/product/ERP5/Document/TradeModelCell.py b/product/ERP5/Document/TradeModelCell.py index 947e0b1837..3fc76f8fdd 100644 --- a/product/ERP5/Document/TradeModelCell.py +++ b/product/ERP5/Document/TradeModelCell.py @@ -50,7 +50,7 @@ class TradeModelCell(TradeModelLine, MappedValue): # Declarative interfaces # interfaces.IVariated as soon as interfaces.IVariated will be zope3 zope.interface.implements( - interfaces.ITransformation + interfaces.IAmountGenerator ) # Declarative properties diff --git a/product/ERP5/Document/TradeModelLine.py b/product/ERP5/Document/TradeModelLine.py index f5b8119385..0fe44767f5 100644 --- a/product/ERP5/Document/TradeModelLine.py +++ b/product/ERP5/Document/TradeModelLine.py @@ -56,7 +56,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): # Declarative interfaces zope.interface.implements( - interfaces.ITransformation, + interfaces.IAmountGenerator, interfaces.IVariated ) diff --git a/product/ERP5/Document/Transformation.py b/product/ERP5/Document/Transformation.py index 658e72cab0..774c169861 100644 --- a/product/ERP5/Document/Transformation.py +++ b/product/ERP5/Document/Transformation.py @@ -83,7 +83,7 @@ class Transformation(XMLObject, Predicate, Variated): # Declarative interfaces zope.interface.implements(interfaces.IVariated, - interfaces.ITransformation + interfaces.IAmountGenerator ) diff --git a/product/ERP5/Document/TransformedResource.py b/product/ERP5/Document/TransformedResource.py index d1d9a3b3ed..8502f9e0cd 100644 --- a/product/ERP5/Document/TransformedResource.py +++ b/product/ERP5/Document/TransformedResource.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2002, 2004 Nexedi SARL and Contributors. All Rights Reserved. @@ -78,7 +79,7 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount): ) # Declarative interfaces - zope.interface.implements( interfaces.ITransformation ) + zope.interface.implements(interfaces.IAmountGenerator,) ### Variation matrix definition # diff --git a/product/ERP5/interfaces/amount_generator.py b/product/ERP5/interfaces/amount_generator.py new file mode 100644 index 0000000000..025e230c99 --- /dev/null +++ b/product/ERP5/interfaces/amount_generator.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. +# Jean-Paul Smets-Solanes <jp@nexedi.com> +# Åukasz Nowak <luke@nexedi.com> +# +# 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 advised 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +""" +""" + +from zope.interface import Interface + +class IAmountGenerator(Interface): + """Amount Generator interface specification + + Documents which implement IAmountGenerator + can be used to generate an IAmountList from + an existing IMovementCollection, IAmountList or + IAmount. Typical IMovementGenerator are Transformations + and Trade Conditions. + """ + + def getAggregatedAmountList(context, movement_list=None, rounding=False): + """ + Returns an IAmountList generated by a model a model applied to the + context. + + context - an IMovementCollection, an IAmountList or an IAmount + + movement_list - optional IAmountList which can be passed explicitely + whenever context is an IMovementCollection and whenever + we want to filter context.geMovementList + + rounding - boolean argument, which controls if rounding shall be applied on + generated movements or not + + NOTE: + - implement rounding appropriately (True or False seems + simplistic) + """ diff --git a/product/ERP5/interfaces/transformation.py b/product/ERP5/interfaces/transformation.py deleted file mode 100644 index 65627934f5..0000000000 --- a/product/ERP5/interfaces/transformation.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. -# Jean-Paul Smets-Solanes <jp@nexedi.com> -# Åukasz Nowak <luke@nexedi.com> -# -# 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 advised 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## -""" -Products.ERP5.interfaces.simulation_movement -""" - -from zope.interface import Interface -from zope.schema.interfaces import ISequence - -class ITransformation(Interface): - """ - Common Interface to implementing querying of indirect amount - models (TaxModelLine, InvoiceModelLine, etc) shall be based on this - interface - """ - - def getAggregatedAmountList(context, movement_list=None, rounding=False): - """Returns list of amounts generated by set of models - - context - represents object on which calculation shall happen - - movement_list - optional argument, movement list to apply on, if not passed - it will be generated from passed context - - rounding - boolean argument, which controls if rounding shall be applied on - generated movements or not - - Returns an instance implementing IAggregatedAmountList. - - Note: This method shall be linear in case if context is order, line, - applied rule or movement. In case of built delivery this method shall - be wise enough to CORRECTLY un-linearise calculation, eg. tax is - time dependent, paysheet build from invoices. - """ - - def updateAggregatedAmountList(context, movement_list=None, rounding=False): - """Updates existing movements and returns new or deleted if any according to model - - context - represents object on which update shall happen - - movement_list - optional argument, movement list to apply on, if not passed - it will be generated from passed context - - rounding - boolean argument, which controls if rounding shall be applied on - generated movements or not - - Returns a dictionary with two keys: - * movement_to_add_list - an instance of IAggregatedAmountList for amounts - that have to be added in the context. - FIXME: this is not 'movement' - * movement_to_delete_list - a list of movements from movement_list or from the - context that shall be deleted. - """ -- 2.30.9