transformation.py 3.16 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 30 31
# 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
Jean-Paul Smets's avatar
Jean-Paul Smets committed
32

33 34
class ITransformation(Interface):
  """
35
    Common Interface to implementing querying of Indirect Amount
36 37
    Models (TaxModelLine, InvoiceModelLine, etc) shall be based on this
    interface
38 39
  """

40
  def getAggregatedAmountList(context, movement_list=None, rounding=False):
41
    """Returns list of amounts generated by set of models
42 43

    context - represents object for which calculation shall happen
44

45 46
    movement_list - optional argument, movement list to apply on, if not passed
      it will be generated from passed context
47

48 49
    rounding - boolean argument, which controls if rounding shall be applied on
      generated movements or not
50

51
    Returns list of instance of AggregatedAmountList class
52 53 54 55 56 57 58 59

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

60
  def updateAggregatedAmountList(context, movement_list=None, rounding=False):
61
    """Updates existing movement and returns new or deleted if any according to model
62 63

    context - represents object on which update shall happen
64

65 66
    movement_list - optional argument, movement list to apply on, if not passed
      it will be generated from passed context
67

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

    Returns a dictionary of list of instances of AggregatedAmountList class.
    Dictionary contain lists described by keys:
      * movement_to_add_list - list for movements which shall be added
      * movement_to_delete_list - list of movements which shall be deleted
75 76
    """
    pass