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

Base_getAccountingPeriodStartDateForSectionCategory:

  a new script to guess the start date of the current period (based on the
  date parameter) for a section_category.
AccountModule_getTrialBalanceReportSectionList:
  use Base_getAccountingPeriodStartDateForSectionCategory



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13982 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d4a61f29
...@@ -68,9 +68,7 @@ ...@@ -68,9 +68,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>""" Trial balance.\n
""" Trial balance.\n
"""\n """\n
from Products.ERP5Form.Report import ReportSection\n from Products.ERP5Form.Report import ReportSection\n
\n \n
...@@ -86,22 +84,10 @@ show_empty_accounts = request[\'show_empty_accounts\']\n ...@@ -86,22 +84,10 @@ show_empty_accounts = request[\'show_empty_accounts\']\n
\n \n
section_uid = portal.Base_getSectionUidListForSectionCategory(\n section_uid = portal.Base_getSectionUidListForSectionCategory(\n
request[\'section_category\'])\n request[\'section_category\'])\n
# XXX for now we guess period start date from the first organisation having\n \n
# accounting periods\n period_start_date = portal.Base_getAccountingPeriodStartDateForSectionCategory(\n
period_start_date = None\n section_category=request[\'section_category\'], date=from_date or at_date)\n
valid_accounting_period = dict(portal_type=\'Accounting Period\',\n # for the report summary\n
simulation_state=(\'planned\', \'confirmed\',\n
\'stopped\', \'closing\', \'delivered\'))\n
date = from_date or at_date\n
for uid in section_uid:\n
section = portal.portal_catalog.getObject(uid)\n
for ap in section.contentValues(filter=valid_accounting_period):\n
if ap.getStartDate() <= date <= ap.getStopDate():\n
period_start_date = ap.getStartDate().earliestTime()\n
if period_start_date:\n
break\n
else:\n
period_start_date = DateTime(date.year(), 1, 1)\n
request.set(\'period_start_date\', period_start_date)\n request.set(\'period_start_date\', period_start_date)\n
\n \n
if not from_date:\n if not from_date:\n
...@@ -133,9 +119,7 @@ return [ ReportSection(\n ...@@ -133,9 +119,7 @@ return [ ReportSection(\n
section_uid=section_uid,\n section_uid=section_uid,\n
simulation_state=simulation_state,\n simulation_state=simulation_state,\n
precision=precision ),) ]\n precision=precision ),) ]\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -200,17 +184,10 @@ return [ ReportSection(\n ...@@ -200,17 +184,10 @@ return [ ReportSection(\n
<string>show_empty_accounts</string> <string>show_empty_accounts</string>
<string>section_uid</string> <string>section_uid</string>
<string>period_start_date</string> <string>period_start_date</string>
<string>dict</string>
<string>valid_accounting_period</string>
<string>date</string>
<string>_getiter_</string>
<string>uid</string>
<string>section</string>
<string>ap</string>
<string>DateTime</string>
<string>currency</string> <string>currency</string>
<string>precision</string> <string>precision</string>
<string>True</string> <string>True</string>
<string>dict</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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.ERP5Type.Cache import CachingMethod\n
\n
def getAccountingPeriodStartDateForSectionCategory(section_category, date):\n
portal = context.getPortalObject()\n
section_uid = portal.Base_getSectionUidListForSectionCategory(\n
section_category)\n
# XXX for now we guess period start date from the first organisation having\n
# accounting periods\n
period_start_date = None\n
valid_accounting_period = dict(portal_type=\'Accounting Period\',\n
simulation_state=(\'planned\', \'confirmed\',\n
\'stopped\', \'closing\', \'delivered\'))\n
for uid in section_uid:\n
section = portal.portal_catalog.getObject(uid)\n
for ap in section.contentValues(filter=valid_accounting_period):\n
if ap.getStartDate() <= date <= ap.getStopDate():\n
period_start_date = ap.getStartDate().earliestTime()\n
if period_start_date:\n
break\n
else:\n
period_start_date = DateTime(date.year(), 1, 1)\n
return period_start_date\n
\n
getAccountingPeriodStartDateForSectionCategory = CachingMethod(\n
getAccountingPeriodStartDateForSectionCategory,\n
id=script.getId(), cache_factory=\'erp5_content_long\')\n
\n
return getAccountingPeriodStartDateForSectionCategory(section_category, date)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>section_category, date</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>section_category</string>
<string>date</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>getAccountingPeriodStartDateForSectionCategory</string>
<string>_getattr_</string>
<string>script</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getAccountingPeriodStartDateForSectionCategory</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
242 243
\ 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