From 6152293f20d630e4cefa51a62c5f000e9a5c2b7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 12 Mar 2009 16:38:14 +0000
Subject: [PATCH] test order report when dates are not selected in the dialog

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

diff --git a/product/ERP5/tests/testTradeReports.py b/product/ERP5/tests/testTradeReports.py
index 5992f40e5d..9c7aad1ac9 100644
--- a/product/ERP5/tests/testTradeReports.py
+++ b/product/ERP5/tests/testTradeReports.py
@@ -521,6 +521,71 @@ class TestTradeReports(ERP5ReportTestCase):
                       'total amount': 3*11 + 7*6 + 5*3 + 6})
 
 
+    # dates not specified -> they should be guessed
+    request['from_date'] = None
+    request['at_date'] = None
+    request['simulation_state'] = ['draft',]
+    request['aggregation_level'] = "year"
+    request['group_by'] = "both"
+    request['group'] = 'g2'
+    report_section_list = self.getReportSectionList(self.sale_order_module,
+                                                    'OrderModule_viewOrderReport')
+    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()]
+    stat_line_list = [l for l in line_list if l.isStatLine()]
+    self.assertEquals(3, len(data_line_list))
+    self.assertEquals(1, len(stat_line_list))
+    # First organisation    
+    d = {'Amount 2006': 75.0,
+                 'Amount 2007': 9.0,
+                 'Quantity 2006': None,
+                 'Quantity 2007': None,
+                 'Quantity Unit 2006': None,
+                 'Quantity Unit 2007': None,
+                 'client': 'Organisation_1',
+                 'product': None,
+                 'total amount': 84.0,
+                 'total quantity': None}
+    self.checkLineProperties(data_line_list[0],**d)
+    # Product one for organisation
+    d = {'Amount 2006': 33.0,
+                 'Amount 2007': 9.0,
+                 'Quantity 2006': 11.0,
+                 'Quantity 2007': 3.0,
+                 'Quantity Unit 2006': 'G',
+                 'Quantity Unit 2007': 'G',
+                 'client': None,
+                 'product': 'product_A',
+                 'total amount': 42.0,
+                 'total quantity': 14.0}
+    # Product two for organisation
+    self.checkLineProperties(data_line_list[1],**d)
+    d = {'Amount 2006': 42.0,
+                 'Amount 2007': 0,
+                 'Quantity 2006': 7.0,
+                 'Quantity 2007': 0,
+                 'Quantity Unit 2006': 'Kg',
+                 'Quantity Unit 2007': '',
+                 'client': None,
+                 'product': 'product_B',
+                 'total amount': 42.0,
+                 'total quantity': 7.0}
+    self.checkLineProperties(data_line_list[2],**d)
+    # stat line
+    d = {'Amount 2006': 75.0,
+                 'Amount 2007': 9.0,
+                 'Quantity 2006': None,
+                 'Quantity 2007': None,
+                 'Quantity Unit 2006': None,
+                 'Quantity Unit 2007': None,
+                 'client': 'Total',
+                 'product': None,
+                 'total amount': 84.0,
+                 'total quantity': None}
+    self.checkLineProperties(stat_line_list[0],**d)
+  
   def testStockReport(self):
     """
     Stock report.
-- 
2.30.9