Commit bb0617e8 authored by Łukasz Nowak's avatar Łukasz Nowak

Improve rule testing.

Share and improve common logic: if Business Process does not provide links for
rule's trade phase do not apply.
parent 834f4c4c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
business_link = movement.getCausalityValue(portal_type=\'Business Link\')\n
\n
if len(business_link.getParentValue().getBusinessLinkValueList(trade_phase=rule.getTradePhaseList())) == 0:\n
# If Business Process does not define invoicing do not apply\n
return False\n
\n
if movement.getSimulationState() in business_link.getCompletedStateList():\n
return True\n
\n
return False\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>rule</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SimulationMovement_testCommonRule</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,12 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
if movement.getSimulationState() in movement.getCausalityValue(portal_type=\'Business Link\').getCompletedStateList():\n
return True\n
\n
return False\n
<value> <string>return context.SimulationMovement_testCommonRule(rule)\n
</string> </value>
</item>
<item>
......
......@@ -52,10 +52,7 @@
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
business_link = movement.getCausalityValue(portal_type=\'Business Link\')\n
\n
if len(business_link.getParentValue().getBusinessLinkValueList(trade_phase=rule.getTradePhaseList())) == 0:\n
# If Business Process does not define invoicing do not apply\n
if not movement.SimulationMovement_testCommonRule(rule):\n
return False\n
\n
source_section = movement.getSourceSection()\n
......@@ -64,10 +61,7 @@ if source_section == destination_section or source_section is None \\\n
or destination_section is None:\n
return False\n
\n
if movement.getSimulationState() in business_link.getCompletedStateList():\n
return True\n
\n
return False\n
return True\n
</string> </value>
</item>
<item>
......
......@@ -52,16 +52,16 @@
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
if not movement.SimulationMovement_testCommonRule(rule):\n
return False\n
\n
delivery_movement = movement.getDeliveryValue()\n
if delivery_movement is not None and (\n
delivery_movement.getPortalType() not in movement.getPortalInvoiceMovementTypeList()\n
and delivery_movement.getPortalType() not in movement.getPortalTaxMovementTypeList()):\n
return False\n
\n
if movement.getSimulationState() in movement.getCausalityValue(portal_type=\'Business Link\').getCompletedStateList():\n
return True\n
\n
return False\n
return True\n
</string> </value>
</item>
<item>
......
......@@ -52,6 +52,11 @@
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
movement = context\n
\n
if not movement.SimulationMovement_testCommonRule(rule):\n
return False\n
\n
# XXX hardcoded\n
receivable_account_type_list = (\'asset/receivable\',)\n
payable_account_type_list = (\'liability/payable\',)\n
......@@ -60,9 +65,6 @@ if movement.getQuantity() == 0:\n
# do not create empty payment movements\n
return False\n
\n
if movement.getSimulationState() not in movement.getCausalityValue(portal_type=\'Business Link\').getCompletedStateList():\n
return False\n
\n
for account in (movement.getSourceValue(portal_type=\'Account\'),\n
movement.getDestinationValue(portal_type=\'Account\')):\n
if account is not None:\n
......
......@@ -52,6 +52,9 @@
<key> <string>_body</string> </key>
<value> <string>movement = context\n
\n
if not movement.SimulationMovement_testCommonRule(rule):\n
return False\n
\n
parent = movement.getParentValue()\n
if parent.getPortalType() != \'Applied Rule\':\n
return False\n
......@@ -61,10 +64,7 @@ if parent_rule.getPortalType() not in (\'Invoice Root Simulation Rule\',\n
\'Invoice Simulation Rule\'):\n
return False\n
\n
if movement.getSimulationState() in movement.getCausalityValue(portal_type=\'Business Link\').getCompletedStateList():\n
return True\n
\n
return False\n
return True\n
</string> </value>
</item>
<item>
......
397
\ No newline at end of file
398
\ No newline at end of file
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