Commit c8d98375 authored by Jérome Perrin's avatar Jérome Perrin

payment_mean: constraint for PaymentTransactionGroup

This constraint will have to be enabled by configurator/upgrader.
parent 2dab75b8
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaymentTransactionGroupConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>payment_mode</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Category\', )</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Payment mode must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>payment_mode_category_existence_constraint</string> </value>
</item>
<item>
<key> <string>message_category_not_set</string> </key>
<value> <string>Payment Mode must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Existence Constraint</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>payment_transaction_group_type</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Category\', )</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Payment Transaction Group Type must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>payment_transaction_group_type_category_existence_constraint</string> </value>
</item>
<item>
<key> <string>message_category_not_set</string> </key>
<value> <string>Payment Transaction Group Type must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Existence Constraint</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>price_currency</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Currency\', )</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Currency must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>price_currency_category_existence_constraint</string> </value>
</item>
<item>
<key> <string>message_category_not_set</string> </key>
<value> <string>Currency must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Existence Constraint</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>source_payment</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: object.getPortalPaymentNodeTypeList()</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Source payment must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>source_payment_category_existence_constraint</string> </value>
</item>
<item>
<key> <string>message_category_not_set</string> </key>
<value> <string>Section bank account must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Existence Constraint</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>source_section</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Organisation\', )</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Source section must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>source_section_category_existence_constraint</string> </value>
</item>
<item>
<key> <string>message_category_not_set</string> </key>
<value> <string>Section must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Existence Constraint</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>stop_date</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Date must be defined</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>stop_date_constraint</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Date must be defined</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Date must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Existence Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -25,8 +25,11 @@ ...@@ -25,8 +25,11 @@
# #
############################################################################## ##############################################################################
from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestPaymentTransactionGroup(ERP5TypeTestCase): class TestPaymentTransactionGroup(ERP5TypeTestCase):
def test_source_reference_generated(self): def test_source_reference_generated(self):
ptg = self.portal.payment_transaction_group_module.newContent( ptg = self.portal.payment_transaction_group_module.newContent(
...@@ -42,3 +45,99 @@ class TestPaymentTransactionGroup(ERP5TypeTestCase): ...@@ -42,3 +45,99 @@ class TestPaymentTransactionGroup(ERP5TypeTestCase):
# a new source reference # a new source reference
self.assertNotEqual( self.assertNotEqual(
ptg.getSourceReference(), cloned_ptg.getSourceReference()) ptg.getSourceReference(), cloned_ptg.getSourceReference())
class TestPaymentTransactionGroupConstraint(ERP5TypeTestCase):
def afterSetUp(self):
ti = self.portal.portal_types['Payment Transaction Group']
ti.setTypePropertySheetList(
ti.getTypePropertySheetList() + ['PaymentTransactionGroupConstraint'])
self.commit()
def beforeTearDown(self):
self.abort()
ti = self.portal.portal_types['Payment Transaction Group']
ti.setTypePropertySheetList(
[ps for ps in ti.getTypePropertySheetList() if ps != 'PaymentTransactionGroupConstraint'])
self.commit()
def test_constraints(self):
ptg = self.portal.payment_transaction_group_module.newContent(
portal_type='Payment Transaction Group',
stop_date=None,
)
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Currency must be defined',
'Date must be defined',
'Payment Mode must be defined',
'Payment Transaction Group Type must be defined',
'Section bank account must be defined',
'Section must be defined',
],
)
ptg.setPriceCurrencyValue(
self.portal.currency_module.newContent(portal_type='Currency'))
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Date must be defined',
'Payment Mode must be defined',
'Payment Transaction Group Type must be defined',
'Section bank account must be defined',
'Section must be defined',
],
)
ptg.setStopDate(DateTime(2021, 1, 1))
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Payment Mode must be defined',
'Payment Transaction Group Type must be defined',
'Section bank account must be defined',
'Section must be defined',
],
)
ptg.setPaymentModeValue(
self.portal.portal_categories.payment_mode.newContent(portal_type='Category'))
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Payment Transaction Group Type must be defined',
'Section bank account must be defined',
'Section must be defined',
],
)
ptg.setPaymentTransactionGroupTypeValue(
self.portal.portal_categories.payment_transaction_group_type.incoming)
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Section bank account must be defined',
'Section must be defined',
],
)
section = self.portal.organisation_module.newContent(
portal_type='Organisation'
)
ptg.setSourceSectionValue(section)
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[
'Section bank account must be defined',
],
)
bank_account = section.newContent(
portal_type='Bank Account'
)
ptg.setSourcePaymentValue(bank_account)
self.assertEqual(
sorted([str(m.getMessage()) for m in ptg.checkConsistency()]),
[])
PaymentTransactionGroupConstraint
\ 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