Commit 87679a96 authored by Vincent Pelletier's avatar Vincent Pelletier

Allow defining no check on a CheckDepositLine, but only is a manager enabled...

Allow defining no check on a CheckDepositLine, but only is a manager enabled it on parent document. In that case, disable all check-related verifications and their validation.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24993 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c7f4a806
##############################################################################
#
# Copyright (c) 2002-2007 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
class CheckDeposit:
"""
CheckDeposit properties for all ERP5 objects
"""
_properties = (
{ 'id' : 'check_less',
'description' : 'When true, disable check number verification on lines.',
'type' : 'boolean',
'mode' : 'w' },
)
<?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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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 AccessControl import getSecurityManager\n
return getSecurityManager().getUser().has_permission(\'Manage portal\', context)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>AccessControl</string>
<string>getSecurityManager</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>Base_isUserManager</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -120,6 +120,7 @@
<list>
<string>my_start_date</string>
<string>my_description</string>
<string>my_check_less</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_check_less</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Disable check reference verification</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/Base_isUserManager</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -67,9 +67,10 @@
<key> <string>_body</string> </key>
<value> <string>transaction = state_change[\'object\']\n
\n
for check_operation_line in transaction.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
check = check_operation_line.getAggregateValue()\n
check.deliver()\n
if not transaction.isCheckLess():\n
for check_operation_line in transaction.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
check = check_operation_line.getAggregateValue()\n
check.deliver()\n
</string> </value>
</item>
<item>
......@@ -115,8 +116,8 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
<string>state_change</string>
<string>_getitem_</string>
<string>transaction</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>_getiter_</string>
<string>check_operation_line</string>
<string>check</string>
</tuple>
......
......@@ -118,6 +118,8 @@ if state_change[\'transition\'].getId() == "wait_action":\n
bank_account_dict = {}\n
seen_check_dict = {}\n
\n
is_check_less = transaction.isCheckLess()\n
\n
# Check each check operation line.\n
for check_operation_line in transaction.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
\n
......@@ -126,39 +128,52 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
check_number = check_operation_line.getAggregateFreeText()\n
if not check_number:\n
msg = Message(domain=\'ui\', message=\'Check is not defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
check_type = check_operation_line.getAggregateResource()\n
if check_type is None:\n
msg = Message(domain=\'ui\', message=\'Check type is not defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
\n
source_bank_account = check_operation_line.getSourcePaymentValue()\n
if source_bank_account is None:\n
msg = Message(domain=\'ui\', message=\'Bank account not defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
seen_check_dict_key = (source_bank_account, check_type, check_number)\n
seen_check = seen_check_dict.get(seen_check_dict_key)\n
if seen_check is not None:\n
msg = Message(domain=\'ui\', message=\'Check on line $line is already used on line $oldline.\'\n
, mapping={"line" : check_operation_line.getId(), "oldline": seen_check})\n
raise ValidationFailed, (msg,)\n
seen_check_dict[seen_check_dict_key] = check_operation_line.getId()\n
check_number = check_operation_line.getAggregateFreeText()\n
check_type = check_operation_line.getAggregateResource()\n
if is_check_less:\n
if check_number:\n
msg = Message(domain=\'ui\', message=\'Check is defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
# Test check is valid based on date\n
transaction.Check_checkIntervalBetweenDate(resource=check_operation_line.getAggregateResourceValue(),\n
start_date=check_operation_line.getIssueDate(),\n
stop_date=check_operation_line.getStopDate(),\n
check_nb=check_operation_line.getAggregateFreeText())\n
\n
if check_type is not None:\n
msg = Message(domain=\'ui\', message=\'Check type is defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
else:\n
if not check_number:\n
msg = Message(domain=\'ui\', message=\'Check is not defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
if check_type is None:\n
msg = Message(domain=\'ui\', message=\'Check type is not defined on line $line.\'\n
, mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
\n
seen_check_dict_key = (source_bank_account, check_type, check_number)\n
seen_check = seen_check_dict.get(seen_check_dict_key)\n
if seen_check is not None:\n
msg = Message(domain=\'ui\', message=\'Check on line $line is already used on line $oldline.\'\n
, mapping={"line" : check_operation_line.getId(), "oldline": seen_check})\n
raise ValidationFailed, (msg,)\n
seen_check_dict[seen_check_dict_key] = check_operation_line.getId()\n
\n
# Test check is valid based on date\n
transaction.Check_checkIntervalBetweenDate(resource=check_operation_line.getAggregateResourceValue(),\n
start_date=check_operation_line.getIssueDate(),\n
stop_date=check_operation_line.getStopDate(),\n
check_nb=check_operation_line.getAggregateFreeText())\n
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
......@@ -180,11 +195,6 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
elif error[\'error_code\'] != 0:\n
msg = Message(domain=\'ui\', message="Unknown error code.")\n
raise ValidationFailed, (msg,)\n
\n
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
if transaction.getSimulationState() == "draft" and state_change[\'transition\'].getId() == "plan_action":\n
context.createCheckDepositLine(state_change)\n
......@@ -259,18 +269,19 @@ if transaction.getSimulationState() == "draft" and state_change[\'transition\'].
<string>context</string>
<string>bank_account_dict</string>
<string>seen_check_dict</string>
<string>is_check_less</string>
<string>_getiter_</string>
<string>check_operation_line</string>
<string>source_bank_account</string>
<string>check_number</string>
<string>check_type</string>
<string>source_bank_account</string>
<string>seen_check_dict_key</string>
<string>seen_check</string>
<string>_write_</string>
<string>check</string>
<string>account_path</string>
<string>check_price</string>
<string>error</string>
<string>check</string>
</tuple>
</value>
</item>
......
416
\ No newline at end of file
418
\ No newline at end of file
StopPayment
CheckbookReception
\ No newline at end of file
CheckbookReception
CheckDeposit
\ 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