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