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

validate on 'date' not start_date / stop_date, if one is missing, the other

will be filled automatically.

really set *all* lines to account_type/cash/bank in test for payment.

don't test destination only transactions, as it's not supposed to be supported
today.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8192 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 475d308f
...@@ -42,7 +42,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -42,7 +42,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG from zLOG import LOG
from testPackingList import TestPackingListMixin
from Products.ERP5Type.tests.Sequence import Sequence, SequenceList from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
from DateTime import DateTime from DateTime import DateTime
...@@ -712,23 +711,15 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -712,23 +711,15 @@ class TestAccounting(ERP5TypeTestCase):
receivable = receivable receivable = receivable
) )
def stepValidateNoStartDate(self, sequence, sequence_list=None, **kw) : def stepValidateNoDate(self, sequence, sequence_list=None, **kw) :
"""When no start date is defined, validation should be impossible """When no date is defined, validation should be impossible.
because of the source_section side."""
transaction = sequence.get('transaction') Actually, we could say that if we have source_section, we need start_date,
old_date = transaction.getStartDate() and if we have destination section, we need stop_date only, but we decided
transaction.setStartDate(None) to update a date (of start_date / stop_date) using the other one if one is
self.assertRaises(ValidationFailed, missing. (ie. stop_date defaults automatically to start_date if not set and
self.getWorkflowTool().doActionFor, start_date is set to stop_date in the workflow script if not set.
transaction, """
'stop_action')
transaction.setStartDate(old_date)
self.getWorkflowTool().doActionFor(transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped')
def stepValidateNoStopDate(self, sequence, sequence_list=None, **kw) :
"""When no stop date is defined, validation should be impossible
because of the destination_section side."""
transaction = sequence.get('transaction') transaction = sequence.get('transaction')
old_stop_date = transaction.getStopDate() old_stop_date = transaction.getStopDate()
old_start_date = transaction.getStartDate() old_start_date = transaction.getStartDate()
...@@ -786,7 +777,10 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -786,7 +777,10 @@ class TestAccounting(ERP5TypeTestCase):
# if we do not use any payable / receivable account, then we can # if we do not use any payable / receivable account, then we can
# validate the transaction without setting the mirror section. # validate the transaction without setting the mirror section.
for side in (SOURCE, DESTINATION) : for side in (SOURCE, ): # DESTINATION) :
# TODO: for now, we only test for source, as it makes no sense to use for
# destination section only. We could theoritically support it.
# get a new valid transaction # get a new valid transaction
self.stepCreateValidAccountingTransaction(sequence) self.stepCreateValidAccountingTransaction(sequence)
transaction = sequence.get('transaction') transaction = sequence.get('transaction')
...@@ -952,16 +946,22 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -952,16 +946,22 @@ class TestAccounting(ERP5TypeTestCase):
`payment node` portal type group. It can be defined on transaction `payment node` portal type group. It can be defined on transaction
or line. or line.
""" """
def useBankAccount(transaction):
"""Modify the transaction, so that a line will use an account member of
account_type/cash/bank , which requires to use a payment category.
"""
# get the default and replace income account by bank
income_account_found = 0
for line in transaction.getMovementList() :
source_account = line.getSourceValue()
if source_account.isMemberOf('account_type/income') :
income_account_found = 1
line.edit( source_value = sequence.get('bank_account'),
destination_value = sequence.get('bank_account') )
self.failUnless(income_account_found)
transaction = sequence.get('transaction') transaction = sequence.get('transaction')
# get the default and replace income account by bank useBankAccount(transaction)
income_account_found = 0
for line in transaction.getMovementList() :
source_account = line.getSourceValue()
if source_account.isMemberOf('account_type/income') :
income_account_found = 1
line.edit( source_value = sequence.get('bank_account'),
destination_value = sequence.get('bank_account') )
self.failUnless(income_account_found)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, transaction,
...@@ -976,6 +976,8 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -976,6 +976,8 @@ class TestAccounting(ERP5TypeTestCase):
portal_type = ptype, ) portal_type = ptype, )
self.stepCreateValidAccountingTransaction(sequence) self.stepCreateValidAccountingTransaction(sequence)
transaction = sequence.get('transaction') transaction = sequence.get('transaction')
useBankAccount(transaction)
# payment node have to be set on both sides # payment node have to be set on both sides
transaction.setSourcePaymentValue(source_payment_value) transaction.setSourcePaymentValue(source_payment_value)
transaction.setDestinationPaymentValue(None) transaction.setDestinationPaymentValue(None)
...@@ -1155,9 +1157,7 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -1155,9 +1157,7 @@ class TestAccounting(ERP5TypeTestCase):
stepCreateCurrencies stepCreateCurrencies
stepCreateAccounts stepCreateAccounts
stepCreateValidAccountingTransaction stepCreateValidAccountingTransaction
stepValidateNoStartDate stepValidateNoDate""")
stepCreateValidAccountingTransaction
stepValidateNoStopDate""")
def test_AccountingTransactionValidationSection(self, quiet=0, def test_AccountingTransactionValidationSection(self, quiet=0,
run=RUN_ALL_TESTS): run=RUN_ALL_TESTS):
......
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