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

some tests were using "transaction" as local variable name, and thus hiding the

transaction module 



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26966 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1e5ef10d
...@@ -305,7 +305,7 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -305,7 +305,7 @@ class TestTransactionValidation(AccountingTestCase):
def test_SaleInvoiceTransactionValidationDate(self): def test_SaleInvoiceTransactionValidationDate(self):
# Accounting Period Date matters for Sale Invoice Transaction # Accounting Period Date matters for Sale Invoice Transaction
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
start_date=DateTime('2006/03/03'), start_date=DateTime('2006/03/03'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -316,14 +316,14 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -316,14 +316,14 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because period is closed # validation is refused, because period is closed
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# in 2007, it's OK # in 2007, it's OK
transaction.setStartDate(DateTime("2007/03/03")) accounting_transaction.setStartDate(DateTime("2007/03/03"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_PurchaseInvoiceTransactionValidationDate(self): def test_PurchaseInvoiceTransactionValidationDate(self):
# Accounting Period Date matters for Purchase Invoice Transaction # Accounting Period Date matters for Purchase Invoice Transaction
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2006/03/03'), stop_date=DateTime('2006/03/03'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -334,14 +334,14 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -334,14 +334,14 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because period is closed # validation is refused, because period is closed
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# in 2007, it's OK # in 2007, it's OK
transaction.setStopDate(DateTime("2007/03/03")) accounting_transaction.setStopDate(DateTime("2007/03/03"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_PaymentTransactionValidationDate(self): def test_PaymentTransactionValidationDate(self):
# Accounting Period Date matters for Payment Transaction # Accounting Period Date matters for Payment Transaction
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Payment Transaction', portal_type='Payment Transaction',
start_date=DateTime('2006/03/03'), start_date=DateTime('2006/03/03'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -353,14 +353,14 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -353,14 +353,14 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because period is closed # validation is refused, because period is closed
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# in 2007, it's OK # in 2007, it's OK
transaction.setStartDate(DateTime("2007/03/03")) accounting_transaction.setStartDate(DateTime("2007/03/03"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_DestinationPaymentTransactionValidationDate(self): def test_DestinationPaymentTransactionValidationDate(self):
# Accounting Period Date matters for Payment Transaction # Accounting Period Date matters for Payment Transaction
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Payment Transaction', portal_type='Payment Transaction',
stop_date=DateTime('2006/03/03'), stop_date=DateTime('2006/03/03'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -373,15 +373,15 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -373,15 +373,15 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because period is closed # validation is refused, because period is closed
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# in 2007, it's OK # in 2007, it's OK
transaction.setStopDate(DateTime("2007/03/03")) accounting_transaction.setStopDate(DateTime("2007/03/03"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_UnusedSectionTransactionValidationDate(self): def test_UnusedSectionTransactionValidationDate(self):
# If a section doesn't have any accounts on its side, we don't check the # If a section doesn't have any accounts on its side, we don't check the
# accounting period dates # accounting period dates
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2006/03/03'), start_date=DateTime('2006/03/03'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -397,16 +397,16 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -397,16 +397,16 @@ class TestTransactionValidation(AccountingTestCase):
# 2006 is closed for destination_section # 2006 is closed for destination_section
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# If we don't have accounts on destination side, validating transaction is # If we don't have accounts on destination side, validating transaction is
# not refused # not refused
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
line.setDestination(None) line.setDestination(None)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_AccountingTransactionValidationStartDate(self): def test_AccountingTransactionValidationStartDate(self):
# Check we can/cannot validate at date boundaries of the period # Check we can/cannot validate at date boundaries of the period
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2006/12/31'), start_date=DateTime('2006/12/31'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -418,13 +418,13 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -418,13 +418,13 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because period is closed # validation is refused, because period is closed
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
transaction.setStartDate(DateTime("2007/01/01")) accounting_transaction.setStartDate(DateTime("2007/01/01"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_AccountingTransactionValidationBeforePeriod(self): def test_AccountingTransactionValidationBeforePeriod(self):
# Check we cannot validate before the period # Check we cannot validate before the period
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2003/12/31'), start_date=DateTime('2003/12/31'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -436,11 +436,11 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -436,11 +436,11 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because there are no open period for 2008 # validation is refused, because there are no open period for 2008
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
def test_AccountingTransactionValidationAfterPeriod(self): def test_AccountingTransactionValidationAfterPeriod(self):
# Check we cannot validate after the period # Check we cannot validate after the period
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2008/12/31'), start_date=DateTime('2008/12/31'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -452,7 +452,7 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -452,7 +452,7 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because there are no open period for 2008 # validation is refused, because there are no open period for 2008
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
def test_AccountingTransactionValidationRecursivePeriod(self): def test_AccountingTransactionValidationRecursivePeriod(self):
# Check we can/cannot validate when secondary period exists # Check we can/cannot validate when secondary period exists
...@@ -471,7 +471,7 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -471,7 +471,7 @@ class TestTransactionValidation(AccountingTestCase):
stop_date=DateTime('2007/02/28'),) stop_date=DateTime('2007/02/28'),)
accounting_period_2007_2.start() accounting_period_2007_2.start()
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -483,16 +483,16 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -483,16 +483,16 @@ class TestTransactionValidation(AccountingTestCase):
# validation is refused, because there are no open period for 2007-01 # validation is refused, because there are no open period for 2007-01
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# in 2007-02, it's OK # in 2007-02, it's OK
transaction.setStartDate(DateTime("2007/02/02")) accounting_transaction.setStartDate(DateTime("2007/02/02"))
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_PaymentTransactionWithEmployee(self): def test_PaymentTransactionWithEmployee(self):
# we have to set bank account if we use an asset/cash/bank account, but not # we have to set bank account if we use an asset/cash/bank account, but not
# for our employees # for our employees
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.person_module.john_smith, destination_section_value=self.person_module.john_smith,
...@@ -506,15 +506,15 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -506,15 +506,15 @@ class TestTransactionValidation(AccountingTestCase):
# refused because no bank account # refused because no bank account
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
# with bank account, it's OK # with bank account, it's OK
bank_account = self.section.newContent(portal_type='Bank Account') bank_account = self.section.newContent(portal_type='Bank Account')
transaction.setSourcePaymentValue(bank_account) accounting_transaction.setSourcePaymentValue(bank_account)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedAccountingTransaction(self): def test_NonBalancedAccountingTransaction(self):
# Accounting Transactions have to be balanced to be validated # Accounting Transactions have to be balanced to be validated
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -528,16 +528,16 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -528,16 +528,16 @@ class TestTransactionValidation(AccountingTestCase):
# refused because not balanced # refused because not balanced
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getSourceId() == 'payable': if line.getSourceId() == 'payable':
line.setSourceAssetDebit(38.99) line.setSourceAssetDebit(38.99)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedDestinationAccountingTransaction(self): def test_NonBalancedDestinationAccountingTransaction(self):
# Accounting Transactions have to be balanced to be validated, # Accounting Transactions have to be balanced to be validated,
# also for destination # also for destination
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -553,16 +553,16 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -553,16 +553,16 @@ class TestTransactionValidation(AccountingTestCase):
# refused because not balanced # refused because not balanced
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getDestinationId() == 'receivable': if line.getDestinationId() == 'receivable':
line.setDestinationAssetDebit(38.99) line.setDestinationAssetDebit(38.99)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedDestinationAccountingTransactionNoAccount(self): def test_NonBalancedDestinationAccountingTransactionNoAccount(self):
# Accounting Transactions have to be balanced to be validated, # Accounting Transactions have to be balanced to be validated,
# also for destination # also for destination
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -577,15 +577,15 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -577,15 +577,15 @@ class TestTransactionValidation(AccountingTestCase):
# This is not balanced but there are no accounts on destination # This is not balanced but there are no accounts on destination
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getDestinationId() == 'receivable': if line.getDestinationId() == 'receivable':
line.setDestination(None) line.setDestination(None)
# but if there are no accounts defined it's not a problem # but if there are no accounts defined it's not a problem
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedAccountingTransactionSectionOnLines(self): def test_NonBalancedAccountingTransactionSectionOnLines(self):
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
resource='currency_module/yen', resource='currency_module/yen',
...@@ -599,15 +599,15 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -599,15 +599,15 @@ class TestTransactionValidation(AccountingTestCase):
# This is not balanced for client 1 # This is not balanced for client 1
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
line.setDestinationSection(None) line.setDestinationSection(None)
self.assertEquals([], transaction.checkConsistency()) self.assertEquals([], accounting_transaction.checkConsistency())
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedAccountingTransactionDifferentSectionOnLines(self): def test_NonBalancedAccountingTransactionDifferentSectionOnLines(self):
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
resource='currency_module/yen', resource='currency_module/yen',
...@@ -624,19 +624,19 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -624,19 +624,19 @@ class TestTransactionValidation(AccountingTestCase):
# it looks balanced. # it looks balanced.
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
self.assertEquals(1, len(transaction.checkConsistency()), self.assertEquals(1, len(accounting_transaction.checkConsistency()),
transaction.checkConsistency()) accounting_transaction.checkConsistency())
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
line.setDestinationSectionValue( line.setDestinationSectionValue(
self.organisation_module.client_2) self.organisation_module.client_2)
self.assertEquals([], transaction.checkConsistency()) self.assertEquals([], accounting_transaction.checkConsistency())
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_NonBalancedAccountingTransactionSectionPersonOnLines(self): def test_NonBalancedAccountingTransactionSectionPersonOnLines(self):
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
resource='currency_module/yen', resource='currency_module/yen',
...@@ -649,15 +649,15 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -649,15 +649,15 @@ class TestTransactionValidation(AccountingTestCase):
# This is not balanced for john smith, but as he is a person, it's not a # This is not balanced for john smith, but as he is a person, it's not a
# problem # problem
self.assertEquals([], transaction.checkConsistency()) self.assertEquals([], accounting_transaction.checkConsistency())
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_AccountingTransactionValidationRefusedWithCategoriesAsSections(self): def test_AccountingTransactionValidationRefusedWithCategoriesAsSections(self):
# Validating a transaction with categories as sections is refused. # Validating a transaction with categories as sections is refused.
# See http://wiki.erp5.org/Discussion/AccountingProblems # See http://wiki.erp5.org/Discussion/AccountingProblems
category = self.section.getGroupValue() category = self.section.getGroupValue()
self.assertNotEquals(category, None) self.assertNotEquals(category, None)
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
source_section_value=category, source_section_value=category,
...@@ -670,18 +670,18 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -670,18 +670,18 @@ class TestTransactionValidation(AccountingTestCase):
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
transaction.setSourceSectionValue(self.section) accounting_transaction.setSourceSectionValue(self.section)
transaction.setDestinationSectionValue(category) accounting_transaction.setDestinationSectionValue(category)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor, self.portal.portal_workflow.doActionFor,
transaction, 'stop_action') accounting_transaction, 'stop_action')
transaction.setDestinationSectionValue(self.organisation_module.client_1) accounting_transaction.setDestinationSectionValue(self.organisation_module.client_1)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action') self.portal.portal_workflow.doActionFor(accounting_transaction, 'stop_action')
def test_AccountingWorkflow(self): def test_AccountingWorkflow(self):
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -693,41 +693,49 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -693,41 +693,49 @@ class TestTransactionValidation(AccountingTestCase):
source_credit=500))) source_credit=500)))
doActionFor = self.portal.portal_workflow.doActionFor doActionFor = self.portal.portal_workflow.doActionFor
self.assertEquals('draft', transaction.getSimulationState()) self.assertEquals('draft', accounting_transaction.getSimulationState())
self.assertTrue(_checkPermission('Modify portal content', transaction)) self.assertTrue(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'plan_action') doActionFor(accounting_transaction, 'plan_action')
self.assertEquals('planned', transaction.getSimulationState()) self.assertEquals('planned', accounting_transaction.getSimulationState())
self.assertTrue(_checkPermission('Modify portal content', transaction)) self.assertTrue(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'confirm_action') doActionFor(accounting_transaction, 'confirm_action')
self.assertEquals('confirmed', transaction.getSimulationState()) self.assertEquals('confirmed', accounting_transaction.getSimulationState())
self.assertTrue(_checkPermission('Modify portal content', transaction)) self.assertTrue(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'start_action') doActionFor(accounting_transaction, 'start_action')
self.assertEquals('started', transaction.getSimulationState()) self.assertEquals('started', accounting_transaction.getSimulationState())
self.assertTrue(_checkPermission('Modify portal content', transaction)) self.assertTrue(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'stop_action') doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState()) self.assertEquals('stopped', accounting_transaction.getSimulationState())
self.assertFalse(_checkPermission('Modify portal content', transaction)) self.assertFalse(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'restart_action') doActionFor(accounting_transaction, 'restart_action')
self.assertEquals('started', transaction.getSimulationState()) self.assertEquals('started', accounting_transaction.getSimulationState())
self.assertTrue(_checkPermission('Modify portal content', transaction)) self.assertTrue(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'stop_action') doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState()) self.assertEquals('stopped', accounting_transaction.getSimulationState())
self.assertFalse(_checkPermission('Modify portal content', transaction)) self.assertFalse(_checkPermission('Modify portal content',
accounting_transaction))
doActionFor(transaction, 'deliver_action') doActionFor(accounting_transaction, 'deliver_action')
self.assertEquals('delivered', transaction.getSimulationState()) self.assertEquals('delivered', accounting_transaction.getSimulationState())
self.assertFalse(_checkPermission('Modify portal content', transaction)) self.assertFalse(_checkPermission('Modify portal content',
accounting_transaction))
def test_UneededSourceAssetPrice(self): def test_UneededSourceAssetPrice(self):
# It is refunsed to validate an accounting transaction if lines have an # It is refunsed to validate an accounting transaction if lines have an
# asset price but the resource is the same as the accounting resource # asset price but the resource is the same as the accounting resource
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -738,35 +746,35 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -738,35 +746,35 @@ class TestTransactionValidation(AccountingTestCase):
source_credit=500, source_credit=500,
source_asset_credit=600))) source_asset_credit=600)))
section = transaction.getSourceSectionValue() section = accounting_transaction.getSourceSectionValue()
self.assertEquals(section.getPriceCurrency(), self.assertEquals(section.getPriceCurrency(),
transaction.getResource()) accounting_transaction.getResource())
# validation is refused # validation is refused
doActionFor = self.portal.portal_workflow.doActionFor doActionFor = self.portal.portal_workflow.doActionFor
self.assertRaises(ValidationFailed, doActionFor, transaction, self.assertRaises(ValidationFailed, doActionFor, accounting_transaction,
'stop_action') 'stop_action')
# and the source conversion tab is visible # and the source conversion tab is visible
self.failUnless( self.failUnless(
transaction.AccountingTransaction_isSourceCurrencyConvertible()) accounting_transaction.AccountingTransaction_isSourceCurrencyConvertible())
# if asset price is set to the same value as quantity, validation is # if asset price is set to the same value as quantity, validation is
# allowed # allowed
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getSourceValue() == self.account_module.payable: if line.getSourceValue() == self.account_module.payable:
line.setSourceAssetDebit(line.getSourceDebit()) line.setSourceAssetDebit(line.getSourceDebit())
elif line.getSourceValue() == self.account_module.receivable: elif line.getSourceValue() == self.account_module.receivable:
line.setSourceAssetCredit(line.getSourceCredit()) line.setSourceAssetCredit(line.getSourceCredit())
else: else:
self.fail('wrong line ?') self.fail('wrong line ?')
doActionFor(transaction, 'stop_action') doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState()) self.assertEquals('stopped', accounting_transaction.getSimulationState())
def test_UneededDestinationAssetPrice(self): def test_UneededDestinationAssetPrice(self):
# It is refunsed to validate an accounting transaction if lines have an # It is refunsed to validate an accounting transaction if lines have an
# asset price but the resource is the same as the accounting resource # asset price but the resource is the same as the accounting resource
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
source_section_value=self.organisation_module.client_1, source_section_value=self.organisation_module.client_1,
...@@ -777,21 +785,21 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -777,21 +785,21 @@ class TestTransactionValidation(AccountingTestCase):
destination_credit=500, destination_credit=500,
destination_asset_credit=600))) destination_asset_credit=600)))
section = transaction.getDestinationSectionValue() section = accounting_transaction.getDestinationSectionValue()
self.assertEquals(section.getPriceCurrency(), self.assertEquals(section.getPriceCurrency(),
transaction.getResource()) accounting_transaction.getResource())
# validation is refused # validation is refused
doActionFor = self.portal.portal_workflow.doActionFor doActionFor = self.portal.portal_workflow.doActionFor
self.assertRaises(ValidationFailed, doActionFor, transaction, self.assertRaises(ValidationFailed, doActionFor, accounting_transaction,
'stop_action') 'stop_action')
# and the destination conversion tab is visible # and the destination conversion tab is visible
self.failUnless( self.failUnless(
transaction.AccountingTransaction_isDestinationCurrencyConvertible()) accounting_transaction.AccountingTransaction_isDestinationCurrencyConvertible())
# if asset price is set to the same value as quantity, validation is # if asset price is set to the same value as quantity, validation is
# allowed # allowed
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getDestinationValue() == self.account_module.payable: if line.getDestinationValue() == self.account_module.payable:
line.setDestinationAssetDebit(line.getDestinationDebit()) line.setDestinationAssetDebit(line.getDestinationDebit())
elif line.getDestinationValue() == self.account_module.receivable: elif line.getDestinationValue() == self.account_module.receivable:
...@@ -799,8 +807,8 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -799,8 +807,8 @@ class TestTransactionValidation(AccountingTestCase):
else: else:
self.fail('wrong line ?') self.fail('wrong line ?')
doActionFor(transaction, 'stop_action') doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState()) self.assertEquals('stopped', accounting_transaction.getSimulationState())
class TestClosingPeriod(AccountingTestCase): class TestClosingPeriod(AccountingTestCase):
...@@ -1421,7 +1429,7 @@ class TestClosingPeriod(AccountingTestCase): ...@@ -1421,7 +1429,7 @@ class TestClosingPeriod(AccountingTestCase):
self.assertEquals('started', period.getSimulationState()) self.assertEquals('started', period.getSimulationState())
# create a simple transaction in the period # create a simple transaction in the period
transaction = self._makeOne( accounting_transaction = self._makeOne(
start_date=DateTime(2006, 6, 30), start_date=DateTime(2006, 6, 30),
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -1944,10 +1952,10 @@ class TestAccountingExport(AccountingTestCase): ...@@ -1944,10 +1952,10 @@ class TestAccountingExport(AccountingTestCase):
""" """
def test_export_transaction(self): def test_export_transaction(self):
# test we can export an accounting transaction as ODS # test we can export an accounting transaction as ODS
transaction = self._makeOne(lines=( accounting_transaction = self._makeOne(lines=(
dict(source_value=self.account_module.payable, dict(source_value=self.account_module.payable,
quantity=200),)) quantity=200),))
ods_data = transaction.Base_viewAsODS( ods_data = accounting_transaction.Base_viewAsODS(
form_id='AccountingTransaction_view') form_id='AccountingTransaction_view')
from Products.ERP5OOo.OOoUtils import OOoParser from Products.ERP5OOo.OOoUtils import OOoParser
parser = OOoParser() parser = OOoParser()
...@@ -2066,10 +2074,10 @@ class TestTransactions(AccountingTestCase): ...@@ -2066,10 +2074,10 @@ class TestTransactions(AccountingTestCase):
def test_SearchableText(self): def test_SearchableText(self):
transaction = self._makeOne(title='A new Transaction', accounting_transaction = self._makeOne(title='A new Transaction',
description="A description", description="A description",
comment="Some comments") comment="Some comments")
searchable_text = transaction.SearchableText() searchable_text = accounting_transaction.SearchableText()
self.assertTrue('A new Transaction' in searchable_text) self.assertTrue('A new Transaction' in searchable_text)
self.assertTrue('A description' in searchable_text) self.assertTrue('A description' in searchable_text)
self.assertTrue('Some comments' in searchable_text) self.assertTrue('Some comments' in searchable_text)
...@@ -2266,14 +2274,14 @@ class TestTransactions(AccountingTestCase): ...@@ -2266,14 +2274,14 @@ class TestTransactions(AccountingTestCase):
# Balance Transaction cannot be copy and pasted, because they are not # Balance Transaction cannot be copy and pasted, because they are not
# in visible allowed types. # in visible allowed types.
continue continue
transaction = accounting_module.newContent( accounting_transaction = accounting_module.newContent(
portal_type=portal_type) portal_type=portal_type)
line = transaction.newContent( line = accounting_transaction.newContent(
id = 'line_with_grouping_reference', id = 'line_with_grouping_reference',
grouping_reference='A', grouping_reference='A',
portal_type=transaction_to_line_mapping[portal_type]) portal_type=transaction_to_line_mapping[portal_type])
cp = accounting_module.manage_copyObjects(ids=[transaction.getId()]) cp = accounting_module.manage_copyObjects(ids=[accounting_transaction.getId()])
copy_id = accounting_module.manage_pasteObjects(cp)[0]['new_id'] copy_id = accounting_module.manage_pasteObjects(cp)[0]['new_id']
self.failIf(accounting_module[copy_id]\ self.failIf(accounting_module[copy_id]\
.line_with_grouping_reference.getGroupingReference()) .line_with_grouping_reference.getGroupingReference())
...@@ -2498,7 +2506,7 @@ class TestTransactions(AccountingTestCase): ...@@ -2498,7 +2506,7 @@ class TestTransactions(AccountingTestCase):
def test_AccountingTransaction_getTotalDebitCredit(self): def test_AccountingTransaction_getTotalDebitCredit(self):
# source view # source view
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -2508,12 +2516,12 @@ class TestTransactions(AccountingTestCase): ...@@ -2508,12 +2516,12 @@ class TestTransactions(AccountingTestCase):
dict(source_value=self.account_module.receivable, dict(source_value=self.account_module.receivable,
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
source_credit=400))) source_credit=400)))
self.assertTrue(transaction.AccountingTransaction_isSourceView()) self.assertTrue(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(500, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(500, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(400, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(400, accounting_transaction.AccountingTransaction_getTotalCredit())
# destination view # destination view
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
source_section_value=self.organisation_module.client_1, source_section_value=self.organisation_module.client_1,
...@@ -2524,12 +2532,12 @@ class TestTransactions(AccountingTestCase): ...@@ -2524,12 +2532,12 @@ class TestTransactions(AccountingTestCase):
dict(source_value=self.account_module.receivable, dict(source_value=self.account_module.receivable,
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
destination_credit=400))) destination_credit=400)))
self.assertFalse(transaction.AccountingTransaction_isSourceView()) self.assertFalse(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(500, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(500, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(400, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(400, accounting_transaction.AccountingTransaction_getTotalCredit())
# source view, with conversion on our side # source view, with conversion on our side
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -2541,12 +2549,12 @@ class TestTransactions(AccountingTestCase): ...@@ -2541,12 +2549,12 @@ class TestTransactions(AccountingTestCase):
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
source_asset_credit=40, source_asset_credit=40,
source_credit=400))) source_credit=400)))
self.assertTrue(transaction.AccountingTransaction_isSourceView()) self.assertTrue(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(50, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(50, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(40, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(40, accounting_transaction.AccountingTransaction_getTotalCredit())
# destination view, with conversion on our side # destination view, with conversion on our side
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
source_section_value=self.organisation_module.client_1, source_section_value=self.organisation_module.client_1,
...@@ -2559,12 +2567,12 @@ class TestTransactions(AccountingTestCase): ...@@ -2559,12 +2567,12 @@ class TestTransactions(AccountingTestCase):
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
destination_asset_credit=40, destination_asset_credit=40,
destination_credit=400))) destination_credit=400)))
self.assertFalse(transaction.AccountingTransaction_isSourceView()) self.assertFalse(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(50, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(50, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(40, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(40, accounting_transaction.AccountingTransaction_getTotalCredit())
# source view, with conversion on other side # source view, with conversion on other side
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1, destination_section_value=self.organisation_module.client_1,
...@@ -2576,12 +2584,12 @@ class TestTransactions(AccountingTestCase): ...@@ -2576,12 +2584,12 @@ class TestTransactions(AccountingTestCase):
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
destination_asset_credit=40, destination_asset_credit=40,
source_credit=400))) source_credit=400)))
self.assertTrue(transaction.AccountingTransaction_isSourceView()) self.assertTrue(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(500, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(500, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(400, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(400, accounting_transaction.AccountingTransaction_getTotalCredit())
# destination view, with conversion on other side # destination view, with conversion on other side
transaction = self._makeOne( accounting_transaction = self._makeOne(
portal_type='Accounting Transaction', portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'), start_date=DateTime('2007/01/02'),
source_section_value=self.organisation_module.client_1, source_section_value=self.organisation_module.client_1,
...@@ -2594,9 +2602,9 @@ class TestTransactions(AccountingTestCase): ...@@ -2594,9 +2602,9 @@ class TestTransactions(AccountingTestCase):
destination_value=self.account_module.payable, destination_value=self.account_module.payable,
source_asset_credit=40, source_asset_credit=40,
destination_credit=400))) destination_credit=400)))
self.assertFalse(transaction.AccountingTransaction_isSourceView()) self.assertFalse(accounting_transaction.AccountingTransaction_isSourceView())
self.assertEquals(500, transaction.AccountingTransaction_getTotalDebit()) self.assertEquals(500, accounting_transaction.AccountingTransaction_getTotalDebit())
self.assertEquals(400, transaction.AccountingTransaction_getTotalCredit()) self.assertEquals(400, accounting_transaction.AccountingTransaction_getTotalCredit())
...@@ -3211,7 +3219,7 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3211,7 +3219,7 @@ class TestAccountingWithSequences(AccountingTestCase):
kw['stop_date'] = stop_date kw['stop_date'] = stop_date
# create the transaction. # create the transaction.
transaction = self.getAccountingModule().newContent( accounting_transaction = self.getAccountingModule().newContent(
portal_type=portal_type, portal_type=portal_type,
start_date=kw['start_date'], start_date=kw['start_date'],
stop_date=kw['stop_date'], stop_date=kw['stop_date'],
...@@ -3221,7 +3229,7 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3221,7 +3229,7 @@ class TestAccountingWithSequences(AccountingTestCase):
created_by_builder = 1 # prevent the init script from created_by_builder = 1 # prevent the init script from
# creating lines. # creating lines.
) )
income = transaction.newContent( income = accounting_transaction.newContent(
id='income', id='income',
portal_type=line_portal_type, portal_type=line_portal_type,
quantity=-quantity, quantity=-quantity,
...@@ -3231,7 +3239,7 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3231,7 +3239,7 @@ class TestAccountingWithSequences(AccountingTestCase):
self.failUnless(income.getSource() != None) self.failUnless(income.getSource() != None)
self.failUnless(income.getDestination() != None) self.failUnless(income.getDestination() != None)
receivable = transaction.newContent( receivable = accounting_transaction.newContent(
id='receivable', id='receivable',
portal_type=line_portal_type, portal_type=line_portal_type,
quantity=quantity, quantity=quantity,
...@@ -3245,29 +3253,29 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3245,29 +3253,29 @@ class TestAccountingWithSequences(AccountingTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
if check_consistency: if check_consistency:
self.failUnless(len(transaction.checkConsistency()) == 0, self.failUnless(len(accounting_transaction.checkConsistency()) == 0,
"Check consistency failed : %s" % transaction.checkConsistency()) "Check consistency failed : %s" % accounting_transaction.checkConsistency())
return transaction return accounting_transaction
def test_createAccountingTransaction(self): def test_createAccountingTransaction(self):
"""Make sure acounting transactions created by createAccountingTransaction """Make sure acounting transactions created by createAccountingTransaction
method are valid. method are valid.
""" """
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
self.assertEquals(self.vendor, transaction.getSourceSectionValue()) self.assertEquals(self.vendor, accounting_transaction.getSourceSectionValue())
self.assertEquals(self.client, transaction.getDestinationSectionValue()) self.assertEquals(self.client, accounting_transaction.getDestinationSectionValue())
self.assertEquals(self.EUR, transaction.getResourceValue()) self.assertEquals(self.EUR, accounting_transaction.getResourceValue())
self.failUnless(transaction.AccountingTransaction_isSourceView()) self.failUnless(accounting_transaction.AccountingTransaction_isSourceView())
self.workflow_tool.doActionFor(transaction, 'stop_action') self.workflow_tool.doActionFor(accounting_transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState()) self.assertEquals('stopped', accounting_transaction.getSimulationState())
self.assertEquals([] , transaction.checkConsistency()) self.assertEquals([] , accounting_transaction.checkConsistency())
def stepCreateValidAccountingTransaction(self, sequence, def stepCreateValidAccountingTransaction(self, sequence,
sequence_list=None, **kw) : sequence_list=None, **kw) :
"""Creates a valid accounting transaction and put it in """Creates a valid accounting transaction and put it in
the sequence as `transaction` key. """ the sequence as `transaction` key. """
transaction = self.createAccountingTransaction( accounting_transaction = self.createAccountingTransaction(
resource_value=sequence.get('EUR'), resource_value=sequence.get('EUR'),
source_section_value=sequence.get('vendor'), source_section_value=sequence.get('vendor'),
destination_section_value=sequence.get('client'), destination_section_value=sequence.get('client'),
...@@ -3276,9 +3284,9 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3276,9 +3284,9 @@ class TestAccountingWithSequences(AccountingTestCase):
receivable_account=sequence.get('receivable_account'), receivable_account=sequence.get('receivable_account'),
payable_account=sequence.get('payable_account'), ) payable_account=sequence.get('payable_account'), )
sequence.edit( sequence.edit(
transaction = transaction, transaction = accounting_transaction,
income = transaction.income, income = accounting_transaction.income,
receivable = transaction.receivable receivable = accounting_transaction.receivable
) )
def stepValidateNoDate(self, sequence, sequence_list=None, **kw) : def stepValidateNoDate(self, sequence, sequence_list=None, **kw) :
...@@ -3290,21 +3298,21 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3290,21 +3298,21 @@ class TestAccountingWithSequences(AccountingTestCase):
missing. (ie. stop_date defaults automatically to start_date if not set and missing. (ie. stop_date defaults automatically to start_date if not set and
start_date is set to stop_date in the workflow script if not set. start_date is set to stop_date in the workflow script if not set.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
old_stop_date = transaction.getStopDate() old_stop_date = accounting_transaction.getStopDate()
old_start_date = transaction.getStartDate() old_start_date = accounting_transaction.getStartDate()
transaction.setStopDate(None) accounting_transaction.setStopDate(None)
if transaction.getStopDate() != None : if accounting_transaction.getStopDate() != None :
transaction.setStartDate(None) accounting_transaction.setStartDate(None)
transaction.setStopDate(None) accounting_transaction.setStopDate(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
transaction.setStartDate(old_start_date) accounting_transaction.setStartDate(old_start_date)
transaction.setStopDate(old_stop_date) accounting_transaction.setStopDate(old_stop_date)
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
def stepValidateNoSection(self, sequence, sequence_list=None, **kw) : def stepValidateNoSection(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour related to section & mirror_section. """Check validation behaviour related to section & mirror_section.
...@@ -3315,29 +3323,29 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3315,29 +3323,29 @@ class TestAccountingWithSequences(AccountingTestCase):
o if we do not use any payable or receivable accounts and we have o if we do not use any payable or receivable accounts and we have
a destination section, validation should be ok. a destination section, validation should be ok.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
old_source_section = transaction.getSourceSection() old_source_section = accounting_transaction.getSourceSection()
old_destination_section = transaction.getDestinationSection() old_destination_section = accounting_transaction.getDestinationSection()
# default transaction uses payable accounts, so validating without # default transaction uses payable accounts, so validating without
# source section is refused. # source section is refused.
transaction.setSourceSection(None) accounting_transaction.setSourceSection(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# ... as well as validation without destination section # ... as well as validation without destination section
transaction.setSourceSection(old_source_section) accounting_transaction.setSourceSection(old_source_section)
transaction.setDestinationSection(None) accounting_transaction.setDestinationSection(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# mirror section can be set only on the line # mirror section can be set only on the line
for line in transaction.getMovementList() : for line in accounting_transaction.getMovementList() :
line.setDestinationSection(old_destination_section) line.setDestinationSection(old_destination_section)
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err : except ValidationFailed, err :
self.assert_(0, "Validation failed : %s" % err.msg) self.assert_(0, "Validation failed : %s" % err.msg)
...@@ -3348,38 +3356,38 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3348,38 +3356,38 @@ class TestAccountingWithSequences(AccountingTestCase):
# destination section only. We could theoritically support it. # destination section only. We could theoritically support it.
# get a new valid transaction # get a new valid transaction
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
expense_account = sequence.get('expense_account') expense_account = sequence.get('expense_account')
for line in transaction.getMovementList() : for line in accounting_transaction.getMovementList() :
line.edit( source_value = expense_account, line.edit( source_value = expense_account,
destination_value = expense_account ) destination_value = expense_account )
if side == SOURCE : if side == SOURCE :
transaction.setDestinationSection(None) accounting_transaction.setDestinationSection(None)
else : else :
transaction.setSourceSection(None) accounting_transaction.setSourceSection(None)
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err : except ValidationFailed, err :
self.assert_(0, "Validation failed : %s" % err.msg) self.assert_(0, "Validation failed : %s" % err.msg)
def stepValidateNoCurrency(self, sequence, sequence_list=None, **kw) : def stepValidateNoCurrency(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour related to currency. """Check validation behaviour related to currency.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
old_resource = transaction.getResource() old_resource = accounting_transaction.getResource()
transaction.setResource(None) accounting_transaction.setResource(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# setting a dummy relationship is not enough, resource must be a # setting a dummy relationship is not enough, resource must be a
# currency # currency
transaction.setResourceValue( accounting_transaction.setResourceValue(
self.portal.product_module.newContent(portal_type='Product')) self.portal.product_module.newContent(portal_type='Product'))
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
def stepValidateClosedAccount(self, sequence, sequence_list=None, **kw) : def stepValidateClosedAccount(self, sequence, sequence_list=None, **kw) :
...@@ -3387,13 +3395,13 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3387,13 +3395,13 @@ class TestAccountingWithSequences(AccountingTestCase):
If an account is blocked, then it's impossible to validate a If an account is blocked, then it's impossible to validate a
transaction related to this account. transaction related to this account.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
account = transaction.getMovementList()[0].getSourceValue() account = accounting_transaction.getMovementList()[0].getSourceValue()
self.getWorkflowTool().doActionFor(account, 'invalidate_action') self.getWorkflowTool().doActionFor(account, 'invalidate_action')
self.assertEquals(account.getValidationState(), 'invalidated') self.assertEquals(account.getValidationState(), 'invalidated')
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# reopen the account for other tests # reopen the account for other tests
account.validate() account.validate()
...@@ -3403,42 +3411,42 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3403,42 +3411,42 @@ class TestAccountingWithSequences(AccountingTestCase):
"""Simple check that the validation is refused when we do not have """Simple check that the validation is refused when we do not have
accounts correctly defined on lines. accounts correctly defined on lines.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
# no account at all is refused # no account at all is refused
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
line.setSource(None) line.setSource(None)
line.setDestination(None) line.setDestination(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# only one line without account and with a quantity is also refused # only one line without account and with a quantity is also refused
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
transaction.getMovementList()[0].setSource(None) accounting_transaction.getMovementList()[0].setSource(None)
transaction.getMovementList()[0].setDestination(None) accounting_transaction.getMovementList()[0].setDestination(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# but if we have a line with 0 quantity on both sides, we can # but if we have a line with 0 quantity on both sides, we can
# validate the transaction and delete this line. # validate the transaction and delete this line.
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
line_count = len(transaction.getMovementList()) line_count = len(accounting_transaction.getMovementList())
transaction.newContent( accounting_transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type) portal_type = self.accounting_transaction_line_portal_type)
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
self.assertEquals(line_count, len(transaction.getMovementList())) self.assertEquals(line_count, len(accounting_transaction.getMovementList()))
# 0 quantity, but a destination asset price => do not delete the # 0 quantity, but a destination asset price => do not delete the
# line # line
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
new_line = transaction.newContent( new_line = accounting_transaction.newContent(
portal_type = self.accounting_transaction_line_portal_type) portal_type = self.accounting_transaction_line_portal_type)
self.assertEquals(len(transaction.getMovementList()), 3) self.assertEquals(len(accounting_transaction.getMovementList()), 3)
line_list = transaction.getMovementList() line_list = accounting_transaction.getMovementList()
line_list[0].setDestinationTotalAssetPrice(100) line_list[0].setDestinationTotalAssetPrice(100)
line_list[0]._setCategoryMembership( line_list[0]._setCategoryMembership(
'destination', sequence.get('expense_account').getRelativeUrl()) 'destination', sequence.get('expense_account').getRelativeUrl())
...@@ -3449,44 +3457,44 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3449,44 +3457,44 @@ class TestAccountingWithSequences(AccountingTestCase):
line_list[2]._setCategoryMembership( line_list[2]._setCategoryMembership(
'destination', sequence.get('expense_account').getRelativeUrl()) 'destination', sequence.get('expense_account').getRelativeUrl())
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err : except ValidationFailed, err :
self.assert_(0, "Validation failed : %s" % err.msg) self.assert_(0, "Validation failed : %s" % err.msg)
def stepValidateNotBalanced(self, sequence, sequence_list=None, **kw) : def stepValidateNotBalanced(self, sequence, sequence_list=None, **kw) :
"""Check validation behaviour when transaction is not balanced. """Check validation behaviour when transaction is not balanced.
""" """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
transaction.getMovementList()[0].setQuantity(4325) accounting_transaction.getMovementList()[0].setQuantity(4325)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# asset price have priority (ie. if asset price is not balanced, # asset price have priority (ie. if asset price is not balanced,
# refuses validation even if quantity is balanced) # refuses validation even if quantity is balanced)
transaction = self.createAccountingTransaction(resource_value=self.YEN) accounting_transaction = self.createAccountingTransaction(resource_value=self.YEN)
line_list = transaction.getMovementList() line_list = accounting_transaction.getMovementList()
line_list[0].setDestinationTotalAssetPrice(10) line_list[0].setDestinationTotalAssetPrice(10)
line_list[1].setDestinationTotalAssetPrice(100) line_list[1].setDestinationTotalAssetPrice(100)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
transaction = self.createAccountingTransaction(resource_value=self.YEN) accounting_transaction = self.createAccountingTransaction(resource_value=self.YEN)
line_list = transaction.getMovementList() line_list = accounting_transaction.getMovementList()
line_list[0].setSourceTotalAssetPrice(10) line_list[0].setSourceTotalAssetPrice(10)
line_list[1].setSourceTotalAssetPrice(100) line_list[1].setSourceTotalAssetPrice(100)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
# only asset price needs to be balanced # only asset price needs to be balanced
transaction = self.createAccountingTransaction(resource_value=self.YEN) accounting_transaction = self.createAccountingTransaction(resource_value=self.YEN)
line_list = transaction.getMovementList() line_list = accounting_transaction.getMovementList()
line_list[0].setSourceTotalAssetPrice(100) line_list[0].setSourceTotalAssetPrice(100)
line_list[0].setDestinationTotalAssetPrice(100) line_list[0].setDestinationTotalAssetPrice(100)
line_list[0].setQuantity(432432) line_list[0].setQuantity(432432)
...@@ -3494,8 +3502,8 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3494,8 +3502,8 @@ class TestAccountingWithSequences(AccountingTestCase):
line_list[1].setDestinationTotalAssetPrice(-100) line_list[1].setDestinationTotalAssetPrice(-100)
line_list[1].setQuantity(32546787) line_list[1].setQuantity(32546787)
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err : except ValidationFailed, err :
self.assert_(0, "Validation failed : %s" % err.msg) self.assert_(0, "Validation failed : %s" % err.msg)
...@@ -3507,13 +3515,13 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3507,13 +3515,13 @@ class TestAccountingWithSequences(AccountingTestCase):
`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): def useBankAccount(accounting_transaction):
"""Modify the transaction, so that a line will use an account member of """Modify the transaction, so that a line will use an account member of
account_type/cash/bank , which requires to use a payment category. account_type/cash/bank , which requires to use a payment category.
""" """
# get the default and replace income account by bank # get the default and replace income account by bank
income_account_found = 0 income_account_found = 0
for line in transaction.getMovementList() : for line in accounting_transaction.getMovementList() :
source_account = line.getSourceValue() source_account = line.getSourceValue()
if source_account.isMemberOf('account_type/income') : if source_account.isMemberOf('account_type/income') :
income_account_found = 1 income_account_found = 1
...@@ -3521,87 +3529,87 @@ class TestAccountingWithSequences(AccountingTestCase): ...@@ -3521,87 +3529,87 @@ class TestAccountingWithSequences(AccountingTestCase):
destination_value = sequence.get('bank_account') ) destination_value = sequence.get('bank_account') )
self.failUnless(income_account_found) self.failUnless(income_account_found)
# XXX # XXX
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
useBankAccount(transaction) useBankAccount(accounting_transaction)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
source_section_value = transaction.getSourceSectionValue() source_section_value = accounting_transaction.getSourceSectionValue()
destination_section_value = transaction.getDestinationSectionValue() destination_section_value = accounting_transaction.getDestinationSectionValue()
for ptype in self.getPortal().getPortalPaymentNodeTypeList() : for ptype in self.getPortal().getPortalPaymentNodeTypeList() :
source_payment_value = source_section_value.newContent( source_payment_value = source_section_value.newContent(
portal_type = ptype, ) portal_type = ptype, )
destination_payment_value = destination_section_value.newContent( destination_payment_value = destination_section_value.newContent(
portal_type = ptype, ) portal_type = ptype, )
transaction = self.createAccountingTransaction( accounting_transaction = self.createAccountingTransaction(
destination_section_value=self.other_vendor) destination_section_value=self.other_vendor)
useBankAccount(transaction) useBankAccount(accounting_transaction)
# payment node have to be set on both sides if both sides are member of # payment node have to be set on both sides if both sides are member of
# the same group. # the same group.
transaction.setSourcePaymentValue(source_payment_value) accounting_transaction.setSourcePaymentValue(source_payment_value)
transaction.setDestinationPaymentValue(None) accounting_transaction.setDestinationPaymentValue(None)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
transaction.setSourcePaymentValue(None) accounting_transaction.setSourcePaymentValue(None)
transaction.setDestinationPaymentValue(destination_payment_value) accounting_transaction.setDestinationPaymentValue(destination_payment_value)
self.assertRaises(ValidationFailed, self.assertRaises(ValidationFailed,
self.getWorkflowTool().doActionFor, self.getWorkflowTool().doActionFor,
transaction, accounting_transaction,
'stop_action') 'stop_action')
transaction.setSourcePaymentValue(source_payment_value) accounting_transaction.setSourcePaymentValue(source_payment_value)
transaction.setDestinationPaymentValue(destination_payment_value) accounting_transaction.setDestinationPaymentValue(destination_payment_value)
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err : except ValidationFailed, err :
self.fail("Validation failed : %s" % err.msg) self.fail("Validation failed : %s" % err.msg)
# if we are not interested in the accounting for the third party, no need # if we are not interested in the accounting for the third party, no need
# to have a destination_payment # to have a destination_payment
transaction = self.createAccountingTransaction() accounting_transaction = self.createAccountingTransaction()
useBankAccount(transaction) useBankAccount(accounting_transaction)
# only set payment for source # only set payment for source
transaction.setSourcePaymentValue(source_payment_value) accounting_transaction.setSourcePaymentValue(source_payment_value)
transaction.setDestinationPaymentValue(None) accounting_transaction.setDestinationPaymentValue(None)
# then we should be able to validate. # then we should be able to validate.
try: try:
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(transaction.getSimulationState(), 'stopped') self.assertEquals(accounting_transaction.getSimulationState(), 'stopped')
except ValidationFailed, err: except ValidationFailed, err:
self.fail("Validation failed : %s" % err.msg) self.fail("Validation failed : %s" % err.msg)
def stepValidateRemoveEmptyLines(self, sequence, sequence_list=None, **kw): def stepValidateRemoveEmptyLines(self, sequence, sequence_list=None, **kw):
"""Check validating a transaction remove empty lines. """ """Check validating a transaction remove empty lines. """
transaction = sequence.get('transaction') accounting_transaction = sequence.get('transaction')
lines_count = len(transaction.getMovementList()) lines_count = len(accounting_transaction.getMovementList())
empty_lines_count = 0 empty_lines_count = 0
for line in transaction.getMovementList(): for line in accounting_transaction.getMovementList():
if line.getSourceTotalAssetPrice() == \ if line.getSourceTotalAssetPrice() == \
line.getDestinationTotalAssetPrice() == 0: line.getDestinationTotalAssetPrice() == 0:
empty_lines_count += 1 empty_lines_count += 1
if empty_lines_count == 0: if empty_lines_count == 0:
transaction.newContent( accounting_transaction.newContent(
portal_type=self.accounting_transaction_line_portal_type) portal_type=self.accounting_transaction_line_portal_type)
self.getWorkflowTool().doActionFor(transaction, 'stop_action') self.getWorkflowTool().doActionFor(accounting_transaction, 'stop_action')
self.assertEquals(len(transaction.getMovementList()), self.assertEquals(len(accounting_transaction.getMovementList()),
lines_count - empty_lines_count) lines_count - empty_lines_count)
# we don't remove empty lines if there is only empty lines # we don't remove empty lines if there is only empty lines
transaction = self.getAccountingModule().newContent( accounting_transaction = self.getAccountingModule().newContent(
portal_type=self.accounting_transaction_portal_type, portal_type=self.accounting_transaction_portal_type,
created_by_builder=1) created_by_builder=1)
for i in range(3): for i in range(3):
transaction.newContent( accounting_transaction.newContent(
portal_type=self.accounting_transaction_line_portal_type) portal_type=self.accounting_transaction_line_portal_type)
lines_count = len(transaction.getMovementList()) lines_count = len(accounting_transaction.getMovementList())
transaction.AccountingTransaction_deleteEmptyLines(redirect=0) accounting_transaction.AccountingTransaction_deleteEmptyLines(redirect=0)
self.assertEquals(len(transaction.getMovementList()), lines_count) self.assertEquals(len(accounting_transaction.getMovementList()), lines_count)
############################################################################ ############################################################################
## Test Methods ############################################################ ## Test Methods ############################################################
......
...@@ -163,7 +163,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -163,7 +163,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(x_curr_ex_line.getValidationState(), self.assertEquals(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -172,8 +172,8 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -172,8 +172,8 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
destination_debit=500), destination_debit=500),
dict(destination_value=self.account_module.receivable, dict(destination_value=self.account_module.receivable,
destination_credit=500))) destination_credit=500)))
transaction.AccountingTransaction_convertDestinationPrice(form_id='view') invoice.AccountingTransaction_convertDestinationPrice(form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
...@@ -235,7 +235,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -235,7 +235,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
portal_type='Currency Exchange Line') portal_type='Currency Exchange Line')
euro_line.validate() euro_line.validate()
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -244,9 +244,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -244,9 +244,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
destination_debit=500), destination_debit=500),
dict(destination_value=self.account_module.receivable, dict(destination_value=self.account_module.receivable,
destination_credit=500))) destination_credit=500)))
transaction.AccountingTransaction_convertDestinationPrice( invoice.AccountingTransaction_convertDestinationPrice(
form_id='view') form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
...@@ -290,7 +290,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -290,7 +290,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(x_curr_ex_line.getValidationState(), self.assertEquals(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
start_date=DateTime('2008/09/08'), start_date=DateTime('2008/09/08'),
destination_section_value=self.organisation_module.supplier, destination_section_value=self.organisation_module.supplier,
...@@ -298,9 +298,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -298,9 +298,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
source_debit=500), source_debit=500),
dict(source_value=self.account_module.receivable, dict(source_value=self.account_module.receivable,
source_credit=500))) source_credit=500)))
transaction.AccountingTransaction_convertSourcePrice( invoice.AccountingTransaction_convertSourcePrice(
form_id='view') form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getSourceTotalAssetPrice(), self.assertEquals(line.getSourceTotalAssetPrice(),
...@@ -329,7 +329,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -329,7 +329,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
price_currency=new_currency.getRelativeUrl()) price_currency=new_currency.getRelativeUrl())
euro = self.portal.currency_module.euro euro = self.portal.currency_module.euro
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -338,9 +338,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -338,9 +338,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
destination_debit=500), destination_debit=500),
dict(destination_value=self.account_module.receivable, dict(destination_value=self.account_module.receivable,
destination_credit=500))) destination_credit=500)))
transaction.AccountingTransaction_convertDestinationPrice( invoice.AccountingTransaction_convertDestinationPrice(
form_id='view') form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getDestinationTotalAssetPrice(),None) self.assertEquals(line.getDestinationTotalAssetPrice(),None)
...@@ -456,7 +456,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -456,7 +456,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
'validated') 'validated')
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -466,9 +466,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -466,9 +466,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
dict(destination_value=self.account_module.receivable, dict(destination_value=self.account_module.receivable,
destination_credit=500))) destination_credit=500)))
transaction.AccountingTransaction_convertDestinationPrice( invoice.AccountingTransaction_convertDestinationPrice(
form_id='view') form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
...@@ -527,7 +527,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -527,7 +527,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(euro_line2.getValidationState(), self.assertEquals(euro_line2.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module accounting_module = self.portal.accounting_module
transaction = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
source_section_value=self.organisation_module.supplier, source_section_value=self.organisation_module.supplier,
...@@ -536,9 +536,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -536,9 +536,9 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
destination_debit=500), destination_debit=500),
dict(destination_value=self.account_module.receivable, dict(destination_value=self.account_module.receivable,
destination_credit=500))) destination_credit=500)))
transaction.AccountingTransaction_convertDestinationPrice( invoice.AccountingTransaction_convertDestinationPrice(
form_id='view') form_id='view')
line_list = transaction.contentValues( line_list = invoice.contentValues(
portal_type=portal.getPortalAccountingMovementTypeList()) portal_type=portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
......
...@@ -571,11 +571,11 @@ class TestImmobilisationMixin(ERP5TypeTestCase): ...@@ -571,11 +571,11 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
self.getAccountingModule().manage_delObjects(id_list) self.getAccountingModule().manage_delObjects(id_list)
def stepValidateAccounting(self, sequence=None, sequence_list=None, **kw): def stepValidateAccounting(self, sequence=None, sequence_list=None, **kw):
for transaction in self.getAccountingModule().contentValues(): for accounting_transaction in self.getAccountingModule().contentValues():
transaction.stop() accounting_transaction.stop()
transaction.commit() transaction.commit()
self.tic() self.tic()
transaction.deliver() accounting_transaction.deliver()
transaction.commit() transaction.commit()
self.tic() self.tic()
......
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