Commit 9c8400c8 authored by Arnaud Fontaine's avatar Arnaud Fontaine

BusinessProcess: Fix getPreviousPhaseDict() for BL with >1 children/parents BLs.

Called by TransformationSimulationRule and did not work with the
following use case:

  BL(trade_phase=TP1, successor=trade_state/TS1):
    * child_BL1(predecessor=trade_state/TS1,
                trade_phase=TP1/InventoryAccounting)
    * child_BL2(predecessor=trade_state/TS1,
                trade_phase=Transforming)
parent 214a5d3c
...@@ -875,11 +875,15 @@ class BusinessProcess(Path, XMLObject): ...@@ -875,11 +875,15 @@ class BusinessProcess(Path, XMLObject):
# i.e. edit next phases to replace current phase by previous ones # i.e. edit next phases to replace current phase by previous ones
for next in next_set: for next in next_set:
phase_set = result[next] phase_set = result[next]
phase_set.remove(phase) # Not remove() as it may have already been removed earlier
# if >1 elements of next_set have the same parent
phase_set.discard(phase)
phase_set |= previous_set phase_set |= previous_set
# and previous phases to replace current by next ones # and previous phases to replace current by next ones
for previous in previous_set: for previous in previous_set:
phase_set = next_dict[previous] phase_set = next_dict[previous]
phase_set.remove(phase) # Not remove() as it may have already been removed earlier
# if >1 elements of previous_set have the same child
phase_set.discard(phase)
phase_set |= next_set phase_set |= next_set
return result return result
...@@ -475,6 +475,67 @@ class TestBPMImplementation(TestBPMDummyDeliveryMovementMixin): ...@@ -475,6 +475,67 @@ class TestBPMImplementation(TestBPMDummyDeliveryMovementMixin):
business_process.getRemainingTradePhaseList( business_process.getRemainingTradePhaseList(
business_process.invoice)) business_process.invoice))
def test_BusinessState_getPreviousTradePhaseDict(self):
"""
Test for getPreviousTradePhaseDict() and use case for Business
Links with multiple children (in this test, deliver BL has 2
children: invoice and tax BL having deliver BL as predecessor).
"""
category_tool = self.getCategoryTool()
business_process = self.createBusinessProcess()
business_link_order = self.createBusinessLink(business_process,
title='order', id='order',
trade_phase='default/order')
business_link_deliver = self.createBusinessLink(business_process,
title='deliver', id='deliver',
trade_phase='default/delivery')
business_link_invoice = self.createBusinessLink(business_process,
title='invoice', id='invoice',
trade_phase='default/invoicing')
business_link_tax = self.createBusinessLink(business_process,
title='tax', id='tax',
trade_phase='default/tax')
business_link_account = self.createBusinessLink(business_process,
title='accounting', id='account',
trade_phase='default/accounting')
trade_state = category_tool.trade_state
business_link_order.setSuccessorValue(trade_state.ordered)
business_link_deliver.setPredecessorValue(trade_state.ordered)
business_link_deliver.setSuccessorValue(trade_state.delivered)
business_link_invoice.setPredecessorValue(trade_state.delivered)
business_link_invoice.setSuccessorValue(trade_state.invoiced)
business_link_tax.setPredecessorValue(trade_state.delivered)
business_link_tax.setSuccessorValue(trade_state.invoiced)
business_link_account.setPredecessorValue(trade_state.invoiced)
business_link_account.setSuccessorValue(trade_state.accounted)
trade_phase = category_tool.trade_phase.default
def _u(trade_phase):
return trade_phase.getCategoryRelativeUrl()
self.assertEqual(
{_u(trade_phase.order): set(),
_u(trade_phase.delivery): {_u(trade_phase.order)},
_u(trade_phase.invoicing): {_u(trade_phase.delivery)},
_u(trade_phase.tax): {_u(trade_phase.delivery)},
_u(trade_phase.accounting): {_u(trade_phase.invoicing), _u(trade_phase.tax)}},
business_process.getPreviousTradePhaseDict())
self.assertEqual(
{_u(trade_phase.order): set(),
_u(trade_phase.invoicing): {_u(trade_phase.order)},
_u(trade_phase.accounting): {_u(trade_phase.invoicing), _u(trade_phase.order)}},
business_process.getPreviousTradePhaseDict(
trade_phase_list=[_u(trade_phase.order),
_u(trade_phase.invoicing),
_u(trade_phase.accounting)]))
self.assertEqual(
{_u(trade_phase.accounting): set()},
business_process.getPreviousTradePhaseDict(
trade_phase_list=[_u(trade_phase.accounting)]))
def test_BusinessProcess_getExpectedTradeModelPathStartAndStopDate(self): def test_BusinessProcess_getExpectedTradeModelPathStartAndStopDate(self):
""" """
This test case is described for what start/stop date is expected on This test case is described for what start/stop date is expected on
......
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