Commit d585c356 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

clean up code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32008 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a6e95021
......@@ -37,11 +37,18 @@ from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class DeliveryRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
"""
Delivery Rule object make sure an Delivery in the simulation
is consistent with the real delivery
WARNING: what to do with movement split ?
"""
# CMF Type Definition
meta_type = 'ERP5 Delivery Rule'
portal_type = 'Delivery Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,38 +71,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class DeliveryRule(Rule):
"""
Delivery Rule object make sure an Delivery in the simulation
is consistent with the real delivery
WARNING: what to do with movement split ?
"""
# CMF Type Definition
meta_type = 'ERP5 Delivery Rule'
portal_type = 'Delivery Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
......@@ -39,9 +39,17 @@ from Products.ERP5.mixin.movement_collection_updater import \
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
from Products.ERP5.Document.PredicateMatrix import PredicateMatrix
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class InvoiceTransactionRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate, PredicateMatrix):
"""
Invoice Transaction Rule object generates accounting movements for
each invoice movement based on category membership and other
predicated. Template accounting movements are stored in cells inside
an instance of the InvoiceTransactionRule.
"""
# CMF Type Definition
meta_type = 'ERP5 Invoice Transaction Rule'
portal_type = 'Invoice Transaction Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,38 +72,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class InvoiceTransactionRule(Rule, PredicateMatrix):
"""
Invoice Transaction Rule object generates accounting movements for
each invoice movement based on category membership and other
predicated. Template accounting movements are stored in cells inside
an instance of the InvoiceTransactionRule.
"""
# CMF Type Definition
meta_type = 'ERP5 Invoice Transaction Rule'
portal_type = 'Invoice Transaction Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
......@@ -37,11 +37,15 @@ from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class InvoicingRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
"""
Invoicing Rule expand simulation created by a order or delivery rule.
"""
# CMF Type Definition
meta_type = 'ERP5 Invoicing Rule'
portal_type = 'Invoicing Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,35 +68,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class InvoicingRule(Rule):
"""
Invoicing Rule expand simulation created by a order or delivery rule.
"""
# CMF Type Definition
meta_type = 'ERP5 Invoicing Rule'
portal_type = 'Invoicing Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
......@@ -37,11 +37,18 @@ from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class OrderRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
"""
Order Rule object make sure an Order in the simulation
is consistent with the real order
WARNING: what to do with movement split ?
"""
# CMF Type Definition
meta_type = 'ERP5 Order Rule'
portal_type = 'Order Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,38 +71,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class OrderRule(Rule):
"""
Order Rule object make sure an Order in the simulation
is consistent with the real order
WARNING: what to do with movement split ?
"""
# CMF Type Definition
meta_type = 'ERP5 Order Rule'
portal_type = 'Order Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
......@@ -37,11 +37,16 @@ from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class PaymentRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
"""
Payment Rule generates payment simulation movement from invoice
transaction simulation movements.
"""
# CMF Type Definition
meta_type = 'ERP5 Payment Rule'
portal_type = 'Payment Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,36 +69,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class PaymentRule(Rule):
"""
Payment Rule generates payment simulation movement from invoice
transaction simulation movements.
"""
# CMF Type Definition
meta_type = 'ERP5 Payment Rule'
portal_type = 'Payment Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
......@@ -37,11 +37,15 @@ from Products.ERP5.mixin.rule import RuleMixin
from Products.ERP5.mixin.movement_collection_updater import \
MovementCollectionUpdaterMixin
from Products.ERP5.mixin.movement_generator import MovementGeneratorMixin
from Products.ERP5.MovementCollectionDiff import _getPropertyAndCategoryList
# XXX this class should be moved to Rule.py once new simulation is fully
# integrated.
class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
class TradeModelRule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
"""
Rule for Trade Model
"""
# CMF Type Definition
meta_type = 'ERP5 Trade Model Rule'
portal_type = 'Trade Model Rule'
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -64,35 +68,6 @@ class Rule(RuleMixin, MovementCollectionUpdaterMixin, Predicate):
PropertySheet.Rule
)
security.declareProtected(Permissions.View, 'getDivergenceList')
def getDivergenceList(self, movement):
"""
Returns a list of divergences of the movements provided
in delivery_or_movement.
movement -- a movement, a delivery, a simulation movement,
or a list thereof
"""
if movement.getDelivery() is None:
return []
result_list = []
for divergence_tester in self._getDivergenceTesterList(
exclude_quantity=False):
result = divergence_tester.explain(movement)
if isinstance(result, (list, tuple)): # for compatibility
result_list.extend(result)
elif result is not None:
result_list.append(result)
return result_list
class TradeModelRule(Rule):
"""
Rule for Trade Model
"""
# CMF Type Definition
meta_type = 'ERP5 Trade Model Rule'
portal_type = 'Trade Model Rule'
def _getMovementGenerator(self):
"""
Return the movement generator to use in the expand process
......
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