From f05f3ba10eac02e84b8929877831d7793fed13f3 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Mon, 18 Oct 2010 14:57:06 +0000 Subject: [PATCH] Remove conditions on current transition id. This makes it easier to understand this workflow. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39285 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../scripts/validateConsistency.xml | 37 +--- .../scripts/validatePlanActionConsistency.xml | 169 ++++++++++++++++++ .../scripts/validateWaitActionConsistency.xml | 134 ++++++++++++++ .../transitions/plan_action.xml | 2 +- .../transitions/wait_action.xml | 2 +- bt5/erp5_banking_check/bt/revision | 2 +- 6 files changed, 307 insertions(+), 39 deletions(-) create mode 100644 bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml create mode 100644 bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateWaitActionConsistency.xml diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml index 51d4311f42..1ed21d1c3c 100644 --- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml +++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateConsistency.xml @@ -98,12 +98,6 @@ if transaction.getTotalPrice(fast=0, portal_type = \'Check Operation Line\') != msg = Message(domain=\'ui\', message="Total price doesn\'t match.")\n raise ValidationFailed, (msg,)\n \n -# if manual validation, check overdreaft facility\n -if state_change[\'transition\'].getId() == "wait_action":\n - context.checkAccountIsOverdraftFacility(state_change)\n - \n -\n -bank_account_dict = {}\n seen_check_dict = {}\n \n is_check_less = transaction.isCheckLess()\n @@ -161,31 +155,7 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\' check = transaction.Base_checkCheck(bank_account=source_bank_account, reference=check_number,\n resource=check_type)\n if check_operation_line.getAggregate() != check.getRelativeUrl():\n - check_operation_line.edit(aggregate=check.getRelativeUrl()) \n - \n - # Test if the account balance is sufficient.\n - if state_change[\'transition\'].getId() == "plan_action":\n - account_path = source_bank_account.getRelativeUrl()\n - if bank_account_dict.has_key(account_path):\n - check_price = bank_account_dict[account_path] + check_operation_line.getPrice() \n - else:\n - check_price = check_operation_line.getPrice()\n - bank_account_dict[account_path] = check_price\n - error = context.BankAccount_checkBalance(account_path, check_price)\n - if error[\'error_code\'] == 1:\n - msg = Message(domain=\'ui\', message="Bank account $account is not sufficient on line $line.",\n - mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n - raise ValidationFailed, (msg,)\n - elif error[\'error_code\'] == 2:\n - msg = Message(domain=\'ui\', message="Bank account $account is not valid on $line.",\n - mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n - raise ValidationFailed, (msg,)\n - elif error[\'error_code\'] != 0:\n - msg = Message(domain=\'ui\', message="Unknown error code.")\n - raise ValidationFailed, (msg,)\n -\n -if transaction.getSimulationState() == "draft" and state_change[\'transition\'].getId() == "plan_action":\n - context.createCheckDepositLine(state_change)\n + check_operation_line.edit(aggregate=check.getRelativeUrl())\n ]]></string> </value> @@ -248,8 +218,6 @@ if transaction.getSimulationState() == "draft" and state_change[\'transition\']. <string>msg</string> <string>price</string> <string>destination_bank_account</string> - <string>context</string> - <string>bank_account_dict</string> <string>seen_check_dict</string> <string>is_check_less</string> <string>_getiter_</string> @@ -261,9 +229,6 @@ if transaction.getSimulationState() == "draft" and state_change[\'transition\']. <string>seen_check</string> <string>_write_</string> <string>check</string> - <string>account_path</string> - <string>check_price</string> - <string>error</string> </tuple> </value> </item> diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml new file mode 100644 index 0000000000..5a9590385b --- /dev/null +++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validatePlanActionConsistency.xml @@ -0,0 +1,169 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </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>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n +from Products.ERP5Type.Message import Message\n +\n +transaction = state_change[\'object\']\n +\n +# Test if the account balance is sufficient.\n +bank_account_dict = {}\n +for check_operation_line in transaction.objectValues(portal_type=\'Check Operation Line\'):\n + account_path = check_operation_line.getSourcePaymentValue().getRelativeUrl()\n + bank_account_dict[account_path] = bank_account_dict.get(account_path, 0) + check_operation_line.getPrice()\n +for account_path, amount in bank_account_dict.items():\n + error = context.BankAccount_checkBalance(account_path, amount)[\'error_code\']\n + if error == 1:\n + raise ValidationFailed, (Message(domain=\'ui\', message="Bank account $account is not sufficient.",\n + mapping={"account": source_bank_account.getInternalBankAccountNumber()}), )\n + elif error == 2:\n + raise ValidationFailed, (Message(domain=\'ui\', message="Bank account $account is not valid.",\n + mapping={"account": source_bank_account.getInternalBankAccountNumber()}), )\n + elif error != 0:\n + raise ValidationFailed, (Message(domain=\'ui\', message="Unknown error code."),)\n +\n +context.validateConsistency(state_change)\n +\n +if transaction.getSimulationState() == "draft":\n + context.createCheckDepositLine(state_change)\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change</string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>state_change</string> + <string>Products.DCWorkflow.DCWorkflow</string> + <string>ValidationFailed</string> + <string>Products.ERP5Type.Message</string> + <string>Message</string> + <string>_getitem_</string> + <string>transaction</string> + <string>bank_account_dict</string> + <string>_getiter_</string> + <string>_getattr_</string> + <string>check_operation_line</string> + <string>account_path</string> + <string>_write_</string> + <string>amount</string> + <string>context</string> + <string>error</string> + <string>source_bank_account</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>validatePlanActionConsistency</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateWaitActionConsistency.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateWaitActionConsistency.xml new file mode 100644 index 0000000000..c6badb449f --- /dev/null +++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/scripts/validateWaitActionConsistency.xml @@ -0,0 +1,134 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </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># if manual validation, check overdreaft facility\n +context.checkAccountIsOverdraftFacility(state_change)\n +\n +context.validateConsistency(state_change)\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change</string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>state_change</string> + <string>_getattr_</string> + <string>context</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>validateWaitActionConsistency</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/plan_action.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/plan_action.xml index ab90c358e2..6fd1ab4a74 100644 --- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/plan_action.xml +++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/plan_action.xml @@ -45,7 +45,7 @@ </item> <item> <key> <string>script_name</string> </key> - <value> <string>validateConsistency</string> </value> + <value> <string>validatePlanActionConsistency</string> </value> </item> <item> <key> <string>title</string> </key> diff --git a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/wait_action.xml b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/wait_action.xml index 6f48d819ff..4355a1e496 100644 --- a/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/wait_action.xml +++ b/bt5/erp5_banking_check/WorkflowTemplateItem/portal_workflow/check_deposit_workflow/transitions/wait_action.xml @@ -45,7 +45,7 @@ </item> <item> <key> <string>script_name</string> </key> - <value> <string>validateConsistency</string> </value> + <value> <string>validateWaitActionConsistency</string> </value> </item> <item> <key> <string>title</string> </key> diff --git a/bt5/erp5_banking_check/bt/revision b/bt5/erp5_banking_check/bt/revision index 8b120bce8f..073c57b52b 100644 --- a/bt5/erp5_banking_check/bt/revision +++ b/bt5/erp5_banking_check/bt/revision @@ -1 +1 @@ -447 \ No newline at end of file +465 -- 2.30.9