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

Test what should happen when conversion is set on accounting lines, but the

currency is the same as the section currency.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23716 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 67a545a5
...@@ -582,6 +582,84 @@ class TestTransactionValidation(AccountingTestCase): ...@@ -582,6 +582,84 @@ class TestTransactionValidation(AccountingTestCase):
self.assertEquals('delivered', transaction.getSimulationState()) self.assertEquals('delivered', transaction.getSimulationState())
self.assertFalse(_checkPermission('Modify portal content', transaction)) self.assertFalse(_checkPermission('Modify portal content', transaction))
def test_UneededSourceAssetPrice(self):
# It is refunsed to validate an accounting transaction if lines have an
# asset price but the resource is the same as the accounting resource
transaction = self._makeOne(
portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1,
lines=(dict(source_value=self.account_module.payable,
source_debit=500,
source_asset_debit=600),
dict(source_value=self.account_module.receivable,
source_credit=500,
source_asset_credit=600)))
section = transaction.getSourceSectionValue()
self.assertEquals(section.getPriceCurrency(),
transaction.getResource())
# validation is refused
doActionFor = self.portal.portal_workflow.doActionFor
self.assertRaises(ValidationFailed, doActionFor, transaction,
'stop_action')
# and the source conversion tab is visible
self.failUnless(
transaction.AccountingTransaction_isSourceCurrencyConvertible())
# if asset price is set to the same value as quantity, validation is
# allowed
for line in transaction.getMovementList():
if line.getSourceValue() == self.account_module.payable:
line.setSourceAssetDebit(line.getSourceDebit())
elif line.getSourceValue() == self.account_module.receivable:
line.setSourceAssetCredit(line.getSourceCredit())
else:
self.fail('wrong line ?')
doActionFor(transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState())
def test_UneededDestinationAssetPrice(self):
# It is refunsed to validate an accounting transaction if lines have an
# asset price but the resource is the same as the accounting resource
transaction = self._makeOne(
portal_type='Purchase Invoice Transaction',
start_date=DateTime('2007/01/02'),
source_section_value=self.organisation_module.client_1,
lines=(dict(destination_value=self.account_module.payable,
destination_debit=500,
destination_asset_debit=600),
dict(destination_value=self.account_module.receivable,
destination_credit=500,
destination_asset_credit=600)))
section = transaction.getDestinationSectionValue()
self.assertEquals(section.getPriceCurrency(),
transaction.getResource())
# validation is refused
doActionFor = self.portal.portal_workflow.doActionFor
self.assertRaises(ValidationFailed, doActionFor, transaction,
'stop_action')
# and the destination conversion tab is visible
self.failUnless(
transaction.AccountingTransaction_isDestinationCurrencyConvertible())
# if asset price is set to the same value as quantity, validation is
# allowed
for line in transaction.getMovementList():
if line.getDestinationValue() == self.account_module.payable:
line.setDestinationAssetDebit(line.getDestinationDebit())
elif line.getDestinationValue() == self.account_module.receivable:
line.setDestinationAssetCredit(line.getDestinationCredit())
else:
self.fail('wrong line ?')
doActionFor(transaction, 'stop_action')
self.assertEquals('stopped', transaction.getSimulationState())
class TestClosingPeriod(AccountingTestCase): class TestClosingPeriod(AccountingTestCase):
"""Various tests for closing the period. """Various tests for closing the period.
......
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