Commit 79541e08 authored by Jérome Perrin's avatar Jérome Perrin

when checking if a transaction is balanced, only look at lines where an account

is defined on this side.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21720 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f830b62
......@@ -50,7 +50,9 @@ class AccountingTransactionBalance(Constraint):
destination_sum = 0
for line in obj.getMovementList(
portal_type=obj.getPortalAccountingMovementTypeList()):
if line.getSourceValue() is not None:
source_sum += line.getSourceInventoriatedTotalAssetPrice() or 0
if line.getDestinationValue() is not None:
destination_sum += \
line.getDestinationInventoriatedTotalAssetPrice() or 0
......
......@@ -487,6 +487,32 @@ class TestTransactionValidation(AccountingTestCase):
line.setDestinationAssetDebit(38.99)
self.portal.portal_workflow.doActionFor(transaction, 'stop_action')
def test_NonBalancedDestinationAccountingTransactionNoAccount(self):
# Accounting Transactions have to be balanced to be validated,
# also for destination
transaction = self._makeOne(
portal_type='Accounting Transaction',
start_date=DateTime('2007/01/02'),
destination_section_value=self.organisation_module.client_1,
resource='currency_module/yen',
lines=(dict(source_value=self.account_module.payable,
destination_asset_debit=39,
source_debit=500),
dict(source_value=self.account_module.receivable,
destination_value=self.account_module.receivable,
destination_asset_credit=38.99,
source_credit=500)))
# This is not balanced
but there are no accounts on destination
self.assertRaises(ValidationFailed,
self.portal.portal_workflow.doActionFor,
transaction, 'stop_action')
for line in transaction.getMovementList():
if line.getDestinationId() == 'receivable':
line.setDestination(None)
# but if there are no accounts defined it's not a problem
self.portal.portal_workflow.doActionFor(transaction, 'stop_action')
def test_AccountingTransactionValidationRefusedWithCategoriesAsSections(self):
# Validating a transaction with categories as sections is refused.
# See http://wiki.erp5.org/Discussion/AccountingProblems
......
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