Commit 70457921 authored by Jérome Perrin's avatar Jérome Perrin

Aged balance report

parent 3bf0a24d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_exchange</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_exchange</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>aged_balance_export</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>20.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Aged Balance</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string encoding="cdata"><![CDATA[
string:${object_url}/AccountingTransactionModule_viewAgedBalanceReportDialog?your_portal_skin=ODS&your_format=
]]></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_report</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_report</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>aged_balance_report</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>20.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Aged Balance</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/AccountingTransactionModule_viewAgedBalanceReportDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Message import translateString\n
from Products.ERP5Form.Report import ReportSection\n
portal = context.getPortalObject()\n
\n
request = container.REQUEST\n
section_category = request[\'section_category\']\n
section_category_strict = request[\'section_category_strict\']\n
simulation_state = request[\'simulation_state\']\n
account_type = request[\'account_type\']\n
period_list = [int(period) for period in request[\'period_list\']]\n
at_date = (request.get("at_date") or DateTime()).latestTime()\n
detailed = request[\'detailed\']\n
\n
selection_columns = [(\'mirror_section_title\', \'Third Party\'), ]\n
if detailed:\n
selection_columns.extend([\n
(\'explanation_title\', \'Title\'),\n
(\'gap_id\', \'Account Number\'),\n
(\'reference\', \'Invoice Number\'),\n
(\'specific_reference\', \'Transaction Reference\'),\n
(\'date\', \'Operation Date\'),\n
(\'portal_type\', \'Transaction Type\'), ])\n
selection_columns.extend([\n
(\'total_price\', \'Balance\'),\n
(\'period_future\', \'Future\'), ] )\n
\n
editable_columns = [(\'date\', \'date\'), (\'period_future\', \'period_future\'),\n
(\'total_price\', \'total_price\')]\n
\n
previous_period = 0\n
for idx, period in enumerate(period_list):\n
if idx != 0:\n
previous_period = period_list[idx - 1]\n
selection_columns.append((\'period_%s\' % idx, unicode(translateString(\n
\'Period ${period_number} (from ${from} to ${to} days)\',\n
mapping={\'period_number\': 1 + idx,\n
\'from\': previous_period,\n
\'to\': period} ))))\n
editable_columns.append((\'period_%s\' % idx, \'\'))\n
\n
selection_columns.append((\'period_%s\' % (idx + 1),\n
unicode(translateString(\'Older (more than ${day_count} days)\',\n
mapping={\'day_count\': period_list[-1]}))))\n
editable_columns.append((\'period_%s\' % (idx + 1), \'\'))\n
\n
\n
return [ReportSection(form_id=(detailed and \n
\'AccountingTransactionModule_viewDetailedAgedBalanceReportSection\' or\n
\'AccountingTransactionModule_viewSummaryAgedBalanceReportSection\'),\n
path=context.getPhysicalPath(),\n
selection_columns=selection_columns,\n
selection_name=(detailed and\n
\'accounting_transaction_module_detailed_aged_balance_selection\' or\n
\'accounting_transaction_module_summary_aged_balance_selection\'),\n
selection_params=dict(section_category=section_category,\n
section_category_strict=section_category_strict,\n
account_type=account_type,\n
editable_columns=editable_columns,\n
simulation_state=simulation_state,\n
period_list=period_list,\n
at_date=at_date))]\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_getAgedBalanceReportSectionList</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
from Products.PythonScripts.standard import Object\n
portal = context.getPortalObject()\n
\n
assert account_type in (\'account_type/asset/receivable\', \'account_type/liability/payable\')\n
\n
currency = context.Base_getCurrencyForSection(section_category)\n
precision = context.account_module.getQuantityPrecisionFromResource(currency)\n
# we set the precision in request, for formatting on editable fields\n
portal.REQUEST.set(\'precision\', precision)\n
\n
section_uid = portal.Base_getSectionUidListForSectionCategory(\n
section_category, section_category_strict)\n
\n
grouping_query = ComplexQuery(\n
Query(grouping_reference=None),\n
Query(grouping_date=at_date, range="min"),\n
operator="OR")\n
\n
account_number_memo = dict()\n
def getAccountNumber(account_url):\n
try:\n
return account_number_memo[account_url]\n
except KeyError:\n
account_number_memo[account_url] =\\\n
portal.restrictedTraverse(account_url).Account_getGapId()\n
return account_number_memo[account_url]\n
\n
section_title_memo = dict()\n
def getSectionTitle(uid):\n
try:\n
return section_title_memo[uid]\n
except KeyError:\n
section_title_memo[uid] =\\\n
portal.portal_catalog.getObject(uid).getTranslatedTitle()\n
return section_title_memo[uid]\n
\n
last_period_id = \'period_%s\' % len(period_list)\n
line_list = []\n
\n
for brain in portal.portal_simulation.getMovementHistoryList(\n
at_date=at_date,\n
simulation_state=simulation_state,\n
node_category_strict_membership=account_type,\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
section_uid=section_uid,\n
grouping_query=grouping_query,\n
sort_on=((\'stock.mirror_section_uid\', \'ASC\'),\n
(\'stock.date\', \'ASC\'),\n
(\'stock.uid\', \'ASC\'))):\n
movement = brain.getObject()\n
transaction = movement.getParentValue()\n
\n
total_price = brain.total_price\n
if account_type == \'account_type/liability/payable\':\n
total_price = - total_price\n
\n
line = Object(uid=\'new_\',\n
mirror_section_title=getSectionTitle(brain.mirror_section_uid),\n
mirror_section_uid=brain.mirror_section_uid,\n
explanation_title=movement.hasTitle() and movement.getTitle()\n
or transaction.getTitle(),\n
reference=transaction.getReference(),\n
portal_type=transaction.getTranslatedPortalType(),\n
date=brain.date,\n
total_price=total_price,)\n
\n
if brain.mirror_section_uid == movement.getSourceSectionUid():\n
line[\'specific_reference\'] = transaction.getDestinationReference()\n
line[\'gap_id\'] = getAccountNumber(movement.getDestination())\n
else:\n
line[\'specific_reference\'] = transaction.getSourceReference()\n
line[\'gap_id\'] = getAccountNumber(movement.getSource())\n
assert brain.mirror_section_uid == movement.getDestinationSectionUid()\n
\n
age = int(at_date - brain.date)\n
line[\'age\'] = age\n
if age < 0:\n
line[\'period_future\'] = total_price\n
elif age <= period_list[0]:\n
line[\'period_0\'] = total_price\n
else:\n
for idx, period in enumerate(period_list):\n
if age <= period:\n
line[\'period_%s\' % idx] = total_price\n
break\n
else:\n
line[last_period_id] = total_price\n
\n
line_list.append(line)\n
\n
return line_list\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date, section_category, section_category_strict, simulation_state, period_list, account_type, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_getDetailedAgedBalanceLineList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.PythonScripts.standard import Object\n
portal = context.getPortalObject()\n
\n
line_list = []\n
detail_line_list = portal\\\n
.AccountingTransactionModule_getDetailedAgedBalanceLineList(\n
at_date, section_category, section_category_strict,\n
simulation_state, period_list, account_type, **kw)\n
\n
period_id_list = [\'period_future\']\n
for idx, period in enumerate(period_list):\n
period_id_list.append(\'period_%s\' % idx)\n
period_id_list.append(\'period_%s\' % (idx + 1))\n
\n
# Initialize to something that will not be equals to \n
# detail_line.mirror_section_uid below.\n
# In case we have used an account with mirror section,\n
# then mirror_section_uid will be None\n
previous_mirror_section_uid = -1\n
\n
for detail_line in detail_line_list:\n
if previous_mirror_section_uid != detail_line.mirror_section_uid:\n
line = Object(uid=\'new_\',\n
mirror_section_title=detail_line.mirror_section_title,\n
total_price=0)\n
line_list.append(line)\n
previous_mirror_section_uid = detail_line.mirror_section_uid\n
line[\'total_price\'] = detail_line.total_price + line[\'total_price\']\n
\n
for period_id in period_id_list:\n
previous_value = line.get(period_id, 0)\n
added_value = detail_line.get(period_id, 0)\n
new_value = previous_value + added_value\n
if previous_value or new_value:\n
line[period_id] = new_value\n
\n
return line_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>at_date, section_category, section_category_strict, simulation_state, period_list, account_type, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_getSummaryAgedBalanceLineList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Report" module="Products.ERP5Form.Report"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>