Commit f18ad53b authored by Jean-Paul Smets's avatar Jean-Paul Smets

renamed transformation interface

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30608 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 00657d70
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -26,6 +27,8 @@ ...@@ -26,6 +27,8 @@
# #
############################################################################## ##############################################################################
import zope.interface
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
...@@ -74,6 +77,9 @@ class AppliedRule(XMLObject): ...@@ -74,6 +77,9 @@ class AppliedRule(XMLObject):
, PropertySheet.AppliedRule , PropertySheet.AppliedRule
) )
# Declarative interfaces
zope.interface.implements(interfaces.IMovementCollection,)
def tpValues(self) : def tpValues(self) :
""" show the content in the left pane of the ZMI """ """ show the content in the left pane of the ZMI """
return self.objectValues() return self.objectValues()
......
...@@ -76,7 +76,9 @@ class TradeCondition(Path, Transformation, XMLMatrix): ...@@ -76,7 +76,9 @@ class TradeCondition(Path, Transformation, XMLMatrix):
, PropertySheet.Order , PropertySheet.Order
) )
zope.interface.implements(interfaces.ITransformation) zope.interface.implements(interfaces.IAmountGenerator,
interfaces.IMovementGenerator,
interfaces.IMovementCollectionUpdater,)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'updateAggregatedAmountList') 'updateAggregatedAmountList')
......
...@@ -50,7 +50,7 @@ class TradeModelCell(TradeModelLine, MappedValue): ...@@ -50,7 +50,7 @@ class TradeModelCell(TradeModelLine, MappedValue):
# Declarative interfaces # Declarative interfaces
# interfaces.IVariated as soon as interfaces.IVariated will be zope3 # interfaces.IVariated as soon as interfaces.IVariated will be zope3
zope.interface.implements( zope.interface.implements(
interfaces.ITransformation interfaces.IAmountGenerator
) )
# Declarative properties # Declarative properties
......
...@@ -56,7 +56,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount): ...@@ -56,7 +56,7 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
# Declarative interfaces # Declarative interfaces
zope.interface.implements( zope.interface.implements(
interfaces.ITransformation, interfaces.IAmountGenerator,
interfaces.IVariated interfaces.IVariated
) )
......
...@@ -83,7 +83,7 @@ class Transformation(XMLObject, Predicate, Variated): ...@@ -83,7 +83,7 @@ class Transformation(XMLObject, Predicate, Variated):
# Declarative interfaces # Declarative interfaces
zope.interface.implements(interfaces.IVariated, zope.interface.implements(interfaces.IVariated,
interfaces.ITransformation interfaces.IAmountGenerator
) )
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002, 2004 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002, 2004 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -78,7 +79,7 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount): ...@@ -78,7 +79,7 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
) )
# Declarative interfaces # Declarative interfaces
zope.interface.implements( interfaces.ITransformation ) zope.interface.implements(interfaces.IAmountGenerator,)
### Variation matrix definition ### Variation matrix definition
# #
......
...@@ -28,53 +28,35 @@ ...@@ -28,53 +28,35 @@
# #
############################################################################## ##############################################################################
""" """
Products.ERP5.interfaces.simulation_movement
""" """
from zope.interface import Interface from zope.interface import Interface
from zope.schema.interfaces import ISequence
class ITransformation(Interface): class IAmountGenerator(Interface):
""" """Amount Generator interface specification
Common Interface to implementing querying of indirect amount
models (TaxModelLine, InvoiceModelLine, etc) shall be based on this Documents which implement IAmountGenerator
interface 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): 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.
""" """
Returns an IAmountList generated by a model a model applied to the
context.
def updateAggregatedAmountList(context, movement_list=None, rounding=False): context - an IMovementCollection, an IAmountList or an IAmount
"""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 movement_list - optional IAmountList which can be passed explicitely
it will be generated from passed context whenever context is an IMovementCollection and whenever
we want to filter context.geMovementList
rounding - boolean argument, which controls if rounding shall be applied on rounding - boolean argument, which controls if rounding shall be applied on
generated movements or not generated movements or not
Returns a dictionary with two keys: NOTE:
* movement_to_add_list - an instance of IAggregatedAmountList for amounts - implement rounding appropriately (True or False seems
that have to be added in the context. simplistic)
FIXME: this is not 'movement'
* movement_to_delete_list - a list of movements from movement_list or from the
context that shall be deleted.
""" """
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