Commit ccf57f64 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Support of new check numbers.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36701 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9b6bf66f
......@@ -6,6 +6,7 @@
</portal_type>
<portal_type id="Check Payment">
<item>ItemAggregation</item>
<item>CheckPayment</item>
<item>Price</item>
</portal_type>
<portal_type id="Checkbook Delivery">
......
##############################################################################
#
# 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 CheckPayment:
"""
CheckPayment properties for all ERP5 objects
"""
_properties = (
{ 'id' : 'unique_per_account',
'description' : 'If the check has an number that must be unique per account',
'type' : 'boolean',
'mode' : 'w' },
)
......@@ -99,6 +99,7 @@
<string>my_destination_payment_title</string>
<string>my_source</string>
<string>my_source_total_asset_price</string>
<string>my_unique_per_account</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_unique_per_account</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> <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>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>Old version</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -104,6 +104,7 @@
<list>
<string>my_price_currency</string>
<string>my_composition</string>
<string>my_unique_per_account</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_unique_per_account</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> <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>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>Unique per account</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -129,11 +129,11 @@ def assertReferenceMatchListEmpty(match_list, destination_payment_uid):\n
mapping={\'reference_list\': matched_reference_list})\n
raise ValidationFailed, (message,)\n
\n
def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_uid):\n
def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_uid, unique_per_account):\n
"""\n
Check each given reference not to already exist.\n
"""\n
if destination_payment_uid is None:\n
if destination_payment_uid is None or not unique_per_account:\n
match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, default_resource_uid=model_uid, simulation_state=\'!=deleted\')\n
else:\n
match_list = portal.portal_catalog(portal_type=\'Check\', reference=reference_list, destination_payment_uid=destination_payment_uid, default_resource_uid=model_uid,\n
......@@ -148,11 +148,11 @@ def checkReferenceListUniqueness(reference_list, model_uid, destination_payment_
raise ValidationFailed, (message,)\n
encountered_check_identifiers_dict[tag] = None\n
\n
def checkReferenceUniqueness(reference, model_uid, destination_payment_uid):\n
def checkReferenceUniqueness(reference, model_uid, destination_payment_uid, unique_per_account):\n
"""\n
Check the given reference not to already exist.\n
"""\n
checkReferenceListUniqueness([reference, ], model_uid, destination_payment_uid)\n
checkReferenceListUniqueness([reference, ], model_uid, destination_payment_uid, unique_per_account=unique_per_account)\n
\n
start_date = checkbook_reception.getStartDate()\n
destination = checkbook_reception.getDestination()\n
......@@ -206,6 +206,7 @@ else:\n
destination_payment_value = None\n
destination_payment_uid = None\n
\n
unique_per_account = resource.isUniquePerAccount()\n
aggregate_list = []\n
for i in xrange(quantity):\n
if create == 1:\n
......@@ -220,7 +221,7 @@ for i in xrange(quantity):\n
reference_list = [int_to_reference(x, reference_range_min) for x in range(reference_to_int(reference_range_min), last_reference_value + 1)]\n
reference_range_max = int_to_reference(last_reference_value, reference_range_min)\n
if check == 1:\n
checkReferenceListUniqueness(reference_list, model_uid, destination_payment_uid)\n
checkReferenceListUniqueness(reference_list, model_uid, destination_payment_uid, unique_per_account)\n
if create == 1:\n
item.setReferenceRangeMax(reference_range_max)\n
item.setReferenceRangeMin(reference_range_min)\n
......@@ -245,7 +246,7 @@ for i in xrange(quantity):\n
else:\n
last_reference_value = reference_to_int(reference_range_min)\n
if check == 1:\n
checkReferenceUniqueness(reference_range_min, model_uid, destination_payment_uid)\n
checkReferenceUniqueness(reference_range_min, model_uid, destination_payment_uid, unique_per_account)\n
if create == 1:\n
item.setReference(reference_range_min)\n
item.setResource(model)\n
......@@ -367,6 +368,7 @@ return encountered_check_identifiers_dict\n
<string>ValueError</string>
<string>destination_payment_uid</string>
<string>destination_trade</string>
<string>unique_per_account</string>
<string>aggregate_list</string>
<string>_getiter_</string>
<string>xrange</string>
......
......@@ -72,14 +72,19 @@ if destination_id is None:\n
# serialize destination vault to only have one operation at a time\n
destination_value = context.getDestinationValue()\n
destination_value.serialize()\n
line_list = context.objectValues(portal_type=\'Checkbook Reception Line\')\n
\n
# first check that there is not a particular tag\n
checkbook_reception_tag = "CheckbookReception_%s" % destination_id\n
if context.portal_activities.countMessageWithTag(checkbook_reception_tag) != 0:\n
for line in line_list:\n
if not line.getResourceValue().isUniquePerAccount():\n
checkbook_reception_tag = "CheckbookReception_global"\n
msg = Message(domain=\'ui\', message=\'Sorry, there is already a pending checkbook reception\')\n
break\n
else:\n
msg = Message(domain=\'ui\', message=\'Sorry, there is already a checkbook reception newly validated\')\n
checkbook_reception_tag = "CheckbookReception_%s" % destination_id\n
if context.portal_activities.countMessageWithTag(checkbook_reception_tag) != 0:\n
raise ValidationFailed, (msg, )\n
\n
line_list = context.objectValues(portal_type=\'Checkbook Reception Line\')\n
if check == 1:\n
encountered_check_identifiers_dict = {}\n
for line in line_list:\n
......@@ -139,11 +144,11 @@ if create==1:\n
<string>None</string>
<string>msg</string>
<string>destination_value</string>
<string>checkbook_reception_tag</string>
<string>line_list</string>
<string>encountered_check_identifiers_dict</string>
<string>_getiter_</string>
<string>line</string>
<string>checkbook_reception_tag</string>
<string>encountered_check_identifiers_dict</string>
</tuple>
</value>
</item>
......
......@@ -107,12 +107,11 @@ if bank_account is None:\n
\n
# Check the check.\n
check_number = transaction.getAggregateFreeText()\n
check_resource = transaction.getAggregateResource()\n
\n
# Automated calculation of the aggregate resource\n
if check_resource is None:\n
check_resource = transaction.Base_getCheckModelByBankAccount(\n
bank_account=bank_account).getRelativeUrl()\n
# always verify check model as the version may have changed\n
version = transaction.isUniquePerAccount() and 1 or 2\n
check_resource = bank_account.BankAccount_getCheckModel(version=version).getRelativeUrl()\n
if transaction.getAggregateResource() != check_resource:\n
transaction.edit(aggregate_resource=check_resource)\n
\n
if not check_number:\n
......@@ -213,9 +212,10 @@ elif error[\'error_code\'] != 0:\n
<string>price</string>
<string>bank_account</string>
<string>check_number</string>
<string>version</string>
<string>check_resource</string>
<string>check</string>
<string>context</string>
<string>check</string>
<string>error</string>
</tuple>
</value>
......
Check Deposit | Amount
Check Deposit | CheckDeposit
Check Deposit | Price
Check Payment | CheckPayment
Check Payment | ItemAggregation
Check Payment | Price
Checkbook Delivery | Amount
......
StopPayment
CheckbookReception
CheckDeposit
\ No newline at end of file
CheckDeposit
CheckPayment
\ No newline at end of file
......@@ -907,15 +907,17 @@ class TestERP5BankingMixin(ERP5TypeTestCase):
reference_range_max = max,
start_date = date)
def createCheckbookModel(self, id, check_model, reference=None):
def createCheckbookModel(self, id, check_model, reference=None, version=1):
"""
Create a checkbook for the given bank account
with 3 variations
"""
unique_per_account = version == 1
model = self.checkbook_model_module.newContent(id = id,
portal_type = 'Checkbook Model',
title='Generic',
account_number_enabled=True,
unique_per_account=unique_per_account,
reference=reference,
composition=check_model.getRelativeUrl())
model.newContent(id='variant_1', portal_type='Checkbook Model Check Amount Variation',
......@@ -927,15 +929,17 @@ class TestERP5BankingMixin(ERP5TypeTestCase):
return model
def createCheckModel(self, id, reference='CCOP'):
def createCheckModel(self, id, reference='CCOP', version=1):
"""
Create a checkbook for the given bank account
"""
unique_per_account = version == 1
return self.checkbook_model_module.newContent(id = id,
portal_type = 'Check Model',
title = 'Check',
reference = reference,
account_number_enabled=True,
unique_per_account=unique_per_account
)
def createCheckAndCheckbookModel(self):
......@@ -945,11 +949,31 @@ class TestERP5BankingMixin(ERP5TypeTestCase):
self.check_model = self.createCheckModel(id='check_model')
self.check_model_1 = self.check_model
self.check_model_2 = self.createCheckModel(id='check_model_2', reference='CCCO')
self.check_model_1_2 = self.createCheckModel(
id='check_model_1_2',
reference='CCOP2',
version=2,
)
self.check_model_2_2 = self.createCheckModel(
id='check_model_2_2',
reference='CCCO2',
version=2,
)
self.checkbook_model = self.createCheckbookModel(
id='checkbook_model', check_model=self.check_model)
self.checkbook_model_1 = self.checkbook_model
self.checkbook_model_2 = self.createCheckbookModel(
id='checkbook_model_2', check_model=self.check_model_2)
self.checkbook_model_1_2 = self.createCheckbookModel(
id='checkbook_model_1_2',
check_model=self.check_model_1_2,
version=2,
)
self.checkbook_model_2_2 = self.createCheckbookModel(
id='checkbook_model_2_2',
check_model=self.check_model_2_2,
version=2,
)
def createCheck(self, id, reference, checkbook, bank_account=None,
resource_value=None, destination_value=None):
......
......@@ -222,7 +222,8 @@ class TestERP5BankingCheckPaymentMixin(TestERP5BankingMixin):
description = "test",
# source_value = self.bi_counter,
start_date = DateTime().Date(),
source_total_asset_price = 20000.0)
source_total_asset_price = 20000.0,
unique_per_account=True)
# call set source to go into the interaction workflow to update local roles
self.check_payment._setSource(self.bi_counter.getRelativeUrl())
self.assertNotEqual(self.check_payment, None)
......
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