movement.py 7.75 KB
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1
# -*- coding: utf-8 -*-
2 3
##############################################################################
#
Jean-Paul Smets's avatar
Jean-Paul Smets committed
4
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#                    Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability 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
# garantees 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################
29 30 31
"""
Products.ERP5.interfaces.movement
"""
32
from Products.ERP5Type import PropertySheet
33 34
from Products.ERP5.interfaces.amount import IAmount
from Products.ERP5.interfaces.arrow_base import IArrowBase
35

36 37
class IAssetMovement(IAmount):
  """Asset Movement private interface specification
38

39 40 41 42 43 44
  Asset movements are use to represent the asset 
  value of a movement of resources leaving a 
  source and reach a destination. 
  """
  # We must a find a way to use property sheets in or as interfaces
  # property_sheets = (PropertySheet.Price, )
45

46 47 48 49 50 51 52 53 54 55 56 57
  def getSourceAssetPrice():
    """
    Return the asset price for the source section,
    usually the price of the movement converted to
    the currency of the source section using the currency
    rate of the day. If no price is defined, an internal
    price may be looked up. It is also possible for
    a movement to have 'None' source asset price,
    for example for a movement with positive quantity
    going from one warehouse to another warehouse of
    the same company.
    """
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  def getDestinationAssetPrice():
    """
    Return the asset price for the destination section,
    usually the price of the movement converted to
    the currency of the destination section using the currency
    rate of the day. If no price is defined, an internal
    price may be looked up first. It is also possible for
    a movement to have 'None' destination asset price,
    for example for a movement with negative quantity
    going from one warehouse to another warehouse of
    the same company.
    """

  def getSourceInventoriatedTotalAssetPrice():
    """
    Returns the total asset price for the source section, either
    defined explicitely by the source_asset_price property
    (as in accounting) or by calling getSourceAssetPrice and
    multiplying it by the quantity. If no asset price
    is defined, return None. Asset calculation methods
    (SimulationTool.getInventoryAssetPrice) interprete
    None using FIFO, FILO or Average algorithm.
    """

  def getDestinationInventoriatedTotalAssetPrice():
    """
    Returns the total asset price for the destination section, either
    defined explicitely by the destination_asset_price property
    (as in accounting) or by calling getDestinationAssetPrice and
    multiplying it by the quantity. If no asset price
    is defined, return None. Asset calculation methods
    (SimulationTool.getInventoryAssetPrice) interprete
    None using FIFO, FILO or Average algorithm.
    """

class IProductionMovement(IAmount):
  """Production Movement private interface specification

  Production movements have a source or a destination equal
  to None. They are used to represent productions or
  consumptions or resources according to the following
  specification:
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

    (A -> B)
      production_quantity means nothing
      consumption_quantity means nothing

    (A -> Nothing)
    if quantity > 0
      consumption_quantity = quantity
      production_quantity = 0

    if quantity < 0
      consumption_quantity = 0
      production_quantity = - quantity

    (Nothing -> B)
    if quantity > 0
      consumption_quantity = 0
      production_quantity = quantity

    if quantity < 0
      consumption_quantity = - quantity 
      production_quantity = 0
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
  """
  def getConsumptionQuantity():
    """
    Returns the consumed quantity during production
    """

  def getProductionQuantity():
    """
    Returns the produced quantity during production
    """

class IAccountingMovement(IAssetMovement):
  """
  Accounting Movement private interface specification

  The notion of debit and credit is used in accounting
  instead of signed quantity. The following calculation
  rules apply:
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

    Credit/Debit

    if quantity > 0
      source_credit = - quantity
      source_debit = quantity
      destination_credit = quantity
      destination_debit = - quantity

    if quantity < 0
      source_credit = quantity
      source_debit = - quantity
      destination_credit = - quantity
      destination_debit = quantity

  """
157 158
  # We must a find a way to use property sheets in or as interfaces
  # property_sheets = (PropertySheet.Price, )
159 160 161

  # Helper methods for single currency Accounting (debit / credit)
  def getSourceDebit():
162 163
    """
    Returns the source debit in the transaction currency
164 165 166
    """

  def getSourceCredit():
167 168
    """
    Returns the source credit in the transaction currency
169 170 171
    """

  def getDestinationDebit():
172 173
    """
    Returns the destination debit in the transaction currency
174 175 176
    """

  def getDestinationCredit():
177 178
    """
    Returns the destination credit in the transaction currency
179 180 181 182
    """

  # Helper methods for multi currency Accounting (debit / credit)
  def getSourceAssetDebit():
183 184 185
    """
    Returns the source debit in the source section management currency
    based on the source_total_asset price property
186 187 188
    """

  def getSourceAssetCredit():
189 190 191
    """
    Returns the source credit in the source section management currency
    based on the source_total_asset price property
192 193 194
    """

  def getDestinationAssetDebit():
195 196 197
    """
    Returns the destination debit in the destination section management currency
    based on the destination_total_asset price property
198 199 200
    """

  def getDestinationAssetCredit():
201 202 203
    """
    Returns the destination credit in the destination section management currency
    based on the destination_total_asset price property
204 205
    """

206 207 208 209 210 211
  # The following is really unclear - 
  #   It uses getSourceInventoriatedTotalAssetPrice instead of
  #   of getSourceInventoriatedTotalAssetPrice instead of getSourceTotalAssetPrice
  #   I can only see one purpose: presentation of reports in predictive accounting
  #   ie. in transactions generated by simulation which do not yet have
  #   well defined source_total_asset/destination_total_asset
212
  def getSourceInventoriatedTotalAssetDebit():
213 214
    """
    Unclear - XXX
215 216 217
    """

  def getSourceInventoriatedTotalAssetCredit():
218 219
    """
    Unclear - XXX
220 221 222
    """

  def getDestinationInventoriatedTotalAssetDebit():
223 224
    """
    Unclear - XXX
225 226 227
    """

  def getDestinationInventoriatedTotalAssetCredit():
228
    """
229 230 231 232 233
    Unclear - XXX
    """

class IMovement(IProductionMovement, IArrowBase):
  """Movement interface specification
234

235 236 237 238 239 240 241 242 243
  A movement represents an amount of resources which 
  is moved along an Arrow (source and destination)
  from a source A to a destination B. 
  """
  def isMovement():
    """
    Returns True if this movement should be indexed in the
    stock table of the catalog, False else.
    """