Commit 21f40032 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Business Path has beed splitted in 2 parts. A first part which is only used to...

Business Path has beed splitted in 2 parts. A first part which is only used to control completation of trade phases and build process. A second part which is only used to define arrows, quantity shares and dates on amounts generated by amount generators. The first part is a predicate but no longer a Path (no arrow, no quantity, no delay, etc.). It is thus renamed to Business Link. The second part is a Path since it defines an Arrow, a quantity, a lead time, etc. It is thus renamed to Trade Model Path. 
It is now time to review in detail all interfaces. In particular those interfaces on Business Link related to time management many no longer be needed since it is simpler to lookup simulation. However, time management must be handled at Business Process level as a helper method for rules which need to calculate dates based on Business Links and/or Trade Model Path.

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@36465 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b1f4f161
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -43,6 +43,7 @@ class SelectMethodError(Exception): pass ...@@ -43,6 +43,7 @@ class SelectMethodError(Exception): pass
class BPMBuilder(Alarm): class BPMBuilder(Alarm):
"""Top class for builders. """Top class for builders.
XXX-JPS Wrong Naming - Abbreviation (BPM)
WARNING: This is BPM evaluation of building approach. WARNING: This is BPM evaluation of building approach.
WARNING: Do NOT use it in production environment. WARNING: Do NOT use it in production environment.
...@@ -100,10 +101,10 @@ class BPMBuilder(Alarm): ...@@ -100,10 +101,10 @@ class BPMBuilder(Alarm):
# Select movements # Select movements
if input_movement_list is None: if input_movement_list is None:
if not select_method_dict.has_key('causality_uid'): if not select_method_dict.has_key('causality_uid'):
business_path_value_list = self.getRelatedBusinessPathValueList() business_link_value_list = self.getRelatedBusinessLinkValueList()
if len(business_path_value_list) > 0: if len(business_link_value_list) > 0:
# use only Business Path related movements # use only Business Link related movements
select_method_dict['causality_uid'] = [q.getUid() for q in business_path_value_list] select_method_dict['causality_uid'] = [q.getUid() for q in business_link_value_list]
# do search # do search
input_movement_value_list = self.searchMovementList( input_movement_value_list = self.searchMovementList(
delivery_relative_url_list=existing_delivery_list, delivery_relative_url_list=existing_delivery_list,
...@@ -220,10 +221,10 @@ class BPMBuilder(Alarm): ...@@ -220,10 +221,10 @@ class BPMBuilder(Alarm):
input_movement.edit(delivery_value=delivery_movement, input_movement.edit(delivery_value=delivery_movement,
activate_kw=activate_kw) activate_kw=activate_kw)
def getRelatedBusinessPathValueList(self): def getRelatedBusinessLinkValueList(self):
return self.getDeliveryBuilderRelatedValueList( return self.getDeliveryBuilderRelatedValueList(
portal_type='Business Path') + self.getOrderBuilderRelatedValueList( portal_type='Business Link') + self.getOrderBuilderRelatedValueList(
portal_type='Business Path') portal_type='Business Link')
def callBeforeBuildingScript(self): def callBeforeBuildingScript(self):
""" """
......
...@@ -32,7 +32,7 @@ from AccessControl import ClassSecurityInfo ...@@ -32,7 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Path import Path from Products.ERP5.Document.Path import Path
from Products.ERP5.ExplanationCache import _getExplanationCache, _getBusinessPathClosure from Products.ERP5.ExplanationCache import _getExplanationCache, _getBusinessLinkClosure
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
import zope.interface import zope.interface
...@@ -40,7 +40,7 @@ import zope.interface ...@@ -40,7 +40,7 @@ import zope.interface
class BusinessProcess(Path, XMLObject): class BusinessProcess(Path, XMLObject):
"""The BusinessProcess class is a container class which is used """The BusinessProcess class is a container class which is used
to describe business processes in the area of trade, payroll to describe business processes in the area of trade, payroll
and production. Processes consists of a collection of Business Path and production. Processes consists of a collection of Business Link
which define an arrow between a 'predecessor' trade_state and a which define an arrow between a 'predecessor' trade_state and a
'successor' trade_state, for a given trade_phase_list. 'successor' trade_state, for a given trade_phase_list.
...@@ -63,8 +63,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -63,8 +63,8 @@ class BusinessProcess(Path, XMLObject):
always in the context of an explanation. Sometimes, always in the context of an explanation. Sometimes,
it is necessary to ignore certain business path to evaluate it is necessary to ignore certain business path to evaluate
completion or completion dates. This is very true for Union completion or completion dates. This is very true for Union
Business Processes. This is the concept of Business Path closure, Business Processes. This is the concept of Business Link closure,
ie. filtering out all Business Path which are not used in an explanation. ie. filtering out all Business Link which are not used in an explanation.
TODO: TODO:
- add support to prevent infinite loop. (but beware, this notion has changed - add support to prevent infinite loop. (but beware, this notion has changed
...@@ -91,7 +91,7 @@ class BusinessProcess(Path, XMLObject): ...@@ -91,7 +91,7 @@ class BusinessProcess(Path, XMLObject):
- support conversions in business path - support conversions in business path
RENAMED: RENAMED:
getPathValueList -> getBusinessPathValueList getPathValueList -> getBusinessLinkValueList
""" """
meta_type = 'ERP5 Business Process' meta_type = 'ERP5 Business Process'
portal_type = 'Business Process' portal_type = 'Business Process'
...@@ -115,17 +115,17 @@ class BusinessProcess(Path, XMLObject): ...@@ -115,17 +115,17 @@ class BusinessProcess(Path, XMLObject):
zope.interface.implements(interfaces.IBusinessProcess, zope.interface.implements(interfaces.IBusinessProcess,
interfaces.IArrowBase) interfaces.IArrowBase)
# IBusinessPathProcess implementation # IBusinessLinkProcess implementation
security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessPathValueList') security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessLinkValueList')
def getBusinessPathValueList(self, trade_phase=None, context=None, def getBusinessLinkValueList(self, trade_phase=None, context=None,
predecessor=None, successor=None, **kw): predecessor=None, successor=None, **kw):
"""Returns all Path of the current BusinessProcess which """Returns all Path of the current BusinessProcess which
are matching the given trade_phase and the optional context. are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase trade_phase -- filter by trade phase
context -- a context to test each Business Path on context -- a context to test each Business Link on
and filter out Business Path which do not match and filter out Business Link which do not match
predecessor -- filter by trade state predecessor predecessor -- filter by trade state predecessor
...@@ -141,46 +141,46 @@ class BusinessProcess(Path, XMLObject): ...@@ -141,46 +141,46 @@ class BusinessProcess(Path, XMLObject):
trade_phase = set(trade_phase) trade_phase = set(trade_phase)
result = [] result = []
if kw.get('portal_type', None) is None: if kw.get('portal_type', None) is None:
kw['portal_type'] = self.getPortalBusinessPathTypeList() kw['portal_type'] = self.getPortalBusinessLinkTypeList()
if kw.get('sort_on', None) is None: if kw.get('sort_on', None) is None:
kw['sort_on'] = 'int_index' kw['sort_on'] = 'int_index'
original_business_path_list = self.objectValues(**kw) # Why Object Values ??? XXX-JPS original_business_link_list = self.objectValues(**kw) # Why Object Values ??? XXX-JPS
# Separate the selection of business paths into two steps # Separate the selection of business paths into two steps
# for easier debugging. # for easier debugging.
# First, collect business paths which can be applicable to a given context. # First, collect business paths which can be applicable to a given context.
business_path_list = [] business_link_list = []
for business_path in original_business_path_list: for business_link in original_business_link_list:
accept_path = True accept_path = True
if predecessor is not None and business_path.getPredecessor() != predecessor: if predecessor is not None and business_link.getPredecessor() != predecessor:
accept_path = False # Filter our business path which predecessor does not match accept_path = False # Filter our business path which predecessor does not match
if successor is not None and business_path.getSuccessor() != successor: if successor is not None and business_link.getSuccessor() != successor:
accept_path = False # Filter our business path which predecessor does not match accept_path = False # Filter our business path which predecessor does not match
if trade_phase is not None and not trade_phase.intersection(business_path.getTradePhaseList()): if trade_phase is not None and not trade_phase.intersection(business_link.getTradePhaseList()):
accept_path = False # Filter our business path which trade phase does not match accept_path = False # Filter our business path which trade phase does not match
if accept_path: if accept_path:
business_path_list.append(business_path) business_link_list.append(business_link)
# Then, filter business paths by Predicate API. # Then, filter business paths by Predicate API.
# FIXME: Ideally, we should use the Domain Tool to search business paths, # FIXME: Ideally, we should use the Domain Tool to search business paths,
# and avoid using the low level Predicate API. But the Domain Tool does # and avoid using the low level Predicate API. But the Domain Tool does
# support the condition above without scripting? # support the condition above without scripting?
for business_path in business_path_list: for business_link in business_link_list:
if business_path.test(context): if business_link.test(context):
result.append(business_path) result.append(business_link)
return result return result
def isBusinessPathCompleted(self, explanation, business_path): def isBusinessLinkCompleted(self, explanation, business_link):
"""Returns True if given Business Path document """Returns True if given Business Link document
is completed in the context of provided explanation. is completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
# Return False if Business Path is not completed # Return False if Business Link is not completed
if not business_path.isCompleted(explanation): if not business_link.isCompleted(explanation):
return False return False
predecessor_state = business_path.getPredecessor() predecessor_state = business_link.getPredecessor()
if not predecessor_state: if not predecessor_state:
# This is a root business path, no predecessor # This is a root business path, no predecessor
# so no need to do any recursion # so no need to do any recursion
...@@ -197,22 +197,22 @@ class BusinessProcess(Path, XMLObject): ...@@ -197,22 +197,22 @@ class BusinessProcess(Path, XMLObject):
# path wich are directly related to the current business path but DO NOT # path wich are directly related to the current business path but DO NOT
# narrow down the explanation else we might narrow down so much that # narrow down the explanation else we might narrow down so much that
# it becomes an empty set # it becomes an empty set
closure_process = _getBusinessPathClosure(self, explanation, business_path) closure_process = _getBusinessLinkClosure(self, explanation, business_link)
return closure_process.isTradeStateCompleted(explanation, predecessor_state) return closure_process.isTradeStateCompleted(explanation, predecessor_state)
def isBusinessPathPartiallyCompleted(self, explanation, business_path): def isBusinessLinkPartiallyCompleted(self, explanation, business_link):
"""Returns True if given Business Path document """Returns True if given Business Link document
is partially completed in the context of provided explanation. is partially completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
# Return False if Business Path is not partially completed # Return False if Business Link is not partially completed
if not business_path.isPartiallyCompleted(explanation): if not business_link.isPartiallyCompleted(explanation):
return False return False
predecessor_state = business_path.getPredecessor() predecessor_state = business_link.getPredecessor()
if not predecessor_state: if not predecessor_state:
# This is a root business path, no predecessor # This is a root business path, no predecessor
# so no need to do any recursion # so no need to do any recursion
...@@ -229,179 +229,179 @@ class BusinessProcess(Path, XMLObject): ...@@ -229,179 +229,179 @@ class BusinessProcess(Path, XMLObject):
# path wich are directly related to the current business path but DO NOT # path wich are directly related to the current business path but DO NOT
# narrow down the explanation else we might narrow down so much that # narrow down the explanation else we might narrow down so much that
# it becomes an empty set # it becomes an empty set
closure_process = _getBusinessPathClosure(explanation, business_path) closure_process = _getBusinessLinkClosure(explanation, business_link)
return closure_process.isTradeStatePartiallyCompleted(explanation, return closure_process.isTradeStatePartiallyCompleted(explanation,
predecessor_state) predecessor_state)
def getExpectedBusinessPathCompletionDate(self, explanation, business_path, def getExpectedBusinessLinkCompletionDate(self, explanation, business_link,
delay_mode=None): delay_mode=None):
"""Returns the expected completion date of given Business Path document """Returns the expected completion date of given Business Link document
in the context of provided explanation. in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
delay_mode -- optional value to specify calculation mode ('min', 'max') delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay if no value specified use average delay
""" """
closure_process = _getBusinessPathClosure(self, explanation, business_path) closure_process = _getBusinessLinkClosure(self, explanation, business_link)
# XXX use explanation cache to optimize # XXX use explanation cache to optimize
predecessor = business_path.getPredecessor() predecessor = business_link.getPredecessor()
if closure_process.isInitialTradeState(predecessor): if closure_process.isInitialTradeState(predecessor):
return business_path.getCompletionDate(explanation) return business_link.getCompletionDate(explanation)
# Recursively find reference_date # Recursively find reference_date
reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor) reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor)
start_date = reference_date + business_path.getPaymentTerm() # XXX-JPS Until better naming start_date = reference_date + business_link.getPaymentTerm() # XXX-JPS Until better naming
if delay_mode == 'min': if delay_mode == 'min':
delay = business_path.getMinDelay() delay = business_link.getMinDelay()
elif delay_mode == 'max': elif delay_mode == 'max':
delay = business_path.getMaxDelay() delay = business_link.getMaxDelay()
else: else:
delay = (business_path.getMaxDelay() + business_path.getMinDelay()) / 2.0 delay = (business_link.getMaxDelay() + business_link.getMinDelay()) / 2.0
stop_date = start_date + delay stop_date = start_date + delay
completion_date_method_id = business_path.getCompletionDateMethodId() completion_date_method_id = business_link.getCompletionDateMethodId()
if completion_date_method_id == 'getStartDate': if completion_date_method_id == 'getStartDate':
return start_date return start_date
elif completion_date_method_id == 'getStopDate': elif completion_date_method_id == 'getStopDate':
return stop_date return stop_date
raise ValueError("Business Path does not support %s complete date method" % completion_date_method_id) raise ValueError("Business Link does not support %s complete date method" % completion_date_method_id)
def getExpectedBusinessPathStartAndStopDate(self, explanation, business_path, def getExpectedTradeModelPathStartAndStopDate(self, explanation, trade_model_path,
delay_mode=None): delay_mode=None):
"""Returns the expected start and stop dates of given Business Path """Returns the expected start and stop dates of given Trade Model Path
document in the context of provided explanation. document in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document trade_model_path -- a Trade Model Path document
delay_mode -- optional value to specify calculation mode ('min', 'max') delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay if no value specified use average delay
""" """
if explanation.getPortalType() != 'Applied Rule': if explanation.getPortalType() != 'Applied Rule':
raise TypeError('explanation must be an Applied Rule as part of expand process') raise TypeError('explanation must be an Applied Rule as part of expand process')
closure_process = _getBusinessPathClosure(self, explanation, business_path) closure_process = _getBusinessLinkClosure(self, explanation, trade_model_path) # XXX-JPS ???
# XXX use explanation cache to optimize # XXX use explanation cache to optimize
trade_date = business_path.getTradeDate() trade_date = trade_model_path.getTradeDate()
if trade_date is not None: if trade_date is not None:
trade_phase = trade_date[len('trade_phase/'):] # XXX-JPS quite dirty way trade_phase = trade_date[len('trade_date/'):] # XXX-JPS quite dirty way
reference_date = closure_process.getExpectedTradePhaseCompletionDate(explanation, trade_phase) reference_date = closure_process.getExpectedTradePhaseCompletionDate(explanation, trade_phase)
else: else:
predecessor = business_path.getPredecessor() # XXX-JPS all states are supposed to have a predecessor predecessor = business_link.getPredecessor() # XXX-JPS all states are supposed to have a predecessor
reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor) reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor)
# Recursively find reference_date # Recursively find reference_date
reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor) reference_date = closure_process.getExpectedTradeStateCompletionDate(explanation, predecessor)
start_date = reference_date + business_path.getPaymentTerm() # XXX-JPS Until better naming start_date = reference_date + trade_model_path.getPaymentTerm() # XXX-JPS Until better naming
if delay_mode == 'min': if delay_mode == 'min':
delay = business_path.getMinDelay() delay = trade_model_path.getMinDelay()
elif delay_mode == 'max': elif delay_mode == 'max':
delay = business_path.getMaxDelay() delay = trade_model_path.getMaxDelay()
else: else:
delay = (business_path.getMaxDelay() + business_path.getMinDelay()) / 2.0 delay = (business_link.getMaxDelay() + trade_model_path.getMinDelay()) / 2.0
stop_date = start_date + delay stop_date = start_date + delay
return start_date, stop_date return start_date, stop_date
# IBuildableBusinessPathProcess implementation # IBuildableBusinessLinkProcess implementation
def getBuildableBusinessPathValueList(self, explanation): def getBuildableBusinessLinkValueList(self, explanation):
"""Returns the list of Business Path which are buildable """Returns the list of Business Link which are buildable
by taking into account trade state dependencies between by taking into account trade state dependencies between
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
result = [] result = []
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
if self.isBusinessPathBuildable(explanation, business_path): if self.isBusinessLinkBuildable(explanation, business_link):
result.append(business_path) result.append(business_link)
return result return result
def getPartiallyBuildableBusinessPathValueList(self, explanation): def getPartiallyBuildableBusinessLinkValueList(self, explanation):
"""Returns the list of Business Path which are partially buildable """Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between by taking into account trade state dependencies between
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
result = [] result = []
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
if self.isBusinessPathPartiallyBuildable(explanation, business_path): if self.isBusinessLinkPartiallyBuildable(explanation, business_link):
result.append(business_path) result.append(business_link)
return result return result
def isBusinessPathBuildable(self, explanation, business_path): def isBusinessLinkBuildable(self, explanation, business_link):
"""Returns True if any of the related Simulation Movement """Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is completed. is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
# If everything is delivered, no need to build # If everything is delivered, no need to build
if business_path.isDelivered(explanation): if business_link.isDelivered(explanation):
return False return False
# We must take the closure cause only way to combine business process # We must take the closure cause only way to combine business process
closure_process = _getBusinessPathClosure(self, explanation, business_path) closure_process = _getBusinessLinkClosure(self, explanation, business_link)
predecessor = business_path.getPredecessor() predecessor = business_link.getPredecessor()
return closure_process.isTradeStateCompleted(predecessor) return closure_process.isTradeStateCompleted(predecessor)
def isBusinessPathPartiallyBuildable(self, explanation, business_path): def isBusinessLinkPartiallyBuildable(self, explanation, business_link):
"""Returns True if any of the related Simulation Movement """Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is partially completed. is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
# If everything is delivered, no need to build # If everything is delivered, no need to build
if business_path.isDelivered(explanation): if business_link.isDelivered(explanation):
return False return False
# We must take the closure cause only way to combine business process # We must take the closure cause only way to combine business process
closure_process = _getBusinessPathClosure(self, explanation, business_path) closure_process = _getBusinessLinkClosure(self, explanation, business_link)
predecessor = business_path.getPredecessor() predecessor = business_link.getPredecessor()
return closure_process.isTradeStatePartiallyCompleted(predecessor) return closure_process.isTradeStatePartiallyCompleted(predecessor)
# ITradeStateProcess implementation # ITradeStateProcess implementation
def getTradeStateList(self): def getTradeStateList(self):
"""Returns list of all trade_state of this Business Process """Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained by looking at successor and predecessor values of contained
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
result = set() result = set()
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
result.add(business_path.getPredecessor()) result.add(business_link.getPredecessor())
result.add(business_path.getSuccessor()) result.add(business_link.getSuccessor())
return result return result
def isInitialTradeState(self, trade_state): def isInitialTradeState(self, trade_state):
"""Returns True if given 'trade_state' has no successor related """Returns True if given 'trade_state' has no successor related
Business Path. Business Link.
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
return len(self.getBusinessPathValueList(successor=trade_state)) == 0 return len(self.getBusinessLinkValueList(successor=trade_state)) == 0
def isFinalTradeState(self, trade_state): def isFinalTradeState(self, trade_state):
"""Returns True if given 'trade_state' has no predecessor related """Returns True if given 'trade_state' has no predecessor related
Business Path. Business Link.
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
return len(self.getBusinessPathValueList(predecessor=trade_state)) == 0 return len(self.getBusinessLinkValueList(predecessor=trade_state)) == 0
def getSuccessorTradeStateList(self, explanation, trade_state): def getSuccessorTradeStateList(self, explanation, trade_state):
"""Returns the list of successor states in the """Returns the list of successor states in the
...@@ -415,9 +415,9 @@ class BusinessProcess(Path, XMLObject): ...@@ -415,9 +415,9 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
result = set() result = set()
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
if business_path.getPredecessor() == trade_state: if business_link.getPredecessor() == trade_state:
result.add(business_path.getSuccessor()) result.add(business_link.getSuccessor())
return result return result
def getPredecessorTradeStateList(self, explanation, trade_state): def getPredecessorTradeStateList(self, explanation, trade_state):
...@@ -432,9 +432,9 @@ class BusinessProcess(Path, XMLObject): ...@@ -432,9 +432,9 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
result = set() result = set()
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
if business_path.getSuccessor() == trade_state: if business_link.getSuccessor() == trade_state:
result.add(business_path.getPredecessor()) result.add(business_link.getPredecessor())
return result return result
def getCompletedTradeStateList(self, explanation): def getCompletedTradeStateList(self, explanation):
...@@ -465,8 +465,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -465,8 +465,8 @@ class BusinessProcess(Path, XMLObject):
""" """
result = set() result = set()
for state in self.getCompletedTradeStateValue(explanation): for state in self.getCompletedTradeStateValue(explanation):
for business_path in state.getPredecessorRelatedValueList(): for business_link in state.getPredecessorRelatedValueList():
if not self.isBusinessPathCompleted(explanation, business_path): if not self.isBusinessLinkCompleted(explanation, business_link):
result.add(state) result.add(state)
return result return result
...@@ -480,8 +480,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -480,8 +480,8 @@ class BusinessProcess(Path, XMLObject):
""" """
result = set() result = set()
for state in self.getCompletedTradeStateValue(explanation): for state in self.getCompletedTradeStateValue(explanation):
for business_path in state.getPredecessorRelatedValueList(): for business_link in state.getPredecessorRelatedValueList():
if not self.isBusinessPathPartiallyCompleted(explanation, business_path): if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
result.add(state) result.add(state)
return result return result
...@@ -495,8 +495,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -495,8 +495,8 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
for business_path in self.getBusinessPathValueList(successor=trade_state): for business_link in self.getBusinessLinkValueList(successor=trade_state):
if not closure_process.isBusinessPathCompleted(explanation, business_path): if not closure_process.isBusinessLinkCompleted(explanation, business_link):
return False return False
return True return True
...@@ -510,8 +510,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -510,8 +510,8 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
for business_path in self.getBusinessPathValueList(successor=trade_state): for business_link in self.getBusinessLinkValueList(successor=trade_state):
if not self.isBusinessPathPartiallyCompleted(explanation, business_path): if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
return False return False
return True return True
...@@ -529,18 +529,18 @@ class BusinessProcess(Path, XMLObject): ...@@ -529,18 +529,18 @@ class BusinessProcess(Path, XMLObject):
if no value specified use average delay if no value specified use average delay
""" """
date_list = [] date_list = []
for business_path in self.getBusinessPathValueList(successor=trade_state): for business_link in self.getBusinessLinkValueList(successor=trade_state):
date_list.append(self.getExpectedBusinessPathCompletionDate(explanation, business_path)) date_list.append(self.getExpectedBusinessLinkCompletionDate(explanation, business_link))
return max(date_list) # XXX-JPS it would be good that date support infinite values return max(date_list) # XXX-JPS it would be good that date support infinite values
# ITradePhaseProcess implementation # ITradePhaseProcess implementation
def getTradePhaseList(self): def getTradePhaseList(self):
"""Returns list of all trade_phase of this Business Process """Returns list of all trade_phase of this Business Process
by looking at trade_phase values of contained Business Path. by looking at trade_phase values of contained Business Link.
""" """
result = set() result = set()
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
result = result.union(business_path.getTradePhaseList()) result = result.union(business_link.getTradePhaseList())
return result return result
def getCompletedTradePhaseList(self, explanation): def getCompletedTradePhaseList(self, explanation):
...@@ -570,8 +570,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -570,8 +570,8 @@ class BusinessProcess(Path, XMLObject):
trade_phase -- a Trade Phase category trade_phase -- a Trade Phase category
""" """
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase): for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
if not self.isBusinessPathCompleted(explanation, business_path): if not self.isBusinessLinkCompleted(explanation, business_link):
return False return False
return True return True
...@@ -585,8 +585,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -585,8 +585,8 @@ class BusinessProcess(Path, XMLObject):
trade_phase -- a Trade Phase category trade_phase -- a Trade Phase category
""" """
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase): for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
if not self.isBusinessPathPartiallyCompleted(explanation, business_path): if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
return False return False
return True return True
...@@ -606,11 +606,11 @@ class BusinessProcess(Path, XMLObject): ...@@ -606,11 +606,11 @@ class BusinessProcess(Path, XMLObject):
if no value specified use average delay if no value specified use average delay
""" """
date_list = [] date_list = []
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase): for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
date_list.append(self.getExpectedBusinessPathCompletionDate(explanation, business_path, delay_mode=delay_mode)) date_list.append(self.getExpectedBusinessLinkCompletionDate(explanation, business_link, delay_mode=delay_mode))
return max(date_list) return max(date_list)
def getRemainingTradePhaseList(self, business_path, trade_phase_list=None): def getRemainingTradePhaseList(self, business_link, trade_phase_list=None):
"""Returns the list of remaining trade phases which to be achieved """Returns the list of remaining trade phases which to be achieved
as part of a business process. This list is calculated by analysing as part of a business process. This list is calculated by analysing
the graph of business path and trade states, starting from a given the graph of business path and trade states, starting from a given
...@@ -618,7 +618,7 @@ class BusinessProcess(Path, XMLObject): ...@@ -618,7 +618,7 @@ class BusinessProcess(Path, XMLObject):
method is useful mostly for production and MRP to manage a distributed method is useful mostly for production and MRP to manage a distributed
supply and production chain. supply and production chain.
business_path -- a Business Path document business_link -- a Business Link document
trade_phase_list -- if provided, the result is filtered by it after trade_phase_list -- if provided, the result is filtered by it after
being collected - XXX-JPS - is this really useful ? being collected - XXX-JPS - is this really useful ?
...@@ -627,13 +627,13 @@ class BusinessProcess(Path, XMLObject): ...@@ -627,13 +627,13 @@ class BusinessProcess(Path, XMLObject):
NOTE: explanation is not involved here because we consider here that NOTE: explanation is not involved here because we consider here that
self is the result of asUnionBusinessProcess and thus only contains self is the result of asUnionBusinessProcess and thus only contains
applicable Business Path to a given simulation subtree. Since the list applicable Business Link to a given simulation subtree. Since the list
of remaining trade phases does not depend on exact values in the of remaining trade phases does not depend on exact values in the
simulation, we did not include the explanation. However, this makes the simulation, we did not include the explanation. However, this makes the
API less uniform. API less uniform.
""" """
remaining_trade_phase_list = [] remaining_trade_phase_list = []
for path in [x for x in self.objectValues(portal_type="Business Path") \ for path in [x for x in self.objectValues(portal_type="Business Link") \
if x.getPredecessorValue() == trade_state]: if x.getPredecessorValue() == trade_state]:
# XXX When no simulations related to path, what should path.isCompleted return? # XXX When no simulations related to path, what should path.isCompleted return?
# if True we don't have way to add remaining trade phases to new movement # if True we don't have way to add remaining trade phases to new movement
...@@ -657,7 +657,7 @@ class BusinessProcess(Path, XMLObject): ...@@ -657,7 +657,7 @@ class BusinessProcess(Path, XMLObject):
def getTradePhaseMovementList(self, explanation, amount, trade_phase=None, delay_mode=None): def getTradePhaseMovementList(self, explanation, amount, trade_phase=None, delay_mode=None):
"""Returns a list of movement with appropriate arrow and dates, """Returns a list of movement with appropriate arrow and dates,
based on the Business Path definitions, provided 'amount' and optional based on the Business Link definitions, provided 'amount' and optional
trade phases. If no trade_phase is provided, the trade_phase defined trade phases. If no trade_phase is provided, the trade_phase defined
on the Amount is used instead. on the Amount is used instead.
...@@ -681,10 +681,10 @@ class BusinessProcess(Path, XMLObject): ...@@ -681,10 +681,10 @@ class BusinessProcess(Path, XMLObject):
result = [] result = []
id_index = 0 id_index = 0
base_id = amount.getId() base_id = amount.getId()
for business_path in self.getBusinessPathValueList(context=amount, trade_phase=trade_phase): for business_link in self.getTradePathValueList(context=amount, trade_phase=trade_phase):
id_index += 1 id_index += 1
movement = newTempMovement(business_path, '%s_%s' % (base_id, id_index)) movement = newTempMovement(business_link, '%s_%s' % (base_id, id_index))
kw = self._getPropertyAndCategoryDict(explanation, amount, business_path, delay_mode=delay_mode) kw = self._getPropertyAndCategoryDict(explanation, amount, business_link, delay_mode=delay_mode)
movement._edit(**kw) movement._edit(**kw)
result.append(movement) result.append(movement)
...@@ -711,8 +711,8 @@ class BusinessProcess(Path, XMLObject): ...@@ -711,8 +711,8 @@ class BusinessProcess(Path, XMLObject):
return stripped_result return stripped_result
def _getPropertyAndCategoryDict(self, explanation, amount, business_path, delay_mode=None): def _getPropertyAndCategoryDict(self, explanation, amount, business_link, delay_mode=None):
"""A private method to merge an amount and a business_path and return """A private method to merge an amount and a business_link and return
a dict of properties and categories which can be used to create a a dict of properties and categories which can be used to create a
new movement. new movement.
...@@ -721,7 +721,7 @@ class BusinessProcess(Path, XMLObject): ...@@ -721,7 +721,7 @@ class BusinessProcess(Path, XMLObject):
amount -- an IAmount instance or an IMovement instance amount -- an IAmount instance or an IMovement instance
business_path -- an IBusinessPath instance business_link -- an IBusinessLink instance
delay_mode -- optional value to specify calculation mode ('min', 'max') delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay if no value specified use average delay
...@@ -740,16 +740,16 @@ class BusinessProcess(Path, XMLObject): ...@@ -740,16 +740,16 @@ class BusinessProcess(Path, XMLObject):
# Arrow categories # Arrow categories
for base_category, category_url_list in \ for base_category, category_url_list in \
business_path.getArrowCategoryDict(context=amount).iteritems(): business_link.getArrowCategoryDict(context=amount).iteritems():
property_dict[base_category] = category_url_list property_dict[base_category] = category_url_list
# Amount quantities - XXX-JPS maybe we should consider handling unit conversions here # Amount quantities - XXX-JPS maybe we should consider handling unit conversions here
# and specifying units # and specifying units
if business_path.getQuantity(): if business_link.getQuantity():
property_dict['quantity'] = business_path.getQuantity() property_dict['quantity'] = business_link.getQuantity()
elif business_path.getEfficiency(): elif business_link.getEfficiency():
property_dict['quantity'] = amount.getQuantity() *\ property_dict['quantity'] = amount.getQuantity() *\
business_path.getEfficiency() business_link.getEfficiency()
else: else:
property_dict['quantity'] = amount.getQuantity() property_dict['quantity'] = amount.getQuantity()
...@@ -765,15 +765,15 @@ class BusinessProcess(Path, XMLObject): ...@@ -765,15 +765,15 @@ class BusinessProcess(Path, XMLObject):
# applied rules which are not root applied rules. # applied rules which are not root applied rules.
# XXX-JPS could be extended with a rule property instead # XXX-JPS could be extended with a rule property instead
# of supports only in root applied rule case # of supports only in root applied rule case
start_date, stop_date = self.getExpectedBusinessPathStartAndStopDate( start_date, stop_date = self.getExpectedTradePathStartAndStopDate(
explanation, business_path, delay_mode=delay_mode) explanation, business_link, delay_mode=delay_mode)
property_dict['start_date'] = start_date property_dict['start_date'] = start_date
property_dict['stop_date'] = stop_date property_dict['stop_date'] = stop_date
else: else:
raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do
# Set causality to business path # Set causality to business path
property_dict['causality'] = business_path.getRelativeUrl() # XXX-JPS Will not work if we do not use real object property_dict['causality'] = business_link.getRelativeUrl() # XXX-JPS Will not work if we do not use real object
return property_dict return property_dict
...@@ -808,26 +808,26 @@ class BusinessProcess(Path, XMLObject): ...@@ -808,26 +808,26 @@ class BusinessProcess(Path, XMLObject):
return max(date_list) return max(date_list)
def isBuildable(self, explanation): def isBuildable(self, explanation):
"""Returns True is one Business Path of this Business Process """Returns True is one Business Link of this Business Process
is buildable in the context of given explanation. is buildable in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
return len(self.getBuildableBusinessPathValueList(explanation)) != 0 return len(self.getBuildableBusinessLinkValueList(explanation)) != 0
def isPartiallyBuildable(self, explanation): def isPartiallyBuildable(self, explanation):
"""Returns True is one Business Path of this Business Process """Returns True is one Business Link of this Business Process
is partially buildable in the context of given explanation. is partially buildable in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
return len(self.getPartiallyBuildableBusinessPathValueList(explanation)) != 0 return len(self.getPartiallyBuildableBusinessLinkValueList(explanation)) != 0
def build(self, explanation): def build(self, explanation):
""" """
Build whatever is buildable Build whatever is buildable
""" """
for business_path in self.getBuildableBusinessPathValueList(explanation): for business_link in self.getBuildableBusinessLinkValueList(explanation):
business_path.build(explanation) business_link.build(explanation)
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
...@@ -44,7 +45,7 @@ class DeliveryRootSimulationRule(DeliveryRule): ...@@ -44,7 +45,7 @@ class DeliveryRootSimulationRule(DeliveryRule):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_link, current_property_dict):
"""Order rule specific update dictionary""" """Order rule specific update dictionary"""
return { return {
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
...@@ -44,7 +45,7 @@ class InvoiceRootSimulationRule(InvoiceRule): ...@@ -44,7 +45,7 @@ class InvoiceRootSimulationRule(InvoiceRule):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_link, current_property_dict):
"""Order rule specific update dictionary""" """Order rule specific update dictionary"""
return { return {
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -47,7 +48,7 @@ class OrderRootSimulationRule(OrderRule): ...@@ -47,7 +48,7 @@ class OrderRootSimulationRule(OrderRule):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_link, current_property_dict):
"""Order rule specific update dictionary""" """Order rule specific update dictionary"""
return { return {
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -200,11 +201,11 @@ class PaySheetTransaction(Invoice): ...@@ -200,11 +201,11 @@ class PaySheetTransaction(Invoice):
movement_list_trade_phase_dic[trade_phase].append(movement) movement_list_trade_phase_dic[trade_phase].append(movement)
for trade_phase in movement_list_trade_phase_dic.keys(): for trade_phase in movement_list_trade_phase_dic.keys():
business_path_list = business_process.getPathValueList(trade_phase=\ business_link_list = business_process.getPathValueList(trade_phase=\
trade_phase) trade_phase)
for business_path in business_path_list: for business_link in business_link_list:
builder_list = [portal.restrictedTraverse(url) for url in\ builder_list = [portal.restrictedTraverse(url) for url in\
business_path.getDeliveryBuilderList()] business_link.getDeliveryBuilderList()]
for builder in builder_list: for builder in builder_list:
builder.build(delivery_relative_url_list=[self.getRelativeUrl(),], builder.build(delivery_relative_url_list=[self.getRelativeUrl(),],
movement_list = movement_list_trade_phase_dic[trade_phase]) movement_list = movement_list_trade_phase_dic[trade_phase])
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -45,7 +46,7 @@ class ProductionOrderModelRootSimulationRule(ProductionOrderModelRule): ...@@ -45,7 +46,7 @@ class ProductionOrderModelRootSimulationRule(ProductionOrderModelRule):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_link, current_property_dict):
"""Order rule specific update dictionary""" """Order rule specific update dictionary"""
return { return {
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -45,7 +46,7 @@ class ProductionOrderRootSimulationRule(ProductionOrderRule): ...@@ -45,7 +46,7 @@ class ProductionOrderRootSimulationRule(ProductionOrderRule):
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement, def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict): business_link, current_property_dict):
"""Order rule specific update dictionary""" """Order rule specific update dictionary"""
return { return {
'delivery': movement.getRelativeUrl(), 'delivery': movement.getRelativeUrl(),
......
...@@ -202,11 +202,11 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin): ...@@ -202,11 +202,11 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
simulation_state is in of completed state list defined on business path simulation_state is in of completed state list defined on business path
""" """
# only available in BPM, so fail totally in case of working without BPM # only available in BPM, so fail totally in case of working without BPM
business_path = self.getCausalityValue( business_link = self.getCausalityValue(
portal_type=self.getPortalBusinessPathTypeList()) portal_type=self.getPortalBusinessLinkTypeList())
if business_path is None: if business_link is None:
return False return False
return self.getSimulationState() in business_path.getCompletedStateList() return self.getSimulationState() in business_link.getCompletedStateList()
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'isFrozen') 'isFrozen')
...@@ -214,9 +214,9 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin): ...@@ -214,9 +214,9 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
"""Lookup business path and, if any, return True whenever """Lookup business path and, if any, return True whenever
simulation_state is in one of the frozen states defined on business path simulation_state is in one of the frozen states defined on business path
""" """
business_path = self.getCausalityValue( business_link = self.getCausalityValue(
portal_type=self.getPortalBusinessPathTypeList()) portal_type=self.getPortalBusinessLinkTypeList())
if business_path is None: if business_link is None:
# Legacy support - this should never happen # Legacy support - this should never happen
# XXX-JPS ADD WARNING # XXX-JPS ADD WARNING
if self.getSimulationState() in ('stopped', 'delivered', 'cancelled'): if self.getSimulationState() in ('stopped', 'delivered', 'cancelled'):
...@@ -224,7 +224,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin): ...@@ -224,7 +224,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
if self._baseIsFrozen() == 0: if self._baseIsFrozen() == 0:
self._baseSetFrozen(None) self._baseSetFrozen(None)
return self._baseGetFrozen() or False return self._baseGetFrozen() or False
return self.getSimulationState() in business_path.getFrozenStateList() return self.getSimulationState() in business_link.getFrozenStateList()
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'isAccountable') 'isAccountable')
...@@ -580,32 +580,32 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin): ...@@ -580,32 +580,32 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
return False return False
# might be buildable - business path depended # might be buildable - business path depended
business_path = self.getCausalityValue(portal_type='Business Path') business_link = self.getCausalityValue(portal_type='Business Link')
explanation_value = self.getExplanationValue() explanation_value = self.getExplanationValue()
if business_path is None or explanation_value is None: if business_link is None or explanation_value is None:
return True return True
predecessor = business_path.getPredecessorValue() predecessor = business_link.getPredecessorValue()
if predecessor is None: if predecessor is None:
# first one, can be built # first one, can be built
return True # XXX-JPS wrong cause root is marked return True # XXX-JPS wrong cause root is marked
for successor_related in predecessor.getSuccessorRelatedValueList(): # XXX-JPS wrong cause state shared by multi BPM for successor_related in predecessor.getSuccessorRelatedValueList(): # XXX-JPS wrong cause state shared by multi BPM
for business_path_movement in successor_related \ for business_link_movement in successor_related \
.getRelatedSimulationMovementValueList(explanation_value): .getRelatedSimulationMovementValueList(explanation_value):
if successor_related.isMovementRelatedWithMovement(self, if successor_related.isMovementRelatedWithMovement(self,
business_path_movement): business_link_movement):
business_path_movement_delivery = business_path_movement \ business_link_movement_delivery = business_link_movement \
.getDeliveryValue() .getDeliveryValue()
if business_path_movement_delivery is None: if business_link_movement_delivery is None:
return False # related movement is not delivered yet return False # related movement is not delivered yet
business_path_movement_delivery_document = \ business_link_movement_delivery_document = \
business_path_movement_delivery.getExplanationValue() business_link_movement_delivery.getExplanationValue()
# here we can optimise somehow, as # here we can optimise somehow, as
# business_path_movement_delivery_document would repeat # business_link_movement_delivery_document would repeat
if not successor_related.isCompleted( if not successor_related.isCompleted(
business_path_movement_delivery_document): business_link_movement_delivery_document):
# related movements delivery is not completed # related movements delivery is not completed
return False return False
return True return True
......
...@@ -40,11 +40,11 @@ import zope.interface ...@@ -40,11 +40,11 @@ import zope.interface
from zLOG import LOG from zLOG import LOG
class BusinessPath(Path, Predicate): class TradeModelPath(Path, Predicate):
""" """
The BusinessPath class embeds all information related to The TradeModelPath class embeds all information related to
lead times and parties involved at a given phase of a business lead times and parties involved at a given phase of a business
process. BusinessPath are also the most common way to trigger process. TradeModelPath are also the most common way to trigger
the build deliveries from buildable movements. the build deliveries from buildable movements.
The idea is to invoke isBuildable() on the collected simulation The idea is to invoke isBuildable() on the collected simulation
...@@ -53,8 +53,10 @@ class BusinessPath(Path, Predicate): ...@@ -53,8 +53,10 @@ class BusinessPath(Path, Predicate):
Here is the typical code of an alarm in charge of the building process:: Here is the typical code of an alarm in charge of the building process::
builder = portal_deliveries.a_delivery_builder builder = portal_deliveries.a_delivery_builder
for business_path in builder.getDeliveryBuilderRelatedValueList(): for trade_model_path in builder.getDeliveryBuilderRelatedValueList():
builder.build(causality_uid=business_path.getUid(),) # Select movements builder.build(causality_uid=trade_model_path.getUid(),) # Select movements
WRONG - too slow
Pros: global select is possible by not providing a causality_uid Pros: global select is possible by not providing a causality_uid
Cons: global select retrieves long lists of orphan movements which Cons: global select retrieves long lists of orphan movements which
...@@ -67,8 +69,8 @@ class BusinessPath(Path, Predicate): ...@@ -67,8 +69,8 @@ class BusinessPath(Path, Predicate):
- _getExplanationRelatedMovementValueList may be superfluous. Make - _getExplanationRelatedMovementValueList may be superfluous. Make
sure it is really needed sure it is really needed
""" """
meta_type = 'ERP5 Business Path' meta_type = 'ERP5 Trade Model Path'
portal_type = 'Business Path' portal_type = 'Trade Model Path'
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -86,7 +88,7 @@ class BusinessPath(Path, Predicate): ...@@ -86,7 +88,7 @@ class BusinessPath(Path, Predicate):
, PropertySheet.Amount , PropertySheet.Amount
, PropertySheet.Chain # XXX-JPS Why N , PropertySheet.Chain # XXX-JPS Why N
, PropertySheet.SortIndex , PropertySheet.SortIndex
, PropertySheet.BusinessPath , PropertySheet.TradeModelPath
, PropertySheet.FlowCapacity , PropertySheet.FlowCapacity
, PropertySheet.Reference , PropertySheet.Reference
, PropertySheet.PaymentCondition # XXX-JPS must be renames some day , PropertySheet.PaymentCondition # XXX-JPS must be renames some day
...@@ -95,18 +97,18 @@ class BusinessPath(Path, Predicate): ...@@ -95,18 +97,18 @@ class BusinessPath(Path, Predicate):
# Declarative interfaces # Declarative interfaces
zope.interface.implements(interfaces.ICategoryAccessProvider, zope.interface.implements(interfaces.ICategoryAccessProvider,
interfaces.IArrowBase, interfaces.IArrowBase,
interfaces.IBusinessPath, interfaces.ITradeModelPath,
interfaces.IPredicate, interfaces.IPredicate,
) )
# Helper Methods # Helper Methods
def _getExplanationRelatedSimulationMovementValueList(self, explanation): def _getExplanationRelatedSimulationMovementValueList(self, explanation):
explanation_cache = _getExplanationCache(explanation) explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathRelatedSimulationMovementValueList(self) return explanation_cache.getTradeModelPathRelatedSimulationMovementValueList(self)
def _getExplanationRelatedMovementValueList(self, explanation): def _getExplanationRelatedMovementValueList(self, explanation):
explanation_cache = _getExplanationCache(explanation) explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathRelatedMovementValueList(self) return explanation_cache.getTradeModelPathRelatedMovementValueList(self)
# IArrowBase implementation # IArrowBase implementation
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -176,7 +178,7 @@ class BusinessPath(Path, Predicate): ...@@ -176,7 +178,7 @@ class BusinessPath(Path, Predicate):
def _getCategoryMembershipList(self, category, **kw): def _getCategoryMembershipList(self, category, **kw):
""" """
Overridden in order to take into account dynamic arrow categories in case if no static Overridden in order to take into account dynamic arrow categories in case if no static
categories are set on Business Path categories are set on Trade Model Path
""" """
context = kw.pop('context') context = kw.pop('context')
result = Path._getCategoryMembershipList(self, category, **kw) result = Path._getCategoryMembershipList(self, category, **kw)
...@@ -191,7 +193,7 @@ class BusinessPath(Path, Predicate): ...@@ -191,7 +193,7 @@ class BusinessPath(Path, Predicate):
def _getAcquiredCategoryMembershipList(self, category, **kw): def _getAcquiredCategoryMembershipList(self, category, **kw):
""" """
Overridden in order to take into account dynamic arrow categories in case if no static Overridden in order to take into account dynamic arrow categories in case if no static
categories are set on Business Path categories are set on Trade Model Path
""" """
context = kw.pop('context', None) context = kw.pop('context', None)
result = Path._getAcquiredCategoryMembershipList(self, category, **kw) result = Path._getAcquiredCategoryMembershipList(self, category, **kw)
...@@ -238,46 +240,6 @@ class BusinessPath(Path, Predicate): ...@@ -238,46 +240,6 @@ class BusinessPath(Path, Predicate):
return method(context) return method(context)
return [] return []
# IBusinessPath implementation
security.declareProtected(Permissions.AccessContentsInformation,
'getMovementCompletionDate')
def getMovementCompletionDate(self, movement):
"""Returns the date of completion of the movemnet
based on paremeters of the business path. This complete date can be
the start date, the stop date, the date of a given workflow transition
on the explaining delivery, etc.
movement -- a Simulation Movement
"""
method_id = self.getCompletionDateMethodId()
method = getattr(movement, method_id) # We wish to raise if it does not exist
return method()
def getCompletionDate(self, explanation):
"""Returns the date of completion of business path in the
context of the explanation. The completion date of the Business
Path is the max date of all simulation movements which are
related to the Business Path and which are part of the explanation.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
date_list = []
# First, let us try to find simulation movements in simulation
# (hoping that it is already built)
for movement in self._getExplanationRelatedSimulationMovementValueList(explanation):
date_list.append(self.getMovementCompletionDate(movement))
# Next, try to find delivery lines or cells which may provide
# a good definition of completion date.
if not date_list:
for movement in self._getExplanationRelatedMovementValueList(explanation):
date_list.append(self.getMovementCompletionDate(movement))
return max(date_list)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getExpectedQuantity') 'getExpectedQuantity')
def getExpectedQuantity(self, amount): def getExpectedQuantity(self, amount):
...@@ -294,110 +256,3 @@ class BusinessPath(Path, Predicate): ...@@ -294,110 +256,3 @@ class BusinessPath(Path, Predicate):
return amount.getQuantity() * self.getEfficiency() return amount.getQuantity() * self.getEfficiency()
else: else:
return amount.getQuantity() return amount.getQuantity()
security.declareProtected(Permissions.AccessContentsInformation,
'isCompleted')
def isCompleted(self, explanation):
"""returns True if all related simulation movements for this explanation
document are in a simulation state which is considered as completed
according to the configuration of the current business path.
Completed means that it is possible to move to next step
of Business Process. This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
NOTE: simulation movements can be completed (ex. in 'started' state) but
not yet frozen (ex. in 'delivered' state).
"""
acceptable_state_list = self.getCompletedStateList()
for movement in self._getExplanationRelatedSimulationMovementValueList(
explanation):
if movement.getSimulationState() not in acceptable_state_list:
return False
return True
security.declareProtected(Permissions.AccessContentsInformation,
'isPartiallyCompleted')
def isPartiallyCompleted(self, explanation):
"""returns True if some related simulation movements for this explanation
document are in a simulation state which is considered as completed
according to the configuration of the current business path.
Completed means that it is possible to move to next step
of Business Process. This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
acceptable_state_list = self.getCompletedStateList()
for movement in self._getExplanationRelatedSimulationMovementValueList(
explanation):
if movement.getSimulationState() in acceptable_state_list:
return True
return False
security.declareProtected(Permissions.AccessContentsInformation, 'isFrozen')
def isFrozen(self, explanation):
"""returns True if all related simulation movements for this explanation
document are in a simulation state which is considered as frozen
according to the configuration of the current business path.
Frozen means that simulation movement cannot be modified.
This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
NOTE: simulation movements can be frozen (ex. in 'stopped' state) but
not yet completed (ex. in 'delivered' state).
"""
acceptable_state_list = self.getFrozenStateList()
movement_list = self._getExplanationRelatedSimulationMovementValueList(
explanation)
if not movement_list:
return False # Frozen is True only if some delivered movements exist
for movement in movement_list:
if movement.getDelivery() and movement.getSimulationState() not in acceptable_state_list: # XXX-JPS is it acceptable optimizatoin ?
return False
return True
def isDelivered(self, explanation):
"""Returns True is all simulation movements related to this
Business Path in the context of given explanation are built
and related to a delivery through the 'delivery' category.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
for simulation_movement in self._getExplanationRelatedSimulationMovementValueList(
explanation):
if not simulation_movement.getDelivery():
return False
return True
def build(self, explanation):
"""Builds all related movements in the simulation using the builders
defined on the Business Path.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
builder_list = self.getDeliveryBuilderValueList()
explanation_cache = _getExplanationCache(explanation)
for builder in builder_list:
# Call build on each builder
# Provide 2 parameters: self and and explanation_cache
builder.build(select_method_dict={
'business_path': self,
'explanation_cache': explanation_cache,
})
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
...@@ -186,7 +187,7 @@ portal_supply_type_list = ('Purchase Supply','Sale Supply') ...@@ -186,7 +187,7 @@ portal_supply_type_list = ('Purchase Supply','Sale Supply')
portal_supply_path_type_list = ('Supply Line','Supply Cell') portal_supply_path_type_list = ('Supply Line','Supply Cell')
portal_business_process_type_list = ('Business Process',) portal_business_process_type_list = ('Business Process',)
portal_business_path_type_list = ('Business Path',) portal_business_link_type_list = ('Business Link',)
# This transaction lines are special because destination must be None. # This transaction lines are special because destination must be None.
portal_balance_transaction_line_type_list = ('Balance Transaction Line',) portal_balance_transaction_line_type_list = ('Balance Transaction Line',)
......
...@@ -775,24 +775,6 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -775,24 +775,6 @@ class ERP5Site(FolderMixIn, CMFSite):
return self._getPortalGroupedTypeList('supply_path') or \ return self._getPortalGroupedTypeList('supply_path') or \
self._getPortalConfiguration('portal_supply_path_type_list') self._getPortalConfiguration('portal_supply_path_type_list')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalBusinessProcessTypeList')
def getPortalBusinessProcessTypeList(self):
"""
Return business process types.
"""
return self._getPortalGroupedTypeList('business_process') or \
self._getPortalConfiguration('portal_business_process_type_list')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalBusinessPathTypeList')
def getPortalBusinessPathTypeList(self):
"""
Return business path types.
"""
return self._getPortalGroupedTypeList('business_path') or \
self._getPortalConfiguration('portal_business_path_type_list')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalAcquisitionMovementTypeList') 'getPortalAcquisitionMovementTypeList')
def getPortalAcquisitionMovementTypeList(self): def getPortalAcquisitionMovementTypeList(self):
...@@ -1141,13 +1123,22 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1141,13 +1123,22 @@ class ERP5Site(FolderMixIn, CMFSite):
""" """
return self._getPortalGroupedTypeList('business_process') return self._getPortalGroupedTypeList('business_process')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalBusinessPathTypeList') 'getPortalBusinessLinkTypeList')
def getPortalBusinessPathTypeList(self): def getPortalBusinessLinkTypeList(self):
""" """
Return amount generator line types. Return business link types.
"""
return self._getPortalGroupedTypeList('business_link')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalTradeModelPathTypeList')
def getPortalTradeModelPathTypeList(self):
"""
Return trade model path types.
""" """
return self._getPortalGroupedTypeList('business_path') return self._getPortalGroupedTypeList('trade_model_path')
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getPortalCalendarPeriodTypeList') 'getPortalCalendarPeriodTypeList')
......
...@@ -148,18 +148,18 @@ class ExplanationCache: ...@@ -148,18 +148,18 @@ class ExplanationCache:
self.explanation_path_pattern_cache = result self.explanation_path_pattern_cache = result
return result return result
def getBusinessPathRelatedSimulationMovementValueList(self, business_path): def getBusinessLinkRelatedSimulationMovementValueList(self, business_link):
"""Returns the list of simulation movements caused by a business_path """Returns the list of simulation movements caused by a business_link
in the context the our explanation. in the context the our explanation.
""" """
return self.getSimulationMovementValueList(causality_uid=business_path.getUid()) return self.getSimulationMovementValueList(causality_uid=business_link.getUid())
def getBusinessPathRelatedMovementValueList(self, business_path): def getBusinessLinkRelatedMovementValueList(self, business_link):
"""Returns the list of delivery movements related to a business_path """Returns the list of delivery movements related to a business_link
in the context the our explanation. in the context the our explanation.
""" """
#XXXXXXXXXXX BAD #XXXXXXXXXXX BAD
return self.getSimulationMovementValueList(causality_uid=business_path.getUid()) return self.getSimulationMovementValueList(causality_uid=business_link.getUid())
def getSimulationMovementValueList(self, **kw): def getSimulationMovementValueList(self, **kw):
"""Search Simulation Movements related to our explanation. """Search Simulation Movements related to our explanation.
...@@ -182,42 +182,42 @@ class ExplanationCache: ...@@ -182,42 +182,42 @@ class ExplanationCache:
**kw) **kw)
return self.simulation_movement_cache[kw_tuple] return self.simulation_movement_cache[kw_tuple]
def getBusinessPathValueList(self, **kw): def getBusinessLinkValueList(self, **kw):
"""Find all business path which are related to the simulation """Find all business path which are related to the simulation
trees defined by the explanation. trees defined by the explanation.
""" """
business_type_list = self.getPortalBusinessPathTypeList() business_type_list = self.getPortalBusinessLinkTypeList()
simulation_movement_list = self.getSimulationMovementValueList() simulation_movement_list = self.getSimulationMovementValueList()
simulation_movement_uid_list = map(lambda x:x.uid, simulation_movement_list) simulation_movement_uid_list = map(lambda x:x.uid, simulation_movement_list)
# We could use related keys instead of 2 queries # We could use related keys instead of 2 queries
business_path_list = self.portal_catalog( business_link_list = self.portal_catalog(
portal_type=business_type_list, portal_type=business_type_list,
causality_related_uid=simulation_movement_uid_list, causality_related_uid=simulation_movement_uid_list,
**kw) **kw)
return business_path_list return business_link_list
def getBusinessPathClosure(self, business_process, business_path): def getBusinessLinkClosure(self, business_process, business_link):
"""Creates a Business Process by filtering out all Business Path """Creates a Business Process by filtering out all Business Link
in 'business_process' which are not related to a simulation movement in 'business_process' which are not related to a simulation movement
which is either a parent or a child of explanation simulations movements which is either a parent or a child of explanation simulations movements
caused by 'business_path' caused by 'business_link'
NOTE: Business Path Closure must be at least as "big" as composed NOTE: Business Link Closure must be at least as "big" as composed
business path. The appropriate calculation is still not clear. business path. The appropriate calculation is still not clear.
Options are: Options are:
- take all path of composed business path (even not yet expanded) - take all path of composed business path (even not yet expanded)
- take all path of composed business path which phase is not yet expanded - take all path of composed business path which phase is not yet expanded
""" """
# Try to return cached value first # Try to return cached value first
new_business_process = self.closure_cache.get(business_path, None) new_business_process = self.closure_cache.get(business_link, None)
if new_business_process is not None: if new_business_process is not None:
return new_business_process return new_business_process
# Build a list of path patterns which apply to current business_path # Build a list of path patterns which apply to current business_link
path_list = self.getSimulationPathPatternList() path_list = self.getSimulationPathPatternList()
path_list = map(lambda x:x[0:-1], path_list) # Remove trailing % path_list = map(lambda x:x[0:-1], path_list) # Remove trailing %
path_set = set() path_set = set()
for simulation_movement in business_path.\ for simulation_movement in business_link.\
_getExplanationRelatedSimulationMovementValueList(self.explanation): _getExplanationRelatedSimulationMovementValueList(self.explanation):
simulation_path = simulation_movement.getPath() simulation_path = simulation_movement.getPath()
for path in path_list: for path in path_list:
...@@ -228,30 +228,30 @@ class ExplanationCache: ...@@ -228,30 +228,30 @@ class ExplanationCache:
path_tuple = tuple(path_set) # XXX-JPS is the order guaranteed here ? path_tuple = tuple(path_set) # XXX-JPS is the order guaranteed here ?
new_business_process = self.closure_cache.get(path_tuple, None) new_business_process = self.closure_cache.get(path_tuple, None)
if new_business_process is not None: if new_business_process is not None:
self.closure_cache[business_path] = new_business_process self.closure_cache[business_link] = new_business_process
return new_business_process return new_business_process
# Build a new closure business process # Build a new closure business process
def hasMatchingMovement(business_path): def hasMatchingMovement(business_link):
return len(self.getSimulationMovementValueList(path=path_tuple, return len(self.getSimulationMovementValueList(path=path_tuple,
causality_uid=business_path.getUid())) causality_uid=business_link.getUid()))
module = business_process.getPortalObject().business_process_module # XXX-JPS module = business_process.getPortalObject().business_process_module # XXX-JPS
new_business_process = module.newContent(portal_type="Business Process", new_business_process = module.newContent(portal_type="Business Process",
temp_object=True) # XXX-JPS is this really OK with union business processes temp_object=True) # XXX-JPS is this really OK with union business processes
i = 0 i = 0
for business_path in business_process.getBusinessPathValueList(): for business_link in business_process.getBusinessLinkValueList():
if hasMatchingMovement(business_path): if hasMatchingMovement(business_link):
i += 1 i += 1
id = 'closure_path_%s' % i id = 'closure_path_%s' % i
new_business_process._setOb(id, business_path.asContext(id=id)) new_business_process._setOb(id, business_link.asContext(id=id))
self.closure_cache[business_path] = new_business_process self.closure_cache[business_link] = new_business_process
self.closure_cache[path_tuple] = new_business_process self.closure_cache[path_tuple] = new_business_process
return new_business_process return new_business_process
def getUnionBusinessProcess(self): def getUnionBusinessProcess(self):
"""Return a Business Process made of all Business Path """Return a Business Process made of all Business Link
which are the cause of Simulation Movements in the simulation which are the cause of Simulation Movements in the simulation
trees related to explanation. trees related to explanation.
""" """
...@@ -264,10 +264,10 @@ class ExplanationCache: ...@@ -264,10 +264,10 @@ class ExplanationCache:
from Products.ERP5Type.Document import newTempBusinessProcess from Products.ERP5Type.Document import newTempBusinessProcess
new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process') new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process')
i = 0 i = 0
for business_path in self.getBusinessPathValueList(): for business_link in self.getBusinessLinkValueList():
i += 1 i += 1
id = 'union_path_%s' % i id = 'union_path_%s' % i
new_business_process._setOb(id, business_path.asContext(id=id)) new_business_process._setOb(id, business_link.asContext(id=id))
# Keep it in cache and return # Keep it in cache and return
self.union_cache = new_business_process self.union_cache = new_business_process
...@@ -281,10 +281,10 @@ def _getExplanationCache(explanation): ...@@ -281,10 +281,10 @@ def _getExplanationCache(explanation):
tv['explanation_cache'] = ExplanationCache(explanation) tv['explanation_cache'] = ExplanationCache(explanation)
return tv.get('explanation_cache') return tv.get('explanation_cache')
def _getBusinessPathClosure(business_process, explanation, business_path): def _getBusinessLinkClosure(business_process, explanation, business_link):
"""Returns a closure Business Process for given """Returns a closure Business Process for given
business_path and explanation. This Business Process business_link and explanation. This Business Process
contains only those Business Path which are related to business_path contains only those Business Link which are related to business_link
in the context of explanation. in the context of explanation.
""" """
if explanation.getPortalType() == "Applied Rule": if explanation.getPortalType() == "Applied Rule":
...@@ -293,10 +293,10 @@ def _getBusinessPathClosure(business_process, explanation, business_path): ...@@ -293,10 +293,10 @@ def _getBusinessPathClosure(business_process, explanation, business_path):
# closure might be smaller than expexted # closure might be smaller than expexted
return business_process return business_process
explanation_cache = _getExplanationCache(explanation) explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathClosure(business_process, business_path) return explanation_cache.getBusinessLinkClosure(business_process, business_link)
def _getUnionBusinessProcess(explanation): def _getUnionBusinessProcess(explanation):
"""Build a Business Process by taking the union of Business Path """Build a Business Process by taking the union of Business Link
which are involved in the simulation trees related to explanation which are involved in the simulation trees related to explanation
""" """
explanation_cache = _getExplanationCache(explanation) explanation_cache = _getExplanationCache(explanation)
......
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
...@@ -47,11 +47,11 @@ class BuilderTool(BaseTool): ...@@ -47,11 +47,11 @@ class BuilderTool(BaseTool):
BuilderPortalType_selectDefaultMovement BuilderPortalType_selectDefaultMovement
business_process_list - optional Business Process list, if defined only business_process_list - optional Business Process list, if defined only
builders for Business Paths contained in those Business Process will builders for Business Links contained in those Business Process will
be run be run
trade_phase_list - optional list of trade phases, if defined only trade_phase_list - optional list of trade phases, if defined only
Business Paths for this trade phase will be used Business Links for this trade phase will be used
existing_delivery_list - list of deliveries to which builder will *try* existing_delivery_list - list of deliveries to which builder will *try*
add new/update existing movements and update delivery. It is not add new/update existing movements and update delivery. It is not
...@@ -80,9 +80,9 @@ class BuilderTool(BaseTool): ...@@ -80,9 +80,9 @@ class BuilderTool(BaseTool):
method_id = getattr(self,method_id_dict[self.getPortalType()]) method_id = getattr(self,method_id_dict[self.getPortalType()])
for business_process_url in business_process_list: for business_process_url in business_process_list:
business_process = self.unrestrictedTraverse(business_process_url) business_process = self.unrestrictedTraverse(business_process_url)
for business_path in business_process.getPathValueList( for business_link in business_process.getPathValueList(
trade_phase=trade_phase_list): trade_phase=trade_phase_list):
builder_value_list.extend(getattr(business_path,method_id)()) builder_value_list.extend(getattr(business_link,method_id)())
# FIXME: what kind of sorting to use? # FIXME: what kind of sorting to use?
return sorted(builder_value_list) return sorted(builder_value_list)
......
...@@ -230,8 +230,8 @@ class SolverTool(BaseTool): ...@@ -230,8 +230,8 @@ class SolverTool(BaseTool):
test_property = divergence_tester.getTestedProperty() test_property = divergence_tester.getTestedProperty()
application_value_level = {} application_value_level = {}
for simulation_movement in movement.getDeliveryRelatedValueList(): for simulation_movement in movement.getDeliveryRelatedValueList():
business_path = simulation_movement.getCausalityValue() business_link = simulation_movement.getCausalityValue()
for delivery_builder in business_path.getDeliveryBuilderValueList(): for delivery_builder in business_link.getDeliveryBuilderValueList():
for movement_group in delivery_builder.contentValues(): # filter missing for movement_group in delivery_builder.contentValues(): # filter missing
if test_property in movement_group.getTestedPropertyList(): if test_property in movement_group.getTestedPropertyList():
application_value_level[movement_group.getCollectGroupOrder()] = None application_value_level[movement_group.getCollectGroupOrder()] = None
...@@ -267,8 +267,8 @@ class SolverTool(BaseTool): ...@@ -267,8 +267,8 @@ class SolverTool(BaseTool):
test_property = divergence_tester.getTestedProperty() test_property = divergence_tester.getTestedProperty()
application_value_level = {} application_value_level = {}
for simulation_movement in movement.getDeliveryRelatedValueList(): for simulation_movement in movement.getDeliveryRelatedValueList():
business_path = simulation_movement.getCausalityValue() business_link = simulation_movement.getCausalityValue()
for delivery_builder in business_path.getDeliveryBuilderValueList(): for delivery_builder in business_link.getDeliveryBuilderValueList():
for property_group in delivery_builder.contentValues(portal_type="Property group"): for property_group in delivery_builder.contentValues(portal_type="Property group"):
if test_property in property_group.getTestedPropertyList(): if test_property in property_group.getTestedPropertyList():
application_value_level[property_group.getCollectGroupOrder()] = None application_value_level[property_group.getCollectGroupOrder()] = None
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# 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.
#
##############################################################################
"""
Products.ERP5.interfaces.business_path
"""
from zope.interface import Interface
class IBusinessPath(Interface):
"""Business Path interface specification
IBusinessPath provides a method to calculate the completion
date of existing movements based on business path properties.
It also provides methods to determine whether all related simulation
movements related to a given explanation are completed, partially
completed or frozen. Finally, it provides a method to invoke
delivery builders for all movements related to a given explanation.
"""
def getDeliveryBuilderValueList():
"""Return the list of delivery builders to invoke with
this Business Path.
NOTE: redundant with PropertySheet definition
"""
def getMovementCompletionDate(movement):
"""Returns the date of completion of the movemnet
based on paremeters of the business path. This completion date can be
the start date, the stop date, the date of a given workflow transition
on the explaining delivery, etc.
movement -- a Simulation Movement
"""
def getCompletionDate(explanation):
"""Returns the date of completion of business path in the
context of the explanation. The completion date of the Business
Path is the max date of all simulation movements which are
related to the Business Path and which are part of the explanation.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
def getExpectedQuantity(amount):
"""Returns the new quantity for the provided amount taking
into account the efficiency or the quantity defined on the business path.
This is used to implement payment conditions or splitting production
over multiple path. The total of getExpectedQuantity for all business
path which are applicable should never exceed the original quantity.
The implementation of this validation is left to rules.
"""
def isCompleted(explanation):
"""returns True if all related simulation movements for this explanation
document are in a simulation state which is considered as completed
according to the configuration of the current business path.
Completed means that it is possible to move to next step
of Business Process. This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
NOTE: simulation movements can be completed (ex. in 'started' state) but
not yet frozen (ex. in 'delivered' state).
"""
def isPartiallyCompleted(explanation):
"""returns True if some related simulation movements for this explanation
document are in a simulation state which is considered as completed
according to the configuration of the current business path.
Completed means that it is possible to move to next step
of Business Process. This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
def isFrozen(explanation):
"""returns True if all related simulation movements for this explanation
document are in a simulation state which is considered as frozen
according to the configuration of the current business path.
Frozen means that simulation movement cannot be modified.
This method does not check however whether previous
trade states of a given business process are completed or not.
Use instead IBusinessPathProcess.isBusinessPathCompleted for this purpose.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
NOTE: simulation movements can be frozen (ex. in 'stopped' state) but
not yet completed (ex. in 'delivered' state).
"""
def isDelivered(explanation):
"""Returns True is all simulation movements related to this
Business Path in the context of given explanation are built
and related to a delivery through the 'delivery' category.
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
def build(explanation):
"""Builds all related movements in the simulation using the builders
defined on the Business Path
explanation -- the Order, Order Line, Delivery or Delivery Line which
implicitely defines a simulation subtree and a union
business process.
"""
\ No newline at end of file
...@@ -32,11 +32,35 @@ Products.ERP5.interfaces.business_process ...@@ -32,11 +32,35 @@ Products.ERP5.interfaces.business_process
from zope.interface import Interface from zope.interface import Interface
class IBusinessPathProcess(Interface): class ITradeModelPathProcess(Interface):
"""Business Path Process interface specification """
"""
def getTradeModelPathValueList():
"""
"""
def getExpectedTradeModelPathStartAndStopDate(explanation, business_link,
delay_mode=None):
"""Returns the expected start and stop dates of given Business Link
document in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_link -- a Business Link document
delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay
"""
IBusinessPathProcess defines Business Process APIs related
to Business Path completion status and expected completion dates.
class IBusinessLinkProcess(Interface):
"""Business Link Process interface specification
IBusinessLinkProcess defines Business Process APIs related
to Business Link completion status and expected completion dates.
IMPORTANT: IMPORTANT:
- explanation implicitely defines a subtree of the simulation - explanation implicitely defines a subtree of the simulation
...@@ -52,17 +76,17 @@ class IBusinessPathProcess(Interface): ...@@ -52,17 +76,17 @@ class IBusinessPathProcess(Interface):
parameters to be copied (this used to be done through rule parameters to be copied (this used to be done through rule
parameter in provivate method) parameter in provivate method)
- Is there a reason why trade_phase should be a list in - Is there a reason why trade_phase should be a list in
getBusinessPathValueList ? (for rules ?) getBusinessLinkValueList ? (for rules ?)
""" """
def getBusinessPathValueList(trade_phase=None, context=None, def getBusinessLinkValueList(trade_phase=None, context=None,
predecessor=None, successor=None, **kw): predecessor=None, successor=None, **kw):
"""Returns the list of contained Business Path documents """Returns the list of contained Business Link documents
trade_phase -- filter by trade phase trade_phase -- filter by trade phase
context -- a context to test each Business Path on context -- a context to test each Business Link on
and filter out Business Path which do not match and filter out Business Link which do not match
predecessor -- filter by trade state predecessor predecessor -- filter by trade state predecessor
...@@ -71,108 +95,95 @@ class IBusinessPathProcess(Interface): ...@@ -71,108 +95,95 @@ class IBusinessPathProcess(Interface):
**kw -- same arguments as those passed to searchValues / contentValues **kw -- same arguments as those passed to searchValues / contentValues
""" """
def isBusinessPathCompleted(explanation, business_path): def isBusinessLinkCompleted(explanation, business_link):
"""Returns True if given Business Path document """Returns True if given Business Link document
is completed in the context of provided explanation. is completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
def isBusinessPathPartiallyCompleted(explanation, business_path): def isBusinessLinkPartiallyCompleted(explanation, business_link):
"""Returns True if given Business Path document """Returns True if given Business Link document
is partially completed in the context of provided explanation. is partially completed in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
def getExpectedBusinessPathCompletionDate(explanation, business_path, def getExpectedBusinessLinkCompletionDate(explanation, business_link,
delay_mode=None): delay_mode=None):
"""Returns the expected completion date of given Business Path document """Returns the expected completion date of given Business Link document
in the context of provided explanation. in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
delay_mode -- optional value to specify calculation mode ('min', 'max') delay_mode -- optional value to specify calculation mode ('min', 'max')
if no value specified use average delay if no value specified use average delay
""" """
def getExpectedBusinessPathStartAndStopDate(explanation, business_path,
delay_mode=None):
"""Returns the expected start and stop dates of given Business Path
document in the context of provided explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document class IBuildableBusinessLinkProcess(Interface):
"""Buildable Business Link Process interface specification
delay_mode -- optional value to specify calculation mode ('min', 'max') IBuildableBusinessLinkProcess defines an API to build
if no value specified use average delay
"""
class IBuildableBusinessPathProcess(Interface):
"""Buildable Business Path Process interface specification
IBuildableBusinessPathProcess defines an API to build
simulation movements related to business pathj in the context simulation movements related to business pathj in the context
of a given explanation. of a given explanation.
""" """
def getBuildableBusinessPathValueList(explanation): def getBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Path which are buildable """Returns the list of Business Link which are buildable
by taking into account trade state dependencies between by taking into account trade state dependencies between
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
def getPartiallyBuildableBusinessPathValueList(explanation): def getPartiallyBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Path which are partially buildable """Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between by taking into account trade state dependencies between
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
""" """
def isBusinessPathBuildable(explanation, business_path): def isBusinessLinkBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement """Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is completed. is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
def isBusinessPatPartiallyBuildable(explanation, business_path): def isBusinessPatPartiallyBuildable(explanation, business_link):
"""Returns True if any of the related Simulation Movement """Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is partially completed. is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document business_link -- a Business Link document
""" """
def isBuildable(explanation): def isBuildable(explanation):
"""Returns True is this business process has at least one """Returns True is this business process has at least one
Business Path which is buildable Business Link which is buildable
""" """
def isPartiallyBuildable(explanation): def isPartiallyBuildable(explanation):
"""Returns True is this business process has at least one """Returns True is this business process has at least one
Business Path which is partially buildable Business Link which is partially buildable
""" """
class ITradeStateProcess(Interface): class ITradeStateProcess(Interface):
...@@ -192,7 +203,7 @@ class ITradeStateProcess(Interface): ...@@ -192,7 +203,7 @@ class ITradeStateProcess(Interface):
def getTradeStateList(): def getTradeStateList():
"""Returns list of all trade_state of this Business Process """Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained by looking at successor and predecessor values of contained
Business Path. Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree Applied Rule which implicitely defines a simulation subtree
...@@ -200,14 +211,14 @@ class ITradeStateProcess(Interface): ...@@ -200,14 +211,14 @@ class ITradeStateProcess(Interface):
def isInitialTradeState(trade_state): def isInitialTradeState(trade_state):
"""Returns True if given 'trade_state' has no successor related """Returns True if given 'trade_state' has no successor related
Business Path. Business Link.
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
def isFinalTradeState(trade_state): def isFinalTradeState(trade_state):
"""Returns True if given 'trade_state' has no predecessor related """Returns True if given 'trade_state' has no predecessor related
Business Path. Business Link.
trade_state -- a Trade State category trade_state -- a Trade State category
""" """
...@@ -323,7 +334,7 @@ class ITradePhaseProcess(Interface): ...@@ -323,7 +334,7 @@ class ITradePhaseProcess(Interface):
def getTradePhaseList(): def getTradePhaseList():
"""Returns list of all trade_phase of this Business Process """Returns list of all trade_phase of this Business Process
by looking at trade_phase values of contained Business Path. by looking at trade_phase values of contained Business Link.
""" """
def getCompletedTradePhaseList(explanation): def getCompletedTradePhaseList(explanation):
...@@ -379,7 +390,7 @@ class ITradePhaseProcess(Interface): ...@@ -379,7 +390,7 @@ class ITradePhaseProcess(Interface):
if no value specified use average delay if no value specified use average delay
""" """
def getRemainingTradePhaseList(business_path, trade_phase_list=None): def getRemainingTradePhaseList(business_link, trade_phase_list=None):
"""Returns the list of remaining trade phases which to be achieved """Returns the list of remaining trade phases which to be achieved
as part of a business process. This list is calculated by analysing as part of a business process. This list is calculated by analysing
the graph of business path and trade states, starting from a given the graph of business path and trade states, starting from a given
...@@ -387,14 +398,14 @@ class ITradePhaseProcess(Interface): ...@@ -387,14 +398,14 @@ class ITradePhaseProcess(Interface):
method is useful mostly for production and MRP to manage a distributed method is useful mostly for production and MRP to manage a distributed
supply and production chain. supply and production chain.
business_path -- a Business Path document business_link -- a Business Link document
trade_phase_list -- if provided, the result is filtered by it after trade_phase_list -- if provided, the result is filtered by it after
being collected - ???? useful ? XXX-JPS ? being collected - ???? useful ? XXX-JPS ?
NOTE: explanation is not involved here because we consider here that NOTE: explanation is not involved here because we consider here that
self is the result of asUnionBusinessProcess and thus only contains self is the result of asUnionBusinessProcess and thus only contains
applicable Business Path to a given simulation subtree. Since the list applicable Business Link to a given simulation subtree. Since the list
of remaining trade phases does not depend on exact values in the of remaining trade phases does not depend on exact values in the
simulation, we did not include the explanation. However, this makes the simulation, we did not include the explanation. However, this makes the
API less uniform. API less uniform.
...@@ -402,7 +413,7 @@ class ITradePhaseProcess(Interface): ...@@ -402,7 +413,7 @@ class ITradePhaseProcess(Interface):
def getTradePhaseMovementList(explanation, amount, trade_phase=None, delay_mode=None): def getTradePhaseMovementList(explanation, amount, trade_phase=None, delay_mode=None):
"""Returns a list of movement with appropriate arrow and dates, """Returns a list of movement with appropriate arrow and dates,
based on the Business Path definitions, provided 'amount' and optional based on the Business Link definitions, provided 'amount' and optional
trade phases. If no trade_phase is provided, the trade_phase defined trade phases. If no trade_phase is provided, the trade_phase defined
on the Amount is used instead. on the Amount is used instead.
...@@ -417,7 +428,7 @@ class ITradePhaseProcess(Interface): ...@@ -417,7 +428,7 @@ class ITradePhaseProcess(Interface):
if no value specified use average delay if no value specified use average delay
""" """
class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess, class IBusinessProcess(ITradeModelPathProcess, IBusinessLinkProcess, IBuildableBusinessLinkProcess,
ITradeStateProcess, ITradePhaseProcess, ): ITradeStateProcess, ITradePhaseProcess, ):
"""Business Process interface specification. """Business Process interface specification.
...@@ -435,7 +446,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess, ...@@ -435,7 +446,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
""" """
def isBuildable(explanation): def isBuildable(explanation):
"""Returns True is one Business Path of this Business Process """Returns True is one Business Link of this Business Process
is buildable in the context of given explanation. is buildable in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
...@@ -443,7 +454,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess, ...@@ -443,7 +454,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
""" """
def isPartiallyBuildable(explanation): def isPartiallyBuildable(explanation):
"""Returns True is one Business Path of this Business Process """Returns True is one Business Link of this Business Process
is partially buildable in the context of given explanation. is partially buildable in the context of given explanation.
explanation -- an Order, Order Line, Delivery or Delivery Line or explanation -- an Order, Order Line, Delivery or Delivery Line or
...@@ -468,3 +479,5 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess, ...@@ -468,3 +479,5 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
buildable business path. Else buildable business path. Else
only build strictly buildable path. only build strictly buildable path.
""" """
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
""" """
Products.ERP5.interfaces.business_path Products.ERP5.interfaces.explainable
""" """
from zope.interface import Interface from zope.interface import Interface
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
############################################################################## ##############################################################################
# #
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Lukasz Nowak <luke@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# Yusuke Muraoka <yusuke@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
...@@ -27,55 +26,28 @@ ...@@ -27,55 +26,28 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
"""
Products.ERP5.interfaces.trade_model_path
"""
class BusinessPath: from zope.interface import Interface
"""
Business Path properties class ITradeModelPath(Interface):
"""Trade Model Path interface specification
ITradeModelPath provides a method to calculate the completion
date of existing movements based on business path properties.
It also provides methods to determine whether all related simulation
movements related to a given explanation are completed, partially
completed or frozen. Finally, it provides a method to invoke
delivery builders for all movements related to a given explanation.
""" """
_properties = (
{ 'id' : 'deliverable', # XXX-JPS: same is in Simulation property sheet
'description' : 'If 1 it is related to root of simulation tree (root explanation)',
'type' : 'boolean',
'mode' : 'w' },
{ 'id' : 'source_method_id',
'description' : 'ID of method to get source list of categories',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'destination_method_id',
'description' : 'ID of method to get destination list of categories',
'type' : 'string',
'mode' : 'w' },
{ 'id' : 'completion_date_method_id',
'description' : 'ID of method to get source list of categories',
'type' : 'string',
'default' : 'getStartDate',
'mode' : 'w' },
{ 'id' : 'completed_state',
'description' : 'List of states for which related Simulation '
'Movement is considered as completed',
'type' : 'lines',
'default' : [],
'multivalued' : 1,
'mode' : 'w' },
{ 'id' : 'frozen_state',
'description' : 'List of states for which related Simulation '
'Movement is considered as frozen',
'type' : 'lines',
'default' : [],
'multivalued' : 1,
'mode' : 'w' },
# Legacy
{ 'id' : 'lead_time', # XXX-JPS use FlowCapacity instead (min_delay)
'description' : 'How much time shall be spent on path',
'default' : 0.0,
'type' : 'float',
'mode' : 'w' },
{ 'id' : 'wait_time', # XXX-JPS: duplicate with PaymentCondition
'description' : 'How much time to wait before initiating path',
'default' : 0.0,
'type' : 'float',
'mode' : 'w' },
)
_categories = ('delivery_builder', 'order_builder', 'end_of', def getExpectedQuantity(amount):
'trade_phase' , 'incoterm') """Returns the new quantity for the provided amount taking
into account the efficiency or the quantity defined on the business path.
This is used to implement payment conditions or splitting production
over multiple path. The total of getExpectedQuantity for all business
path which are applicable should never exceed the original quantity.
The implementation of this validation is left to rules.
"""
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com> # Łukasz Nowak <luke@nexedi.com>
...@@ -45,7 +45,7 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -45,7 +45,7 @@ class TestBPMMixin(ERP5TypeTestCase):
'erp5_invoicing', 'erp5_simplified_invoicing') 'erp5_invoicing', 'erp5_simplified_invoicing')
business_process_portal_type = 'Business Process' business_process_portal_type = 'Business Process'
business_path_portal_type = 'Business Path' business_link_portal_type = 'Business Link'
normal_resource_use_category_list = ['normal'] normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax'] invoicing_resource_use_category_list = ['discount', 'tax']
...@@ -79,16 +79,16 @@ class TestBPMMixin(ERP5TypeTestCase): ...@@ -79,16 +79,16 @@ class TestBPMMixin(ERP5TypeTestCase):
**kw) **kw)
@reindex @reindex
def createBusinessPath(self, business_process=None, **kw): def createBusinessLink(self, business_process=None, **kw):
if business_process is None: if business_process is None:
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
kw['destination_method_id'] = kw.pop('destination_method_id', kw['destination_method_id'] = kw.pop('destination_method_id',
'BusinessPath_getDefaultDestinationList') 'BusinessLink_getDefaultDestinationList')
kw['source_method_id'] = kw.pop('source_method_id', kw['source_method_id'] = kw.pop('source_method_id',
'BusinessPath_getDefaultSourceList') 'BusinessLink_getDefaultSourceList')
business_path = business_process.newContent( business_link = business_process.newContent(
portal_type=self.business_path_portal_type, **kw) portal_type=self.business_link_portal_type, **kw)
return business_path return business_link
def createMovement(self): def createMovement(self):
# returns a movement for testing # returns a movement for testing
...@@ -218,105 +218,105 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -218,105 +218,105 @@ class TestBPMImplementation(TestBPMMixin):
def test_BusinessProcess_getPathValueList(self): def test_BusinessProcess_getPathValueList(self):
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
accounting_business_path = business_process.newContent( accounting_business_link = business_process.newContent(
portal_type=self.business_path_portal_type, portal_type=self.business_link_portal_type,
trade_phase='default/accounting') trade_phase='default/accounting')
delivery_business_path = business_process.newContent( delivery_business_link = business_process.newContent(
portal_type=self.business_path_portal_type, portal_type=self.business_link_portal_type,
trade_phase='default/delivery') trade_phase='default/delivery')
accounting_delivery_business_path = business_process.newContent( accounting_delivery_business_link = business_process.newContent(
portal_type=self.business_path_portal_type, portal_type=self.business_link_portal_type,
trade_phase=('default/accounting', 'default/delivery')) trade_phase=('default/accounting', 'default/delivery'))
self.stepTic() self.stepTic()
self.assertSameSet( self.assertSameSet(
(accounting_business_path, accounting_delivery_business_path), (accounting_business_link, accounting_delivery_business_link),
business_process.getPathValueList(trade_phase='default/accounting') business_process.getPathValueList(trade_phase='default/accounting')
) )
self.assertSameSet( self.assertSameSet(
(delivery_business_path, accounting_delivery_business_path), (delivery_business_link, accounting_delivery_business_link),
business_process.getPathValueList(trade_phase='default/delivery') business_process.getPathValueList(trade_phase='default/delivery')
) )
self.assertSameSet( self.assertSameSet(
(accounting_delivery_business_path, delivery_business_path, (accounting_delivery_business_link, delivery_business_link,
accounting_business_path), accounting_business_link),
business_process.getPathValueList(trade_phase=('default/delivery', business_process.getPathValueList(trade_phase=('default/delivery',
'default/accounting')) 'default/accounting'))
) )
def test_BusinessPathStandardCategoryAccessProvider(self): def test_BusinessLinkStandardCategoryAccessProvider(self):
source_node = self.portal.organisation_module.newContent( source_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
source_section_node = self.portal.organisation_module.newContent( source_section_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
business_path = self.createBusinessPath() business_link = self.createBusinessLink()
business_path.setSourceValue(source_node) business_link.setSourceValue(source_node)
business_path.setSourceSectionValue(source_section_node) business_link.setSourceSectionValue(source_section_node)
self.assertEquals([source_node], business_path.getSourceValueList()) self.assertEquals([source_node], business_link.getSourceValueList())
self.assertEquals([source_node.getRelativeUrl()], business_path.getSourceList()) self.assertEquals([source_node.getRelativeUrl()], business_link.getSourceList())
self.assertEquals(source_node.getRelativeUrl(), self.assertEquals(source_node.getRelativeUrl(),
business_path.getSource(default='something')) business_link.getSource(default='something'))
def test_EmptyBusinessPathStandardCategoryAccessProvider(self): def test_EmptyBusinessLinkStandardCategoryAccessProvider(self):
business_path = self.createBusinessPath() business_link = self.createBusinessLink()
self.assertEquals(None, business_path.getSourceValue()) self.assertEquals(None, business_link.getSourceValue())
self.assertEquals(None, business_path.getSource()) self.assertEquals(None, business_link.getSource())
self.assertEquals('something', self.assertEquals('something',
business_path.getSource(default='something')) business_link.getSource(default='something'))
def test_BuinessPathDynamicCategoryAccessProvider(self): def test_BuinessPathDynamicCategoryAccessProvider(self):
source_node = self.portal.organisation_module.newContent( source_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
source_section_node = self.portal.organisation_module.newContent( source_section_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
business_path = self.createBusinessPath() business_link = self.createBusinessLink()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList') business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
context_movement = self.createMovement() context_movement = self.createMovement()
context_movement.setSourceValue(source_node) context_movement.setSourceValue(source_node)
context_movement.setSourceSectionValue(source_section_node) context_movement.setSourceSectionValue(source_section_node)
self.assertEquals(None, business_path.getSourceValue()) self.assertEquals(None, business_link.getSourceValue())
self.assertEquals([source_node], self.assertEquals([source_node],
business_path.getSourceValueList(context=context_movement)) business_link.getSourceValueList(context=context_movement))
self.assertEquals([source_node.getRelativeUrl()], self.assertEquals([source_node.getRelativeUrl()],
business_path.getSourceList(context=context_movement)) business_link.getSourceList(context=context_movement))
self.assertEquals(source_node.getRelativeUrl(), self.assertEquals(source_node.getRelativeUrl(),
business_path.getSource(context=context_movement, default='something')) business_link.getSource(context=context_movement, default='something'))
def test_BuinessPathDynamicCategoryAccessProviderBusinessPathPrecedence(self): def test_BuinessPathDynamicCategoryAccessProviderBusinessLinkPrecedence(self):
movement_node = self.portal.organisation_module.newContent( movement_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
path_node = self.portal.organisation_module.newContent( path_node = self.portal.organisation_module.newContent(
portal_type='Organisation') portal_type='Organisation')
business_path = self.createBusinessPath() business_link = self.createBusinessLink()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList') business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
business_path.setSourceValue(path_node) business_link.setSourceValue(path_node)
context_movement = self.createMovement() context_movement = self.createMovement()
context_movement.setSourceValue(movement_node) context_movement.setSourceValue(movement_node)
self.assertEquals(path_node, business_path.getSourceValue()) self.assertEquals(path_node, business_link.getSourceValue())
self.assertEquals(path_node, self.assertEquals(path_node,
business_path.getSourceValue(context=context_movement)) business_link.getSourceValue(context=context_movement))
self.assertEquals([path_node], self.assertEquals([path_node],
business_path.getSourceValueList(context=context_movement)) business_link.getSourceValueList(context=context_movement))
def test_BuinessPathDynamicCategoryAccessProviderEmptyMovement(self): def test_BuinessPathDynamicCategoryAccessProviderEmptyMovement(self):
business_path = self.createBusinessPath() business_link = self.createBusinessLink()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList') business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
context_movement = self.createMovement() context_movement = self.createMovement()
self.assertEquals(None, business_path.getSourceValue()) self.assertEquals(None, business_link.getSourceValue())
self.assertEquals(None, self.assertEquals(None,
business_path.getSourceValue(context=context_movement)) business_link.getSourceValue(context=context_movement))
self.assertEquals(None, self.assertEquals(None,
business_path.getSource(context=context_movement)) business_link.getSource(context=context_movement))
self.assertEquals('something', self.assertEquals('something',
business_path.getSource(context=context_movement, default='something')) business_link.getSource(context=context_movement, default='something'))
def test_BusinessState_getRemainingTradePhaseList(self): def test_BusinessState_getRemainingTradePhaseList(self):
""" """
...@@ -344,41 +344,41 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -344,41 +344,41 @@ class TestBPMImplementation(TestBPMMixin):
# define business process # define business process
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path_a_b = self.createBusinessPath(business_process) business_link_a_b = self.createBusinessLink(business_process)
business_path_b_c = self.createBusinessPath(business_process) business_link_b_c = self.createBusinessLink(business_process)
business_path_b_d = self.createBusinessPath(business_process) business_link_b_d = self.createBusinessLink(business_process)
business_path_c_d = self.createBusinessPath(business_process) business_link_c_d = self.createBusinessLink(business_process)
business_path_d_e = self.createBusinessPath(business_process) business_link_d_e = self.createBusinessLink(business_process)
business_state_a = category_tool.trade_state.state_a business_state_a = category_tool.trade_state.state_a
business_state_b = category_tool.trade_state.state_b business_state_b = category_tool.trade_state.state_b
business_state_c = category_tool.trade_state.state_c business_state_c = category_tool.trade_state.state_c
business_state_d = category_tool.trade_state.state_d business_state_d = category_tool.trade_state.state_d
business_state_e = category_tool.trade_state.state_e business_state_e = category_tool.trade_state.state_e
business_path_a_b.setPredecessorValue(business_state_a) business_link_a_b.setPredecessorValue(business_state_a)
business_path_b_c.setPredecessorValue(business_state_b) business_link_b_c.setPredecessorValue(business_state_b)
business_path_b_d.setPredecessorValue(business_state_b) business_link_b_d.setPredecessorValue(business_state_b)
business_path_c_d.setPredecessorValue(business_state_c) business_link_c_d.setPredecessorValue(business_state_c)
business_path_d_e.setPredecessorValue(business_state_d) business_link_d_e.setPredecessorValue(business_state_d)
business_path_a_b.setSuccessorValue(business_state_b) business_link_a_b.setSuccessorValue(business_state_b)
business_path_b_c.setSuccessorValue(business_state_c) business_link_b_c.setSuccessorValue(business_state_c)
business_path_b_d.setSuccessorValue(business_state_d) business_link_b_d.setSuccessorValue(business_state_d)
business_path_c_d.setSuccessorValue(business_state_d) business_link_c_d.setSuccessorValue(business_state_d)
business_path_d_e.setSuccessorValue(business_state_e) business_link_d_e.setSuccessorValue(business_state_e)
# set title for debug # set title for debug
business_path_a_b.edit(title="a_b") business_link_a_b.edit(title="a_b")
business_path_b_c.edit(title="b_c") business_link_b_c.edit(title="b_c")
business_path_b_d.edit(title="b_d") business_link_b_d.edit(title="b_d")
business_path_c_d.edit(title="c_d") business_link_c_d.edit(title="c_d")
business_path_d_e.edit(title="d_e") business_link_d_e.edit(title="d_e")
# set trade_phase # set trade_phase
business_path_a_b.edit(trade_phase=['default/discount'], business_link_a_b.edit(trade_phase=['default/discount'],
completed_state=['ordered']) # (*1) completed_state=['ordered']) # (*1)
business_path_b_c.edit(trade_phase=['default/delivery']) business_link_b_c.edit(trade_phase=['default/delivery'])
business_path_b_d.edit(trade_phase=['default/invoicing']) business_link_b_d.edit(trade_phase=['default/invoicing'])
business_path_c_d.edit(trade_phase=['default/payment']) business_link_c_d.edit(trade_phase=['default/payment'])
business_path_d_e.edit(trade_phase=['default/accounting']) business_link_d_e.edit(trade_phase=['default/accounting'])
# mock order # mock order
order = self.portal.sale_order_module.newContent(portal_type="Sale Order") order = self.portal.sale_order_module.newContent(portal_type="Sale Order")
...@@ -391,20 +391,20 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -391,20 +391,20 @@ class TestBPMImplementation(TestBPMMixin):
applied_rule = order.getCausalityRelatedValue() applied_rule = order.getCausalityRelatedValue()
sm = applied_rule.contentValues(portal_type="Simulation Movement")[0] sm = applied_rule.contentValues(portal_type="Simulation Movement")[0]
sm.edit(causality_value=business_path_a_b) sm.edit(causality_value=business_link_a_b)
# make other movements for each business path # make other movements for each business path
applied_rule.newContent(portal_type="Simulation Movement", applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_b_c, causality_value=business_link_b_c,
order_value=order_line) order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement", applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_b_d, causality_value=business_link_b_d,
order_value=order_line) order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement", applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_c_d, causality_value=business_link_c_d,
order_value=order_line) order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement", applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_d_e, causality_value=business_link_d_e,
order_value=order_line) order_value=order_line)
self.stepTic() self.stepTic()
...@@ -412,7 +412,7 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -412,7 +412,7 @@ class TestBPMImplementation(TestBPMMixin):
trade_phase = self.portal.portal_categories.trade_phase.default trade_phase = self.portal.portal_categories.trade_phase.default
# assertion which getRemainingTradePhaseList must return category which will be passed # assertion which getRemainingTradePhaseList must return category which will be passed
# discount is passed, business_path_a_b is already completed, because simulation state is "ordered" # discount is passed, business_link_a_b is already completed, because simulation state is "ordered"
self.assertEquals(set([trade_phase.delivery, self.assertEquals(set([trade_phase.delivery,
trade_phase.invoicing, trade_phase.invoicing,
trade_phase.payment, trade_phase.payment,
...@@ -441,7 +441,7 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -441,7 +441,7 @@ class TestBPMImplementation(TestBPMMixin):
trade_phase_list=['default/delivery', trade_phase_list=['default/delivery',
'default/accounting']))) 'default/accounting'])))
def test_BusinessPath_calculateExpectedDate(self): def test_BusinessLink_calculateExpectedDate(self):
""" """
This test case is described for what start/stop date is expected on This test case is described for what start/stop date is expected on
each path by explanation. each path by explanation.
...@@ -469,36 +469,36 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -469,36 +469,36 @@ class TestBPMImplementation(TestBPMMixin):
# define business process # define business process
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path_a_b = self.createBusinessPath(business_process) business_link_a_b = self.createBusinessLink(business_process)
business_path_b_c = self.createBusinessPath(business_process) business_link_b_c = self.createBusinessLink(business_process)
business_path_b_d = self.createBusinessPath(business_process) business_link_b_d = self.createBusinessLink(business_process)
business_path_c_d = self.createBusinessPath(business_process) business_link_c_d = self.createBusinessLink(business_process)
business_path_d_e = self.createBusinessPath(business_process) business_link_d_e = self.createBusinessLink(business_process)
business_state_a = category_tool.trade_state.state_a business_state_a = category_tool.trade_state.state_a
business_state_b = category_tool.trade_state.state_b business_state_b = category_tool.trade_state.state_b
business_state_c = category_tool.trade_state.state_c business_state_c = category_tool.trade_state.state_c
business_state_d = category_tool.trade_state.state_d business_state_d = category_tool.trade_state.state_d
business_state_e = category_tool.trade_state.state_e business_state_e = category_tool.trade_state.state_e
business_path_a_b.setPredecessorValue(business_state_a) business_link_a_b.setPredecessorValue(business_state_a)
business_path_b_c.setPredecessorValue(business_state_b) business_link_b_c.setPredecessorValue(business_state_b)
business_path_b_d.setPredecessorValue(business_state_b) business_link_b_d.setPredecessorValue(business_state_b)
business_path_c_d.setPredecessorValue(business_state_c) business_link_c_d.setPredecessorValue(business_state_c)
business_path_d_e.setPredecessorValue(business_state_d) business_link_d_e.setPredecessorValue(business_state_d)
business_path_a_b.setSuccessorValue(business_state_b) business_link_a_b.setSuccessorValue(business_state_b)
business_path_b_c.setSuccessorValue(business_state_c) business_link_b_c.setSuccessorValue(business_state_c)
business_path_b_d.setSuccessorValue(business_state_d) business_link_b_d.setSuccessorValue(business_state_d)
business_path_c_d.setSuccessorValue(business_state_d) business_link_c_d.setSuccessorValue(business_state_d)
business_path_d_e.setSuccessorValue(business_state_e) business_link_d_e.setSuccessorValue(business_state_e)
business_process.edit(referential_date='stop_date') business_process.edit(referential_date='stop_date')
business_path_a_b.edit(title='a_b', lead_time=2, wait_time=1) business_link_a_b.edit(title='a_b', lead_time=2, wait_time=1)
business_path_b_c.edit(title='b_c', lead_time=2, wait_time=1) business_link_b_c.edit(title='b_c', lead_time=2, wait_time=1)
business_path_b_d.edit(title='b_d', lead_time=3, wait_time=1) business_link_b_d.edit(title='b_d', lead_time=3, wait_time=1)
business_path_c_d.edit(title='c_d', lead_time=3, wait_time=0) business_link_c_d.edit(title='c_d', lead_time=3, wait_time=0)
business_path_d_e.edit(title='d_e', lead_time=4, wait_time=2) business_link_d_e.edit(title='d_e', lead_time=4, wait_time=2)
# root explanation # root explanation
business_path_b_d.edit(deliverable=True) business_link_b_d.edit(deliverable=True)
self.stepTic() self.stepTic()
""" """
...@@ -516,18 +516,18 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -516,18 +516,18 @@ class TestBPMImplementation(TestBPMMixin):
mock = Mock(base_date) mock = Mock(base_date)
# root explanation. # root explanation.
self.assertEquals(business_path_b_d.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9')) self.assertEquals(business_link_b_d.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_path_b_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9')) self.assertEquals(business_link_b_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9'))
# assertion for each path without root explanation. # assertion for each path without root explanation.
self.assertEquals(business_path_a_b.getExpectedStartDate(mock), DateTime('2009/03/27 GMT+9')) self.assertEquals(business_link_a_b.getExpectedStartDate(mock), DateTime('2009/03/27 GMT+9'))
self.assertEquals(business_path_a_b.getExpectedStopDate(mock), DateTime('2009/03/29 GMT+9')) self.assertEquals(business_link_a_b.getExpectedStopDate(mock), DateTime('2009/03/29 GMT+9'))
self.assertEquals(business_path_b_c.getExpectedStartDate(mock), DateTime('2009/03/30 GMT+9')) self.assertEquals(business_link_b_c.getExpectedStartDate(mock), DateTime('2009/03/30 GMT+9'))
self.assertEquals(business_path_b_c.getExpectedStopDate(mock), DateTime('2009/04/01 GMT+9')) self.assertEquals(business_link_b_c.getExpectedStopDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_path_c_d.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9')) self.assertEquals(business_link_c_d.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_path_c_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9')) self.assertEquals(business_link_c_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9'))
self.assertEquals(business_path_d_e.getExpectedStartDate(mock), DateTime('2009/04/06 GMT+9')) self.assertEquals(business_link_d_e.getExpectedStartDate(mock), DateTime('2009/04/06 GMT+9'))
self.assertEquals(business_path_d_e.getExpectedStopDate(mock), DateTime('2009/04/10 GMT+9')) self.assertEquals(business_link_d_e.getExpectedStopDate(mock), DateTime('2009/04/10 GMT+9'))
""" """
Test of illegal case, lead time of reality and simulation are inconsistent, Test of illegal case, lead time of reality and simulation are inconsistent,
...@@ -536,11 +536,11 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -536,11 +536,11 @@ class TestBPMImplementation(TestBPMMixin):
How we know which is referential, currently implementation of it can be known by How we know which is referential, currently implementation of it can be known by
BusinessProcess.isStartDateReferential and BusinessProcess.isStopDateReferential. BusinessProcess.isStartDateReferential and BusinessProcess.isStopDateReferential.
In this test case, stop_date on business_path_b_d is referential, because business_path_b_d is In this test case, stop_date on business_link_b_d is referential, because business_link_b_d is
root explanation and business_process refer to stop_date as referential. root explanation and business_process refer to stop_date as referential.
calculation example(when referential date is 2009/04/06 GMT+9): calculation example(when referential date is 2009/04/06 GMT+9):
start_date of business_path_b_d = referential_date - 3(lead_time of business_path_b_d) start_date of business_link_b_d = referential_date - 3(lead_time of business_link_b_d)
= 2009/04/06 GMT+9 - 3 = 2009/04/06 GMT+9 - 3
= 2009/04/03 GMT+9 = 2009/04/03 GMT+9
""" """
...@@ -555,19 +555,19 @@ class TestBPMImplementation(TestBPMMixin): ...@@ -555,19 +555,19 @@ class TestBPMImplementation(TestBPMMixin):
base_date = DateTime('2009/04/01 GMT+9') base_date = DateTime('2009/04/01 GMT+9')
mock = Mock(base_date) mock = Mock(base_date)
self.assertEquals(business_path_b_d.getExpectedStartDate(mock), DateTime('2009/04/03 GMT+9')) self.assertEquals(business_link_b_d.getExpectedStartDate(mock), DateTime('2009/04/03 GMT+9'))
# This is base in this context, because referential_date is 'stop_date' # This is base in this context, because referential_date is 'stop_date'
self.assertEquals(business_path_b_d.getExpectedStopDate(mock), DateTime('2009/04/06 GMT+9')) self.assertEquals(business_link_b_d.getExpectedStopDate(mock), DateTime('2009/04/06 GMT+9'))
# assertion for each path without root explanation. # assertion for each path without root explanation.
self.assertEquals(business_path_a_b.getExpectedStartDate(mock), DateTime('2009/03/29 GMT+9')) self.assertEquals(business_link_a_b.getExpectedStartDate(mock), DateTime('2009/03/29 GMT+9'))
self.assertEquals(business_path_a_b.getExpectedStopDate(mock), DateTime('2009/03/31 GMT+9')) self.assertEquals(business_link_a_b.getExpectedStopDate(mock), DateTime('2009/03/31 GMT+9'))
self.assertEquals(business_path_b_c.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9')) self.assertEquals(business_link_b_c.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_path_b_c.getExpectedStopDate(mock), DateTime('2009/04/03 GMT+9')) self.assertEquals(business_link_b_c.getExpectedStopDate(mock), DateTime('2009/04/03 GMT+9'))
self.assertEquals(business_path_c_d.getExpectedStartDate(mock), DateTime('2009/04/03 GMT+9')) self.assertEquals(business_link_c_d.getExpectedStartDate(mock), DateTime('2009/04/03 GMT+9'))
self.assertEquals(business_path_c_d.getExpectedStopDate(mock), DateTime('2009/04/06 GMT+9')) self.assertEquals(business_link_c_d.getExpectedStopDate(mock), DateTime('2009/04/06 GMT+9'))
self.assertEquals(business_path_d_e.getExpectedStartDate(mock), DateTime('2009/04/08 GMT+9')) self.assertEquals(business_link_d_e.getExpectedStartDate(mock), DateTime('2009/04/08 GMT+9'))
self.assertEquals(business_path_d_e.getExpectedStopDate(mock), DateTime('2009/04/12 GMT+9')) self.assertEquals(business_link_d_e.getExpectedStopDate(mock), DateTime('2009/04/12 GMT+9'))
class TestBPMDummyDeliveryMovementMixin(TestBPMMixin): class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
def _createDelivery(self, **kw): def _createDelivery(self, **kw):
...@@ -609,19 +609,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin): ...@@ -609,19 +609,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
# path which is completed, as soon as related simulation movements are in # path which is completed, as soon as related simulation movements are in
# proper state # proper state
self.order_path = self.createBusinessPath(business_process, self.order_path = self.createBusinessLink(business_process,
successor_value = ordered, successor_value = ordered,
trade_phase='default/order', trade_phase='default/order',
completed_state_list = self.completed_state_list, completed_state_list = self.completed_state_list,
frozen_state_list = self.frozen_state_list) frozen_state_list = self.frozen_state_list)
self.delivery_path = self.createBusinessPath(business_process, self.delivery_path = self.createBusinessLink(business_process,
predecessor_value = ordered, successor_value = delivered, predecessor_value = ordered, successor_value = delivered,
trade_phase='default/delivery', trade_phase='default/delivery',
completed_state_list = self.completed_state_list, completed_state_list = self.completed_state_list,
frozen_state_list = self.frozen_state_list) frozen_state_list = self.frozen_state_list)
self.invoice_path = self.createBusinessPath(business_process, self.invoice_path = self.createBusinessLink(business_process,
predecessor_value = delivered, successor_value = invoiced, predecessor_value = delivered, successor_value = invoiced,
trade_phase='default/invoicing') trade_phase='default/invoicing')
self.stepTic() self.stepTic()
...@@ -633,19 +633,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin): ...@@ -633,19 +633,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
delivered = category_tool.trade_state.delivered delivered = category_tool.trade_state.delivered
invoiced = category_tool.trade_state.invoiced invoiced = category_tool.trade_state.invoiced
self.order_path = self.createBusinessPath(business_process, self.order_path = self.createBusinessLink(business_process,
successor_value = ordered, successor_value = ordered,
trade_phase='default/order', trade_phase='default/order',
completed_state_list = self.completed_state_list, completed_state_list = self.completed_state_list,
frozen_state_list = self.frozen_state_list) frozen_state_list = self.frozen_state_list)
self.invoice_path = self.createBusinessPath(business_process, self.invoice_path = self.createBusinessLink(business_process,
predecessor_value = ordered, successor_value = invoiced, predecessor_value = ordered, successor_value = invoiced,
trade_phase='default/invoicing', trade_phase='default/invoicing',
completed_state_list = self.completed_state_list, completed_state_list = self.completed_state_list,
frozen_state_list = self.frozen_state_list) frozen_state_list = self.frozen_state_list)
self.delivery_path = self.createBusinessPath(business_process, self.delivery_path = self.createBusinessLink(business_process,
predecessor_value = invoiced, successor_value = delivered, predecessor_value = invoiced, successor_value = delivered,
trade_phase='default/delivery') trade_phase='default/delivery')
self.stepTic() self.stepTic()
...@@ -769,7 +769,7 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -769,7 +769,7 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
self.assertEquals(invoicing_simulation_movement.isBuildable(), True) self.assertEquals(invoicing_simulation_movement.isBuildable(), True)
self.assertEquals(self.invoice_path.isBuildable(delivery), True) self.assertEquals(self.invoice_path.isBuildable(delivery), True)
# XXX look at comments in BusinessPath.isBuildable # XXX look at comments in BusinessLink.isBuildable
self.assertEquals(self.invoice_path.isBuildable(order), True) self.assertEquals(self.invoice_path.isBuildable(order), True)
self.assertEquals(self.delivery_path.isBuildable(delivery), False) self.assertEquals(self.delivery_path.isBuildable(delivery), False)
......
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com> # Łukasz Nowak <luke@nexedi.com>
...@@ -505,7 +505,7 @@ class TestBPMEvaluationDefaultProcessMixin: ...@@ -505,7 +505,7 @@ class TestBPMEvaluationDefaultProcessMixin:
referential_date='start_date') referential_date='start_date')
self._setTradeStateList() self._setTradeStateList()
self.order_path = self.createBusinessPath(self.business_process, self.order_path = self.createBusinessLink(self.business_process,
successor_value=self.ordered_state, successor_value=self.ordered_state,
trade_phase='default/order', trade_phase='default/order',
deliverable=1, deliverable=1,
...@@ -513,7 +513,7 @@ class TestBPMEvaluationDefaultProcessMixin: ...@@ -513,7 +513,7 @@ class TestBPMEvaluationDefaultProcessMixin:
frozen_state_list=['confirmed'], frozen_state_list=['confirmed'],
) )
self.delivery_path = self.createBusinessPath(self.business_process, self.delivery_path = self.createBusinessLink(self.business_process,
predecessor_value=self.ordered_state, predecessor_value=self.ordered_state,
successor_value=self.delivered_state, successor_value=self.delivered_state,
trade_phase='default/delivery', trade_phase='default/delivery',
...@@ -523,7 +523,7 @@ class TestBPMEvaluationDefaultProcessMixin: ...@@ -523,7 +523,7 @@ class TestBPMEvaluationDefaultProcessMixin:
delivery_builder='portal_deliveries/bpm_sale_packing_list_builder', delivery_builder='portal_deliveries/bpm_sale_packing_list_builder',
) )
self.invoice_path = self.createBusinessPath(self.business_process, self.invoice_path = self.createBusinessLink(self.business_process,
predecessor_value=self.delivered_state, predecessor_value=self.delivered_state,
successor_value=self.invoiced_state, successor_value=self.invoiced_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
...@@ -531,14 +531,14 @@ class TestBPMEvaluationDefaultProcessMixin: ...@@ -531,14 +531,14 @@ class TestBPMEvaluationDefaultProcessMixin:
delivery_builder='portal_deliveries/bpm_sale_invoice_builder', delivery_builder='portal_deliveries/bpm_sale_invoice_builder',
trade_phase='default/invoicing') trade_phase='default/invoicing')
self.account_path = self.createBusinessPath(self.business_process, self.account_path = self.createBusinessLink(self.business_process,
predecessor_value=self.invoiced_state, predecessor_value=self.invoiced_state,
successor_value=self.accounted_state, successor_value=self.accounted_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'], frozen_state_list=['stopped', 'delivered'],
trade_phase='default/accounting') trade_phase='default/accounting')
self.pay_path = self.createBusinessPath(self.business_process, self.pay_path = self.createBusinessLink(self.business_process,
predecessor_value=self.invoiced_state, predecessor_value=self.invoiced_state,
successor_value=self.accounted_state, successor_value=self.accounted_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
...@@ -553,7 +553,7 @@ class TestBPMEvaluationDifferentProcessMixin: ...@@ -553,7 +553,7 @@ class TestBPMEvaluationDifferentProcessMixin:
referential_date='start_date') referential_date='start_date')
self._setTradeStateList() self._setTradeStateList()
self.order_path = self.createBusinessPath(self.business_process, self.order_path = self.createBusinessLink(self.business_process,
successor_value=self.ordered_state, successor_value=self.ordered_state,
trade_phase='default/order', trade_phase='default/order',
deliverable=1, deliverable=1,
...@@ -561,28 +561,28 @@ class TestBPMEvaluationDifferentProcessMixin: ...@@ -561,28 +561,28 @@ class TestBPMEvaluationDifferentProcessMixin:
frozen_state_list=['confirmed'], frozen_state_list=['confirmed'],
) )
self.invoice_path = self.createBusinessPath(self.business_process, self.invoice_path = self.createBusinessLink(self.business_process,
predecessor_value=self.ordered_state, predecessor_value=self.ordered_state,
successor_value=self.invoiced_state, successor_value=self.invoiced_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'], frozen_state_list=['stopped', 'delivered'],
trade_phase='default/invoicing') trade_phase='default/invoicing')
self.account_path = self.createBusinessPath(self.business_process, self.account_path = self.createBusinessLink(self.business_process,
predecessor_value=self.invoiced_state, predecessor_value=self.invoiced_state,
successor_value=self.accounted_state, successor_value=self.accounted_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'], frozen_state_list=['stopped', 'delivered'],
trade_phase='default/accounting') trade_phase='default/accounting')
self.pay_path = self.createBusinessPath(self.business_process, self.pay_path = self.createBusinessLink(self.business_process,
predecessor_value=self.accounted_state, predecessor_value=self.accounted_state,
successor_value=self.paid_state, successor_value=self.paid_state,
completed_state_list=['delivered'], completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'], frozen_state_list=['stopped', 'delivered'],
trade_phase='default/payment') trade_phase='default/payment')
self.delivery_path = self.createBusinessPath(self.business_process, self.delivery_path = self.createBusinessLink(self.business_process,
predecessor_value=self.paid_state, predecessor_value=self.paid_state,
successor_value=self.delivered_state, successor_value=self.delivered_state,
trade_phase='default/delivery', trade_phase='default/delivery',
......
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com> # Łukasz Nowak <luke@nexedi.com>
...@@ -35,9 +35,9 @@ import unittest ...@@ -35,9 +35,9 @@ import unittest
# manually and treated as reference to what implements what # manually and treated as reference to what implements what
implements_tuple_list = [ implements_tuple_list = [
(('Products.ERP5Type.Document.RoleDefinition', 'RoleDefinition'), 'ILocalRoleGenerator'), (('Products.ERP5Type.Document.RoleDefinition', 'RoleDefinition'), 'ILocalRoleGenerator'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'IArrowBase'), (('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'IArrowBase'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'IBusinessPath'), (('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'IBusinessLink'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'ICategoryAccessProvider'), (('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'ICategoryAccessProvider'),
(('Products.ERP5Type.Document.TradeCondition','TradeCondition'), 'IAmountGenerator'), (('Products.ERP5Type.Document.TradeCondition','TradeCondition'), 'IAmountGenerator'),
(('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IAmountGenerator'), (('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IAmountGenerator'),
(('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IVariated'), (('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IVariated'),
...@@ -84,8 +84,8 @@ addTestMethodDynamically(TestERP5Interfaces, implements_tuple_list) ...@@ -84,8 +84,8 @@ addTestMethodDynamically(TestERP5Interfaces, implements_tuple_list)
for failing_method in [ for failing_method in [
'test_Products.ERP5.AggregatedAmountList_AggregatedAmountList_implements_IAmountList', 'test_Products.ERP5.AggregatedAmountList_AggregatedAmountList_implements_IAmountList',
'test_Products.ERP5Type.Document.BusinessPath_BusinessPath_implements_IBusinessPath', 'test_Products.ERP5Type.Document.BusinessLink_BusinessLink_implements_IBusinessLink',
'test_Products.ERP5Type.Document.BusinessPath_BusinessPath_implements_ICategoryAccessProvider', 'test_Products.ERP5Type.Document.BusinessLink_BusinessLink_implements_ICategoryAccessProvider',
'test_Products.ERP5Type.Document.TradeCondition_TradeCondition_implements_IAmountGenerator', 'test_Products.ERP5Type.Document.TradeCondition_TradeCondition_implements_IAmountGenerator',
'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IAmountGenerator', 'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IAmountGenerator',
'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IVariated', 'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IVariated',
......
...@@ -57,9 +57,9 @@ class TestERP5SimulationMixin(TestInvoiceMixin): ...@@ -57,9 +57,9 @@ class TestERP5SimulationMixin(TestInvoiceMixin):
def setUpBusinessProcess(self): def setUpBusinessProcess(self):
business_process = self.portal.business_process_module.erp5_default_business_process business_process = self.portal.business_process_module.erp5_default_business_process
pay_business_path = business_process['pay'] pay_business_link = business_process['pay']
pay_business_path.setSource('account_module/bank') pay_business_link.setSource('account_module/bank')
pay_business_path.setDestination('account_module/bank') pay_business_link.setDestination('account_module/bank')
@UnrestrictedMethod @UnrestrictedMethod
def createInvoiceTransactionRule(self, resource=None): def createInvoiceTransactionRule(self, resource=None):
......
...@@ -158,8 +158,8 @@ class TestMRPMixin(TestBPMMixin): ...@@ -158,8 +158,8 @@ class TestMRPMixin(TestBPMMixin):
ready -------- partial_produced ------- done ready -------- partial_produced ------- done
""" """
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path_p2 = self.createBusinessPath(business_process) business_link_p2 = self.createBusinessLink(business_process)
business_path_p3 = self.createBusinessPath(business_process) business_link_p3 = self.createBusinessLink(business_process)
business_state_ready = self.createBusinessState(business_process) business_state_ready = self.createBusinessState(business_process)
business_state_partial = self.createBusinessState(business_process) business_state_partial = self.createBusinessState(business_process)
business_state_done = self.createBusinessState(business_process) business_state_done = self.createBusinessState(business_process)
...@@ -171,7 +171,7 @@ class TestMRPMixin(TestBPMMixin): ...@@ -171,7 +171,7 @@ class TestMRPMixin(TestBPMMixin):
destination = self.createOrganisation(title='destination') destination = self.createOrganisation(title='destination')
business_process.edit(referential_date='stop_date') business_process.edit(referential_date='stop_date')
business_path_p2.edit(id='p2', business_link_p2.edit(id='p2',
predecessor_value=business_state_ready, predecessor_value=business_state_ready,
successor_value=business_state_partial, successor_value=business_state_partial,
quantity=1, quantity=1,
...@@ -181,7 +181,7 @@ class TestMRPMixin(TestBPMMixin): ...@@ -181,7 +181,7 @@ class TestMRPMixin(TestBPMMixin):
destination_section_value=destination_section, destination_section_value=destination_section,
destination_value=destination, destination_value=destination,
) )
business_path_p3.edit(id='p3', business_link_p3.edit(id='p3',
predecessor_value=business_state_partial, predecessor_value=business_state_partial,
successor_value=business_state_done, successor_value=business_state_done,
quantity=1, quantity=1,
...@@ -201,8 +201,8 @@ class TestMRPMixin(TestBPMMixin): ...@@ -201,8 +201,8 @@ class TestMRPMixin(TestBPMMixin):
mrp/p3 mrp/p3
""" """
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path_p2 = self.createBusinessPath(business_process) business_link_p2 = self.createBusinessLink(business_process)
business_path_p3 = self.createBusinessPath(business_process) business_link_p3 = self.createBusinessLink(business_process)
business_state_ready = self.createBusinessState(business_process) business_state_ready = self.createBusinessState(business_process)
business_state_partial = self.createBusinessState(business_process) business_state_partial = self.createBusinessState(business_process)
...@@ -213,7 +213,7 @@ class TestMRPMixin(TestBPMMixin): ...@@ -213,7 +213,7 @@ class TestMRPMixin(TestBPMMixin):
destination = self.createOrganisation(title='destination') destination = self.createOrganisation(title='destination')
business_process.edit(referential_date='stop_date') business_process.edit(referential_date='stop_date')
business_path_p2.edit(id='p2', business_link_p2.edit(id='p2',
predecessor_value=business_state_ready, predecessor_value=business_state_ready,
successor_value=business_state_partial, successor_value=business_state_partial,
quantity=1, quantity=1,
...@@ -223,7 +223,7 @@ class TestMRPMixin(TestBPMMixin): ...@@ -223,7 +223,7 @@ class TestMRPMixin(TestBPMMixin):
destination_section_value=destination_section, destination_section_value=destination_section,
destination_value=destination, destination_value=destination,
) )
business_path_p3.edit(id='p3', business_link_p3.edit(id='p3',
predecessor_value=business_state_ready, predecessor_value=business_state_ready,
successor_value=business_state_partial, successor_value=business_state_partial,
quantity=1, quantity=1,
...@@ -280,7 +280,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase): ...@@ -280,7 +280,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations # organisations
path = business_process.objectValues( path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0] portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection() source_section = path.getSourceSection()
source = path.getSource() source = path.getSource()
destination_section = path.getDestinationSection() destination_section = path.getDestinationSection()
...@@ -344,7 +344,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase): ...@@ -344,7 +344,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations # organisations
path = business_process.objectValues( path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0] portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection() source_section = path.getSourceSection()
source = path.getSource() source = path.getSource()
destination_section = path.getDestinationSection() destination_section = path.getDestinationSection()
...@@ -413,7 +413,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase): ...@@ -413,7 +413,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations # organisations
path = business_process.objectValues( path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0] portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection() source_section = path.getSourceSection()
source = path.getSource() source = path.getSource()
destination_section = path.getDestinationSection() destination_section = path.getDestinationSection()
......
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
...@@ -36,9 +37,9 @@ import transaction ...@@ -36,9 +37,9 @@ import transaction
class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin): class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin):
BUSINESS_PATH_CREATION_SEQUENCE_STRING = """ BUSINESS_PATH_CREATION_SEQUENCE_STRING = """
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
CreateUrssafRoubaixOrganisation CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase ModifyBusinessLinkTradePhase
ModelSpecialiseBusinessProcess ModelSpecialiseBusinessProcess
Tic Tic
""" """
...@@ -841,14 +842,14 @@ class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin): ...@@ -841,14 +842,14 @@ class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin):
node.edit(title='Urssaf de Roubaix Tourcoing') node.edit(title='Urssaf de Roubaix Tourcoing')
sequence.edit(urssaf_roubaix = node) sequence.edit(urssaf_roubaix = node)
def stepModifyBusinessPathTradePhase(self, sequence=None, **kw): def stepModifyBusinessLinkTradePhase(self, sequence=None, **kw):
business_path = sequence.get('business_path') business_link = sequence.get('business_link')
business_path.setTradePhaseList(['payroll/france/urssaf', business_link.setTradePhaseList(['payroll/france/urssaf',
'payroll/france/labour']) 'payroll/france/labour'])
business_path.setSourceValue(sequence.get('urssaf_roubaix')) business_link.setSourceValue(sequence.get('urssaf_roubaix'))
business_path.setSourceSectionValue(sequence.get('urssaf_roubaix')) business_link.setSourceSectionValue(sequence.get('urssaf_roubaix'))
business_path.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',)) business_link.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',))
sequence.edit(business_path=business_path) sequence.edit(business_link=business_link)
def stepModelSpecialiseBusinessProcess(self, sequence=None, **kw): def stepModelSpecialiseBusinessProcess(self, sequence=None, **kw):
model = sequence.get('model') model = sequence.get('model')
...@@ -3240,9 +3241,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -3240,9 +3241,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency CreatePriceCurrency
CreateLabourOutputService CreateLabourOutputService
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
CreateUrssafRoubaixOrganisation CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase ModifyBusinessLinkTradePhase
Tic Tic
CheckModelWithoutRefValidity CheckModelWithoutRefValidity
""" """
...@@ -3260,9 +3261,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -3260,9 +3261,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency CreatePriceCurrency
CreateLabourOutputService CreateLabourOutputService
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
CreateUrssafRoubaixOrganisation CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase ModifyBusinessLinkTradePhase
Tic Tic
CheckModelWithoutDateValidity CheckModelWithoutDateValidity
""" """
...@@ -3278,9 +3279,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -3278,9 +3279,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency CreatePriceCurrency
CreateLabourOutputService CreateLabourOutputService
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
CreateUrssafRoubaixOrganisation CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase ModifyBusinessLinkTradePhase
Tic Tic
CheckModelDateValidity CheckModelDateValidity
""" """
...@@ -3295,9 +3296,9 @@ class TestPayroll(TestPayrollMixin): ...@@ -3295,9 +3296,9 @@ class TestPayroll(TestPayrollMixin):
sequence_string = """ sequence_string = """
CreatePriceCurrency CreatePriceCurrency
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
CreateUrssafRoubaixOrganisation CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase ModifyBusinessLinkTradePhase
Tic Tic
CheckModelVersioning CheckModelVersioning
""" """
......
# -*- coding: utf-8 -*- # -*- coding: shift_jis -*-
############################################################################## ##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com> # Łukasz Nowak <luke@nexedi.com>
...@@ -56,9 +56,9 @@ class TestTradeModelLineMixin(TestBPMMixin): ...@@ -56,9 +56,9 @@ class TestTradeModelLineMixin(TestBPMMixin):
sequence.edit(business_process=self.createBusinessProcess( sequence.edit(business_process=self.createBusinessProcess(
title=self.id())) title=self.id()))
def stepCreateBusinessPath(self, sequence=None, **kw): def stepCreateBusinessLink(self, sequence=None, **kw):
business_process = sequence.get('business_process') business_process = sequence.get('business_process')
sequence.edit(business_path=self.createBusinessPath(business_process)) sequence.edit(business_link=self.createBusinessLink(business_process))
class TestTradeModelLine(TestTradeModelLineMixin): class TestTradeModelLine(TestTradeModelLineMixin):
quiet = True quiet = True
...@@ -101,10 +101,10 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -101,10 +101,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
AGGREGATED_AMOUNT_LIST_COMMON_SEQUENCE_STRING = \ AGGREGATED_AMOUNT_LIST_COMMON_SEQUENCE_STRING = \
COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """ COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathTaxing ModifyBusinessLinkTaxing
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathDiscounting ModifyBusinessLinkDiscounting
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -195,35 +195,35 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -195,35 +195,35 @@ class TestTradeModelLine(TestTradeModelLineMixin):
portal_type='Trade Model Line', portal_type='Trade Model Line',
**kw) **kw)
def stepModifyBusinessPathDiscounting(self, sequence=None, **kw): def stepModifyBusinessLinkDiscounting(self, sequence=None, **kw):
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed successor = category_tool.trade_state.taxed
business_path = sequence.get('business_path') business_link = sequence.get('business_link')
self.assertNotEqual(None, predecessor) self.assertNotEqual(None, predecessor)
self.assertNotEqual(None, successor) self.assertNotEqual(None, successor)
business_path.edit( business_link.edit(
predecessor_value = predecessor, predecessor_value = predecessor,
successor_value = successor, successor_value = successor,
trade_phase = 'default/discount' trade_phase = 'default/discount'
) )
sequence.edit(business_path=None, business_path_discounting=business_path) sequence.edit(business_link=None, business_link_discounting=business_link)
def stepModifyBusinessPathTaxing(self, sequence=None, **kw): def stepModifyBusinessLinkTaxing(self, sequence=None, **kw):
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced predecessor = category_tool.trade_state.invoiced
successor = category_tool.trade_state.taxed successor = category_tool.trade_state.taxed
business_path = sequence.get('business_path') business_link = sequence.get('business_link')
self.assertNotEqual(None, predecessor) self.assertNotEqual(None, predecessor)
self.assertNotEqual(None, successor) self.assertNotEqual(None, successor)
business_path.edit( business_link.edit(
predecessor_value = predecessor, predecessor_value = predecessor,
successor_value = successor, successor_value = successor,
trade_phase = 'default/tax' trade_phase = 'default/tax'
) )
sequence.edit(business_path=None, business_path_taxing=business_path) sequence.edit(business_link=None, business_link_taxing=business_link)
def stepAcceptDecisionQuantityInvoice(self, sequence=None, **kw): def stepAcceptDecisionQuantityInvoice(self, sequence=None, **kw):
invoice = sequence.get('invoice') invoice = sequence.get('invoice')
...@@ -506,15 +506,15 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -506,15 +506,15 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineDiscountedTaxedSimulation(self, sequence=None, **kw): def stepCheckOrderLineDiscountedTaxedSimulation(self, sequence=None, **kw):
order_line = sequence.get('order_line_discounted_taxed') order_line = sequence.get('order_line_discounted_taxed')
business_path_discounting = sequence.get('business_path_discounting') business_link_discounting = sequence.get('business_link_discounting')
business_path_taxing = sequence.get('business_path_taxing') business_link_taxing = sequence.get('business_link_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
service_tax = sequence.get('service_tax') service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount') service_discount = sequence.get('service_discount')
self.assertNotEqual(None, business_path_discounting) self.assertNotEqual(None, business_link_discounting)
self.assertNotEqual(None, business_path_taxing) self.assertNotEqual(None, business_link_taxing)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \ for trade_model_simulation_movement_list in \
...@@ -537,7 +537,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -537,7 +537,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
self.assertEqual( self.assertEqual(
business_path_discounting, business_link_discounting,
trade_model_simulation_movement_discount_complex.getCausalityValue() trade_model_simulation_movement_discount_complex.getCausalityValue()
) )
...@@ -578,7 +578,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -578,7 +578,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
self.assertEqual( self.assertEqual(
business_path_taxing, business_link_taxing,
trade_model_simulation_movement_tax_complex.getCausalityValue() trade_model_simulation_movement_tax_complex.getCausalityValue()
) )
...@@ -606,15 +606,15 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -606,15 +606,15 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineDiscountedSimulation(self, sequence=None, **kw): def stepCheckOrderLineDiscountedSimulation(self, sequence=None, **kw):
order_line = sequence.get('order_line_discounted') order_line = sequence.get('order_line_discounted')
business_path_discounting = sequence.get('business_path_discounting') business_link_discounting = sequence.get('business_link_discounting')
business_path_taxing = sequence.get('business_path_taxing') business_link_taxing = sequence.get('business_link_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
service_tax = sequence.get('service_tax') service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount') service_discount = sequence.get('service_discount')
self.assertNotEqual(None, business_path_discounting) self.assertNotEqual(None, business_link_discounting)
self.assertNotEqual(None, business_path_taxing) self.assertNotEqual(None, business_link_taxing)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \ for trade_model_simulation_movement_list in \
...@@ -637,7 +637,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -637,7 +637,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
self.assertEqual( self.assertEqual(
business_path_discounting, business_link_discounting,
trade_model_simulation_movement_discount_only.getCausalityValue() trade_model_simulation_movement_discount_only.getCausalityValue()
) )
...@@ -671,7 +671,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -671,7 +671,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
trade_model_simulation_movement_tax_only.getTotalPrice()) trade_model_simulation_movement_tax_only.getTotalPrice())
self.assertEqual( self.assertEqual(
business_path_taxing, business_link_taxing,
trade_model_simulation_movement_tax_only.getCausalityValue() trade_model_simulation_movement_tax_only.getCausalityValue()
) )
...@@ -700,9 +700,9 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -700,9 +700,9 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineTaxedSimulation(self, sequence=None, **kw): def stepCheckOrderLineTaxedSimulation(self, sequence=None, **kw):
order_line = sequence.get('order_line_taxed') order_line = sequence.get('order_line_taxed')
business_path = sequence.get('business_path_taxing') business_link = sequence.get('business_link_taxing')
price_currency = sequence.get('price_currency') price_currency = sequence.get('price_currency')
self.assertNotEqual(None, business_path) self.assertNotEqual(None, business_link)
self.assertNotEqual(None, price_currency) self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \ for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line): self.getTradeModelSimulationMovementList(order_line):
...@@ -717,7 +717,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -717,7 +717,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
) )
self.assertEqual( self.assertEqual(
business_path, business_link,
trade_model_simulation_movement.getCausalityValue() trade_model_simulation_movement.getCausalityValue()
) )
...@@ -1447,10 +1447,10 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1447,10 +1447,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ORDER_SPECIALISE_AGGREGATED_AMOUNT_COMMON_SEQUENCE_STRING = \ ORDER_SPECIALISE_AGGREGATED_AMOUNT_COMMON_SEQUENCE_STRING = \
COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """ COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathTaxing ModifyBusinessLinkTaxing
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathDiscounting ModifyBusinessLinkDiscounting
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -1876,10 +1876,10 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1876,10 +1876,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """ sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathTaxing ModifyBusinessLinkTaxing
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathDiscounting ModifyBusinessLinkDiscounting
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -1937,10 +1937,10 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1937,10 +1937,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
sequence_list = SequenceList() sequence_list = SequenceList()
sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """ sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess CreateBusinessProcess
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathTaxing ModifyBusinessLinkTaxing
CreateBusinessPath CreateBusinessLink
ModifyBusinessPathDiscounting ModifyBusinessLinkDiscounting
CreateTradeCondition CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine CreateTradeModelLine
...@@ -1970,7 +1970,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -1970,7 +1970,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def test_BuildTradeModelLineAndAccountingFromOrder(self): def test_BuildTradeModelLineAndAccountingFromOrder(self):
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path = self.createBusinessPath(business_process, business_link = self.createBusinessLink(business_process,
trade_phase='default/tax') trade_phase='default/tax')
product = self.createResource('Product', product = self.createResource('Product',
...@@ -2070,7 +2070,7 @@ class TestTradeModelLine(TestTradeModelLineMixin): ...@@ -2070,7 +2070,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def test_BuildTradeModelLineAndAccountingFromInvoice(self): def test_BuildTradeModelLineAndAccountingFromInvoice(self):
business_process = self.createBusinessProcess() business_process = self.createBusinessProcess()
business_path = self.createBusinessPath(business_process, business_link = self.createBusinessLink(business_process,
trade_phase='default/tax') trade_phase='default/tax')
product = self.createResource('Product', product = self.createResource('Product',
......
...@@ -267,7 +267,7 @@ class ERP5TypeInformation(XMLObject, ...@@ -267,7 +267,7 @@ class ERP5TypeInformation(XMLObject,
'divergence_tester', 'target_solver', 'divergence_tester', 'target_solver',
'amount_generator', 'amount_generator_line', 'amount_generator_cell', 'amount_generator', 'amount_generator_line', 'amount_generator_cell',
# Business Processes # Business Processes
'business_path', 'business_process', 'trade_model_path', 'business_link', 'business_process',
# Movement Group # Movement Group
'movement_group', 'movement_group',
# Calendar # Calendar
......
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