From eb255c6aaa1612619f4991445ffaa01593a43b7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 28 Jan 2011 10:57:12 +0000
Subject: [PATCH] * support that one can have more account types in asset,
 equity or liability. It was producing wrong GL and TB * make sure to call the
 analytic scripts on accounting_module

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42732 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ntModule_getAccountListForTrialBalance.xml | 53 ++++++++-----------
 ...dule_getGeneralLedgerReportSectionList.xml | 16 +++---
 ...tionModule_getJournalReportSectionList.xml |  2 +-
 bt5/erp5_accounting/bt/revision               |  2 +-
 4 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance.xml
index c19632380e..ef05e3068b 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountModule_getAccountListForTrialBalance.xml
@@ -117,13 +117,11 @@ line_per_account = {}\n
 # account ?"\n
 account_used = {}\n
 \n
-account_type_to_group_by_node = [\n
-                  \'account_type/asset\',\n
-                  \'account_type/asset/cash\',\n
-                  \'account_type/asset/receivable/refundable_vat\',\n
-                  \'account_type/liability/payable/collected_vat\',\n
-                  \'account_type/equity\',\n
-                  \'account_type/liability\',]\n
+account_type = portal.portal_categories.account_type\n
+balance_sheet_account_type_list = [c[0] for c in \n
+ account_type.asset.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False ) + \\\n
+ account_type.equity.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False) + \\\n
+ account_type.liability.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False) ]\n
 \n
 profit_and_loss_account_type = [\n
                   \'account_type/expense\',\n
@@ -131,16 +129,21 @@ profit_and_loss_account_type = [\n
 \n
 account_type_to_group_by_payment = [ \'account_type/asset/cash/bank\' ]\n
 \n
-if expand_accounts:\n
-  account_type_to_group_by_mirror_section = [\n
+account_type_payable_receivable = [\n
                   \'account_type/asset/receivable\',\n
                   \'account_type/liability/payable\', ]\n
+if expand_accounts:\n
+  account_type_to_group_by_mirror_section = account_type_payable_receivable\n
 else:\n
-  account_type_to_group_by_node.extend([\n
-                  \'account_type/asset/receivable\',\n
-                  \'account_type/liability/payable\' ])\n
   account_type_to_group_by_mirror_section = []\n
 \n
+account_type_to_group_by_node = [at for at in balance_sheet_account_type_list\n
+  if at not in account_type_to_group_by_payment\n
+  and at not in account_type_to_group_by_mirror_section]\n
+\n
+account_type_to_group_by_node_previous_period = [at for at in account_type_to_group_by_node if at not in account_type_payable_receivable]\n
+\n
+\n
 total_debit = 0\n
 total_credit = 0\n
 total_initial_debit_balance = 0\n
@@ -342,13 +345,8 @@ initial_balance_date = (from_date - 1).latestTime()\n
 # standards accounts {{{\n
 # balance at period start date\n
 for node in getInventoryList(\n
-                node_category_strict_membership=[\n
-                  \'account_type/asset\',\n
-                  \'account_type/asset/cash\',\n
-                  \'account_type/asset/receivable/refundable_vat\',\n
-                  \'account_type/liability/payable/collected_vat\',\n
-                  \'account_type/equity\',\n
-                  \'account_type/liability\',],\n
+                node_category_strict_membership=\n
+                   account_type_to_group_by_node_previous_period,\n
                 group_by_node=1,\n
                 to_date=period_start_date,\n
                 portal_type=accounting_movement_type_list +\n
@@ -364,13 +362,8 @@ for node in getInventoryList(\n
 found_balance = False\n
 # Balance Transaction\n
 for node in getInventoryList(\n
-                node_category_strict_membership=[\n
-                  \'account_type/asset\',\n
-                  \'account_type/asset/cash\',\n
-                  \'account_type/asset/receivable/refundable_vat\',\n
-                  \'account_type/liability/payable/collected_vat\',\n
-                  \'account_type/equity\',\n
-                  \'account_type/liability\',],\n
+                node_category_strict_membership=\n
+                   account_type_to_group_by_node_previous_period,\n
                 group_by_node=1,\n
                 from_date=from_date,\n
                 at_date=from_date + 1,\n
@@ -451,9 +444,7 @@ for node in getInventoryList(\n
 # payable / receivable accounts {{{\n
 # initial balance\n
 for node in getInventoryList(\n
-                node_category_strict_membership=[\n
-                        \'account_type/asset/receivable\',\n
-                        \'account_type/liability/payable\', ],\n
+                node_category_strict_membership=account_type_payable_receivable,\n
                 group_by_mirror_section=1,\n
                 group_by_node=1,\n
                 to_date=period_start_date,\n
@@ -476,9 +467,7 @@ for node in getInventoryList(\n
 found_balance=False\n
 # Balance Transactions\n
 for node in getInventoryList(\n
-                node_category_strict_membership=[\n
-                        \'account_type/asset/receivable\',\n
-                        \'account_type/liability/payable\', ],\n
+                node_category_strict_membership=account_type_payable_receivable,\n
                 group_by_mirror_section=1,\n
                 group_by_node=1,\n
                 from_date=from_date,\n
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 c65011215e..f46109cf2d 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
@@ -129,7 +129,7 @@ if hide_analytic:\n
                                            \'mirror_section_uid\',\n
                                            \'payment_uid\' )\n
 else:\n
-  analytic_column_list = context.AccountModule_getAnalyticColumnList()\n
+  analytic_column_list = context.accounting_module.AccountModule_getAnalyticColumnList()\n
 \n
 account_columns = (\n
       (\'Movement_getSpecificReference\', \'Reference\'),\n
@@ -187,13 +187,10 @@ def getFullAccountName(account_info):\n
 \n
 \n
 # look at inventories to decide which sections will be shown\n
-account_type_to_group_by_node = [\n
-                  \'account_type/asset\',\n
-                  \'account_type/asset/cash\',\n
-                  \'account_type/asset/receivable/refundable_vat\',\n
-                  \'account_type/liability/payable/collected_vat\',\n
-                  \'account_type/equity\',\n
-                  \'account_type/liability\',]\n
+balance_sheet_account_type_list = [c[0] for c in \n
+ cat_tool.account_type.asset.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False ) + \\\n
+ cat_tool.account_type.equity.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False) + \\\n
+ cat_tool.account_type.liability.getCategoryChildItemList(base=1, is_self_excluded=False, display_none_category=False) ]\n
 \n
 profit_and_loss_account_type = []\n
 for account_type_value in (cat_tool.account_type.expense,\n
@@ -208,6 +205,9 @@ account_type_to_group_by_mirror_section = [\n
                   \'account_type/asset/receivable\',\n
                   \'account_type/liability/payable\', ]\n
 \n
+account_type_to_group_by_node = [at for at in balance_sheet_account_type_list\n
+  if at not in account_type_to_group_by_payment\n
+  and at not in account_type_to_group_by_mirror_section]\n
 \n
 if gap_list or gap_root:\n
   params[\'node_category\'] = gap_list or gap_root\n
diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalReportSectionList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalReportSectionList.xml
index e4c9f85399..f5c20481cc 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalReportSectionList.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_getJournalReportSectionList.xml
@@ -99,7 +99,7 @@ if hide_analytic:\n
                                    \'payment_uid\',\n
                                    \'node_uid\' )\n
 else:\n
-  analytic_column_list = context.AccountModule_getAnalyticColumnList()\n
+  analytic_column_list = context.accounting_module.AccountModule_getAnalyticColumnList()\n
   selection_params[\'analytic_column_list\'] = analytic_column_list\n
 \n
 selection_columns = (\n
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index 99b41733b9..63c889e3b9 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-1433
\ No newline at end of file
+1436
\ No newline at end of file
-- 
2.30.9