transformation.py 3.47 KB
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1
# -*- coding: utf-8 -*-
2 3 4 5 6 7 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
9
# programmers who take the whole responsibility of assessing all potential
10 11
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
12
# guarantees and support are strongly advised to contract a Free Software
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# 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.
#
##############################################################################
30 31 32
"""
Products.ERP5.interfaces.simulation_movement
"""
33 34

from zope.interface import Interface
35
from zope.schema.interfaces import ISequence
36

37 38
class ITransformation(Interface):
  """
39 40
    Common Interface to implementing querying of indirect amount
    models (TaxModelLine, InvoiceModelLine, etc) shall be based on this
41
    interface
42 43
  """

44
  def getAggregatedAmountList(context, movement_list=None, rounding=False):
45
    """Returns list of amounts generated by set of models
46

Łukasz Nowak's avatar
Łukasz Nowak committed
47
    context - represents object on which calculation shall happen
48

49 50
    movement_list - optional argument, movement list to apply on, if not passed
      it will be generated from passed context
51

52 53
    rounding - boolean argument, which controls if rounding shall be applied on
      generated movements or not
54

55
    Returns an instance implementing IAggregatedAmountList.
56 57 58 59 60 61 62

    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.
    """

63
  def updateAggregatedAmountList(context, movement_list=None, rounding=False):
64
    """Updates existing movements and returns new or deleted if any according to model
65 66

    context - represents object on which update shall happen
67

68 69
    movement_list - optional argument, movement list to apply on, if not passed
      it will be generated from passed context
70

71 72
    rounding - boolean argument, which controls if rounding shall be applied on
      generated movements or not
73

74 75 76 77 78 79
    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.
80
    """
81 82 83 84 85 86 87 88


class IAggregatedAmountList(ISequence):
  """An Aggregated Amount List is a list of amounts aggregated together.

  It is a sequence of objects implementing IAmount interface.
  """