Commit 14da89cc authored by Jean-Paul Smets's avatar Jean-Paul Smets

Changes in this commit are the consequence of discussion between JPS and YO on...

Changes in this commit are the consequence of discussion between JPS and YO on the split of business path into business link and trade model path.
The notion of "completion date" does not make much sense anymore in a context in which Business Link are unrelated to dates. Instead, we provide helpers to gather lists and stats of simulation movements of an expanded simulation tree. This should be equivalet for usability at user level, with appropriate reports. The notion of "expected start date and stop date" is kept because it is useful. It is only related to Trade Model Path. A mockup (non working) implementation is provided and supports a bit of recursion so that it can handle the case of transformations. Various security declarations were added.
Next commit will make this work if everyone agrees on interfaces.

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@36833 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eac4b445
This diff is collapsed.
......@@ -203,8 +203,8 @@ class ExplanationCache:
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
- take all link of composed business link (even not yet expanded)
- take all link of composed business link which phase is not yet expanded
"""
# Try to return cached value first
new_business_process = self.closure_cache.get(business_link, None)
......@@ -271,6 +271,43 @@ class ExplanationCache:
self.union_cache = new_business_process
return new_business_process
def getReferenceDate(self, business_process, trade_phase, reference_date_method_id, delay_mode=None):
"""Browse parent similation movements until a movement with
appropriate trade_phase is found.
"""
# Find simulation movements with appropriate trade_phase
movement_list = self.getSimulationMovementValueList(trade_phase=trade_phase)
# Case 1: some (parent) simulation movement with appropriate trade phase exists
if len(movement_list):
# XXX-JPS - for now take arbitrary one
# but we should in reality some way to configure this
movement = movement_list[0]
method = getattr(movement, reference_date_method_id)
return method()
# Case 2: we must recursively find another trade phase
# to find the value recursively
# XXX-JPS this is only useful for production (MRP) in reality
# whenever trade model path define time constraints within the same
# movement generator (ie. transformation with multiple phases)
path_list = business_process.getTradeModelPathValueList(trade_phase=trade_phase)
if not len(path_list):
raise ValueError('No Trade Model Path defines a reference data.')
path = path_list[0]
# XXX-JPS - for now take arbitrary one
# but we should in reality some way to configure this
start_date, stop_date = business_process.getExpectedTradeModelPathStartAndStopDate(
self.explanation, path, delay_mode=delay_mode)
# Create a fake simulation movement and lookup property
movement = self.explanation.newContent(portal_type="Simulation Movement",
temp_object=True,
start_date=start_date, stop_date=stop_date,
trade_phase=trade_phase, causality=path)
method = getattr(movement, reference_date_method_id)
return method()
def _getExplanationCache(explanation):
# Return cached value if any
......
......@@ -33,11 +33,6 @@ class BusinessLink:
Business Link properties
"""
_properties = (
{ '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',
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2009 Nexedi SA and Contributors. All Rights Reserved.
# Lukasz Nowak <luke@nexedi.com>
# Yusuke Muraoka <yusuke@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.
#
##############################################################################
class TradeModelPath:
"""
Trade Model Path properties
"""
_properties = (
{ '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' : 'reference_date_method_id',
'description' : 'ID of method to get the reference date at the trade_phase defined by trade_date',
'type' : 'string',
'default' : 'getStopDate',
'mode' : 'w' },
)
_categories = ('end_of', # XXX-JPS What is end_of ????
'trade_phase' , 'incoterm') # XXX-JPS why incoterm ?
This diff is collapsed.
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