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

Add constraints for Accounts


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18217 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f43fe5e0
......@@ -42,3 +42,25 @@ class Account:
)
_categories = ( 'account_type', 'gap', 'pcg', 'financial_section', )
_constraints = (
{ 'id': 'account_type_existance',
'description': 'Account Type must be set',
'type': 'CategoryMembershipArity',
'min_arity': 1,
'max_arity': 1,
'portal_type': ('Category', ),
'base_category' : ('account_type',),
'condition' : 'python: object.getValidationState() not'
' in ("invalidated", "deleted")'
},
{ 'id': 'gap_existance',
'description': 'GAP must be set',
'type': 'CategoryMembershipArity',
'min_arity': 1,
'portal_type': ('Category', ),
'base_category' : ('gap',),
'condition' : 'python: object.getValidationState() not'
' in ("invalidated", "deleted")'
},
)
......@@ -220,6 +220,31 @@ class AccountingTestCase(ERP5TypeTestCase):
'erp5_accounting_ui_test')
class TestAccounts(AccountingTestCase):
"""Tests Accounts.
"""
def test_AccountValidation(self):
# Accounts need a gap category and an account_type category to be valid
account = self.portal.account_module.newContent(portal_type='Account')
self.assertEquals(2, len(account.checkConsistency()))
account.setAccountType('equity')
self.assertEquals(1, len(account.checkConsistency()))
account.setGap('my_country/my_accounting_standards/1')
self.assertEquals(0, len(account.checkConsistency()))
def test_AccountWorkflow(self):
account = self.portal.account_module.newContent(portal_type='Account')
self.assertEquals('draft', account.getValidationState())
doActionFor = self.portal.portal_workflow.doActionFor
self.assertRaises(ValidationFailed, doActionFor, account,
'validate_action')
account.setAccountType('equity')
account.setGap('my_country/my_accounting_standards/1')
doActionFor(account, 'validate_action')
self.assertEquals('validated', account.getValidationState())
class TestTransactionValidation(AccountingTestCase):
"""Test validations of accounting transactions.
......@@ -2738,6 +2763,7 @@ class TestAccounting(ERP5TypeTestCase):
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestAccounting))
suite.addTest(unittest.makeSuite(TestAccounts))
suite.addTest(unittest.makeSuite(TestClosingPeriod))
suite.addTest(unittest.makeSuite(TestTransactionValidation))
return suite
......
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