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.
......@@ -43,6 +43,7 @@ class SelectMethodError(Exception): pass
class BPMBuilder(Alarm):
"""Top class for builders.
XXX-JPS Wrong Naming - Abbreviation (BPM)
WARNING: This is BPM evaluation of building approach.
WARNING: Do NOT use it in production environment.
......@@ -100,10 +101,10 @@ class BPMBuilder(Alarm):
# Select movements
if input_movement_list is None:
if not select_method_dict.has_key('causality_uid'):
business_path_value_list = self.getRelatedBusinessPathValueList()
if len(business_path_value_list) > 0:
# use only Business Path related movements
select_method_dict['causality_uid'] = [q.getUid() for q in business_path_value_list]
business_link_value_list = self.getRelatedBusinessLinkValueList()
if len(business_link_value_list) > 0:
# use only Business Link related movements
select_method_dict['causality_uid'] = [q.getUid() for q in business_link_value_list]
# do search
input_movement_value_list = self.searchMovementList(
delivery_relative_url_list=existing_delivery_list,
......@@ -220,10 +221,10 @@ class BPMBuilder(Alarm):
input_movement.edit(delivery_value=delivery_movement,
activate_kw=activate_kw)
def getRelatedBusinessPathValueList(self):
def getRelatedBusinessLinkValueList(self):
return self.getDeliveryBuilderRelatedValueList(
portal_type='Business Path') + self.getOrderBuilderRelatedValueList(
portal_type='Business Path')
portal_type='Business Link') + self.getOrderBuilderRelatedValueList(
portal_type='Business Link')
def callBeforeBuildingScript(self):
"""
......
......@@ -32,7 +32,7 @@ from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet, interfaces
from Products.ERP5Type.XMLObject import XMLObject
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
import zope.interface
......@@ -40,7 +40,7 @@ import zope.interface
class BusinessProcess(Path, XMLObject):
"""The BusinessProcess class is a container class which is used
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
'successor' trade_state, for a given trade_phase_list.
......@@ -63,8 +63,8 @@ class BusinessProcess(Path, XMLObject):
always in the context of an explanation. Sometimes,
it is necessary to ignore certain business path to evaluate
completion or completion dates. This is very true for Union
Business Processes. This is the concept of Business Path closure,
ie. filtering out all Business Path which are not used in an explanation.
Business Processes. This is the concept of Business Link closure,
ie. filtering out all Business Link which are not used in an explanation.
TODO:
- add support to prevent infinite loop. (but beware, this notion has changed
......@@ -91,7 +91,7 @@ class BusinessProcess(Path, XMLObject):
- support conversions in business path
RENAMED:
getPathValueList -> getBusinessPathValueList
getPathValueList -> getBusinessLinkValueList
"""
meta_type = 'ERP5 Business Process'
portal_type = 'Business Process'
......@@ -115,17 +115,17 @@ class BusinessProcess(Path, XMLObject):
zope.interface.implements(interfaces.IBusinessProcess,
interfaces.IArrowBase)
# IBusinessPathProcess implementation
security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessPathValueList')
def getBusinessPathValueList(self, trade_phase=None, context=None,
# IBusinessLinkProcess implementation
security.declareProtected(Permissions.AccessContentsInformation, 'getBusinessLinkValueList')
def getBusinessLinkValueList(self, trade_phase=None, context=None,
predecessor=None, successor=None, **kw):
"""Returns all Path of the current BusinessProcess which
are matching the given trade_phase and the optional context.
trade_phase -- filter by trade phase
context -- a context to test each Business Path on
and filter out Business Path which do not match
context -- a context to test each Business Link on
and filter out Business Link which do not match
predecessor -- filter by trade state predecessor
......@@ -141,46 +141,46 @@ class BusinessProcess(Path, XMLObject):
trade_phase = set(trade_phase)
result = []
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:
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
# for easier debugging.
# First, collect business paths which can be applicable to a given context.
business_path_list = []
for business_path in original_business_path_list:
business_link_list = []
for business_link in original_business_link_list:
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
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
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
if accept_path:
business_path_list.append(business_path)
business_link_list.append(business_link)
# Then, filter business paths by Predicate API.
# 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
# support the condition above without scripting?
for business_path in business_path_list:
if business_path.test(context):
result.append(business_path)
for business_link in business_link_list:
if business_link.test(context):
result.append(business_link)
return result
def isBusinessPathCompleted(self, explanation, business_path):
"""Returns True if given Business Path document
def isBusinessLinkCompleted(self, explanation, business_link):
"""Returns True if given Business Link document
is completed 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
business_link -- a Business Link document
"""
# Return False if Business Path is not completed
if not business_path.isCompleted(explanation):
# Return False if Business Link is not completed
if not business_link.isCompleted(explanation):
return False
predecessor_state = business_path.getPredecessor()
predecessor_state = business_link.getPredecessor()
if not predecessor_state:
# This is a root business path, no predecessor
# so no need to do any recursion
......@@ -197,22 +197,22 @@ class BusinessProcess(Path, XMLObject):
# 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
# 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)
def isBusinessPathPartiallyCompleted(self, explanation, business_path):
"""Returns True if given Business Path document
def isBusinessLinkPartiallyCompleted(self, explanation, business_link):
"""Returns True if given Business Link document
is partially completed 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
business_link -- a Business Link document
"""
# Return False if Business Path is not partially completed
if not business_path.isPartiallyCompleted(explanation):
# Return False if Business Link is not partially completed
if not business_link.isPartiallyCompleted(explanation):
return False
predecessor_state = business_path.getPredecessor()
predecessor_state = business_link.getPredecessor()
if not predecessor_state:
# This is a root business path, no predecessor
# so no need to do any recursion
......@@ -229,179 +229,179 @@ class BusinessProcess(Path, XMLObject):
# 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
# it becomes an empty set
closure_process = _getBusinessPathClosure(explanation, business_path)
closure_process = _getBusinessLinkClosure(explanation, business_link)
return closure_process.isTradeStatePartiallyCompleted(explanation,
predecessor_state)
def getExpectedBusinessPathCompletionDate(self, explanation, business_path,
def getExpectedBusinessLinkCompletionDate(self, explanation, business_link,
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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')
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
predecessor = business_path.getPredecessor()
predecessor = business_link.getPredecessor()
if closure_process.isInitialTradeState(predecessor):
return business_path.getCompletionDate(explanation)
return business_link.getCompletionDate(explanation)
# Recursively find reference_date
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':
delay = business_path.getMinDelay()
delay = business_link.getMinDelay()
elif delay_mode == 'max':
delay = business_path.getMaxDelay()
delay = business_link.getMaxDelay()
else:
delay = (business_path.getMaxDelay() + business_path.getMinDelay()) / 2.0
delay = (business_link.getMaxDelay() + business_link.getMinDelay()) / 2.0
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':
return start_date
elif completion_date_method_id == 'getStopDate':
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):
"""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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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')
if no value specified use average delay
"""
if explanation.getPortalType() != 'Applied Rule':
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
trade_date = business_path.getTradeDate()
trade_date = trade_model_path.getTradeDate()
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)
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)
# Recursively find reference_date
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':
delay = business_path.getMinDelay()
delay = trade_model_path.getMinDelay()
elif delay_mode == 'max':
delay = business_path.getMaxDelay()
delay = trade_model_path.getMaxDelay()
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
return start_date, stop_date
# IBuildableBusinessPathProcess implementation
def getBuildableBusinessPathValueList(self, explanation):
"""Returns the list of Business Path which are buildable
# IBuildableBusinessLinkProcess implementation
def getBuildableBusinessLinkValueList(self, explanation):
"""Returns the list of Business Link which are buildable
by taking into account trade state dependencies between
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
result = []
for business_path in self.getBusinessPathValueList():
if self.isBusinessPathBuildable(explanation, business_path):
result.append(business_path)
for business_link in self.getBusinessLinkValueList():
if self.isBusinessLinkBuildable(explanation, business_link):
result.append(business_link)
return result
def getPartiallyBuildableBusinessPathValueList(self, explanation):
"""Returns the list of Business Path which are partially buildable
def getPartiallyBuildableBusinessLinkValueList(self, explanation):
"""Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
result = []
for business_path in self.getBusinessPathValueList():
if self.isBusinessPathPartiallyBuildable(explanation, business_path):
result.append(business_path)
for business_link in self.getBusinessLinkValueList():
if self.isBusinessLinkPartiallyBuildable(explanation, business_link):
result.append(business_link)
return result
def isBusinessPathBuildable(self, explanation, business_path):
def isBusinessLinkBuildable(self, explanation, business_link):
"""Returns True if any of the related Simulation Movement
is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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 business_path.isDelivered(explanation):
if business_link.isDelivered(explanation):
return False
# We must take the closure cause only way to combine business process
closure_process = _getBusinessPathClosure(self, explanation, business_path)
predecessor = business_path.getPredecessor()
closure_process = _getBusinessLinkClosure(self, explanation, business_link)
predecessor = business_link.getPredecessor()
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
is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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 business_path.isDelivered(explanation):
if business_link.isDelivered(explanation):
return False
# We must take the closure cause only way to combine business process
closure_process = _getBusinessPathClosure(self, explanation, business_path)
predecessor = business_path.getPredecessor()
closure_process = _getBusinessLinkClosure(self, explanation, business_link)
predecessor = business_link.getPredecessor()
return closure_process.isTradeStatePartiallyCompleted(predecessor)
# ITradeStateProcess implementation
def getTradeStateList(self):
"""Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
result = set()
for business_path in self.getBusinessPathValueList():
result.add(business_path.getPredecessor())
result.add(business_path.getSuccessor())
for business_link in self.getBusinessLinkValueList():
result.add(business_link.getPredecessor())
result.add(business_link.getSuccessor())
return result
def isInitialTradeState(self, trade_state):
"""Returns True if given 'trade_state' has no successor related
Business Path.
Business Link.
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):
"""Returns True if given 'trade_state' has no predecessor related
Business Path.
Business Link.
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):
"""Returns the list of successor states in the
......@@ -415,9 +415,9 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category
"""
result = set()
for business_path in self.getBusinessPathValueList():
if business_path.getPredecessor() == trade_state:
result.add(business_path.getSuccessor())
for business_link in self.getBusinessLinkValueList():
if business_link.getPredecessor() == trade_state:
result.add(business_link.getSuccessor())
return result
def getPredecessorTradeStateList(self, explanation, trade_state):
......@@ -432,9 +432,9 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category
"""
result = set()
for business_path in self.getBusinessPathValueList():
if business_path.getSuccessor() == trade_state:
result.add(business_path.getPredecessor())
for business_link in self.getBusinessLinkValueList():
if business_link.getSuccessor() == trade_state:
result.add(business_link.getPredecessor())
return result
def getCompletedTradeStateList(self, explanation):
......@@ -465,8 +465,8 @@ class BusinessProcess(Path, XMLObject):
"""
result = set()
for state in self.getCompletedTradeStateValue(explanation):
for business_path in state.getPredecessorRelatedValueList():
if not self.isBusinessPathCompleted(explanation, business_path):
for business_link in state.getPredecessorRelatedValueList():
if not self.isBusinessLinkCompleted(explanation, business_link):
result.add(state)
return result
......@@ -480,8 +480,8 @@ class BusinessProcess(Path, XMLObject):
"""
result = set()
for state in self.getCompletedTradeStateValue(explanation):
for business_path in state.getPredecessorRelatedValueList():
if not self.isBusinessPathPartiallyCompleted(explanation, business_path):
for business_link in state.getPredecessorRelatedValueList():
if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
result.add(state)
return result
......@@ -495,8 +495,8 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category
"""
for business_path in self.getBusinessPathValueList(successor=trade_state):
if not closure_process.isBusinessPathCompleted(explanation, business_path):
for business_link in self.getBusinessLinkValueList(successor=trade_state):
if not closure_process.isBusinessLinkCompleted(explanation, business_link):
return False
return True
......@@ -510,8 +510,8 @@ class BusinessProcess(Path, XMLObject):
trade_state -- a Trade State category
"""
for business_path in self.getBusinessPathValueList(successor=trade_state):
if not self.isBusinessPathPartiallyCompleted(explanation, business_path):
for business_link in self.getBusinessLinkValueList(successor=trade_state):
if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
return False
return True
......@@ -529,18 +529,18 @@ class BusinessProcess(Path, XMLObject):
if no value specified use average delay
"""
date_list = []
for business_path in self.getBusinessPathValueList(successor=trade_state):
date_list.append(self.getExpectedBusinessPathCompletionDate(explanation, business_path))
for business_link in self.getBusinessLinkValueList(successor=trade_state):
date_list.append(self.getExpectedBusinessLinkCompletionDate(explanation, business_link))
return max(date_list) # XXX-JPS it would be good that date support infinite values
# ITradePhaseProcess implementation
def getTradePhaseList(self):
"""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()
for business_path in self.getBusinessPathValueList():
result = result.union(business_path.getTradePhaseList())
for business_link in self.getBusinessLinkValueList():
result = result.union(business_link.getTradePhaseList())
return result
def getCompletedTradePhaseList(self, explanation):
......@@ -570,8 +570,8 @@ class BusinessProcess(Path, XMLObject):
trade_phase -- a Trade Phase category
"""
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase):
if not self.isBusinessPathCompleted(explanation, business_path):
for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
if not self.isBusinessLinkCompleted(explanation, business_link):
return False
return True
......@@ -585,8 +585,8 @@ class BusinessProcess(Path, XMLObject):
trade_phase -- a Trade Phase category
"""
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase):
if not self.isBusinessPathPartiallyCompleted(explanation, business_path):
for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
if not self.isBusinessLinkPartiallyCompleted(explanation, business_link):
return False
return True
......@@ -606,11 +606,11 @@ class BusinessProcess(Path, XMLObject):
if no value specified use average delay
"""
date_list = []
for business_path in self.getBusinessPathValueList(trade_phase=trade_phase):
date_list.append(self.getExpectedBusinessPathCompletionDate(explanation, business_path, delay_mode=delay_mode))
for business_link in self.getBusinessLinkValueList(trade_phase=trade_phase):
date_list.append(self.getExpectedBusinessLinkCompletionDate(explanation, business_link, delay_mode=delay_mode))
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
as part of a business process. This list is calculated by analysing
the graph of business path and trade states, starting from a given
......@@ -618,7 +618,7 @@ class BusinessProcess(Path, XMLObject):
method is useful mostly for production and MRP to manage a distributed
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
being collected - XXX-JPS - is this really useful ?
......@@ -627,13 +627,13 @@ class BusinessProcess(Path, XMLObject):
NOTE: explanation is not involved here because we consider here that
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
simulation, we did not include the explanation. However, this makes the
API less uniform.
"""
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]:
# 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
......@@ -657,7 +657,7 @@ class BusinessProcess(Path, XMLObject):
def getTradePhaseMovementList(self, explanation, amount, trade_phase=None, delay_mode=None):
"""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
on the Amount is used instead.
......@@ -681,10 +681,10 @@ class BusinessProcess(Path, XMLObject):
result = []
id_index = 0
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
movement = newTempMovement(business_path, '%s_%s' % (base_id, id_index))
kw = self._getPropertyAndCategoryDict(explanation, amount, business_path, delay_mode=delay_mode)
movement = newTempMovement(business_link, '%s_%s' % (base_id, id_index))
kw = self._getPropertyAndCategoryDict(explanation, amount, business_link, delay_mode=delay_mode)
movement._edit(**kw)
result.append(movement)
......@@ -711,8 +711,8 @@ class BusinessProcess(Path, XMLObject):
return stripped_result
def _getPropertyAndCategoryDict(self, explanation, amount, business_path, delay_mode=None):
"""A private method to merge an amount and a business_path and return
def _getPropertyAndCategoryDict(self, explanation, amount, business_link, delay_mode=None):
"""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
new movement.
......@@ -721,7 +721,7 @@ class BusinessProcess(Path, XMLObject):
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')
if no value specified use average delay
......@@ -740,16 +740,16 @@ class BusinessProcess(Path, XMLObject):
# Arrow categories
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
# Amount quantities - XXX-JPS maybe we should consider handling unit conversions here
# and specifying units
if business_path.getQuantity():
property_dict['quantity'] = business_path.getQuantity()
elif business_path.getEfficiency():
if business_link.getQuantity():
property_dict['quantity'] = business_link.getQuantity()
elif business_link.getEfficiency():
property_dict['quantity'] = amount.getQuantity() *\
business_path.getEfficiency()
business_link.getEfficiency()
else:
property_dict['quantity'] = amount.getQuantity()
......@@ -765,15 +765,15 @@ class BusinessProcess(Path, XMLObject):
# applied rules which are not root applied rules.
# XXX-JPS could be extended with a rule property instead
# of supports only in root applied rule case
start_date, stop_date = self.getExpectedBusinessPathStartAndStopDate(
explanation, business_path, delay_mode=delay_mode)
start_date, stop_date = self.getExpectedTradePathStartAndStopDate(
explanation, business_link, delay_mode=delay_mode)
property_dict['start_date'] = start_date
property_dict['stop_date'] = stop_date
else:
raise TypeError("Explanation must be an Applied Rule in expand process") # Nothing to do
# 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
......@@ -808,26 +808,26 @@ class BusinessProcess(Path, XMLObject):
return max(date_list)
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
return len(self.getBuildableBusinessPathValueList(explanation)) != 0
return len(self.getBuildableBusinessLinkValueList(explanation)) != 0
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
return len(self.getPartiallyBuildableBusinessPathValueList(explanation)) != 0
return len(self.getPartiallyBuildableBusinessLinkValueList(explanation)) != 0
def build(self, explanation):
"""
Build whatever is buildable
"""
for business_path in self.getBuildableBusinessPathValueList(explanation):
business_path.build(explanation)
for business_link in self.getBuildableBusinessLinkValueList(explanation):
business_link.build(explanation)
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
......@@ -44,7 +45,7 @@ class DeliveryRootSimulationRule(DeliveryRule):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict):
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
......@@ -44,7 +45,7 @@ class InvoiceRootSimulationRule(InvoiceRule):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict):
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002, 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -47,7 +48,7 @@ class OrderRootSimulationRule(OrderRule):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict):
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -200,11 +201,11 @@ class PaySheetTransaction(Invoice):
movement_list_trade_phase_dic[trade_phase].append(movement)
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)
for business_path in business_path_list:
for business_link in business_link_list:
builder_list = [portal.restrictedTraverse(url) for url in\
business_path.getDeliveryBuilderList()]
business_link.getDeliveryBuilderList()]
for builder in builder_list:
builder.build(delivery_relative_url_list=[self.getRelativeUrl(),],
movement_list = movement_list_trade_phase_dic[trade_phase])
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -45,7 +46,7 @@ class ProductionOrderModelRootSimulationRule(ProductionOrderModelRule):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict):
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved.
......@@ -45,7 +46,7 @@ class ProductionOrderRootSimulationRule(ProductionOrderRule):
security.declareObjectProtected(Permissions.AccessContentsInformation)
def _getExpandablePropertyUpdateDict(self, applied_rule, movement,
business_path, current_property_dict):
business_link, current_property_dict):
"""Order rule specific update dictionary"""
return {
'delivery': movement.getRelativeUrl(),
......
......@@ -202,11 +202,11 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
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
business_path = self.getCausalityValue(
portal_type=self.getPortalBusinessPathTypeList())
if business_path is None:
business_link = self.getCausalityValue(
portal_type=self.getPortalBusinessLinkTypeList())
if business_link is None:
return False
return self.getSimulationState() in business_path.getCompletedStateList()
return self.getSimulationState() in business_link.getCompletedStateList()
security.declareProtected(Permissions.AccessContentsInformation,
'isFrozen')
......@@ -214,9 +214,9 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
"""Lookup business path and, if any, return True whenever
simulation_state is in one of the frozen states defined on business path
"""
business_path = self.getCausalityValue(
portal_type=self.getPortalBusinessPathTypeList())
if business_path is None:
business_link = self.getCausalityValue(
portal_type=self.getPortalBusinessLinkTypeList())
if business_link is None:
# Legacy support - this should never happen
# XXX-JPS ADD WARNING
if self.getSimulationState() in ('stopped', 'delivered', 'cancelled'):
......@@ -224,7 +224,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
if self._baseIsFrozen() == 0:
self._baseSetFrozen(None)
return self._baseGetFrozen() or False
return self.getSimulationState() in business_path.getFrozenStateList()
return self.getSimulationState() in business_link.getFrozenStateList()
security.declareProtected( Permissions.AccessContentsInformation,
'isAccountable')
......@@ -580,32 +580,32 @@ class SimulationMovement(Movement, PropertyRecordableMixin, ExplainableMixin):
return False
# 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()
if business_path is None or explanation_value is None:
if business_link is None or explanation_value is None:
return True
predecessor = business_path.getPredecessorValue()
predecessor = business_link.getPredecessorValue()
if predecessor is None:
# first one, can be built
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 business_path_movement in successor_related \
for business_link_movement in successor_related \
.getRelatedSimulationMovementValueList(explanation_value):
if successor_related.isMovementRelatedWithMovement(self,
business_path_movement):
business_path_movement_delivery = business_path_movement \
business_link_movement):
business_link_movement_delivery = business_link_movement \
.getDeliveryValue()
if business_path_movement_delivery is None:
if business_link_movement_delivery is None:
return False # related movement is not delivered yet
business_path_movement_delivery_document = \
business_path_movement_delivery.getExplanationValue()
business_link_movement_delivery_document = \
business_link_movement_delivery.getExplanationValue()
# 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(
business_path_movement_delivery_document):
business_link_movement_delivery_document):
# related movements delivery is not completed
return False
return True
......
......@@ -40,11 +40,11 @@ import zope.interface
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
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 idea is to invoke isBuildable() on the collected simulation
......@@ -53,8 +53,10 @@ class BusinessPath(Path, Predicate):
Here is the typical code of an alarm in charge of the building process::
builder = portal_deliveries.a_delivery_builder
for business_path in builder.getDeliveryBuilderRelatedValueList():
builder.build(causality_uid=business_path.getUid(),) # Select movements
for trade_model_path in builder.getDeliveryBuilderRelatedValueList():
builder.build(causality_uid=trade_model_path.getUid(),) # Select movements
WRONG - too slow
Pros: global select is possible by not providing a causality_uid
Cons: global select retrieves long lists of orphan movements which
......@@ -67,8 +69,8 @@ class BusinessPath(Path, Predicate):
- _getExplanationRelatedMovementValueList may be superfluous. Make
sure it is really needed
"""
meta_type = 'ERP5 Business Path'
portal_type = 'Business Path'
meta_type = 'ERP5 Trade Model Path'
portal_type = 'Trade Model Path'
# Declarative security
security = ClassSecurityInfo()
......@@ -86,7 +88,7 @@ class BusinessPath(Path, Predicate):
, PropertySheet.Amount
, PropertySheet.Chain # XXX-JPS Why N
, PropertySheet.SortIndex
, PropertySheet.BusinessPath
, PropertySheet.TradeModelPath
, PropertySheet.FlowCapacity
, PropertySheet.Reference
, PropertySheet.PaymentCondition # XXX-JPS must be renames some day
......@@ -95,18 +97,18 @@ class BusinessPath(Path, Predicate):
# Declarative interfaces
zope.interface.implements(interfaces.ICategoryAccessProvider,
interfaces.IArrowBase,
interfaces.IBusinessPath,
interfaces.ITradeModelPath,
interfaces.IPredicate,
)
# Helper Methods
def _getExplanationRelatedSimulationMovementValueList(self, explanation):
explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathRelatedSimulationMovementValueList(self)
return explanation_cache.getTradeModelPathRelatedSimulationMovementValueList(self)
def _getExplanationRelatedMovementValueList(self, explanation):
explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathRelatedMovementValueList(self)
return explanation_cache.getTradeModelPathRelatedMovementValueList(self)
# IArrowBase implementation
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -176,7 +178,7 @@ class BusinessPath(Path, Predicate):
def _getCategoryMembershipList(self, category, **kw):
"""
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')
result = Path._getCategoryMembershipList(self, category, **kw)
......@@ -191,7 +193,7 @@ class BusinessPath(Path, Predicate):
def _getAcquiredCategoryMembershipList(self, category, **kw):
"""
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)
result = Path._getAcquiredCategoryMembershipList(self, category, **kw)
......@@ -237,46 +239,6 @@ class BusinessPath(Path, Predicate):
method = getattr(self, method_id)
return method(context)
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,
'getExpectedQuantity')
......@@ -294,110 +256,3 @@ class BusinessPath(Path, Predicate):
return amount.getQuantity() * self.getEfficiency()
else:
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.
......@@ -186,7 +187,7 @@ portal_supply_type_list = ('Purchase Supply','Sale Supply')
portal_supply_path_type_list = ('Supply Line','Supply Cell')
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.
portal_balance_transaction_line_type_list = ('Balance Transaction Line',)
......
......@@ -775,24 +775,6 @@ class ERP5Site(FolderMixIn, CMFSite):
return self._getPortalGroupedTypeList('supply_path') or \
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,
'getPortalAcquisitionMovementTypeList')
def getPortalAcquisitionMovementTypeList(self):
......@@ -1141,13 +1123,22 @@ class ERP5Site(FolderMixIn, CMFSite):
"""
return self._getPortalGroupedTypeList('business_process')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalBusinessPathTypeList')
def getPortalBusinessPathTypeList(self):
'getPortalBusinessLinkTypeList')
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,
'getPortalCalendarPeriodTypeList')
......
......@@ -148,18 +148,18 @@ class ExplanationCache:
self.explanation_path_pattern_cache = result
return result
def getBusinessPathRelatedSimulationMovementValueList(self, business_path):
"""Returns the list of simulation movements caused by a business_path
def getBusinessLinkRelatedSimulationMovementValueList(self, business_link):
"""Returns the list of simulation movements caused by a business_link
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):
"""Returns the list of delivery movements related to a business_path
def getBusinessLinkRelatedMovementValueList(self, business_link):
"""Returns the list of delivery movements related to a business_link
in the context the our explanation.
"""
#XXXXXXXXXXX BAD
return self.getSimulationMovementValueList(causality_uid=business_path.getUid())
return self.getSimulationMovementValueList(causality_uid=business_link.getUid())
def getSimulationMovementValueList(self, **kw):
"""Search Simulation Movements related to our explanation.
......@@ -182,42 +182,42 @@ class ExplanationCache:
**kw)
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
trees defined by the explanation.
"""
business_type_list = self.getPortalBusinessPathTypeList()
business_type_list = self.getPortalBusinessLinkTypeList()
simulation_movement_list = self.getSimulationMovementValueList()
simulation_movement_uid_list = map(lambda x:x.uid, simulation_movement_list)
# 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,
causality_related_uid=simulation_movement_uid_list,
**kw)
return business_path_list
return business_link_list
def getBusinessPathClosure(self, business_process, business_path):
"""Creates a Business Process by filtering out all Business Path
def getBusinessLinkClosure(self, business_process, business_link):
"""Creates a Business Process by filtering out all Business Link
in 'business_process' which are not related to a simulation movement
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.
Options are:
- take all path of composed business path (even not yet expanded)
- take all path of composed business path which phase is not yet expanded
"""
# 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:
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 = map(lambda x:x[0:-1], path_list) # Remove trailing %
path_set = set()
for simulation_movement in business_path.\
for simulation_movement in business_link.\
_getExplanationRelatedSimulationMovementValueList(self.explanation):
simulation_path = simulation_movement.getPath()
for path in path_list:
......@@ -228,30 +228,30 @@ class ExplanationCache:
path_tuple = tuple(path_set) # XXX-JPS is the order guaranteed here ?
new_business_process = self.closure_cache.get(path_tuple, 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
# Build a new closure business process
def hasMatchingMovement(business_path):
def hasMatchingMovement(business_link):
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
new_business_process = module.newContent(portal_type="Business Process",
temp_object=True) # XXX-JPS is this really OK with union business processes
i = 0
for business_path in business_process.getBusinessPathValueList():
if hasMatchingMovement(business_path):
for business_link in business_process.getBusinessLinkValueList():
if hasMatchingMovement(business_link):
i += 1
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
return new_business_process
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
trees related to explanation.
"""
......@@ -264,10 +264,10 @@ class ExplanationCache:
from Products.ERP5Type.Document import newTempBusinessProcess
new_business_process = newTempBusinessProcess(self.explanation, 'union_business_process')
i = 0
for business_path in self.getBusinessPathValueList():
for business_link in self.getBusinessLinkValueList():
i += 1
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
self.union_cache = new_business_process
......@@ -281,10 +281,10 @@ def _getExplanationCache(explanation):
tv['explanation_cache'] = ExplanationCache(explanation)
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
business_path and explanation. This Business Process
contains only those Business Path which are related to business_path
business_link and explanation. This Business Process
contains only those Business Link which are related to business_link
in the context of explanation.
"""
if explanation.getPortalType() == "Applied Rule":
......@@ -293,10 +293,10 @@ def _getBusinessPathClosure(business_process, explanation, business_path):
# closure might be smaller than expexted
return business_process
explanation_cache = _getExplanationCache(explanation)
return explanation_cache.getBusinessPathClosure(business_process, business_path)
return explanation_cache.getBusinessLinkClosure(business_process, business_link)
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
"""
explanation_cache = _getExplanationCache(explanation)
......
# -*- coding: utf-8 -*-
# -*- coding: shift_jis -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
......@@ -47,11 +47,11 @@ class BuilderTool(BaseTool):
BuilderPortalType_selectDefaultMovement
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
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*
add new/update existing movements and update delivery. It is not
......@@ -80,9 +80,9 @@ class BuilderTool(BaseTool):
method_id = getattr(self,method_id_dict[self.getPortalType()])
for business_process_url in business_process_list:
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):
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?
return sorted(builder_value_list)
......
......@@ -230,8 +230,8 @@ class SolverTool(BaseTool):
test_property = divergence_tester.getTestedProperty()
application_value_level = {}
for simulation_movement in movement.getDeliveryRelatedValueList():
business_path = simulation_movement.getCausalityValue()
for delivery_builder in business_path.getDeliveryBuilderValueList():
business_link = simulation_movement.getCausalityValue()
for delivery_builder in business_link.getDeliveryBuilderValueList():
for movement_group in delivery_builder.contentValues(): # filter missing
if test_property in movement_group.getTestedPropertyList():
application_value_level[movement_group.getCollectGroupOrder()] = None
......@@ -267,8 +267,8 @@ class SolverTool(BaseTool):
test_property = divergence_tester.getTestedProperty()
application_value_level = {}
for simulation_movement in movement.getDeliveryRelatedValueList():
business_path = simulation_movement.getCausalityValue()
for delivery_builder in business_path.getDeliveryBuilderValueList():
business_link = simulation_movement.getCausalityValue()
for delivery_builder in business_link.getDeliveryBuilderValueList():
for property_group in delivery_builder.contentValues(portal_type="Property group"):
if test_property in property_group.getTestedPropertyList():
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
from zope.interface import Interface
class IBusinessPathProcess(Interface):
"""Business Path Process interface specification
class ITradeModelPathProcess(Interface):
"""
"""
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:
- explanation implicitely defines a subtree of the simulation
......@@ -52,17 +76,17 @@ class IBusinessPathProcess(Interface):
parameters to be copied (this used to be done through rule
parameter in provivate method)
- 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):
"""Returns the list of contained Business Path documents
"""Returns the list of contained Business Link documents
trade_phase -- filter by trade phase
context -- a context to test each Business Path on
and filter out Business Path which do not match
context -- a context to test each Business Link on
and filter out Business Link which do not match
predecessor -- filter by trade state predecessor
......@@ -71,108 +95,95 @@ class IBusinessPathProcess(Interface):
**kw -- same arguments as those passed to searchValues / contentValues
"""
def isBusinessPathCompleted(explanation, business_path):
"""Returns True if given Business Path document
def isBusinessLinkCompleted(explanation, business_link):
"""Returns True if given Business Link document
is completed 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
business_link -- a Business Link document
"""
def isBusinessPathPartiallyCompleted(explanation, business_path):
"""Returns True if given Business Path document
def isBusinessLinkPartiallyCompleted(explanation, business_link):
"""Returns True if given Business Link document
is partially completed 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
business_link -- a Business Link document
"""
def getExpectedBusinessPathCompletionDate(explanation, business_path,
def getExpectedBusinessLinkCompletionDate(explanation, business_link,
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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')
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')
if no value specified use average delay
"""
class IBuildableBusinessPathProcess(Interface):
"""Buildable Business Path Process interface specification
IBuildableBusinessPathProcess defines an API to build
IBuildableBusinessLinkProcess defines an API to build
simulation movements related to business pathj in the context
of a given explanation.
"""
def getBuildableBusinessPathValueList(explanation):
"""Returns the list of Business Path which are buildable
def getBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are buildable
by taking into account trade state dependencies between
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
"""
def getPartiallyBuildableBusinessPathValueList(explanation):
"""Returns the list of Business Path which are partially buildable
def getPartiallyBuildableBusinessLinkValueList(explanation):
"""Returns the list of Business Link which are partially buildable
by taking into account trade state dependencies between
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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
is buildable and if the predecessor trade state is completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
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
is buildable and if the predecessor trade state is partially completed.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
business_path -- a Business Path document
business_link -- a Business Link document
"""
def isBuildable(explanation):
"""Returns True is this business process has at least one
Business Path which is buildable
Business Link which is buildable
"""
def isPartiallyBuildable(explanation):
"""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):
......@@ -192,7 +203,7 @@ class ITradeStateProcess(Interface):
def getTradeStateList():
"""Returns list of all trade_state of this Business Process
by looking at successor and predecessor values of contained
Business Path.
Business Link.
explanation -- an Order, Order Line, Delivery or Delivery Line or
Applied Rule which implicitely defines a simulation subtree
......@@ -200,14 +211,14 @@ class ITradeStateProcess(Interface):
def isInitialTradeState(trade_state):
"""Returns True if given 'trade_state' has no successor related
Business Path.
Business Link.
trade_state -- a Trade State category
"""
def isFinalTradeState(trade_state):
"""Returns True if given 'trade_state' has no predecessor related
Business Path.
Business Link.
trade_state -- a Trade State category
"""
......@@ -323,7 +334,7 @@ class ITradePhaseProcess(Interface):
def getTradePhaseList():
"""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):
......@@ -379,7 +390,7 @@ class ITradePhaseProcess(Interface):
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
as part of a business process. This list is calculated by analysing
the graph of business path and trade states, starting from a given
......@@ -387,14 +398,14 @@ class ITradePhaseProcess(Interface):
method is useful mostly for production and MRP to manage a distributed
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
being collected - ???? useful ? XXX-JPS ?
NOTE: explanation is not involved here because we consider here that
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
simulation, we did not include the explanation. However, this makes the
API less uniform.
......@@ -402,7 +413,7 @@ class ITradePhaseProcess(Interface):
def getTradePhaseMovementList(explanation, amount, trade_phase=None, delay_mode=None):
"""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
on the Amount is used instead.
......@@ -417,7 +428,7 @@ class ITradePhaseProcess(Interface):
if no value specified use average delay
"""
class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
class IBusinessProcess(ITradeModelPathProcess, IBusinessLinkProcess, IBuildableBusinessLinkProcess,
ITradeStateProcess, ITradePhaseProcess, ):
"""Business Process interface specification.
......@@ -435,7 +446,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
"""
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
......@@ -443,7 +454,7 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
"""
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.
explanation -- an Order, Order Line, Delivery or Delivery Line or
......@@ -468,3 +479,5 @@ class IBusinessProcess(IBusinessPathProcess, IBuildableBusinessPathProcess,
buildable business path. Else
only build strictly buildable path.
"""
......@@ -27,7 +27,7 @@
#
##############################################################################
"""
Products.ERP5.interfaces.business_path
Products.ERP5.interfaces.explainable
"""
from zope.interface import Interface
......
......@@ -2,8 +2,7 @@
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Lukasz Nowak <luke@nexedi.com>
# Yusuke Muraoka <yusuke@nexedi.com>
# 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
......@@ -27,55 +26,28 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
"""
Products.ERP5.interfaces.trade_model_path
"""
class BusinessPath:
"""
Business Path properties
"""
_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' },
)
from zope.interface import Interface
class ITradeModelPath(Interface):
"""Trade Model Path interface specification
_categories = ('delivery_builder', 'order_builder', 'end_of',
'trade_phase' , 'incoterm')
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.
"""
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.
"""
# -*- coding: utf-8 -*-
# -*- coding: shift_jis -*-
##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
......@@ -45,7 +45,7 @@ class TestBPMMixin(ERP5TypeTestCase):
'erp5_invoicing', 'erp5_simplified_invoicing')
business_process_portal_type = 'Business Process'
business_path_portal_type = 'Business Path'
business_link_portal_type = 'Business Link'
normal_resource_use_category_list = ['normal']
invoicing_resource_use_category_list = ['discount', 'tax']
......@@ -79,16 +79,16 @@ class TestBPMMixin(ERP5TypeTestCase):
**kw)
@reindex
def createBusinessPath(self, business_process=None, **kw):
def createBusinessLink(self, business_process=None, **kw):
if business_process is None:
business_process = self.createBusinessProcess()
kw['destination_method_id'] = kw.pop('destination_method_id',
'BusinessPath_getDefaultDestinationList')
'BusinessLink_getDefaultDestinationList')
kw['source_method_id'] = kw.pop('source_method_id',
'BusinessPath_getDefaultSourceList')
business_path = business_process.newContent(
portal_type=self.business_path_portal_type, **kw)
return business_path
'BusinessLink_getDefaultSourceList')
business_link = business_process.newContent(
portal_type=self.business_link_portal_type, **kw)
return business_link
def createMovement(self):
# returns a movement for testing
......@@ -218,105 +218,105 @@ class TestBPMImplementation(TestBPMMixin):
def test_BusinessProcess_getPathValueList(self):
business_process = self.createBusinessProcess()
accounting_business_path = business_process.newContent(
portal_type=self.business_path_portal_type,
accounting_business_link = business_process.newContent(
portal_type=self.business_link_portal_type,
trade_phase='default/accounting')
delivery_business_path = business_process.newContent(
portal_type=self.business_path_portal_type,
delivery_business_link = business_process.newContent(
portal_type=self.business_link_portal_type,
trade_phase='default/delivery')
accounting_delivery_business_path = business_process.newContent(
portal_type=self.business_path_portal_type,
accounting_delivery_business_link = business_process.newContent(
portal_type=self.business_link_portal_type,
trade_phase=('default/accounting', 'default/delivery'))
self.stepTic()
self.assertSameSet(
(accounting_business_path, accounting_delivery_business_path),
(accounting_business_link, accounting_delivery_business_link),
business_process.getPathValueList(trade_phase='default/accounting')
)
self.assertSameSet(
(delivery_business_path, accounting_delivery_business_path),
(delivery_business_link, accounting_delivery_business_link),
business_process.getPathValueList(trade_phase='default/delivery')
)
self.assertSameSet(
(accounting_delivery_business_path, delivery_business_path,
accounting_business_path),
(accounting_delivery_business_link, delivery_business_link,
accounting_business_link),
business_process.getPathValueList(trade_phase=('default/delivery',
'default/accounting'))
)
def test_BusinessPathStandardCategoryAccessProvider(self):
def test_BusinessLinkStandardCategoryAccessProvider(self):
source_node = self.portal.organisation_module.newContent(
portal_type='Organisation')
source_section_node = self.portal.organisation_module.newContent(
portal_type='Organisation')
business_path = self.createBusinessPath()
business_path.setSourceValue(source_node)
business_path.setSourceSectionValue(source_section_node)
self.assertEquals([source_node], business_path.getSourceValueList())
self.assertEquals([source_node.getRelativeUrl()], business_path.getSourceList())
business_link = self.createBusinessLink()
business_link.setSourceValue(source_node)
business_link.setSourceSectionValue(source_section_node)
self.assertEquals([source_node], business_link.getSourceValueList())
self.assertEquals([source_node.getRelativeUrl()], business_link.getSourceList())
self.assertEquals(source_node.getRelativeUrl(),
business_path.getSource(default='something'))
business_link.getSource(default='something'))
def test_EmptyBusinessPathStandardCategoryAccessProvider(self):
business_path = self.createBusinessPath()
self.assertEquals(None, business_path.getSourceValue())
self.assertEquals(None, business_path.getSource())
def test_EmptyBusinessLinkStandardCategoryAccessProvider(self):
business_link = self.createBusinessLink()
self.assertEquals(None, business_link.getSourceValue())
self.assertEquals(None, business_link.getSource())
self.assertEquals('something',
business_path.getSource(default='something'))
business_link.getSource(default='something'))
def test_BuinessPathDynamicCategoryAccessProvider(self):
source_node = self.portal.organisation_module.newContent(
portal_type='Organisation')
source_section_node = self.portal.organisation_module.newContent(
portal_type='Organisation')
business_path = self.createBusinessPath()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList')
business_link = self.createBusinessLink()
business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
context_movement = self.createMovement()
context_movement.setSourceValue(source_node)
context_movement.setSourceSectionValue(source_section_node)
self.assertEquals(None, business_path.getSourceValue())
self.assertEquals(None, business_link.getSourceValue())
self.assertEquals([source_node],
business_path.getSourceValueList(context=context_movement))
business_link.getSourceValueList(context=context_movement))
self.assertEquals([source_node.getRelativeUrl()],
business_path.getSourceList(context=context_movement))
business_link.getSourceList(context=context_movement))
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(
portal_type='Organisation')
path_node = self.portal.organisation_module.newContent(
portal_type='Organisation')
business_path = self.createBusinessPath()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList')
business_path.setSourceValue(path_node)
business_link = self.createBusinessLink()
business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
business_link.setSourceValue(path_node)
context_movement = self.createMovement()
context_movement.setSourceValue(movement_node)
self.assertEquals(path_node, business_path.getSourceValue())
self.assertEquals(path_node, business_link.getSourceValue())
self.assertEquals(path_node,
business_path.getSourceValue(context=context_movement))
business_link.getSourceValue(context=context_movement))
self.assertEquals([path_node],
business_path.getSourceValueList(context=context_movement))
business_link.getSourceValueList(context=context_movement))
def test_BuinessPathDynamicCategoryAccessProviderEmptyMovement(self):
business_path = self.createBusinessPath()
business_path.setSourceMethodId('BusinessPath_getDefaultSourceList')
business_link = self.createBusinessLink()
business_link.setSourceMethodId('BusinessLink_getDefaultSourceList')
context_movement = self.createMovement()
self.assertEquals(None, business_path.getSourceValue())
self.assertEquals(None, business_link.getSourceValue())
self.assertEquals(None,
business_path.getSourceValue(context=context_movement))
business_link.getSourceValue(context=context_movement))
self.assertEquals(None,
business_path.getSource(context=context_movement))
business_link.getSource(context=context_movement))
self.assertEquals('something',
business_path.getSource(context=context_movement, default='something'))
business_link.getSource(context=context_movement, default='something'))
def test_BusinessState_getRemainingTradePhaseList(self):
"""
......@@ -344,41 +344,41 @@ class TestBPMImplementation(TestBPMMixin):
# define business process
category_tool = self.getCategoryTool()
business_process = self.createBusinessProcess()
business_path_a_b = self.createBusinessPath(business_process)
business_path_b_c = self.createBusinessPath(business_process)
business_path_b_d = self.createBusinessPath(business_process)
business_path_c_d = self.createBusinessPath(business_process)
business_path_d_e = self.createBusinessPath(business_process)
business_link_a_b = self.createBusinessLink(business_process)
business_link_b_c = self.createBusinessLink(business_process)
business_link_b_d = self.createBusinessLink(business_process)
business_link_c_d = self.createBusinessLink(business_process)
business_link_d_e = self.createBusinessLink(business_process)
business_state_a = category_tool.trade_state.state_a
business_state_b = category_tool.trade_state.state_b
business_state_c = category_tool.trade_state.state_c
business_state_d = category_tool.trade_state.state_d
business_state_e = category_tool.trade_state.state_e
business_path_a_b.setPredecessorValue(business_state_a)
business_path_b_c.setPredecessorValue(business_state_b)
business_path_b_d.setPredecessorValue(business_state_b)
business_path_c_d.setPredecessorValue(business_state_c)
business_path_d_e.setPredecessorValue(business_state_d)
business_path_a_b.setSuccessorValue(business_state_b)
business_path_b_c.setSuccessorValue(business_state_c)
business_path_b_d.setSuccessorValue(business_state_d)
business_path_c_d.setSuccessorValue(business_state_d)
business_path_d_e.setSuccessorValue(business_state_e)
business_link_a_b.setPredecessorValue(business_state_a)
business_link_b_c.setPredecessorValue(business_state_b)
business_link_b_d.setPredecessorValue(business_state_b)
business_link_c_d.setPredecessorValue(business_state_c)
business_link_d_e.setPredecessorValue(business_state_d)
business_link_a_b.setSuccessorValue(business_state_b)
business_link_b_c.setSuccessorValue(business_state_c)
business_link_b_d.setSuccessorValue(business_state_d)
business_link_c_d.setSuccessorValue(business_state_d)
business_link_d_e.setSuccessorValue(business_state_e)
# set title for debug
business_path_a_b.edit(title="a_b")
business_path_b_c.edit(title="b_c")
business_path_b_d.edit(title="b_d")
business_path_c_d.edit(title="c_d")
business_path_d_e.edit(title="d_e")
business_link_a_b.edit(title="a_b")
business_link_b_c.edit(title="b_c")
business_link_b_d.edit(title="b_d")
business_link_c_d.edit(title="c_d")
business_link_d_e.edit(title="d_e")
# 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)
business_path_b_c.edit(trade_phase=['default/delivery'])
business_path_b_d.edit(trade_phase=['default/invoicing'])
business_path_c_d.edit(trade_phase=['default/payment'])
business_path_d_e.edit(trade_phase=['default/accounting'])
business_link_b_c.edit(trade_phase=['default/delivery'])
business_link_b_d.edit(trade_phase=['default/invoicing'])
business_link_c_d.edit(trade_phase=['default/payment'])
business_link_d_e.edit(trade_phase=['default/accounting'])
# mock order
order = self.portal.sale_order_module.newContent(portal_type="Sale Order")
......@@ -391,20 +391,20 @@ class TestBPMImplementation(TestBPMMixin):
applied_rule = order.getCausalityRelatedValue()
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
applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_b_c,
causality_value=business_link_b_c,
order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_b_d,
causality_value=business_link_b_d,
order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_c_d,
causality_value=business_link_c_d,
order_value=order_line)
applied_rule.newContent(portal_type="Simulation Movement",
causality_value=business_path_d_e,
causality_value=business_link_d_e,
order_value=order_line)
self.stepTic()
......@@ -412,7 +412,7 @@ class TestBPMImplementation(TestBPMMixin):
trade_phase = self.portal.portal_categories.trade_phase.default
# 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,
trade_phase.invoicing,
trade_phase.payment,
......@@ -441,7 +441,7 @@ class TestBPMImplementation(TestBPMMixin):
trade_phase_list=['default/delivery',
'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
each path by explanation.
......@@ -469,36 +469,36 @@ class TestBPMImplementation(TestBPMMixin):
# define business process
category_tool = self.getCategoryTool()
business_process = self.createBusinessProcess()
business_path_a_b = self.createBusinessPath(business_process)
business_path_b_c = self.createBusinessPath(business_process)
business_path_b_d = self.createBusinessPath(business_process)
business_path_c_d = self.createBusinessPath(business_process)
business_path_d_e = self.createBusinessPath(business_process)
business_link_a_b = self.createBusinessLink(business_process)
business_link_b_c = self.createBusinessLink(business_process)
business_link_b_d = self.createBusinessLink(business_process)
business_link_c_d = self.createBusinessLink(business_process)
business_link_d_e = self.createBusinessLink(business_process)
business_state_a = category_tool.trade_state.state_a
business_state_b = category_tool.trade_state.state_b
business_state_c = category_tool.trade_state.state_c
business_state_d = category_tool.trade_state.state_d
business_state_e = category_tool.trade_state.state_e
business_path_a_b.setPredecessorValue(business_state_a)
business_path_b_c.setPredecessorValue(business_state_b)
business_path_b_d.setPredecessorValue(business_state_b)
business_path_c_d.setPredecessorValue(business_state_c)
business_path_d_e.setPredecessorValue(business_state_d)
business_path_a_b.setSuccessorValue(business_state_b)
business_path_b_c.setSuccessorValue(business_state_c)
business_path_b_d.setSuccessorValue(business_state_d)
business_path_c_d.setSuccessorValue(business_state_d)
business_path_d_e.setSuccessorValue(business_state_e)
business_link_a_b.setPredecessorValue(business_state_a)
business_link_b_c.setPredecessorValue(business_state_b)
business_link_b_d.setPredecessorValue(business_state_b)
business_link_c_d.setPredecessorValue(business_state_c)
business_link_d_e.setPredecessorValue(business_state_d)
business_link_a_b.setSuccessorValue(business_state_b)
business_link_b_c.setSuccessorValue(business_state_c)
business_link_b_d.setSuccessorValue(business_state_d)
business_link_c_d.setSuccessorValue(business_state_d)
business_link_d_e.setSuccessorValue(business_state_e)
business_process.edit(referential_date='stop_date')
business_path_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_path_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_path_d_e.edit(title='d_e', lead_time=4, wait_time=2)
business_link_a_b.edit(title='a_b', lead_time=2, wait_time=1)
business_link_b_c.edit(title='b_c', lead_time=2, wait_time=1)
business_link_b_d.edit(title='b_d', lead_time=3, wait_time=1)
business_link_c_d.edit(title='c_d', lead_time=3, wait_time=0)
business_link_d_e.edit(title='d_e', lead_time=4, wait_time=2)
# root explanation
business_path_b_d.edit(deliverable=True)
business_link_b_d.edit(deliverable=True)
self.stepTic()
"""
......@@ -516,18 +516,18 @@ class TestBPMImplementation(TestBPMMixin):
mock = Mock(base_date)
# root explanation.
self.assertEquals(business_path_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.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_link_b_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9'))
# assertion for each path without root explanation.
self.assertEquals(business_path_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_path_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_path_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_path_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_a_b.getExpectedStartDate(mock), DateTime('2009/03/27 GMT+9'))
self.assertEquals(business_link_a_b.getExpectedStopDate(mock), DateTime('2009/03/29 GMT+9'))
self.assertEquals(business_link_b_c.getExpectedStartDate(mock), DateTime('2009/03/30 GMT+9'))
self.assertEquals(business_link_b_c.getExpectedStopDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_link_c_d.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_link_c_d.getExpectedStopDate(mock), DateTime('2009/04/04 GMT+9'))
self.assertEquals(business_link_d_e.getExpectedStartDate(mock), DateTime('2009/04/06 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,
......@@ -536,11 +536,11 @@ class TestBPMImplementation(TestBPMMixin):
How we know which is referential, currently implementation of it can be known by
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.
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/03 GMT+9
"""
......@@ -555,19 +555,19 @@ class TestBPMImplementation(TestBPMMixin):
base_date = DateTime('2009/04/01 GMT+9')
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'
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.
self.assertEquals(business_path_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_path_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_path_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_path_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_a_b.getExpectedStartDate(mock), DateTime('2009/03/29 GMT+9'))
self.assertEquals(business_link_a_b.getExpectedStopDate(mock), DateTime('2009/03/31 GMT+9'))
self.assertEquals(business_link_b_c.getExpectedStartDate(mock), DateTime('2009/04/01 GMT+9'))
self.assertEquals(business_link_b_c.getExpectedStopDate(mock), DateTime('2009/04/03 GMT+9'))
self.assertEquals(business_link_c_d.getExpectedStartDate(mock), DateTime('2009/04/03 GMT+9'))
self.assertEquals(business_link_c_d.getExpectedStopDate(mock), DateTime('2009/04/06 GMT+9'))
self.assertEquals(business_link_d_e.getExpectedStartDate(mock), DateTime('2009/04/08 GMT+9'))
self.assertEquals(business_link_d_e.getExpectedStopDate(mock), DateTime('2009/04/12 GMT+9'))
class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
def _createDelivery(self, **kw):
......@@ -609,19 +609,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
# path which is completed, as soon as related simulation movements are in
# proper state
self.order_path = self.createBusinessPath(business_process,
self.order_path = self.createBusinessLink(business_process,
successor_value = ordered,
trade_phase='default/order',
completed_state_list = self.completed_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,
trade_phase='default/delivery',
completed_state_list = self.completed_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,
trade_phase='default/invoicing')
self.stepTic()
......@@ -633,19 +633,19 @@ class TestBPMDummyDeliveryMovementMixin(TestBPMMixin):
delivered = category_tool.trade_state.delivered
invoiced = category_tool.trade_state.invoiced
self.order_path = self.createBusinessPath(business_process,
self.order_path = self.createBusinessLink(business_process,
successor_value = ordered,
trade_phase='default/order',
completed_state_list = self.completed_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,
trade_phase='default/invoicing',
completed_state_list = self.completed_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,
trade_phase='default/delivery')
self.stepTic()
......@@ -769,7 +769,7 @@ class TestBPMisBuildableImplementation(TestBPMDummyDeliveryMovementMixin):
self.assertEquals(invoicing_simulation_movement.isBuildable(), 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.delivery_path.isBuildable(delivery), False)
......
# -*- coding: utf-8 -*-
# -*- coding: shift_jis -*-
##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
......@@ -505,7 +505,7 @@ class TestBPMEvaluationDefaultProcessMixin:
referential_date='start_date')
self._setTradeStateList()
self.order_path = self.createBusinessPath(self.business_process,
self.order_path = self.createBusinessLink(self.business_process,
successor_value=self.ordered_state,
trade_phase='default/order',
deliverable=1,
......@@ -513,7 +513,7 @@ class TestBPMEvaluationDefaultProcessMixin:
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,
successor_value=self.delivered_state,
trade_phase='default/delivery',
......@@ -523,7 +523,7 @@ class TestBPMEvaluationDefaultProcessMixin:
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,
successor_value=self.invoiced_state,
completed_state_list=['delivered'],
......@@ -531,14 +531,14 @@ class TestBPMEvaluationDefaultProcessMixin:
delivery_builder='portal_deliveries/bpm_sale_invoice_builder',
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,
successor_value=self.accounted_state,
completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'],
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,
successor_value=self.accounted_state,
completed_state_list=['delivered'],
......@@ -553,7 +553,7 @@ class TestBPMEvaluationDifferentProcessMixin:
referential_date='start_date')
self._setTradeStateList()
self.order_path = self.createBusinessPath(self.business_process,
self.order_path = self.createBusinessLink(self.business_process,
successor_value=self.ordered_state,
trade_phase='default/order',
deliverable=1,
......@@ -561,28 +561,28 @@ class TestBPMEvaluationDifferentProcessMixin:
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,
successor_value=self.invoiced_state,
completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'],
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,
successor_value=self.accounted_state,
completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'],
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,
successor_value=self.paid_state,
completed_state_list=['delivered'],
frozen_state_list=['stopped', 'delivered'],
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,
successor_value=self.delivered_state,
trade_phase='default/delivery',
......
# -*- coding: utf-8 -*-
# -*- coding: shift_jis -*-
##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
......@@ -35,9 +35,9 @@ import unittest
# manually and treated as reference to what implements what
implements_tuple_list = [
(('Products.ERP5Type.Document.RoleDefinition', 'RoleDefinition'), 'ILocalRoleGenerator'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'IArrowBase'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'IBusinessPath'),
(('Products.ERP5Type.Document.BusinessPath','BusinessPath'), 'ICategoryAccessProvider'),
(('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'IArrowBase'),
(('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'IBusinessLink'),
(('Products.ERP5Type.Document.BusinessLink','BusinessLink'), 'ICategoryAccessProvider'),
(('Products.ERP5Type.Document.TradeCondition','TradeCondition'), 'IAmountGenerator'),
(('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IAmountGenerator'),
(('Products.ERP5Type.Document.TradeModelCell','TradeModelCell'), 'IVariated'),
......@@ -84,8 +84,8 @@ addTestMethodDynamically(TestERP5Interfaces, implements_tuple_list)
for failing_method in [
'test_Products.ERP5.AggregatedAmountList_AggregatedAmountList_implements_IAmountList',
'test_Products.ERP5Type.Document.BusinessPath_BusinessPath_implements_IBusinessPath',
'test_Products.ERP5Type.Document.BusinessPath_BusinessPath_implements_ICategoryAccessProvider',
'test_Products.ERP5Type.Document.BusinessLink_BusinessLink_implements_IBusinessLink',
'test_Products.ERP5Type.Document.BusinessLink_BusinessLink_implements_ICategoryAccessProvider',
'test_Products.ERP5Type.Document.TradeCondition_TradeCondition_implements_IAmountGenerator',
'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IAmountGenerator',
'test_Products.ERP5Type.Document.TradeModelCell_TradeModelCell_implements_IVariated',
......
......@@ -57,9 +57,9 @@ class TestERP5SimulationMixin(TestInvoiceMixin):
def setUpBusinessProcess(self):
business_process = self.portal.business_process_module.erp5_default_business_process
pay_business_path = business_process['pay']
pay_business_path.setSource('account_module/bank')
pay_business_path.setDestination('account_module/bank')
pay_business_link = business_process['pay']
pay_business_link.setSource('account_module/bank')
pay_business_link.setDestination('account_module/bank')
@UnrestrictedMethod
def createInvoiceTransactionRule(self, resource=None):
......
......@@ -158,8 +158,8 @@ class TestMRPMixin(TestBPMMixin):
ready -------- partial_produced ------- done
"""
business_process = self.createBusinessProcess()
business_path_p2 = self.createBusinessPath(business_process)
business_path_p3 = self.createBusinessPath(business_process)
business_link_p2 = self.createBusinessLink(business_process)
business_link_p3 = self.createBusinessLink(business_process)
business_state_ready = self.createBusinessState(business_process)
business_state_partial = self.createBusinessState(business_process)
business_state_done = self.createBusinessState(business_process)
......@@ -171,7 +171,7 @@ class TestMRPMixin(TestBPMMixin):
destination = self.createOrganisation(title='destination')
business_process.edit(referential_date='stop_date')
business_path_p2.edit(id='p2',
business_link_p2.edit(id='p2',
predecessor_value=business_state_ready,
successor_value=business_state_partial,
quantity=1,
......@@ -181,7 +181,7 @@ class TestMRPMixin(TestBPMMixin):
destination_section_value=destination_section,
destination_value=destination,
)
business_path_p3.edit(id='p3',
business_link_p3.edit(id='p3',
predecessor_value=business_state_partial,
successor_value=business_state_done,
quantity=1,
......@@ -201,8 +201,8 @@ class TestMRPMixin(TestBPMMixin):
mrp/p3
"""
business_process = self.createBusinessProcess()
business_path_p2 = self.createBusinessPath(business_process)
business_path_p3 = self.createBusinessPath(business_process)
business_link_p2 = self.createBusinessLink(business_process)
business_link_p3 = self.createBusinessLink(business_process)
business_state_ready = self.createBusinessState(business_process)
business_state_partial = self.createBusinessState(business_process)
......@@ -213,7 +213,7 @@ class TestMRPMixin(TestBPMMixin):
destination = self.createOrganisation(title='destination')
business_process.edit(referential_date='stop_date')
business_path_p2.edit(id='p2',
business_link_p2.edit(id='p2',
predecessor_value=business_state_ready,
successor_value=business_state_partial,
quantity=1,
......@@ -223,7 +223,7 @@ class TestMRPMixin(TestBPMMixin):
destination_section_value=destination_section,
destination_value=destination,
)
business_path_p3.edit(id='p3',
business_link_p3.edit(id='p3',
predecessor_value=business_state_ready,
successor_value=business_state_partial,
quantity=1,
......@@ -280,7 +280,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations
path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0]
portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection()
source = path.getSource()
destination_section = path.getDestinationSection()
......@@ -344,7 +344,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations
path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0]
portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection()
source = path.getSource()
destination_section = path.getDestinationSection()
......@@ -413,7 +413,7 @@ class TestMRPImplementation(TestMRPMixin, ERP5TypeTestCase):
# organisations
path = business_process.objectValues(
portal_type=self.portal.getPortalBusinessPathTypeList())[0]
portal_type=self.portal.getPortalBusinessLinkTypeList())[0]
source_section = path.getSourceSection()
source = path.getSource()
destination_section = path.getDestinationSection()
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
......@@ -36,9 +37,9 @@ import transaction
class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin):
BUSINESS_PATH_CREATION_SEQUENCE_STRING = """
CreateBusinessProcess
CreateBusinessPath
CreateBusinessLink
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModifyBusinessLinkTradePhase
ModelSpecialiseBusinessProcess
Tic
"""
......@@ -841,14 +842,14 @@ class TestPayrollMixin(ERP5ReportTestCase, TestTradeModelLineMixin):
node.edit(title='Urssaf de Roubaix Tourcoing')
sequence.edit(urssaf_roubaix = node)
def stepModifyBusinessPathTradePhase(self, sequence=None, **kw):
business_path = sequence.get('business_path')
business_path.setTradePhaseList(['payroll/france/urssaf',
def stepModifyBusinessLinkTradePhase(self, sequence=None, **kw):
business_link = sequence.get('business_link')
business_link.setTradePhaseList(['payroll/france/urssaf',
'payroll/france/labour'])
business_path.setSourceValue(sequence.get('urssaf_roubaix'))
business_path.setSourceSectionValue(sequence.get('urssaf_roubaix'))
business_path.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',))
sequence.edit(business_path=business_path)
business_link.setSourceValue(sequence.get('urssaf_roubaix'))
business_link.setSourceSectionValue(sequence.get('urssaf_roubaix'))
business_link.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',))
sequence.edit(business_link=business_link)
def stepModelSpecialiseBusinessProcess(self, sequence=None, **kw):
model = sequence.get('model')
......@@ -3240,9 +3241,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency
CreateLabourOutputService
CreateBusinessProcess
CreateBusinessPath
CreateBusinessLink
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModifyBusinessLinkTradePhase
Tic
CheckModelWithoutRefValidity
"""
......@@ -3260,9 +3261,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency
CreateLabourOutputService
CreateBusinessProcess
CreateBusinessPath
CreateBusinessLink
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModifyBusinessLinkTradePhase
Tic
CheckModelWithoutDateValidity
"""
......@@ -3278,9 +3279,9 @@ class TestPayroll(TestPayrollMixin):
CreatePriceCurrency
CreateLabourOutputService
CreateBusinessProcess
CreateBusinessPath
CreateBusinessLink
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModifyBusinessLinkTradePhase
Tic
CheckModelDateValidity
"""
......@@ -3295,9 +3296,9 @@ class TestPayroll(TestPayrollMixin):
sequence_string = """
CreatePriceCurrency
CreateBusinessProcess
CreateBusinessPath
CreateBusinessLink
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModifyBusinessLinkTradePhase
Tic
CheckModelVersioning
"""
......
# -*- coding: utf-8 -*-
# -*- coding: shift_jis -*-
##############################################################################
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Łukasz Nowak <luke@nexedi.com>
......@@ -56,9 +56,9 @@ class TestTradeModelLineMixin(TestBPMMixin):
sequence.edit(business_process=self.createBusinessProcess(
title=self.id()))
def stepCreateBusinessPath(self, sequence=None, **kw):
def stepCreateBusinessLink(self, sequence=None, **kw):
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):
quiet = True
......@@ -101,10 +101,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
AGGREGATED_AMOUNT_LIST_COMMON_SEQUENCE_STRING = \
COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess
CreateBusinessPath
ModifyBusinessPathTaxing
CreateBusinessPath
ModifyBusinessPathDiscounting
CreateBusinessLink
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -195,35 +195,35 @@ class TestTradeModelLine(TestTradeModelLineMixin):
portal_type='Trade Model Line',
**kw)
def stepModifyBusinessPathDiscounting(self, sequence=None, **kw):
def stepModifyBusinessLinkDiscounting(self, sequence=None, **kw):
category_tool = self.getCategoryTool()
predecessor = category_tool.trade_state.invoiced
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, successor)
business_path.edit(
business_link.edit(
predecessor_value = predecessor,
successor_value = successor,
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()
predecessor = category_tool.trade_state.invoiced
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, successor)
business_path.edit(
business_link.edit(
predecessor_value = predecessor,
successor_value = successor,
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):
invoice = sequence.get('invoice')
......@@ -506,15 +506,15 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineDiscountedTaxedSimulation(self, sequence=None, **kw):
order_line = sequence.get('order_line_discounted_taxed')
business_path_discounting = sequence.get('business_path_discounting')
business_path_taxing = sequence.get('business_path_taxing')
business_link_discounting = sequence.get('business_link_discounting')
business_link_taxing = sequence.get('business_link_taxing')
price_currency = sequence.get('price_currency')
service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount')
self.assertNotEqual(None, business_path_discounting)
self.assertNotEqual(None, business_path_taxing)
self.assertNotEqual(None, business_link_discounting)
self.assertNotEqual(None, business_link_taxing)
self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \
......@@ -537,7 +537,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
self.assertEqual(
business_path_discounting,
business_link_discounting,
trade_model_simulation_movement_discount_complex.getCausalityValue()
)
......@@ -578,7 +578,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
self.assertEqual(
business_path_taxing,
business_link_taxing,
trade_model_simulation_movement_tax_complex.getCausalityValue()
)
......@@ -606,15 +606,15 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineDiscountedSimulation(self, sequence=None, **kw):
order_line = sequence.get('order_line_discounted')
business_path_discounting = sequence.get('business_path_discounting')
business_path_taxing = sequence.get('business_path_taxing')
business_link_discounting = sequence.get('business_link_discounting')
business_link_taxing = sequence.get('business_link_taxing')
price_currency = sequence.get('price_currency')
service_tax = sequence.get('service_tax')
service_discount = sequence.get('service_discount')
self.assertNotEqual(None, business_path_discounting)
self.assertNotEqual(None, business_path_taxing)
self.assertNotEqual(None, business_link_discounting)
self.assertNotEqual(None, business_link_taxing)
self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \
......@@ -637,7 +637,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
self.assertEqual(
business_path_discounting,
business_link_discounting,
trade_model_simulation_movement_discount_only.getCausalityValue()
)
......@@ -671,7 +671,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
trade_model_simulation_movement_tax_only.getTotalPrice())
self.assertEqual(
business_path_taxing,
business_link_taxing,
trade_model_simulation_movement_tax_only.getCausalityValue()
)
......@@ -700,9 +700,9 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def stepCheckOrderLineTaxedSimulation(self, sequence=None, **kw):
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')
self.assertNotEqual(None, business_path)
self.assertNotEqual(None, business_link)
self.assertNotEqual(None, price_currency)
for trade_model_simulation_movement_list in \
self.getTradeModelSimulationMovementList(order_line):
......@@ -717,7 +717,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
)
self.assertEqual(
business_path,
business_link,
trade_model_simulation_movement.getCausalityValue()
)
......@@ -1447,10 +1447,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
ORDER_SPECIALISE_AGGREGATED_AMOUNT_COMMON_SEQUENCE_STRING = \
COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess
CreateBusinessPath
ModifyBusinessPathTaxing
CreateBusinessPath
ModifyBusinessPathDiscounting
CreateBusinessLink
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -1876,10 +1876,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
sequence_list = SequenceList()
sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess
CreateBusinessPath
ModifyBusinessPathTaxing
CreateBusinessPath
ModifyBusinessPathDiscounting
CreateBusinessLink
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -1937,10 +1937,10 @@ class TestTradeModelLine(TestTradeModelLineMixin):
sequence_list = SequenceList()
sequence_string = self.COMMON_DOCUMENTS_CREATION_SEQUENCE_STRING + """
CreateBusinessProcess
CreateBusinessPath
ModifyBusinessPathTaxing
CreateBusinessPath
ModifyBusinessPathDiscounting
CreateBusinessLink
ModifyBusinessLinkTaxing
CreateBusinessLink
ModifyBusinessLinkDiscounting
CreateTradeCondition
SpecialiseTradeConditionWithBusinessProcess
CreateTradeModelLine
......@@ -1970,7 +1970,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def test_BuildTradeModelLineAndAccountingFromOrder(self):
business_process = self.createBusinessProcess()
business_path = self.createBusinessPath(business_process,
business_link = self.createBusinessLink(business_process,
trade_phase='default/tax')
product = self.createResource('Product',
......@@ -2070,7 +2070,7 @@ class TestTradeModelLine(TestTradeModelLineMixin):
def test_BuildTradeModelLineAndAccountingFromInvoice(self):
business_process = self.createBusinessProcess()
business_path = self.createBusinessPath(business_process,
business_link = self.createBusinessLink(business_process,
trade_phase='default/tax')
product = self.createResource('Product',
......
......@@ -267,7 +267,7 @@ class ERP5TypeInformation(XMLObject,
'divergence_tester', 'target_solver',
'amount_generator', 'amount_generator_line', 'amount_generator_cell',
# Business Processes
'business_path', 'business_process',
'trade_model_path', 'business_link', 'business_process',
# Movement Group
'movement_group',
# 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