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

test that balance transactions the first day of the period appears in initial balance columns


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17487 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eed4313d
......@@ -52,6 +52,12 @@ class TestAccountingReports(AccountingTestCase):
def getTitle(self):
return "Accounting Reports"
def beforeTearDown(self):
# workaround the fact that Balance Transaction Line are not unindexed
# correctly when removed
self.portal.erp5_sql_connection.manage_test('TRUNCATE TABLE stock')
get_transaction().commit()
# utility methods for ERP5 Report
def getReportSectionList(self, report_name):
"""Get the list of report sections in a report."""
......@@ -1637,6 +1643,72 @@ class TestAccountingReports(AccountingTestCase):
final_balance_if_debit=200, final_balance_if_credit=200)
def testTrialBalanceInitialBalanceBalanceTransaction(self):
# Test of trial balance and initial balance with balance transactions.
# Unlike other transactions balance transactions passed the first day of
# the period will count as "initial balance", not as movement in the period
account_module = self.portal.account_module
self._makeOne(
portal_type='Balance Transaction',
title='Transaction 0',
destination_reference='0',
simulation_state='delivered',
source_section_value=self.organisation_module.client_1,
start_date=DateTime(2007, 1, 1),
lines=(dict(destination_value=account_module.payable,
destination_debit=100.0),
dict(destination_value=account_module.receivable,
destination_credit=100.0),))
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
simulation_state='delivered',
destination_section_value=self.organisation_module.client_1,
start_date=DateTime(2007, 1, 1),
lines=(dict(source_value=account_module.payable,
source_debit=10.0),
dict(source_value=account_module.receivable,
source_credit=10.0),))
# set request variables and render
request_form = self.portal.REQUEST.form
request_form['from_date'] = DateTime(2007, 1, 1)
request_form['at_date'] = DateTime(2007, 12, 31)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['delivered']
request_form['show_empty_accounts'] = 0
request_form['expand_accounts'] = 0
request_form['per_account_class_summary'] = 0
report_section_list = self.getReportSectionList(
'AccountModule_viewTrialBalanceReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
self.checkLineProperties(data_line_list[0], node_id='40',
node_title='Payable', initial_debit_balance=100,
initial_credit_balance=0, debit=10, credit=0,
final_debit_balance=110, final_credit_balance=0,
final_balance_if_debit=110, final_balance_if_credit=0)
self.checkLineProperties(data_line_list[1], node_id='41',
node_title='Receivable', initial_debit_balance=0,
initial_credit_balance=100, debit=0, credit=10,
final_debit_balance=0, final_credit_balance=110,
final_balance_if_debit=0, final_balance_if_credit=110)
self.failUnless(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], node_id=None, node_title=None,
initial_debit_balance=100, initial_credit_balance=100, debit=10,
credit=10, final_debit_balance=110, final_credit_balance=110,
final_balance_if_debit=110, final_balance_if_credit=110)
def testTrialBalanceInitialBalanceWithPeriod(self):
# Test of trial balance and initial balance
account_module = self.portal.account_module
......@@ -1715,6 +1787,71 @@ class TestAccountingReports(AccountingTestCase):
final_balance_if_debit=89, final_balance_if_credit=89)
def testTrialBalanceInitialBalancePeriodStartDateBalanceTransaction(self):
# Test of trial balance and initial balance with balance transactions and
# transactions between period start date and from date
# This is a combination of
account_module = self.portal.account_module
self._makeOne(
portal_type='Balance Transaction',
title='Transaction 0',
destination_reference='0',
simulation_state='delivered',
source_section_value=self.organisation_module.client_1,
start_date=DateTime(2007, 1, 1),
lines=(dict(destination_value=account_module.payable,
destination_debit=100.0),
dict(destination_value=account_module.receivable,
destination_credit=100.0),))
self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
simulation_state='delivered',
destination_section_value=self.organisation_module.client_1,
start_date=DateTime(2007, 1, 1),
lines=(dict(source_value=account_module.payable,
source_debit=10.0),
dict(source_value=account_module.receivable,
source_credit=10.0),))
# set request variables and render
request_form = self.portal.REQUEST.form
request_form['from_date'] = DateTime(2007, 1, 1)
request_form['at_date'] = DateTime(2007, 12, 31)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['delivered']
request_form['show_empty_accounts'] = 0
request_form['expand_accounts'] = 0
request_form['per_account_class_summary'] = 0
report_section_list = self.getReportSectionList(
'AccountModule_viewTrialBalanceReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
self.checkLineProperties(data_line_list[0], node_id='40',
node_title='Payable', initial_debit_balance=100,
initial_credit_balance=0, debit=10, credit=0,
final_debit_balance=110, final_credit_balance=0,
final_balance_if_debit=110, final_balance_if_credit=0)
self.checkLineProperties(data_line_list[1], node_id='41',
node_title='Receivable', initial_debit_balance=0,
initial_credit_balance=100, debit=0, credit=10,
final_debit_balance=0, final_credit_balance=110,
final_balance_if_debit=0, final_balance_if_credit=110)
self.failUnless(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], node_id=None, node_title=None,
initial_debit_balance=100, initial_credit_balance=100, debit=10,
credit=10, final_debit_balance=110, final_credit_balance=110,
final_balance_if_debit=110, final_balance_if_credit=110)
def testTrialBalanceDifferentCurrencies(self):
# Test of trial balance and different currencies
account_module = self.portal.account_module
......
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