Commit b46c3772 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_accounting: adds filtering on ledger for Third Parties Report

parent 2df92e7f
...@@ -12,6 +12,7 @@ role_filter_list = request.get('mirror_section_category_list', None) ...@@ -12,6 +12,7 @@ role_filter_list = request.get('mirror_section_category_list', None)
omit_balanced_accounts = request['omit_balanced_accounts'] omit_balanced_accounts = request['omit_balanced_accounts']
from_date = request.get('from_date', None) from_date = request.get('from_date', None)
project = request.get('project', None) project = request.get('project', None)
ledger = request.get('ledger', None)
currency = portal.Base_getCurrencyForSection(request['section_category']) currency = portal.Base_getCurrencyForSection(request['section_category'])
precision = portal.account_module.getQuantityPrecisionFromResource(currency) precision = portal.account_module.getQuantityPrecisionFromResource(currency)
...@@ -46,6 +47,16 @@ if project: ...@@ -46,6 +47,16 @@ if project:
else: else:
params['project_uid'] = portal.restrictedTraverse(project).getUid() params['project_uid'] = portal.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:
params.setdefault('ledger_uid', []).append(ledger_value.getUid())
simulation_tool = portal.portal_simulation simulation_tool = portal.portal_simulation
entity_columns = [ entity_columns = [
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<string>your_omit_grouping_reference</string> <string>your_omit_grouping_reference</string>
<string>your_mirror_section_category_list</string> <string>your_mirror_section_category_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>
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,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>
</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>
...@@ -25,8 +25,8 @@ if kw.get('mirror_section_uid'): ...@@ -25,8 +25,8 @@ if kw.get('mirror_section_uid'):
if kw.get('ledger', None): if kw.get('ledger', None):
params['ledger'] = kw['ledger'] params['ledger'] = kw['ledger']
category_uid_list = ('payment_uid', 'project_uid', 'funding_uid', category_uid_list = ('payment_uid', 'project_uid', 'funding_uid', 'function_uid',
'function_uid', 'payment_request_uid', 'default_aggregate_uid') 'ledger_uid', 'payment_request_uid', 'default_aggregate_uid')
for category_uid in category_uid_list: for category_uid in category_uid_list:
category_uid_value = kw.get(category_uid) category_uid_value = kw.get(category_uid)
if category_uid_value: if category_uid_value:
......
...@@ -16,7 +16,7 @@ if kw.get('mirror_section_uid'): ...@@ -16,7 +16,7 @@ if kw.get('mirror_section_uid'):
params['mirror_section_uid'] = kw['mirror_section_uid'] params['mirror_section_uid'] = kw['mirror_section_uid']
category_uid_list = ('payment_uid', 'project_uid', 'funding_uid', category_uid_list = ('payment_uid', 'project_uid', 'funding_uid',
'function_uid', 'payment_request_uid') 'ledger_uid', 'function_uid', 'payment_request_uid')
for category_uid in category_uid_list: for category_uid in category_uid_list:
category_uid_value = kw.get(category_uid) category_uid_value = kw.get(category_uid)
if category_uid_value: if category_uid_value:
......
...@@ -4377,6 +4377,100 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): ...@@ -4377,6 +4377,100 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase):
credit_price=0, credit_price=0,
debit_price=300,) debit_price=300,)
def testOtherPartiesReportLedger(self):
# Other parties report with a filter on ledger
# This tests works because /for the moment/ any transaction between 2
# entities belong to the same ledger
self.createLedgerCategory()
account_module = self.portal.account_module
t1 = self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 1',
source_reference='1',
simulation_state='delivered',
ledger='accounting/general',
destination_section_value=self.organisation_module.client_1,
start_date=DateTime(2006, 2, 1),
lines=(dict(source_value=account_module.receivable,
source_debit=100.0),
dict(source_value=account_module.goods_sales,
source_credit=100.0)))
t2 = self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 2',
source_reference='2',
simulation_state='delivered',
ledger='accounting/general',
destination_section_value=self.organisation_module.client_1,
start_date=DateTime(2006, 2, 1, 0, 1),
lines=(dict(source_value=account_module.payable,
source_debit=200.0),
dict(source_value=account_module.goods_sales,
source_credit=200.0)))
t3 = self._makeOne(
portal_type='Accounting Transaction',
title='Transaction 3',
source_reference='3',
simulation_state='delivered',
ledger='accounting/detailed',
destination_section_value=self.organisation_module.client_1,
start_date=DateTime(2006, 2, 1, 0, 2),
lines=(dict(source_value=account_module.payable,
source_debit=400.0),
dict(source_value=account_module.goods_sales,
source_credit=400.0)))
request_form = self.portal.REQUEST.form
request_form['at_date'] = DateTime(2006, 2, 1)
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['omit_balanced_accounts'] = False
request_form['omit_grouping_reference'] = True
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountModule_viewOtherPartiesReport')
self.assertEqual(1, len(report_section_list))
# the role is displayed in parenthesis
self.assertEqual(report_section_list[0].getTitle(),
'Client 1 (Client)')
# currency is present in the report
self.assertEqual('currency_module/euro', self.portal.
AccountModule_viewOtherPartiesReport.your_currency.get_value('default'))
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],
Movement_getExplanationTitle='Transaction 1',
Movement_getExplanationTranslatedPortalType='Accounting Transaction',
Movement_getNodeGapId='41',
credit_price=0,
debit_price=100,
date=DateTime('2006/02/01'),
getTranslatedSimulationStateTitle='Closed',
running_total_price=100.0)
self.checkLineProperties(data_line_list[1],
Movement_getExplanationTitle='Transaction 2',
Movement_getExplanationTranslatedPortalType='Accounting Transaction',
Movement_getNodeGapId='40',
credit_price=0,
debit_price=200,
date=DateTime(2006, 2, 1, 0, 1),
getTranslatedSimulationStateTitle='Closed',
running_total_price=300.0)
self.assertTrue(line_list[-1].isStatLine())
self.checkLineProperties(line_list[-1],
credit_price=0,
debit_price=300,)
def createAgedBalanceDataSet(self): def createAgedBalanceDataSet(self):
"""Create data set for aged balance: """Create data set for aged balance:
2013/07/30: Purchase invoice 1 (500) 2013/07/30: Purchase invoice 1 (500)
......
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