Commit f05f3ba1 authored by Vincent Pelletier's avatar Vincent Pelletier

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
parent e94ef25f
......@@ -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>
......
<?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>
<?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>
......@@ -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>
......
......@@ -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>
......
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