Commit fe70bd53 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_accounting: adds filtering on ledger for General Ledger Report

parent b46c3772
...@@ -79,6 +79,16 @@ if mirror_section: ...@@ -79,6 +79,16 @@ if mirror_section:
mirror_section_uid = portal.restrictedTraverse(mirror_section).getUid() mirror_section_uid = portal.restrictedTraverse(mirror_section).getUid()
params['mirror_section_uid'] = mirror_section_uid params['mirror_section_uid'] = mirror_section_uid
ledger = request.get('ledger', None)
if ledger:
if not isinstance(ledger, list):
# Allows the generation of reports on different ledgers as the same time
ledger = [ledger]
ledger_value_list = [cat_tool.restrictedTraverse(ledger_category, None)
for ledger_category in ledger]
for ledger_value in ledger_value_list:
params.setdefault('ledger_uid', []).append(ledger_value.getUid())
default_selection_params = params.copy() default_selection_params = params.copy()
default_selection_params['period_start_date'] = period_start_date default_selection_params['period_start_date'] = period_start_date
default_selection_params['movement_portal_type'] = portal.getPortalAccountingMovementTypeList() default_selection_params['movement_portal_type'] = portal.getPortalAccountingMovementTypeList()
......
...@@ -20,6 +20,8 @@ if mirror_section_category: ...@@ -20,6 +20,8 @@ if mirror_section_category:
inventory_kw['mirror_section_category'] = mirror_section_category inventory_kw['mirror_section_category'] = mirror_section_category
if mirror_section_uid: if mirror_section_uid:
inventory_kw['mirror_section_uid'] = mirror_section_uid inventory_kw['mirror_section_uid'] = mirror_section_uid
if ledger_uid:
inventory_kw['ledger_uid'] = ledger_uid
if node_category: if node_category:
# XXX if node category is passed, income or balance accounts are not # XXX if node category is passed, income or balance accounts are not
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>section_uid, simulation_state, at_date, period_start_date, precision, node_category=None, function_category=None, function_uid=None, funding_category=None, funding_uid=None, project_uid=None, from_date=\'ignored\', mirror_section_category=None, mirror_section_uid=None, **kw</string> </value> <value> <string>section_uid, simulation_state, at_date, period_start_date, precision, node_category=None, function_category=None, function_uid=None, funding_category=None, funding_uid=None, project_uid=None, ledger_uid=None, from_date=\'ignored\', mirror_section_category=None, mirror_section_uid=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
<string>your_mirror_section</string> <string>your_mirror_section</string>
<string>your_gap_list</string> <string>your_gap_list</string>
<string>your_gap_root</string> <string>your_gap_root</string>
<string>your_ledger</string>
<string>your_simulation_state</string> <string>your_simulation_state</string>
<string>your_report_date</string> <string>your_report_date</string>
</list> </list>
......
<?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>
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
<list> <list>
<string>your_simulation_state</string> <string>your_simulation_state</string>
<string>your_mirror_section_category_list</string> <string>your_mirror_section_category_list</string>
<string>your_ledger</string>
<string>your_export</string> <string>your_export</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_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>
...@@ -4214,6 +4214,50 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): ...@@ -4214,6 +4214,50 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self.assertEqual(1, len(data_line_list)) self.assertEqual(1, len(data_line_list))
self.checkLineProperties(data_line_list[0], debit_price=500, credit_price=500) self.checkLineProperties(data_line_list[0], debit_price=500, credit_price=500)
def testGeneralLedgerLedger(self):
# general ledger restricted to a ledger
self.createLedgerDataSet()
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['section_category_strict'] = False
request_form['simulation_state'] = ['delivered']
request_form['ledger'] = 'ledger/accounting/general'
request_form['hide_analytic'] = False
request_form['export'] = False
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountModule_viewGeneralLedgerReport')
self.assertEqual(3, 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(1, len(data_line_list))
self.checkLineProperties(data_line_list[0],
Movement_getExplanationTitleAndAnalytics='Ledger general\nlag',
date=DateTime(2006, 2, 2),
debit_price=500, credit_price=0, running_total_price=500, )
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=500, credit_price=0)
line_list = self.getListBoxLineList(report_section_list[1])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(1, len(data_line_list))
self.checkLineProperties(data_line_list[0],
Movement_getExplanationTitleAndAnalytics='Ledger general\nlag',
date=DateTime(2006, 2, 2),
debit_price=0, credit_price=500, running_total_price=-500, )
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1], debit_price=0, credit_price=500)
line_list = self.getListBoxLineList(report_section_list[2])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEqual(1, len(data_line_list))
self.checkLineProperties(data_line_list[0], debit_price=500, credit_price=500)
def testGeneralLedgerMirrorSectionRole(self): def testGeneralLedgerMirrorSectionRole(self):
# general ledger restricted to a mirror section role # general ledger restricted to a mirror section role
self.createMirrorSectionRoleDataSet() self.createMirrorSectionRoleDataSet()
......
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