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

2009-05-06 Jerome

* Introduce recursive accounting periods, used for example for monthly intermediate periods. They do not create balance transaction, but prevent adding more transaction for this period.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26852 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d43fcc8d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>create_secondary_periods</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Add portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Secondary Periods</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/AccountingPeriod_viewCreateSecondaryPeriodDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="Expression" module="Products.CMFCore.Expression"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.getParentValue().getPortalType() == \'Organisation\' and not len(object.contentValues(checked_permission=\'View\'))</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,6 +2,9 @@
<portal_type id="Account Module">
<item>Account</item>
</portal_type>
<portal_type id="Accounting Period">
<item>Accounting Period</item>
</portal_type>
<portal_type id="Accounting Rule Cell">
<item>Accounting Rule Cell Line</item>
<item>Accounting Transaction Line</item>
......@@ -56,8 +59,8 @@
<item>Payment Rule</item>
</portal_type>
<portal_type id="Sale Invoice Transaction">
<item>File</item>
<item>Sale Invoice Transaction Line</item>
<item>File</item>
<item>Image</item>
</portal_type>
</allowed_content_type_list>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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.ERP5Type.DateUtils import addToDate\n
\n
month_added = 1\n
if frequency == \'quarterly\':\n
month_added = 3\n
\n
date = context.getStartDate()\n
while date < context.getStopDate():\n
end_date = addToDate(date, dict(month=month_added))\n
period = context.newContent(portal_type=\'Accounting Period\',\n
start_date=date,\n
stop_date=end_date - 1,)\n
\n
if frequency == \'quarterly\':\n
period.setShortTitle(\'%s-%s\' % (date.strftime(\'%Y %m\'), (end_date - 1).strftime(\'%m\')))\n
else:\n
period.setShortTitle(date.strftime(\'%Y-%m\'))\n
period.setTitle(date.strftime(\'%B\'))\n
\n
if open_periods:\n
period.start()\n
\n
date = end_date\n
\n
return context.Base_redirect(form_id, \n
keep_items=dict(portal_status_message=\'Accounting periods created.\'))\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>frequency, open_periods=0, form_id=\'view\'</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>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>frequency</string>
<string>open_periods</string>
<string>form_id</string>
<string>Products.ERP5Type.DateUtils</string>
<string>addToDate</string>
<string>month_added</string>
<string>_getattr_</string>
<string>context</string>
<string>date</string>
<string>dict</string>
<string>end_date</string>
<string>period</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
<string>view</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingPeriod_createSecondaryPeriod</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -55,6 +55,7 @@
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
......@@ -62,6 +63,14 @@
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox_period_list</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>selection_name</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_period_list</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>all_editable_columns</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>listbox_period_list</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Organisation_viewFinancialInformationList</string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>accounting_period_accounting_period_selection</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</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>AccountingPeriod_createSecondaryPeriod</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>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_frequency</string>
<string>your_open_periods</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingPeriod_viewCreateSecondaryPeriodDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>AccountingPeriod_viewCreateSecondaryPeriodDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create Secondary Periods</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_open_periods</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>
</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</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</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> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</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> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Open the created periods</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</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Open Periods ?</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -133,7 +133,9 @@
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -158,7 +160,7 @@
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -267,11 +269,24 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.getParentValue().getPortalType() != context.getPortalType()</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......
......@@ -13,14 +13,7 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>read_only</string>
<string>editable_permission</string>
<string>title</string>
<string>not_viewable</string>
<string>required</string>
<string>viewable_permission</string>
<string>viewable_role</string>
<string>editable_role</string>
<string>items</string>
</list>
</value>
......@@ -108,6 +101,12 @@
<key> <string>form_id</string> </key>
<value> <string>AccountingTransaction_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>not_viewable</string> </key>
<value> <int>0</int> </value>
......@@ -116,10 +115,6 @@
<key> <string>read_only</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
......
......@@ -65,8 +65,12 @@ all_state_list = [x[1] for x in\n
invalid_simulation_state_list = [state for state in all_state_list\n
if state not in valid_simulation_state_list]\n
\n
section = period.getParentValue()\n
while section.getPortalType() == period.getPortalType():\n
section = section.getParentValue()\n
\n
movement_list = portal.portal_simulation.getMovementHistoryList(\n
section_uid=period.getParentUid(),\n
section_uid=section.getUid(),\n
from_date=period.getStartDate().earliestTime(),\n
at_date=period.getStopDate().latestTime(),\n
simulation_state=invalid_simulation_state_list,\n
......@@ -128,6 +132,7 @@ if movement_list:\n
<string>all_state_list</string>
<string>state</string>
<string>invalid_simulation_state_list</string>
<string>section</string>
<string>movement_list</string>
</tuple>
</value>
......
......@@ -56,6 +56,11 @@
<value> <string>"""Create a balance transaction\n
"""\n
accounting_period = sci[\'object\']\n
\n
# we only create a balance transaction for top level accounting periods\n
if accounting_period.getParentValue().getPortalType() == accounting_period.getPortalType():\n
return\n
\n
portal = accounting_period.getPortalObject()\n
profit_and_loss_account = portal.portal_workflow.getInfoFor(\n
accounting_period, \'profit_and_loss_account\')\n
......
......@@ -96,6 +96,23 @@ if transaction.getSourceSectionValue(portal_type=\'Category\') is not None or\\\
transaction_line_list = transaction.getMovementList(\n
portal_type=transaction.getPortalAccountingMovementTypeList())\n
\n
\n
def checkAccountingPeriodRecusivly(accounting_period, transaction_date):\n
valid = accounting_period.getSimulationState() in (\'planned\', \'started\')\n
if not valid:\n
return False\n
for sub_accounting_period in accounting_period.contentValues():\n
if sub_accounting_period.getSimulationState() in (\n
\'deleted\', \'cancelled\'):\n
continue\n
if sub_accounting_period.getStartDate().earliestTime() <= \\\n
transaction_date <= \\\n
sub_accounting_period.getStopDate().latestTime():\n
if not checkAccountingPeriodRecusivly(sub_accounting_period,\n
transaction_date):\n
return False\n
return True\n
\n
if not skip_period_validation :\n
# check the date is in an opened period\n
if source_section is not None:\n
......@@ -120,8 +137,10 @@ if not skip_period_validation :\n
valid_date = True\n
for apd in openned_accounting_period_list:\n
apd = apd.getObject()\n
if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
valid_date = True\n
if apd.getStartDate().earliestTime() <= transaction_date <= \\\n
apd.getStopDate().latestTime():\n
valid_date = checkAccountingPeriodRecusivly(apd, transaction_date)\n
\n
if not valid_date:\n
raise ValidationFailed(translateString("Date is not in a started Accounting Period "\n
"for source section."))\n
......@@ -144,10 +163,12 @@ if not skip_period_validation :\n
valid_date = True\n
for apd in openned_accounting_period_list:\n
apd = apd.getObject()\n
if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
valid_date = True\n
if apd.getStartDate().earliestTime() <= transaction_date <= \\\n
apd.getStopDate().latestTime():\n
valid_date = checkAccountingPeriodRecusivly(apd, transaction_date)\n
\n
if not valid_date:\n
raise ValidationFailed(translateString("Date is not in an started Accounting Period "\n
raise ValidationFailed(translateString("Date is not in a started Accounting Period "\n
"for destination section."))\n
......@@ -219,6 +240,7 @@ if not skip_period_validation :\n
<string>destination_section</string>
<string>None</string>
<string>transaction_line_list</string>
<string>checkAccountingPeriodRecusivly</string>
<string>False</string>
<string>valid_date</string>
<string>True</string>
......
2009-05-06 Jerome
* Introduce recursive accounting periods, used for example for monthly intermediate periods. They do not create balance transaction, but prevent adding more transaction for this period.
2009-04-18 Kazuhiko
* Version 5.4.1
......
909
\ No newline at end of file
911
\ No newline at end of file
......@@ -5,6 +5,7 @@ Account | jump_active_accounting_pref
Account | jump_to_accounting
Account | transaction_list
Account | view
Accounting Period | create_secondary_periods
Accounting Period | jump_related_balance_transaction
Accounting Period | view
Accounting Rule Cell Line | view
......
Account Module | Account
Accounting Period | Accounting Period
Accounting Rule Cell | Accounting Rule Cell Line
Accounting Rule Cell | Accounting Transaction Line
Accounting Transaction Module | Accounting Transaction
......
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