From 8830fb6dbf9282f5cfc5c09b549c59aa567fff2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 1 Nov 2007 19:42:25 +0000
Subject: [PATCH] add test for the problem fixed in r17345 (wrong initial
 balance when period_start_date == from_date)

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

diff --git a/product/ERP5/tests/testAccountingReports.py b/product/ERP5/tests/testAccountingReports.py
index c14b6eaff3..62065030f6 100644
--- a/product/ERP5/tests/testAccountingReports.py
+++ b/product/ERP5/tests/testAccountingReports.py
@@ -979,6 +979,74 @@ class TestAccountingReports(AccountingTestCase):
     self.failUnless(line_list[-1].isStatLine())
     self.checkLineProperties(line_list[-1], debit=600, credit=21)
 
+  def testAccountStatementPeriodDateEqualsFromDate(self):
+    # Initial balance in Account Statement for standard account: the initial
+    # balance is the balance at the beginning of the period + movements in the
+    # period.
+    # This is for the special case whe the period start date is equals to the
+    # start date
+
+    self.createAccountStatementDataSetOnTwoPeriods()
+    
+    t1b = self._makeOne(
+              portal_type='Sale Invoice Transaction',
+              title='Transaction 1b',
+              source_reference='1b',
+              simulation_state='delivered',
+              destination_section_value=self.organisation_module.client_1,
+              start_date=DateTime(2005, 12, 13),
+              lines=(dict(source_value=self.account_module.goods_sales,
+                          source_debit=21.0),
+                     dict(source_value=self.account_module.receivable,
+                          source_credit=21.0)))
+    
+    # set request variables and render   
+    request_form = self.portal.REQUEST.form
+    request_form['node'] = \
+                self.portal.account_module.receivable.getRelativeUrl()
+    request_form['from_date'] = DateTime(2006, 1, 1)
+    request_form['at_date'] = DateTime(2006, 2, 2)
+    request_form['section_category'] = 'group/demo_group'
+    request_form['simulation_state'] = ['delivered']
+    
+    report_section_list = self.getReportSectionList(
+                               'AccountModule_viewAccountStatementReport')
+    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(3, len(data_line_list))
+
+    self.checkLineProperties(data_line_list[0],
+                             Movement_getSpecificReference='Previous Balance',
+                             date=DateTime(2006, 1, 1),
+                             Movement_getExplanationTitle='',
+                             Movement_getMirrorSectionTitle='',
+                             debit=79,
+                             credit=0,
+                             running_total_price=79)
+
+    self.checkLineProperties(data_line_list[1],
+                             Movement_getSpecificReference='2',
+                             date=DateTime(2006, 1, 1),
+                             Movement_getExplanationTitle='Transaction 2',
+                             Movement_getMirrorSectionTitle='Client 1',
+                             debit=200,
+                             credit=0,
+                             running_total_price=279)
+
+    self.checkLineProperties(data_line_list[2],
+                             Movement_getSpecificReference='3',
+                             date=DateTime(2006, 2, 2),
+                             Movement_getExplanationTitle='Transaction 3',
+                             Movement_getMirrorSectionTitle='Client 1',
+                             debit=300,
+                             credit=0,
+                             running_total_price=579)
+
+    self.failUnless(line_list[-1].isStatLine())
+    self.checkLineProperties(line_list[-1], debit=579, credit=0)
+
 
   def testAccountStatementPeriodDateAndInitialBalanceForExpenseAccounts(self):
     # Account statement for expense or income account will not show
-- 
2.30.9