Commit 2df92e7f authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_accounting: adds filtering on ledger for Journal Report

parent 959ed281
...@@ -2,10 +2,13 @@ from Products.ERP5Form.Report import ReportSection ...@@ -2,10 +2,13 @@ from Products.ERP5Form.Report import ReportSection
request = container.REQUEST request = container.REQUEST
Base_translateString = container.Base_translateString Base_translateString = container.Base_translateString
portal = context.getPortalObject()
portal_type = request['portal_type'] portal_type = request['portal_type']
simulation_state = request['simulation_state'] simulation_state = request['simulation_state']
hide_analytic = request['hide_analytic'] hide_analytic = request['hide_analytic']
project = request.get('project', None) project = request.get('project', None)
ledger = request.get('ledger', None)
at_date = request['at_date'].latestTime() at_date = request['at_date'].latestTime()
from_date = request.get('from_date') or at_date.earliestTime() from_date = request.get('from_date') or at_date.earliestTime()
section_uid = context.Base_getSectionUidListForSectionCategory( section_uid = context.Base_getSectionUidListForSectionCategory(
...@@ -38,6 +41,16 @@ if project: ...@@ -38,6 +41,16 @@ if project:
selection_params['project_uid'] = \ selection_params['project_uid'] = \
context.getPortalObject().restrictedTraverse(project).getUid() context.getPortalObject().restrictedTraverse(project).getUid()
if ledger:
if not isinstance(ledger, list):
# Allows the generation of reports on different ledgers as the same time
ledger = [ledger]
portal_categories = portal.portal_categories
ledger_value_list = [portal_categories.restrictedTraverse(ledger_category, None)
for ledger_category in ledger]
for ledger_value in ledger_value_list:
selection_params.setdefault('ledger_uid', []).append(ledger_value.getUid())
analytic_column_list = () analytic_column_list = ()
if hide_analytic: if hide_analytic:
selection_params['group_by'] = ( 'explanation_uid', selection_params['group_by'] = ( 'explanation_uid',
......
...@@ -19,6 +19,9 @@ if project_uid: ...@@ -19,6 +19,9 @@ if project_uid:
else: else:
extra_kw['project_uid'] = project_uid extra_kw['project_uid'] = project_uid
if ledger_uid:
extra_kw['ledger_uid'] = ledger_uid
account_title_cache = {} account_title_cache = {}
def getAccountId(node_relative_url): def getAccountId(node_relative_url):
if node_relative_url not in account_title_cache: if node_relative_url not in account_title_cache:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>selection, at_date, from_date, portal_type, simulation_state, section_uid, payment_mode=None, payment=None, gap_root=None, group_by=None, analytic_column_list=[], project_uid=None, **kw</string> </value> <value> <string>selection, at_date, from_date, portal_type, simulation_state, section_uid, payment_mode=None, payment=None, gap_root=None, group_by=None, analytic_column_list=[], project_uid=None, ledger_uid=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
<list> <list>
<string>your_simulation_state</string> <string>your_simulation_state</string>
<string>your_portal_type</string> <string>your_portal_type</string>
<string>your_ledger</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountModule_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
<string>your_at_date</string> <string>your_at_date</string>
<string>your_gap_root</string> <string>your_gap_root</string>
<string>your_portal_type</string> <string>your_portal_type</string>
<string>your_ledger</string>
<string>your_simulation_state</string> <string>your_simulation_state</string>
</list> </list>
</value> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_ledger</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountModule_viewReportFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -527,6 +527,39 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): ...@@ -527,6 +527,39 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self.assertTrue(line_list[-1].isStatLine()) self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=500, credit=500) self.checkLineProperties(line_list[-1], debit=500, credit=500)
def testJournalLedger(self):
self.createLedgerDataSet()
request_form = self.portal.REQUEST.form
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['section_category_strict'] = False
request_form['portal_type'] = ['Sale Invoice Transaction']
request_form['simulation_state'] = ['delivered']
request_form['ledger'] = 'ledger/accounting/general'
request_form['hide_analytic'] = True
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewJournalReport')
self.assertEqual(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.assertEqual(2, len(data_line_list))
self.checkLineProperties(data_line_list[0],
node_title='41',
mirror_section_title='Client 1',
debit=500,
credit=0)
self.checkLineProperties(data_line_list[1],
node_title='7',
debit=0,
credit=500)
stat_line = line_list[-1]
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit=500, credit=500)
def createAccountStatementDataSet(self, use_two_bank_accounts=1): def createAccountStatementDataSet(self, use_two_bank_accounts=1):
"""Create transactions for Account statement report. """Create transactions for Account statement report.
......
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