From fd9a5eac1bddd9f7e23cd3c6b9d69ecbe812ade0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 24 Apr 2007 16:55:08 +0000 Subject: [PATCH] Calculate GL summary correctly and pass precision parameter git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14193 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...dule_getGeneralLedgerReportSectionList.xml | 8 +++ .../AccountModule_getGeneralLedgerSummary.xml | 59 +++++++++++++++---- bt5/erp5_accounting/bt/revision | 2 +- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.xml index a7886bf92e..5b1f04d1c4 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.xml +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getGeneralLedgerReportSectionList.xml @@ -90,12 +90,18 @@ period_start_date = context\\\n .Base_getAccountingPeriodStartDateForSectionCategory(\n section_category=section_category, date=from_date or at_date)\n \n +# currency precision\n +currency = portal.Base_getCurrencyForSection(request[\'section_category\'])\n +precision = portal.account_module.getQuantityPrecisionFromResource(currency)\n +request.set(\'precision\', precision)\n +\n # TODO\n omit_grouping_reference = request.get(\'omit_grouping_reference\', False)\n \n request.other[\'is_accounting_report\'] = True\n \n params = dict(at_date=at_date,\n + precision=precision,\n section_uid=section_uid,\n simulation_state=simulation_state,\n omit_grouping_reference=omit_grouping_reference,\n @@ -313,6 +319,8 @@ return result\n <string>False</string> <string>display_categories</string> <string>period_start_date</string> + <string>currency</string> + <string>precision</string> <string>omit_grouping_reference</string> <string>_write_</string> <string>dict</string> 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 80f2cef318..11381b1353 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 @@ -76,14 +76,48 @@ inventory_kw = dict(section_uid=section_uid,\n at_date=at_date,\n portal_type=context.getPortalAccountingMovementTypeList(),\n )\n +\n if node_category:\n - inventory_kw[\'node_category\'] = node_category\n + # XXX if node category is passed, income or balance accounts are not\n + # calculated differently. As a result, the summary doesn\'t take from_date\n + # into account for income accounts.\n + return [Object(\n + debit=getInventoryAssetPrice(omit_output=1,\n + node_category=node_category,\n + precision=precision,\n + **inventory_kw),\n + credit=-getInventoryAssetPrice(omit_input=1,\n + node_category=node_category,\n + precision=precision,\n + **inventory_kw) or 0 ) ]\n +\n +income_node_category = [\'account_type/income\', \'account_type/expense\']\n +balance_node_category = [\'account_type/equity\', \'account_type/asset\',\n + \'account_type/liability\']\n +\n +debit = getInventoryAssetPrice(omit_output=1,\n + from_date=period_start_date,\n + node_category=income_node_category,\n + precision=precision,\n + **inventory_kw)\n +\n +credit = - getInventoryAssetPrice(omit_input=1,\n + from_date=period_start_date,\n + node_category=income_node_category,\n + precision=precision,\n + **inventory_kw) or 0\n +\n +debit += getInventoryAssetPrice(omit_output=1,\n + node_category=balance_node_category,\n + precision=precision,\n + **inventory_kw)\n +\n +credit -= getInventoryAssetPrice(omit_input=1,\n + node_category=balance_node_category,\n + precision=precision,\n + **inventory_kw) or 0\n \n -return [Object(\n - debit=getInventoryAssetPrice(omit_output=1,\n - **inventory_kw),\n - credit= - getInventoryAssetPrice(omit_input=1,\n - **inventory_kw) or 0,)]\n +return [Object(debit=debit, credit=credit)]\n </string> </value> </item> <item> @@ -106,7 +140,7 @@ return [Object(\n </item> <item> <key> <string>_params</string> </key> - <value> <string>section_uid, simulation_state, at_date, node_category=None, from_date=\'ignored\', **kw</string> </value> + <value> <string>section_uid, simulation_state, at_date, period_start_date, precision, node_category=None, from_date=\'ignored\', **kw</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -126,7 +160,7 @@ return [Object(\n <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>5</int> </value> + <value> <int>7</int> </value> </item> <item> <key> <string>co_varnames</string> </key> @@ -135,18 +169,23 @@ return [Object(\n <string>section_uid</string> <string>simulation_state</string> <string>at_date</string> + <string>period_start_date</string> + <string>precision</string> <string>node_category</string> <string>from_date</string> <string>kw</string> <string>Products.PythonScripts.standard</string> <string>Object</string> <string>_getattr_</string> -<string>context</string> + <string>context</string> <string>getInventoryAssetPrice</string> <string>dict</string> <string>inventory_kw</string> - <string>_write_</string> <string>_apply_</string> + <string>income_node_category</string> + <string>balance_node_category</string> + <string>debit</string> + <string>credit</string> </tuple> </value> </item> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index c6876402f5..ac7cd1ac70 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -278 \ No newline at end of file +279 \ No newline at end of file -- 2.30.9