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

First review by JPS.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26605 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 137ae44e
......@@ -26,15 +26,16 @@
#
##############################################################################
from Interface import Interface
from zope.interface import Interface
class IAmount(Interface):
"""
"""Amount interface specification
An amount represents a quantity of a given resource
in a given quantity unit. Optional efficiency
or (exclusive) profit/loss quantity can be specified
in order to represent a profit or loss ratio to take
into account in calculations.
in a given quantity unit. Optional efficiency can be
specified in order to represent a loss ratio to take
into account in calculations. Loss ratio is normally
used only in Path.
The Amount interface is useful each time
we need to add or substract amounts of resources
......@@ -45,11 +46,15 @@ class IAmount(Interface):
net_quantity = quantity * efficiency
TODO:
consider how to make Interface compatible
with accessor generation (ex. getResource)
Addition:
target_quantity is obsolete, it is never defined.
1. make sure getTotalPrice has or does not
have extra parameters (ex. rounding)
2. remove profit_quantity everywhere
3. remove target_quantity everywhere
4. consider how to make Interface compatible
with accessor generation (ex. getResource,
getQuantity, etc.)
5. consider creating an IPriceable interface
which is common to deliveries and amounts
"""
# Core API
......@@ -74,7 +79,7 @@ class IAmount(Interface):
def isCancellationAmount():
"""
A cancellation amount must be interpreted
reversely write to the sign of qauntity.
reversely wrt. to the sign of quantity.
For example, a negative credit for a cancellation
amount is a negative credit, not a positive
......@@ -88,67 +93,62 @@ class IAmount(Interface):
# Net Quantity API
def getEfficiency():
"""
Returns a value which is rate affect to the net quantity
Only used for transformation for now.
Returns the ratio of loss for the given amount. This
is only used in Path such as Transformation. In other
words, efficiency of movements is always 100%.
"""
def getNetQuantity():
"""
Returns affected quantity by some optional effects.
Returns the quantity multiplied by the ratio.
"""
# Price API
def getPrice():
"""
Returns price
Returns the unit price of the resource
"""
def getTotalPrice():
"""
Returns total price for the number of items
Returns total price ie. the unit price of the resource
multiplied by the quantity.
"""
# Conversion API
def getConvertedQuantity():
"""
Returns the quantity converted by the resource
Returns the quantity of the resource converted in the
management unit of the resource
"""
def getNetConvertedQuantity():
"""
Returns the net quantity converted by the resource
Returns the net quantity of the resource converted in the
management unit of the resource
"""
# Make it possible to add amounts
def __add__(value):
"""
Add
"""Add an amount to another amount
If the amount can understands argument as amount for addition,
returns calculated
'value' is an IAmount document
"""
def __sub__(value):
"""
Substract
"""Substract an amount from another amount
If the amount can understands argument as amount for substraction,
returns calculated
'value' is an IAmount document
"""
def __mul__(value):
"""
Multiply
"""Multiply an Amount by a float
If the amount can understands argument as efficiency for multiplication,
returns calculated
'value' is a float
"""
def __div__(value):
"""
Devide
"""Divide an Amount by a float
If the amount can understands argument as efficiency for division,
returns calculated
'value' is a float
"""
......@@ -26,228 +26,138 @@
#
##############################################################################
from Interface import Interface
from zope.interface import Interface
class IMovement(Interface):
"""
A movement represents amount of resource how are changed
on the path. The movement should be ables to provide how
amount is/was existed on node both source and destination.
Because of movement may be affected on path.
"""Movement interface specification
The movement interface can be represents any kind of delivery.
It is useful to represent changed of between nodes.
A movement represents an amount of resources which
is moved along an Arrow (source and destination).
Equations:
destination_quantity = source_quantity * efficiency
(These values can be calculated by Amount)
Production/Consumption
(A -> B)
if source_quantity > 0 and destination_quantity > 0
production_quantity = destination_quantity
consumption_quantity = source_quantity
if source_quantity < 0 and destination_quantity < 0
production_quantity = - source_quantity
consumption_quantity = - destination_quantity
if source_quantity < 0 and destination_quantity > 0
or
source_quantity > 0 and destination_quantity < 0
raise
production_quantity means nothing
consumption_quantity means nothing
(A -> Nothing)
if source_quantity > 0
consumption_quantity = source_quantity
production_quantity = 0
if quantity > 0
consumption_quantity = quantity
production_quantity = 0
if source_quantity < 0
consumption_quantity = 0
production_quantity = - source_quantity
if quantity < 0
consumption_quantity = 0
production_quantity = - quantity
(Nothing -> B)
if destination_quantity > 0
consumption_quantity = 0
production_quantity = destination_quantity
if destination_quantity < 0
consumption_quantity = - destination_quantity
production_quantity = 0
if quantity > 0
consumption_quantity = 0
production_quantity = quantity
if quantity < 0
consumption_quantity = - quantity
production_quantity = 0
Credit/Debit
(A -> B)
if source_quantity > 0 and destination_quantity > 0
source_credit = - source_quantity
source_debit = source_quantity
destination_credit = destination_quantity
destination_debit = - destination_quantity
if source_quantity < 0 and destination_quantity < 0
source_credit = source_quantity
source_debit = - source_quantity
destination_credit = - destination_quantity
destination_debit = destination_quantity
if source_quantity < 0 and destination_quantity > 0
or
source_quantity > 0 and destination_quantity < 0
raise
(A -> Nothing)
if source_quantity > 0
source_credit = source_quantity
source_debit = - source_quantity
destination_credit = 0
destination_debit = 0
if source_quantity < 0
source_credit = - source_quantity
source_debit = source_quantity
destination_credit = 0
destination_debit = 0
(Nothing -> B)
if destination_quantity > 0
source_credit = 0
source_debit = 0
destination_credit = destination_quantity
destination_debit = - destination_quantity
if destination_quantity < 0
source_credit = 0
source_debit = 0
destination_credit = - destination_quantity
destination_debit = destination_quantity
source_asset_price = price
destination_asset_price = price
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
TODO:
1. finish equations (for asset price)
2. clarify asset value application for multi
currency accunting
3. clarify the use of asset price in ERP5
(accounting and outside) since we no
longer store asset price on non accounting
movements
"""
# Conversion API for cataloging
def getConvertedSourceQuantity():
"""
Returns the quantity how are removed
from source by the movement
"""
def getConvertedDestinationQuantity():
"""
Returns the quantity how are reached
to destination by the movement
"""
# Helper methods for Production
# Helper API for Production
def getConsumptionQuantity():
"""
Returns the quantity how are consumed
on the path by the movement
"""Returns the consumed quantity during
production
"""
def getProductionQuantity():
"""
Returns the quantity how are produced
on the path by the movement
"""Returns the produced quantity during
production
"""
# Helper methods for Accounting
def getSourceDebit():
"""
Returns the quantity how are debited
from source node by the movement
# Helper methods for asset value calculation
def getSourceAssetPrice():
"""Returns the asset price on the source, if defined
XXX - it is unclear if we still use this
"""
def getSourceCredit():
"""
Returns the quantity how are credited
from source node by the movement
def getDestinationAssetPrice():
"""Returns the asset price on the destination, if defined
XXX - it is unclear if we still use this
"""
def getDestinationDebit():
"""
Returns the quantity how are debited
to destination node by the movement
def getSourceInventoriatedTotalAssetPrice():
"""Returns the total asset price for the source, if defined
"""
def getDestinationCredit():
"""
Returns the quantity how are credited
to destination node by the movement
def getDestinationInventoriatedTotalAssetPrice():
"""Returns the total asset price for the destination, if defined
"""
def getSourceAssetPrice():
"""
Returns the price how are taken
from source by the movement
# Helper methods for single currency Accounting (debit / credit)
def getSourceDebit():
"""Returns the source debit in the transaction currency
"""
def getSourceInventoriatedTotalAssetPrice():
"""
Returns a price which can be used
to calculate stock value (asset)
def getSourceCredit():
"""Returns the source credit in the transaction currency
"""
def getSourceInventoriatedTotalAssetDebit():
"""
Returns the debit part of inventoriated
source total asset price.
def getDestinationDebit():
"""Returns the destination debit in the transaction currency
"""
def getSourceInventoriatedTotalAssetCredit():
"""
Returns the credit part of inventoriated
source total asset price.
def getDestinationCredit():
"""Returns the destination credit in the transaction currency
"""
# Helper methods for multi currency Accounting (debit / credit)
def getSourceAssetDebit():
"""
Return the debit part of the source total
asset price.
"""Returns the source debit in the source management currency
"""
def getSourceAssetCredit():
"""
Return the credit part of the source total
asset price.
"""Returns the source credit in the source management currency
"""
def getDestinationAssetPrice():
"""
Returns the price how are given
to destination by the movement
def getDestinationAssetDebit():
"""Returns the destination debit in the destination management currency
"""
def getDestinationInventoriatedTotalAssetPrice():
"""
Returns a price which can be used
to calculate stock value (asset)
def getDestinationAssetCredit():
"""Returns the destination credit in the destination management currency
"""
def getDestinationInventoriatedTotalAssetDebit():
"""
Returns the debit part of inventoriated
destination total asset price.
def getSourceInventoriatedTotalAssetDebit():
"""Unclear - XXX
"""
def getDestinationInventoriatedTotalAssetCredit():
"""
Returns the credit part of inventoriated
destination total asset price.
def getSourceInventoriatedTotalAssetCredit():
"""Unclear - XXX
"""
def getDestinationAssetDebit():
"""
Return the debit part of the destination total
asset price.
def getDestinationInventoriatedTotalAssetDebit():
"""Unclear - XXX
"""
def getDestinationAssetCredit():
"""
Return the credit part of the destination total
asset price.
"""
def getDestinationInventoriatedTotalAssetCredit():
"""Unclear - XXX
"""
\ No newline at end of file
......@@ -26,21 +26,20 @@
#
##############################################################################
from Interface import Interface
from zope.interface import Interface
class ISimulationMovement(Interface):
"""
The SimulationMovement interface
introduces the possibility to define
quantity errors between the simulation
and the reality.
"""Simulation Movement interface specification
In short: parent applied rules use the Movement
API to define quantity.
The SimulationMovement interface introduces the option
to define quantity errors between the simulation
and the delivered reality.
Child applied rules use the Delivered API
to use appropriate values which include
the delivery_error.
In short: parent applied rules use the Movement
API to define quantity. Child applied rules
should use the Delivered API to access appropriate
quantity values which are take into account the
delivery_error.
DeliverySolver either solve divergence by
setting the delivery_error (then no target
......@@ -48,9 +47,13 @@ class ISimulationMovement(Interface):
by changing the quantity (then TargetSolver
is needed to backtrack the quantity).
quantity(SM) + delivery_error (SM) =
quantity(DL) * delivery_ratio(SM)
"""
Equation:
quantity(SM) + delivery_error (SM) =
quantity(DL) * delivery_ratio(SM)
TODO:
1. unclear API remaining
"""
# Delivery API
def getDeliveryRatio():
......@@ -69,50 +72,45 @@ class ISimulationMovement(Interface):
def getDeliveryQuantity():
"""
Returns quantity which was actually
shipped, taking into account the errors
of the simulation fixed by the delivery
Returns quantity which was actually shipped, taking
into account the errors of the simulation fixed by
the delivery
quantity + delivery_error
"""
def getDeliveryConvertedQuantity():
"""
Returns delivery quantity converted by the resource
"""XXX - unclear
"""
# Divergence API
def isConvergent():
"""
Returns the simulation movement is convergent
or not, with related the delivery
"""Tells whether the simulation movement is convergent
or not, with related delivery
"""
def isDivergent():
"""
Returns the simulation movement is divergent
or not, to related the delivery
"""Tells whether the simulation movement is divergent
or not, with related delivery
"""
def getDivergenceList():
"""
Returns listed divergences which is made by tester
of parent applied rule
Each divergence has why the delivery was judged
"""Returns a list of divergences
XXX - unclear, please explan what the returned documents
or object are (type, class)
"""
def isFrozen():
"""
Returns status of the simulation movement, it is
frozen or not, once it is frozen, all operations
can not change anything of the simulation movement
"""Tells whether the simulation movement is frozen.
By default, looks up the related Business Process Path
and tells if the simulation state is part of completed
states.
XXX - should this be renamed isCompleted ? are the
notions of isFrozen and isCompleted same or different ?
"""
def isSimulated():
"""
Returns the simulation movement is simulated or not
When the simulation movement is simulated, all operations
can not remove it, but can update, because related delivery
to be orphan, if can remove it
"""XXX - unclear
"""
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