diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.py b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.py index 107cb476c3050b610119ae6db811ffccfb6dcaa3..7df481bf4426767b4610cb7704c4d0f58bfc862d 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.py +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.py @@ -206,13 +206,17 @@ account_type_to_group_by_node = [at for at in balance_sheet_account_type_list if gap_list or gap_root: params['node_category'] = gap_list or gap_root - default_selection_params['node_category'] = gap_list or gap_root if mirror_section_category_list: params['mirror_section_category'] = mirror_section_category_list default_selection_params['mirror_section_category'] =\ mirror_section_category_list +# inventory parameters for the total section +total_params = default_selection_params.copy() +# we'll append all the node used, instead of using node_category. +total_params['node_uid'] = set([]) + report_section_list = [] existing_section_dict = {} @@ -241,6 +245,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # non zero balance at begining of period for inventory in portal.portal_simulation.getInventoryList( @@ -268,6 +273,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # profit & loss -> same, but from date limited to the current period @@ -292,6 +298,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # group by mirror_section # movements in the period @@ -317,6 +324,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # non zero balance at begining of period for inventory in portal.portal_simulation.getInventoryList( @@ -345,6 +353,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # group by payment # movements in the period @@ -370,6 +379,7 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) # non zero balance at begining of period for inventory in portal.portal_simulation.getInventoryList( @@ -397,13 +407,14 @@ for inventory in portal.portal_simulation.getInventoryList( addReportSection(path=inventory.node_relative_url, selection_params=selection_params, title=getFullAccountName(key)) + total_params['node_uid'].add(inventory.node_uid) report_section_list = [x[1] for x in sorted(report_section_list, key=lambda x: x[0])] if not export: - total_params = default_selection_params.copy() total_params['at_date'] = at_date + total_params['node_uid'] = list(total_params['node_uid']) report_section_list.append(ReportSection( path=context.getPhysicalPath(), title=Base_translateString("Total"), diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.py b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.py index 2d54319205ee7242159935266178b5d2cda5ee18..a781d8650d3692ec08f87cb36fd950de24cea86b 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.py +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.py @@ -23,17 +23,17 @@ if mirror_section_uid: if ledger_uid: inventory_kw['ledger_uid'] = ledger_uid -if node_category: - # XXX if node category is passed, income or balance accounts are not +if node_uid: + # XXX if node uid is passed, income or balance accounts are not # calculated differently. As a result, the summary doesn't take from_date # into account for income accounts. return [Object( debit_price=getInventoryAssetPrice(omit_asset_decrease=1, - node_category=node_category, + node_uid=node_uid, precision=precision, **inventory_kw), credit_price=-getInventoryAssetPrice(omit_asset_increase=1, - node_category=node_category, + node_uid=node_uid, precision=precision, **inventory_kw) or 0 ) ] diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.xml index 7911269f3e74668f111872806a0e2b71016494ed..682d7cdf951c0b1b05fc911c04fcf8f4cf395af0 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerSummary.xml @@ -50,7 +50,7 @@ </item> <item> <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, ledger_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_uid=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> <key> <string>id</string> </key> diff --git a/product/ERP5/tests/testAccountingReports.py b/product/ERP5/tests/testAccountingReports.py index 9e0ca6d8bd25ad79db7ce8419e57c47657558dbe..5e84f79d2d694ca1c5ec97764e629c51f9b29ca0 100644 --- a/product/ERP5/tests/testAccountingReports.py +++ b/product/ERP5/tests/testAccountingReports.py @@ -4181,6 +4181,74 @@ class TestAccountingReports(AccountingTestCase, ERP5ReportTestCase): self.assertEqual(1, len(data_line_list)) self.checkLineProperties(data_line_list[0], debit_price=200, credit_price=100) + def testGeneralLedgerGAPFilterSameGAPSelectedTwice(self): + # General Ledger filtered by GAP category. Edge case: selecting + # a gap and its parent. This use to double the amount because + # node is twice member of node_category + + # we will use the same data set as account statement + self.createAccountStatementDataSetOnTwoPeriods() + + # set request variables and render + request_form = self.portal.REQUEST.form + request_form['from_date'] = DateTime(2006, 2, 1) + request_form['at_date'] = DateTime(2006, 12, 31) + # Here we select 4 and 41 + request_form['gap_list'] = [ + 'my_country/my_accounting_standards/4', + 'my_country/my_accounting_standards/4/41'] + + request_form['section_category'] = 'group/demo_group' + request_form['section_category_strict'] = False + request_form['simulation_state'] = ['delivered'] + request_form['hide_analytic'] = False + request_form['export'] = False + + report_section_list = self.getReportSectionList( + self.portal.accounting_module, + 'AccountModule_viewGeneralLedgerReport') + self.assertEqual(2, len(report_section_list)) + + self.assertEqual( + '41 - Receivable (Client 1)', + report_section_list[0].getTitle()) + 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_getSpecificReference='Previous Balance', + date=DateTime(2006, 2, 1), + debit_price=300, + credit_price=0, + running_total_price=300, ) + + self.checkLineProperties( + data_line_list[1], + Movement_getSpecificReference='3', + Movement_getExplanationTitleAndAnalytics='Transaction 3\nref3', + date=DateTime(2006, 2, 2), + debit_price=300, + credit_price=0, + running_total_price=600, ) + + self.assertTrue(line_list[-1].isStatLine()) + self.checkLineProperties(line_list[-1], + Movement_getSpecificReference=None, + Movement_getExplanationTitleAndAnalytics=None, + date=None, + debit_price=600, credit_price=0, ) + + self.assertEqual('Total', report_section_list[1].getTitle()) + 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], + debit_price=600, + credit_price=0) + def testGeneralLedgerFunction(self): # general ledger restricted to a function self.createProjectAndFunctionDataSet()