From 932c5bf125840e6694073d67ab91408013918144 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 1 Nov 2007 22:33:30 +0000
Subject: [PATCH] test for new intermediate sum in trial balance

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17353 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testAccountingReports.py | 79 +++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/product/ERP5/tests/testAccountingReports.py b/product/ERP5/tests/testAccountingReports.py
index 6be36b4860..90bbe3a2a6 100644
--- a/product/ERP5/tests/testAccountingReports.py
+++ b/product/ERP5/tests/testAccountingReports.py
@@ -1171,6 +1171,7 @@ class TestAccountingReports(AccountingTestCase):
     request_form['simulation_state'] = ['stopped', 'delivered']
     request_form['show_empty_accounts'] = 1
     request_form['expand_accounts'] = 0
+    request_form['per_account_class_summary'] = 0
 
     report_section_list = self.getReportSectionList(
                                     'AccountModule_viewTrialBalanceReport')
@@ -1267,6 +1268,7 @@ class TestAccountingReports(AccountingTestCase):
     request_form['simulation_state'] = ['delivered']
     request_form['show_empty_accounts'] = 0
     request_form['expand_accounts'] = 1
+    request_form['per_account_class_summary'] = 0
 
     report_section_list = self.getReportSectionList(
                                     'AccountModule_viewTrialBalanceReport')
@@ -1459,6 +1461,7 @@ class TestAccountingReports(AccountingTestCase):
     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')
@@ -1535,6 +1538,7 @@ class TestAccountingReports(AccountingTestCase):
     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')
@@ -1605,6 +1609,7 @@ class TestAccountingReports(AccountingTestCase):
     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')
@@ -1645,6 +1650,7 @@ class TestAccountingReports(AccountingTestCase):
     request_form['show_empty_accounts'] = 0
     request_form['expand_accounts'] = 1
     request_form['gap'] = 'my_country/my_accounting_standards/4'
+    request_form['per_account_class_summary'] = 0
 
     report_section_list = self.getReportSectionList(
                                     'AccountModule_viewTrialBalanceReport')
@@ -1685,6 +1691,79 @@ class TestAccountingReports(AccountingTestCase):
         credit=300, final_debit_balance=2100, final_credit_balance=300,
         final_balance_if_debit=1800, final_balance_if_credit=0)
 
+
+  def testTrialBalanceAccountClassSummary(self):
+    # Test of trial balance with per "account class" summary
+    account_module = self.portal.account_module
+    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(2006, 2, 1),
+              lines=(dict(source_value=account_module.payable,
+                          source_debit=400.0),
+                     dict(source_value=account_module.receivable,
+                          source_credit=400.0),))
+    self._makeOne(
+              portal_type='Accounting Transaction',
+              title='Transaction 2',
+              source_reference='2',
+              simulation_state='delivered',
+              destination_section_value=self.organisation_module.client_1,
+              start_date=DateTime(2006, 2, 2),
+              lines=(dict(source_value=account_module.receivable,
+                          source_debit=600.0),
+                     dict(source_value=account_module.payable,
+                          source_credit=600.0),))
+    
+    # set request variables and render
+    request_form = self.portal.REQUEST.form
+    request_form['from_date'] = DateTime(2006, 1, 1)
+    request_form['at_date'] = DateTime(2006, 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'] = 1
+
+    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(4, len(data_line_list))
+
+    self.checkLineProperties(data_line_list[0], node_id='40',
+        node_title='Payable', initial_debit_balance=0,
+        initial_credit_balance=0, debit=400, credit=600,
+        final_debit_balance=400, final_credit_balance=600,
+        final_balance_if_debit=0, final_balance_if_credit=200)
+    
+    self.checkLineProperties(data_line_list[1], node_id='41',
+        node_title='Receivable', initial_debit_balance=0,
+        initial_credit_balance=0, debit=600, credit=400,
+        final_debit_balance=600, final_credit_balance=400,
+        final_balance_if_debit=200, final_balance_if_credit=0)
+
+    # The summary line for 4 class 
+    self.checkLineProperties(data_line_list[2],
+        node_title='Total for class 4', initial_debit_balance=0,
+        initial_credit_balance=0, debit=1000, credit=1000,
+        final_debit_balance=1000, final_credit_balance=1000,
+        final_balance_if_debit=200, final_balance_if_credit=200)
+    # an empty line for style
+    self.checkLineProperties(data_line_list[3], node_title=' ')
+
+    self.failUnless(line_list[-1].isStatLine())
+    self.checkLineProperties(line_list[-1], node_id=None, node_title=None,
+        initial_debit_balance=0, initial_credit_balance=0, debit=1000,
+        credit=1000, final_debit_balance=1000, final_credit_balance=1000,
+        final_balance_if_debit=200, final_balance_if_credit=200)
+
+
   def testGeneralLedger(self):
     # Simple test of general ledger
     # we will use the same data set as account statement
-- 
2.30.9