Commit 959ed281 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_accounting: adds filtering on ledger for Account Statement Report

parent ae08f36f
......@@ -24,6 +24,7 @@ mirror_section = request.get('mirror_section', None)
payment = request.get('payment', None)
function = request.get('function', None)
funding = request.get('funding', None)
ledger = request.get('ledger', None)
project = request.get('project', None)
simulation_state = request['simulation_state']
hide_analytic = request['hide_analytic']
......@@ -83,6 +84,8 @@ if mirror_section:
params['mirror_section_uid'] = traverse(mirror_section).getUid()
if parent_portal_type:
params['parent_portal_type'] = parent_portal_type
if ledger:
params['ledger'] = ledger
analytic_column_list = ()
if hide_analytic:
......
......@@ -101,6 +101,7 @@
<string>your_payment</string>
<string>your_node</string>
<string>your_portal_type</string>
<string>your_ledger</string>
<string>your_simulation_state</string>
<string>your_report_date</string>
</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 @@
<list>
<string>your_simulation_state</string>
<string>your_portal_type</string>
<string>your_ledger</string>
<string>your_export</string>
</list>
</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>
......@@ -36,6 +36,8 @@ if project_uid:
inventory_query['project_uid'] = project_uid
if function:
inventory_query['function_category'] = function
if params.get('ledger', None):
inventory_query['ledger'] = params.get('ledger')
if 'parent_portal_type' in params:
portal_type_list = params['parent_portal_type']
......
......@@ -22,6 +22,9 @@ if kw.get('node_uid'):
if kw.get('mirror_section_uid'):
params['mirror_section_uid'] = kw['mirror_section_uid']
if kw.get('ledger', None):
params['ledger'] = kw['ledger']
category_uid_list = ('payment_uid', 'project_uid', 'funding_uid',
'function_uid', 'payment_request_uid', 'default_aggregate_uid')
for category_uid in category_uid_list:
......
......@@ -65,6 +65,9 @@ if not 'parent_portal_type' in params:
# Remove unsupported inventory API parameters
params.pop('detailed_from_date_summary', None)
if kw.get('ledger', None):
params['ledger'] = kw.get('ledger')
period_start_date = params.pop('period_start_date', None)
if period_start_date and params.get('node_uid'):
# find the node for this node_uid
......
......@@ -798,8 +798,8 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
dict(source_value=account_module.goods_sales,
source_credit=300.0)))
def createLedgerDataSet(self):
# create some ledgers
@UnrestrictedMethod
def createLedgerCategory(self):
ledger = self.portal.portal_categories.ledger
self.accounting_ledger = ledger.get('accounting', None)
if self.accounting_ledger is None:
......@@ -810,10 +810,15 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
if self.accounting_ledger.get('detailed', None) is None:
self.accounting_ledger.newContent(portal_type='Category', id='detailed')
def createLedgerDataSet(self):
# create some ledgers
self.createLedgerCategory()
account_module = self.portal.account_module
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Ledger detailed',
reference='lad',
simulation_state='delivered',
destination_section_value=self.organisation_module.client_1,
ledger='accounting/detailed',
......@@ -830,6 +835,7 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self._makeOne(
portal_type='Sale Invoice Transaction',
title='Ledger general',
reference='lag',
simulation_state='delivered',
destination_section_value=self.organisation_module.client_1,
ledger='accounting/general',
......@@ -2193,6 +2199,39 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
self.checkLineProperties(line_list[-1], debit_price=700, credit_price=0)
def testAccountStatementLedger(self):
# test account statement on a ledger
self.createLedgerDataSet()
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, 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_viewAccountStatementReport')
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(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)
def testTrialBalance(self):
# Simple test of trial balance
# we will use the same data set as account statement
......
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