Commit 74f37ab7 authored by Jérome Perrin's avatar Jérome Perrin

support breakdown by various analytic axis in trial balance

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36233 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b3c2ac07
...@@ -62,6 +62,8 @@ request = container.REQUEST\n ...@@ -62,6 +62,8 @@ request = container.REQUEST\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
getInventoryList = portal.portal_simulation.getInventoryList\n getInventoryList = portal.portal_simulation.getInventoryList\n
getInventory = portal.portal_simulation.getInventoryAssetPrice\n getInventory = portal.portal_simulation.getInventoryAssetPrice\n
traverse = context.getPortalObject().restrictedTraverse\n
getObject = context.getPortalObject().portal_catalog.getObject\n
Base_translateString = portal.Base_translateString\n Base_translateString = portal.Base_translateString\n
selected_gap = gap_root\n selected_gap = gap_root\n
\n \n
...@@ -80,6 +82,11 @@ inventory_params = dict(section_uid=section_uid,\n ...@@ -80,6 +82,11 @@ inventory_params = dict(section_uid=section_uid,\n
simulation_state=simulation_state,\n simulation_state=simulation_state,\n
precision=precision,\n precision=precision,\n
group_by_resource=0)\n group_by_resource=0)\n
\n
if group_analytic:\n
inventory_params[\'group_by\'] = group_analytic\n
group_analytic = tuple(group_analytic)\n
\n
if portal_type and portal_type != portal.getPortalAccountingTransactionTypeList():\n if portal_type and portal_type != portal.getPortalAccountingTransactionTypeList():\n
inventory_params[\'parent_portal_type\'] = portal_type\n inventory_params[\'parent_portal_type\'] = portal_type\n
if function:\n if function:\n
...@@ -92,7 +99,7 @@ if node_uid:\n ...@@ -92,7 +99,7 @@ if node_uid:\n
\n \n
MARKER = Object()\n MARKER = Object()\n
\n \n
# a dictionary (node_relative_url, mirror_section_uid, payment_uid)\n # a dictionary (node_relative_url, mirror_section_uid, payment_uid + analytic)\n
# -> dict(debit=, credit=)\n # -> dict(debit=, credit=)\n
line_per_account = {}\n line_per_account = {}\n
# a dictionnary node_relative_url -> boolean "do we have transactions for this\n # a dictionnary node_relative_url -> boolean "do we have transactions for this\n
...@@ -130,6 +137,29 @@ total_initial_credit_balance = 0\n ...@@ -130,6 +137,29 @@ total_initial_credit_balance = 0\n
total_final_balance_if_debit = 0\n total_final_balance_if_debit = 0\n
total_final_balance_if_credit = 0\n total_final_balance_if_credit = 0\n
\n \n
def getKey(brain, mirror_section=MARKER, payment=MARKER, all_empty=False):\n
key = (brain[\'node_relative_url\'],\n
mirror_section,\n
payment)\n
for analytic in group_analytic:\n
if all_empty:\n
key += (MARKER, )\n
elif hasattr(brain, analytic):\n
key += (getattr(brain, analytic), )\n
else:\n
key += (brain.getObject().getProperty(analytic.replace(\'strict_\', \'\', 1)), )\n
return key\n
\n
analytic_title_dict = {None: \'\', }\n
def getAnalyticTitleFromUid(uid):\n
if uid is MARKER:\n
return \'\'\n
try:\n
return analytic_title_dict[uid]\n
except KeyError:\n
return analytic_title_dict.setdefault(uid,\n
getObject(uid).getTitle())\n
\n
# standards accounts {{{\n # standards accounts {{{\n
for node in getInventoryList(\n for node in getInventoryList(\n
node_category_strict_membership=account_type_to_group_by_node,\n node_category_strict_membership=account_type_to_group_by_node,\n
...@@ -140,9 +170,7 @@ for node in getInventoryList(\n ...@@ -140,9 +170,7 @@ for node in getInventoryList(\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'debit\'] = total_price\n account_props[\'debit\'] = total_price\n
total_debit += round(total_price, precision)\n total_debit += round(total_price, precision)\n
...@@ -156,9 +184,7 @@ for node in getInventoryList(\n ...@@ -156,9 +184,7 @@ for node in getInventoryList(\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'credit\'] = -total_price\n account_props[\'credit\'] = -total_price\n
total_credit -= round(total_price, precision)\n total_credit -= round(total_price, precision)\n
...@@ -174,9 +200,7 @@ for node in getInventoryList(\n ...@@ -174,9 +200,7 @@ for node in getInventoryList(\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'debit\'] = total_price\n account_props[\'debit\'] = total_price\n
total_debit += round(total_price, precision)\n total_debit += round(total_price, precision)\n
...@@ -190,9 +214,7 @@ for node in getInventoryList(\n ...@@ -190,9 +214,7 @@ for node in getInventoryList(\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'credit\'] = -total_price\n account_props[\'credit\'] = -total_price\n
total_credit -= round(total_price, precision)\n total_credit -= round(total_price, precision)\n
...@@ -212,8 +234,8 @@ if account_type_to_group_by_mirror_section:\n ...@@ -212,8 +234,8 @@ if account_type_to_group_by_mirror_section:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], node[\'mirror_section_uid\'], MARKER),\n getKey(node, mirror_section=node[\'mirror_section_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'debit\'] = total_price\n account_props[\'debit\'] = total_price\n
total_debit += round(total_price, precision)\n total_debit += round(total_price, precision)\n
...@@ -230,8 +252,8 @@ if account_type_to_group_by_mirror_section:\n ...@@ -230,8 +252,8 @@ if account_type_to_group_by_mirror_section:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], node[\'mirror_section_uid\'], MARKER),\n getKey(node, mirror_section=node[\'mirror_section_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'credit\'] = - total_price\n account_props[\'credit\'] = - total_price\n
total_credit -= round(total_price, precision)\n total_credit -= round(total_price, precision)\n
...@@ -251,8 +273,8 @@ if account_type_to_group_by_payment:\n ...@@ -251,8 +273,8 @@ if account_type_to_group_by_payment:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'debit\'] = total_price\n account_props[\'debit\'] = total_price\n
total_debit += round(total_price, precision)\n total_debit += round(total_price, precision)\n
...@@ -269,17 +291,14 @@ if account_type_to_group_by_payment:\n ...@@ -269,17 +291,14 @@ if account_type_to_group_by_payment:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'credit\'] = - total_price\n account_props[\'credit\'] = - total_price\n
total_credit -= round(total_price, precision)\n total_credit -= round(total_price, precision)\n
# }}}\n # }}}\n
\n \n
\n \n
traverse = context.getPortalObject().restrictedTraverse\n
getObject = context.getPortalObject().portal_catalog.getObject\n
\n
node_title_and_id_cache = {}\n node_title_and_id_cache = {}\n
def getNodeTitleAndId(node_relative_url):\n def getNodeTitleAndId(node_relative_url):\n
try:\n try:\n
...@@ -297,8 +316,9 @@ def getNodeTitleAndId(node_relative_url):\n ...@@ -297,8 +316,9 @@ def getNodeTitleAndId(node_relative_url):\n
# period)\n # period)\n
for node in LazyFilter(context.account_module.contentValues(), skip=\'\'):\n for node in LazyFilter(context.account_module.contentValues(), skip=\'\'):\n
if node.getRelativeUrl() not in account_used:\n if node.getRelativeUrl() not in account_used:\n
line_per_account.setdefault((node.getRelativeUrl(), MARKER, MARKER),\n line_per_account.setdefault(\n
dict(debit=0, credit=0))\n getKey(dict(node_relative_url=node.getRelativeUrl()), all_empty=True),\n
dict(debit=0, credit=0))\n
\n \n
initial_balance_date = (from_date - 1).latestTime()\n initial_balance_date = (from_date - 1).latestTime()\n
\n \n
...@@ -319,9 +339,7 @@ for node in getInventoryList(\n ...@@ -319,9 +339,7 @@ for node in getInventoryList(\n
portal_type=accounting_movement_type_list +\n portal_type=accounting_movement_type_list +\n
balance_movement_type_list,\n balance_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + max(total_price, 0)\n \'initial_debit_balance\', 0) + max(total_price, 0)\n
...@@ -343,9 +361,7 @@ for node in getInventoryList(\n ...@@ -343,9 +361,7 @@ for node in getInventoryList(\n
at_date=from_date + 1,\n at_date=from_date + 1,\n
portal_type=balance_movement_type_list,\n portal_type=balance_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + max(total_price, 0)\n \'initial_debit_balance\', 0) + max(total_price, 0)\n
...@@ -367,9 +383,7 @@ for node in getInventoryList(\n ...@@ -367,9 +383,7 @@ for node in getInventoryList(\n
to_date=from_date,\n to_date=from_date,\n
portal_type=period_movement_type_list,\n portal_type=period_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + total_price\n \'initial_debit_balance\', 0) + total_price\n
...@@ -383,9 +397,7 @@ for node in getInventoryList(\n ...@@ -383,9 +397,7 @@ for node in getInventoryList(\n
to_date=from_date,\n to_date=from_date,\n
portal_type=period_movement_type_list,\n portal_type=period_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_credit_balance\'] = account_props.get(\n account_props[\'initial_credit_balance\'] = account_props.get(\n
\'initial_credit_balance\', 0) - total_price\n \'initial_credit_balance\', 0) - total_price\n
...@@ -401,9 +413,7 @@ for node in getInventoryList(\n ...@@ -401,9 +413,7 @@ for node in getInventoryList(\n
group_by_node=1,\n group_by_node=1,\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + total_price\n \'initial_debit_balance\', 0) + total_price\n
...@@ -417,9 +427,7 @@ for node in getInventoryList(\n ...@@ -417,9 +427,7 @@ for node in getInventoryList(\n
group_by_node=1,\n group_by_node=1,\n
portal_type=accounting_movement_type_list,\n portal_type=accounting_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(getKey(node), dict(debit=0, credit=0))\n
(node[\'node_relative_url\'], MARKER, MARKER),\n
dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_credit_balance\'] = account_props.get(\n account_props[\'initial_credit_balance\'] = account_props.get(\n
\'initial_credit_balance\', 0) - total_price\n \'initial_credit_balance\', 0) - total_price\n
...@@ -440,9 +448,10 @@ for node in getInventoryList(\n ...@@ -440,9 +448,10 @@ for node in getInventoryList(\n
mirror_section_key = MARKER\n mirror_section_key = MARKER\n
if expand_accounts:\n if expand_accounts:\n
mirror_section_key = node[\'mirror_section_uid\']\n mirror_section_key = node[\'mirror_section_uid\']\n
\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], mirror_section_key, MARKER),\n getKey(node, mirror_section=mirror_section_key),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + max(total_price, 0)\n \'initial_debit_balance\', 0) + max(total_price, 0)\n
...@@ -465,8 +474,8 @@ for node in getInventoryList(\n ...@@ -465,8 +474,8 @@ for node in getInventoryList(\n
if expand_accounts:\n if expand_accounts:\n
mirror_section_key = node[\'mirror_section_uid\']\n mirror_section_key = node[\'mirror_section_uid\']\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], mirror_section_key, MARKER),\n getKey(node, mirror_section=mirror_section_key),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + max(total_price, 0)\n \'initial_debit_balance\', 0) + max(total_price, 0)\n
...@@ -493,8 +502,8 @@ if expand_accounts:\n ...@@ -493,8 +502,8 @@ if expand_accounts:\n
portal_type=period_movement_type_list,\n portal_type=period_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], node[\'mirror_section_uid\'], MARKER),\n getKey(node, mirror_section=node[\'mirror_section_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + total_price\n \'initial_debit_balance\', 0) + total_price\n
...@@ -510,8 +519,8 @@ if expand_accounts:\n ...@@ -510,8 +519,8 @@ if expand_accounts:\n
portal_type=period_movement_type_list,\n portal_type=period_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], node[\'mirror_section_uid\'], MARKER),\n getKey(node, mirror_section=node[\'mirror_section_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_credit_balance\'] = account_props.get(\n account_props[\'initial_credit_balance\'] = account_props.get(\n
\'initial_credit_balance\', 0) - total_price\n \'initial_credit_balance\', 0) - total_price\n
...@@ -530,8 +539,8 @@ if account_type_to_group_by_payment:\n ...@@ -530,8 +539,8 @@ if account_type_to_group_by_payment:\n
balance_movement_type_list,\n balance_movement_type_list,\n
**inventory_params):\n **inventory_params):\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + max(total_price, 0)\n \'initial_debit_balance\', 0) + max(total_price, 0)\n
...@@ -551,8 +560,8 @@ if account_type_to_group_by_payment:\n ...@@ -551,8 +560,8 @@ if account_type_to_group_by_payment:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
total_price += account_props.get(\'initial_debit_balance\', 0)\n total_price += account_props.get(\'initial_debit_balance\', 0)\n
total_price -= account_props.get(\'initial_credit_balance\', 0)\n total_price -= account_props.get(\'initial_credit_balance\', 0)\n
...@@ -576,8 +585,8 @@ if account_type_to_group_by_payment:\n ...@@ -576,8 +585,8 @@ if account_type_to_group_by_payment:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_debit_balance\'] = account_props.get(\n account_props[\'initial_debit_balance\'] = account_props.get(\n
\'initial_debit_balance\', 0) + total_price\n \'initial_debit_balance\', 0) + total_price\n
...@@ -594,36 +603,39 @@ if account_type_to_group_by_payment:\n ...@@ -594,36 +603,39 @@ if account_type_to_group_by_payment:\n
**inventory_params):\n **inventory_params):\n
account_used[node[\'node_relative_url\']] = 1\n account_used[node[\'node_relative_url\']] = 1\n
account_props = line_per_account.setdefault(\n account_props = line_per_account.setdefault(\n
(node[\'node_relative_url\'], MARKER, node[\'payment_uid\']),\n getKey(node, payment=node[\'payment_uid\']),\n
dict(debit=0, credit=0))\n dict(debit=0, credit=0))\n
total_price = node[\'total_price\'] or 0\n total_price = node[\'total_price\'] or 0\n
account_props[\'initial_credit_balance\'] = account_props.get(\n account_props[\'initial_credit_balance\'] = account_props.get(\n
\'initial_credit_balance\', 0) - total_price\n \'initial_credit_balance\', 0) - total_price\n
# }}}\n # }}}\n
\n \n
line_list = []\n line_list = []\n
for (node_relative_url, mirror_section_uid, payment_uid), data in \\\n for key, data in line_per_account.items():\n
line_per_account.items():\n node_relative_url = key[0]\n
node_uid, node_title, node_id, string_index, node = getNodeTitleAndId(node_relative_url)\n mirror_section_uid = key[1]\n
if mirror_section_uid is not MARKER:\n payment_uid = key[2]\n
if mirror_section_uid is None:\n analytic_key_list = key[3:]\n
node_title = \'%s (%s)\' % ( node_title, Base_translateString(\'None\'))\n \n
else:\n mirror_section_title = None\n
third_party = getObject(mirror_section_uid)\n if expand_accounts and mirror_section_uid is not MARKER:\n
node_title = "%s (%s)" % ( node_title, third_party.getTitle() )\n mirror_section_title = getObject(mirror_section_uid).getTitle()\n
elif payment_uid is not MARKER:\n \n
node_uid, node_title, node_id, node_string_index, node =\\\n
getNodeTitleAndId(node_relative_url)\n
\n
if selected_gap and not node.isMemberOf(selected_gap):\n
continue\n
\n
if payment_uid is not MARKER:\n
if payment_uid is None:\n if payment_uid is None:\n
node_title = \'%s (%s)\' % ( node_title, Base_translateString(\'None\'))\n node_title = \'%s (%s)\' % ( node_title, Base_translateString(\'None\'))\n
else:\n else:\n
payment = getObject(payment_uid)\n payment = getObject(payment_uid)\n
node_title = "%s (%s)" % ( node_title, payment.getTitle() )\n node_title = "%s (%s)" % ( node_title, payment.getTitle() )\n
\n
if not string_index:\n
string_index = \'%-10s\' % node_id\n
string_index = \'%s %s\' % (string_index, node_title)\n
\n \n
if selected_gap and not node.isMemberOf(selected_gap):\n if not node_string_index:\n
continue\n node_string_index = \'%-10s\' % node_id\n
\n \n
initial_debit_balance = data.get(\'initial_debit_balance\', 0)\n initial_debit_balance = data.get(\'initial_debit_balance\', 0)\n
initial_credit_balance = data.get(\'initial_credit_balance\', 0)\n initial_credit_balance = data.get(\'initial_credit_balance\', 0)\n
...@@ -639,19 +651,32 @@ for (node_relative_url, mirror_section_uid, payment_uid), data in \\\n ...@@ -639,19 +651,32 @@ for (node_relative_url, mirror_section_uid, payment_uid), data in \\\n
total_final_balance_if_credit += round(max(-closing_balance, 0) or 0, precision)\n total_final_balance_if_credit += round(max(-closing_balance, 0) or 0, precision)\n
\n \n
\n \n
line_list.append(Object(uid=\'new_\',\n line = Object(uid=\'new_\',\n
node_id=node_id,\n node_id=node_id,\n
node_title=node_title,\n node_title=node_title,\n
string_index=string_index,\n mirror_section_title=mirror_section_title,\n
node_relative_url=node_relative_url,\n node_relative_url=node_relative_url,\n
initial_debit_balance=initial_debit_balance,\n initial_debit_balance=initial_debit_balance,\n
initial_credit_balance=initial_credit_balance,\n initial_credit_balance=initial_credit_balance,\n
debit=data[\'debit\'],\n debit=data[\'debit\'],\n
credit=data[\'credit\'],\n credit=data[\'credit\'],\n
final_debit_balance=final_debit_balance,\n final_debit_balance=final_debit_balance,\n
final_credit_balance=final_credit_balance,\n final_credit_balance=final_credit_balance,\n
final_balance_if_debit=max(closing_balance, 0),\n final_balance_if_debit=max(closing_balance, 0),\n
final_balance_if_credit=max(-closing_balance, 0) or 0,))\n final_balance_if_credit=max(-closing_balance, 0) or 0,)\n
\n
sort_key = (node_string_index, node_title, mirror_section_title)\n
analytic_dict = dict()\n
for analytic, uid in zip(group_analytic, analytic_key_list):\n
title = getAnalyticTitleFromUid(uid)\n
analytic_dict[analytic] = title\n
sort_key += (title, )\n
\n
analytic_dict[\'sort_key\'] = sort_key\n
line.update(analytic_dict)\n
\n
line_list.append(line)\n
\n
\n \n
if not show_empty_accounts:\n if not show_empty_accounts:\n
line_list = [ line for line in line_list\n line_list = [ line for line in line_list\n
...@@ -660,10 +685,7 @@ if not show_empty_accounts:\n ...@@ -660,10 +685,7 @@ if not show_empty_accounts:\n
line[\'initial_credit_balance\'] or\n line[\'initial_credit_balance\'] or\n
line[\'initial_debit_balance\'] ]\n line[\'initial_debit_balance\'] ]\n
\n \n
# sort\n line_list.sort(key=lambda obj:obj[\'sort_key\'])\n
def getStringIndex(obj):\n
return obj[\'string_index\']\n
line_list.sort(key=getStringIndex)\n
\n \n
# cache values for stat\n # cache values for stat\n
request.set(\'TrialBalance.total_initial_debit_balance\',\n request.set(\'TrialBalance.total_initial_debit_balance\',\n
...@@ -751,7 +773,7 @@ return new_line_list\n ...@@ -751,7 +773,7 @@ return new_line_list\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>show_empty_accounts, expand_accounts, at_date, from_date, period_start_date, section_uid, simulation_state, precision, node_uid, gap_root=None, per_account_class_summary=0, portal_type=None, function=None, project=None, **kw</string> </value> <value> <string>show_empty_accounts, expand_accounts, at_date, from_date, period_start_date, section_uid, simulation_state, precision, node_uid, gap_root=None, per_account_class_summary=0, portal_type=None, function=None, project=None, group_analytic=[], **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -771,7 +793,7 @@ return new_line_list\n ...@@ -771,7 +793,7 @@ return new_line_list\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>14</int> </value> <value> <int>15</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -791,6 +813,7 @@ return new_line_list\n ...@@ -791,6 +813,7 @@ return new_line_list\n
<string>portal_type</string> <string>portal_type</string>
<string>function</string> <string>function</string>
<string>project</string> <string>project</string>
<string>group_analytic</string>
<string>kw</string> <string>kw</string>
<string>Products.PythonScripts.standard</string> <string>Products.PythonScripts.standard</string>
<string>Object</string> <string>Object</string>
...@@ -803,6 +826,8 @@ return new_line_list\n ...@@ -803,6 +826,8 @@ return new_line_list\n
<string>portal</string> <string>portal</string>
<string>getInventoryList</string> <string>getInventoryList</string>
<string>getInventory</string> <string>getInventory</string>
<string>traverse</string>
<string>getObject</string>
<string>Base_translateString</string> <string>Base_translateString</string>
<string>selected_gap</string> <string>selected_gap</string>
<string>inventory_movement_type_list</string> <string>inventory_movement_type_list</string>
...@@ -815,6 +840,7 @@ return new_line_list\n ...@@ -815,6 +840,7 @@ return new_line_list\n
<string>dict</string> <string>dict</string>
<string>inventory_params</string> <string>inventory_params</string>
<string>_write_</string> <string>_write_</string>
<string>tuple</string>
<string>MARKER</string> <string>MARKER</string>
<string>line_per_account</string> <string>line_per_account</string>
<string>account_used</string> <string>account_used</string>
...@@ -828,6 +854,11 @@ return new_line_list\n ...@@ -828,6 +854,11 @@ return new_line_list\n
<string>total_initial_credit_balance</string> <string>total_initial_credit_balance</string>
<string>total_final_balance_if_debit</string> <string>total_final_balance_if_debit</string>
<string>total_final_balance_if_credit</string> <string>total_final_balance_if_credit</string>
<string>False</string>
<string>getKey</string>
<string>None</string>
<string>analytic_title_dict</string>
<string>getAnalyticTitleFromUid</string>
<string>_apply_</string> <string>_apply_</string>
<string>node</string> <string>node</string>
<string>_getitem_</string> <string>_getitem_</string>
...@@ -836,27 +867,25 @@ return new_line_list\n ...@@ -836,27 +867,25 @@ return new_line_list\n
<string>_inplacevar_</string> <string>_inplacevar_</string>
<string>round</string> <string>round</string>
<string>max</string> <string>max</string>
<string>traverse</string>
<string>getObject</string>
<string>node_title_and_id_cache</string> <string>node_title_and_id_cache</string>
<string>getNodeTitleAndId</string> <string>getNodeTitleAndId</string>
<string>True</string>
<string>initial_balance_date</string> <string>initial_balance_date</string>
<string>False</string>
<string>found_balance</string> <string>found_balance</string>
<string>True</string>
<string>period_movement_type_list</string> <string>period_movement_type_list</string>
<string>min</string> <string>min</string>
<string>mirror_section_key</string> <string>mirror_section_key</string>
<string>line_list</string> <string>line_list</string>
<string>key</string>
<string>data</string>
<string>node_relative_url</string> <string>node_relative_url</string>
<string>mirror_section_uid</string> <string>mirror_section_uid</string>
<string>payment_uid</string> <string>payment_uid</string>
<string>data</string> <string>analytic_key_list</string>
<string>mirror_section_title</string>
<string>node_title</string> <string>node_title</string>
<string>node_id</string> <string>node_id</string>
<string>string_index</string> <string>node_string_index</string>
<string>None</string>
<string>third_party</string>
<string>payment</string> <string>payment</string>
<string>initial_debit_balance</string> <string>initial_debit_balance</string>
<string>initial_credit_balance</string> <string>initial_credit_balance</string>
...@@ -864,7 +893,12 @@ return new_line_list\n ...@@ -864,7 +893,12 @@ return new_line_list\n
<string>final_credit_balance</string> <string>final_credit_balance</string>
<string>closing_balance</string> <string>closing_balance</string>
<string>line</string> <string>line</string>
<string>getStringIndex</string> <string>sort_key</string>
<string>analytic_dict</string>
<string>zip</string>
<string>analytic</string>
<string>uid</string>
<string>title</string>
<string>current_gap</string> <string>current_gap</string>
<string>getAccountClass</string> <string>getAccountClass</string>
<string>new_line_list</string> <string>new_line_list</string>
...@@ -895,6 +929,7 @@ return new_line_list\n ...@@ -895,6 +929,7 @@ return new_line_list\n
<none/> <none/>
<none/> <none/>
<none/> <none/>
<list/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -100,17 +100,48 @@ if gap_uid_list:\n ...@@ -100,17 +100,48 @@ if gap_uid_list:\n
default_gap_uid=gap_uid_list)] or -1\n default_gap_uid=gap_uid_list)] or -1\n
\n \n
request.set(\'is_accounting_report\', True)\n request.set(\'is_accounting_report\', True)\n
group_analytic = request[\'group_analytic\']\n
group_analytic_uid = ()\n
\n \n
# flat_mode is a boolean that indicate wether we should use a report tree or a\n extra_columns = ()\n
# flat list of all accounts.\n if expand_accounts:\n
if request.get(\'tree_mode\', False): # TODO\n extra_columns += (\'mirror_section_title\', \'Third Party\'),\n
raise \'Tree mode no longer supported\'\n
\n \n
possible_analytic_column_list = context.AccountModule_getAnalyticColumnList()\n
for analytic in group_analytic:\n
if analytic == \'project\':\n
extra_columns += ((\'project_uid\', \'Project\', ), )\n
group_analytic_uid += (\'project_uid\',)\n
elif analytic == \'function\':\n
extra_columns += ((\'function_uid\',\n
context.AccountingTransactionLine_getFunctionBaseCategoryTitle()),)\n
group_analytic_uid += (\'function_uid\',)\n
else:\n
for analytic_column in possible_analytic_column_list:\n
if analytic_column[0] == analytic:\n
uid_key = \'strict_%s\' % analytic_column[0].replace(\'_translated_title\', \'_uid\')\n
group_analytic_uid += (uid_key, )\n
extra_columns += ((uid_key, analytic_column[1]),)\n
\n
\n
selection_columns = (\n
(\'node_id\', \'GAP Account ID\'),\n
(\'node_title\', \'Account Name\'),\n
) + extra_columns + (\n
(\'initial_debit_balance\', \'Initial Debit Balance\'),\n
(\'initial_credit_balance\', \'Initial Credit Balance\'),\n
(\'debit\', \'Debit Transactions\'),\n
(\'credit\', \'Credit Transactions\'),\n
(\'final_debit_balance\', \'Final Debit Balance\'),\n
(\'final_credit_balance\', \'Final Credit Balance\'),\n
(\'final_balance_if_debit\', \'Final Balance (Debit)\'),\n
(\'final_balance_if_credit\', \'Final Balance (Credit)\'),\n
)\n
return [ ReportSection(\n return [ ReportSection(\n
path=portal.account_module.getPhysicalPath(),\n path=portal.account_module.getPhysicalPath(),\n
level=1,\n
form_id=\'AccountModule_viewAccountListForTrialBalance\',\n form_id=\'AccountModule_viewAccountListForTrialBalance\',\n
selection_name=\'trial_balance_selection\',\n selection_name=\'trial_balance_selection\',\n
selection_columns=selection_columns,\n
selection_params=dict(show_empty_accounts=show_empty_accounts,\n selection_params=dict(show_empty_accounts=show_empty_accounts,\n
expand_accounts=expand_accounts,\n expand_accounts=expand_accounts,\n
at_date=at_date.latestTime(),\n at_date=at_date.latestTime(),\n
...@@ -123,6 +154,7 @@ return [ ReportSection(\n ...@@ -123,6 +154,7 @@ return [ ReportSection(\n
portal_type=portal_type,\n portal_type=portal_type,\n
simulation_state=simulation_state,\n simulation_state=simulation_state,\n
precision=precision,\n precision=precision,\n
group_analytic=group_analytic_uid,\n
node_uid=node_uid,\n node_uid=node_uid,\n
per_account_class_summary=\n per_account_class_summary=\n
per_account_class_summary,\n per_account_class_summary,\n
...@@ -195,6 +227,15 @@ return [ ReportSection(\n ...@@ -195,6 +227,15 @@ return [ ReportSection(\n
<string>$append0</string> <string>$append0</string>
<string>x</string> <string>x</string>
<string>True</string> <string>True</string>
<string>group_analytic</string>
<string>group_analytic_uid</string>
<string>extra_columns</string>
<string>_inplacevar_</string>
<string>possible_analytic_column_list</string>
<string>analytic</string>
<string>analytic_column</string>
<string>uid_key</string>
<string>selection_columns</string>
<string>dict</string> <string>dict</string>
</tuple> </tuple>
</value> </value>
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
<string>your_from_date</string> <string>your_from_date</string>
<string>your_at_date</string> <string>your_at_date</string>
<string>your_expand_accounts</string> <string>your_expand_accounts</string>
<string>your_group_analytic</string>
<string>your_show_empty_accounts</string> <string>your_show_empty_accounts</string>
<string>your_per_account_class_summary</string> <string>your_per_account_class_summary</string>
<string>your_portal_skin</string> <string>your_portal_skin</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="MultiCheckBoxField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_group_analytic</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>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>unknown_selection</string> </key>
<value> <string>You selected an item that was not in the list.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>orientation</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>orientation</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>For each account, there will be a breakdown by each analytic checked here.</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>orientation</string> </key>
<value> <string>vertical</string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Detail Analytics</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>view_separator</string> </key>
<value> <string encoding="cdata"><![CDATA[
<br />
]]></string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>context/AccountModule_getAnalyticColumnList</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(context.Base_translateString(x[1]), x[0]) for x in context.AccountModule_getAnalyticColumnList()]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1268 1277
\ No newline at end of file \ No newline at end of file
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