Commit 236cab9d authored by Kevin Deldycke's avatar Kevin Deldycke

Remove 'transaction_' prefix.

Ignore preferences.
Clean-up code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6700 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent eb7fcd97
...@@ -67,185 +67,165 @@ ...@@ -67,185 +67,165 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""\n
Get the report sections for general ledger\n Get the report sections for general ledger\n
"""\n """\n
from Products.ERP5Form.Report import ReportSection\n from Products.ERP5Form.Report import ReportSection\n
request = context.REQUEST\n request = context.REQUEST\n
\n portal = context.portal_url.getPortalObject()\n
at_date = request[\'at_date\']\n cat_tool = portal.portal_categories\n
transaction_section_category = request[\'transaction_section_category\']\n sim_tool = portal.portal_simulation\n
transaction_simulation_state = request[\'transaction_simulation_state\']\n
from_date = request.get(\'from_date\', None)\n
gap = request.get(\'gap\', None)\n
omit_empty_accounts = request.get(\'omit_empty_accounts\', 1)\n
display_categories = request.get(\'display_categories\', 0)\n
\n \n
at_date = request[\'at_date\']\n
section_category = request[\'transaction_section_category\']\n
simulation_state = request[\'transaction_simulation_state\']\n
from_date = request.get(\'from_date\', None)\n
gap = request.get(\'gap\', None)\n
omit_empty_accounts = request.get(\'omit_empty_accounts\', True)\n
display_categories = request.get(\'display_categories\', False)\n
# TODO\n # TODO\n
omit_grouping_reference = request.get(\'omit_grouping_reference\', 0)\n omit_grouping_reference = request.get(\'omit_grouping_reference\', False)\n
\n
params = {\n
\'at_date\' : at_date,\n
\'section_category\' : transaction_section_category,\n
\'transaction_section_category\' : transaction_section_category,\n
\'simulation_state\' : transaction_simulation_state,\n
\'accounting_transaction_line_currency\' : None,\n
\'omit_grouping_reference\' : omit_grouping_reference,\n
\'from_date_summary\' : 1\n
}\n
\n \n
preferences = {\n params = { \'at_date\' : at_date\n
\'preferred_accounting_transaction_at_date\' : at_date,\n , \'section_category\' : section_category\n
\'preferred_accounting_transaction_simulation_state\' :\n , \'simulation_state\' : simulation_state\n
transaction_simulation_state,\n , \'accounting_transaction_line_currency\': None\n
\'preferred_accounting_transaction_section_category\' :\n , \'omit_grouping_reference\' : omit_grouping_reference\n
transaction_section_category,\n , \'from_date_summary\' : True\n
# XXX put omit_grouping_reference in preferences ?\n , \'is_accounting_report\' : True\n
#\'preferred_accounting_omit_grouping_reference\' : omit_grouping_reference,\n }\n
}\n
\n \n
if from_date:\n if from_date:\n
params[\'from_date\'] = from_date\n params[\'from_date\'] = from_date\n
preferences[\'preferred_accounting_transaction_from_date\'] = from_date\n else:\n
else :\n params[\'no_from_date\'] = True\n
params[\'no_from_date\'] = 1\n
\n \n
result = []\n result = []\n
portal = context.portal_url.getPortalObject()\n
\n \n
account_columns = (\n account_columns = ( (\'date\', \'Date\')\n
(\'date\', \'Date\'),\n , (\'specific_reference\', \'Reference\')\n
(\'specific_reference\', \'Reference\'),\n , (\'title\', \'Label\')\n
(\'title\', \'Label\'),\n , (\'translated_portal_type\', \'Type\')\n
(\'translated_portal_type\', \'Type\'),\n , (\'third_party\', \'Third Party\')\n
(\'third_party\', \'Third Party\'),\n , (\'translated_simulation_state_title\', \'State\')\n
(\'translated_simulation_state_title\', \'State\'),\n , (\'debit\', \'Debit\')\n
(\'debit\', \'Debit\'),\n , (\'credit\', \'Credit\')\n
(\'credit\', \'Credit\'),\n , (\'net_balance\', \'Balance\')\n
(\'net_balance\', \'Balance\'),\n )\n
)\n
\n \n
if gap :\n if gap:\n
gap_value_list = [ portal.portal_categories.gap.restrictedTraverse(gap) ] +\\\n gap_value_list = [cat_tool.gap.restrictedTraverse(gap)] + \\\n
portal.portal_categories.gap.restrictedTraverse(gap)\\\n cat_tool.gap.restrictedTraverse(gap).Category_getSortedCategoryChildValueList()\n
.Category_getSortedCategoryChildValueList()\n else:\n
else :\n cat = \'gap/%s\' % context.portal_preferences.getPreferredAccountingTransactionGap() \\\n
cat = \'gap/%s\'%context.portal_preferences\\\n or context.getPortalDefaultGapRoot()\n
.getPreferredAccountingTransactionGap()\\\n
or context.getPortalDefaultGapRoot()\n
\n \n
gap_value_list = portal.portal_categories.resolveCategory(cat)\\\n gap_value_list = cat_tool.resolveCategory(cat).Category_getSortedCategoryChildValueList()\n
.Category_getSortedCategoryChildValueList()\n
\n \n
# we don\'t want to display accounts that don\'t have any transactions associated,\n # we don\'t want to display accounts that don\'t have any transactions associated,\n
# so we use a cache to see if the account contains transaction or not ( regardless\n # so we use a cache to see if the account contains transaction or not ( regardless\n
# of from_date )\n # of from_date )\n
account_inventory_list_cache = {}\n account_inventory_list_cache = {}\n
account_inventory_list_cache_params = params.copy()\n account_inventory_list_cache_params = params.copy()\n
if account_inventory_list_cache_params.has_key(\'from_date\') :\n if account_inventory_list_cache_params.has_key(\'from_date\'):\n
del account_inventory_list_cache_params[\'from_date\']\n del account_inventory_list_cache_params[\'from_date\']\n
\n \n
for c in gap_value_list :\n for c in gap_value_list:\n
account_list = c.getGapRelatedValueList(portal_type="Account")\n account_list = c.getGapRelatedValueList(portal_type="Account")\n
strict_account_list = c.getGapRelatedValueList(\n strict_account_list = c.getGapRelatedValueList(portal_type="Account", strict_membership=1)\n
portal_type="Account", strict_membership = 1)\n \n
\n
skip_branch = 1\n skip_branch = 1\n
for account in account_list :\n for account in account_list:\n
if account.getUid() not in account_inventory_list_cache :\n if account.getUid() not in account_inventory_list_cache:\n
account_inventory_list_cache[account.getUid()] = len(portal.\\\n account_inventory_list_cache[account.getUid()] = len(sim_tool.getInventoryList( omit_simulation = 1,\n
portal_simulation.getInventoryList( omit_simulation = 1,\n
node_uid = account.getUid(), **account_inventory_list_cache_params))\n node_uid = account.getUid(), **account_inventory_list_cache_params))\n
if account_inventory_list_cache[account.getUid()] != 0 :\n if account_inventory_list_cache[account.getUid()] != 0:\n
skip_branch = 0\n skip_branch = 0\n
\n \n
if skip_branch :\n if skip_branch:\n
continue\n continue\n
\n \n
if display_categories and \\\n if display_categories and \\\n
len(account_list) and \\\n len(account_list) and \\\n
len(strict_account_list) != 1 :\n len(strict_account_list) != 1:\n
result.append(ReportSection(\n result.append(ReportSection( path = c.getPhysicalPath()\n
path = c.getPhysicalPath(),\n , title = "%s: %s" % (c.getId(), c.getTitle())\n
title = "%s: %s" % (c.getId(), c.getTitle()),\n , level = len(c.getPhysicalPath()) - 4\n
level = len(c.getPhysicalPath()) - 4,\n , form_id = None\n
form_id = None) )\n ))\n
\n \n
if len(strict_account_list):\n if len(strict_account_list):\n
for account in strict_account_list:\n for account in strict_account_list:\n
if account.getAccountTypeId() in (\'payable\', \'receivable\') :\n if account.getAccountTypeId() in (\'payable\', \'receivable\'):\n
for third_party_brain in context.Account_zDistinctSectionList(\n for third_party_brain in context.Account_zDistinctSectionList( at_date = at_date\n
at_date = at_date,\n , simulation_state = simulation_state):\n
simulation_state = transaction_simulation_state ) :\n
third_party_params = params.copy()\n third_party_params = params.copy()\n
third_party_params[\'mirror_section_uid\'] = third_party_brain.uid\n third_party_params[\'mirror_section_uid\'] = third_party_brain.uid\n
third_party_uid = third_party_brain.uid or " = NULL"\n third_party_uid = third_party_brain.uid or " = NULL"\n
title = "%s: %s (%s)" % ( c.getId(),\n title = "%s: %s (%s)" % ( c.getId()\n
account.getTitle(),\n , account.getTitle()\n
third_party_brain.title )\n , third_party_brain.title\n
if len(portal.portal_simulation.getInventoryList(\n )\n
mirror_section_uid = third_party_uid,\n if len(sim_tool.getInventoryList( mirror_section_uid = third_party_uid\n
node_uid = account.getUid(),\n , node_uid = account.getUid()\n
**account_inventory_list_cache_params )):\n , **account_inventory_list_cache_params\n
result.append(ReportSection(\n )):\n
path = account.getPhysicalPath(),\n result.append(ReportSection( path = account.getPhysicalPath()\n
title = title,\n , title = title\n
level = 9,\n , level = 9\n
form_id = \'Account_viewAccountingTransactionList\',\n , form_id = \'Account_viewAccountingTransactionList\'\n
selection_name = \'acount_preference_selection\',\n , selection_name = \'acount_preference_selection\'\n
selection_params = third_party_params.copy(),\n , selection_params = third_party_params.copy()\n
selection_columns = account_columns,\n , selection_columns = account_columns\n
listbox_display_mode = \'FlatListMode\',\n , listbox_display_mode = \'FlatListMode\'\n
selection_sort_order = [(\'delivery.stop_date\', \'ascending\')],\n , selection_sort_order = [(\'delivery.stop_date\', \'ascending\')]\n
preferences = preferences ))\n ))\n
\n \n
elif account.isMemberOf(\'account_type/asset/cash/bank\') :\n elif account.isMemberOf(\'account_type/asset/cash/bank\'):\n
# Bank Account\n # Bank Account\n
for bank_account_brain in account.Account_zGetDistinctPaymentList(\n for bank_account_brain in account.Account_zGetDistinctPaymentList( at_date = at_date\n
at_date = at_date,\n , simulation_state = simulation_state\n
simulation_state = transaction_simulation_state ) :\n ):\n
bank_params = params.copy()\n bank_params = params.copy()\n
if bank_account_brain.path is not None :\n if bank_account_brain.path is not None:\n
bank_params[\'payment_uid\'] = bank_account_brain.uid\n bank_params[\'payment_uid\'] = bank_account_brain.uid\n
bank_account_uid = bank_account_brain.uid or " = NULL"\n bank_account_uid = bank_account_brain.uid or " = NULL"\n
title = "%s: %s (%s)" % ( c.getId(),\n title = "%s: %s (%s)" % ( c.getId()\n
account.getTitle(),\n , account.getTitle()\n
bank_account_brain.title )\n , bank_account_brain.title\n
)\n
else :\n else :\n
bank_params[\'no_payment_uid\'] = 1\n bank_params[\'no_payment_uid\'] = 1\n
title = "%s: %s" % ( c.getId(), account.getTitle())\n title = "%s: %s" % ( c.getId(), account.getTitle())\n
if len(portal.portal_simulation.getInventoryList(\n if len(sim_tool.getInventoryList( payment_uid = bank_account_uid\n
payment_uid = bank_account_uid,\n , node_uid = account.getUid()\n
node_uid = account.getUid(),\n , **account_inventory_list_cache_params\n
**account_inventory_list_cache_params )):\n )):\n
result.append(ReportSection(\n result.append(ReportSection( path = account.getPhysicalPath()\n
path = account.getPhysicalPath(),\n , title = title\n
title = title,\n , level = 9\n
level = 9,\n , form_id = \'Account_viewAccountingTransactionList\'\n
form_id = \'Account_viewAccountingTransactionList\',\n , selection_name = \'acount_preference_selection\'\n
selection_name = \'acount_preference_selection\',\n , selection_params = bank_params.copy()\n
selection_params = bank_params.copy(),\n , selection_columns = account_columns\n
selection_columns = account_columns,\n , listbox_display_mode = \'FlatListMode\'\n
listbox_display_mode = \'FlatListMode\',\n , selection_sort_order = [(\'delivery.stop_date\', \'ascending\')]\n
selection_sort_order = [(\'delivery.stop_date\', \'ascending\')],\n ))\n
preferences = preferences ))\n else:\n
else :\n if len(sim_tool.getInventoryList( node_uid = account.getUid()\n
if len(portal.portal_simulation.getInventoryList(\n , **account_inventory_list_cache_params\n
node_uid = account.getUid(),\n )):\n
**account_inventory_list_cache_params )):\n result.append(ReportSection( path = account.getPhysicalPath()\n
result.append(ReportSection(\n , title = "%s: %s" % (c.getId(), account.getTitle())\n
path = account.getPhysicalPath(),\n , level = 9\n
title = "%s: %s" % (c.getId(), account.getTitle()),\n , form_id = \'Account_viewAccountingTransactionList\'\n
level = 9,\n , selection_name = \'acount_preference_selection\'\n
form_id = \'Account_viewAccountingTransactionList\',\n , selection_params = params\n
selection_name = \'acount_preference_selection\',\n , selection_columns = account_columns\n
selection_params = params,\n , listbox_display_mode = \'FlatListMode\'\n
selection_columns = account_columns,\n , selection_sort_order = [(\'delivery.stop_date\', \'ascending\')]\n
listbox_display_mode = \'FlatListMode\',\n ))\n
selection_sort_order = [(\'delivery.stop_date\', \'ascending\')],\n
preferences = preferences ))\n
\n \n
return result\n return result\n
# vim: syntax=python\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -297,21 +277,24 @@ return result\n ...@@ -297,21 +277,24 @@ return result\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>request</string> <string>request</string>
<string>portal</string>
<string>cat_tool</string>
<string>sim_tool</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>at_date</string> <string>at_date</string>
<string>transaction_section_category</string> <string>section_category</string>
<string>transaction_simulation_state</string> <string>simulation_state</string>
<string>None</string> <string>None</string>
<string>from_date</string> <string>from_date</string>
<string>gap</string> <string>gap</string>
<string>True</string>
<string>omit_empty_accounts</string> <string>omit_empty_accounts</string>
<string>False</string>
<string>display_categories</string> <string>display_categories</string>
<string>omit_grouping_reference</string> <string>omit_grouping_reference</string>
<string>params</string> <string>params</string>
<string>preferences</string>
<string>_write_</string> <string>_write_</string>
<string>result</string> <string>result</string>
<string>portal</string>
<string>account_columns</string> <string>account_columns</string>
<string>gap_value_list</string> <string>gap_value_list</string>
<string>cat</string> <string>cat</string>
......
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