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

accounting periods: refuse to close if previous period is not closed

parent ee428750
...@@ -50,7 +50,9 @@ ...@@ -50,7 +50,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n <value> <string encoding="cdata"><![CDATA[
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import translateString\n from Products.ERP5Type.Message import translateString\n
\n \n
period = state_change[\'object\']\n period = state_change[\'object\']\n
...@@ -64,6 +66,18 @@ all_state_list = [x[1] for x in\n ...@@ -64,6 +66,18 @@ all_state_list = [x[1] for x in\n
invalid_simulation_state_list = [state for state in all_state_list\n invalid_simulation_state_list = [state for state in all_state_list\n
if state not in valid_simulation_state_list]\n if state not in valid_simulation_state_list]\n
\n \n
if period.getParentValue().getPortalType() == \'Organisation\':\n
# if this is a "main" accounting period, we refuse to close if the previous\n
# period is not already closed.\n
for other_period in period.getParentValue().contentValues(\n
portal_type=\'Accounting Period\',\n
checked_permission=\'View\'):\n
if other_period != period and \\\n
other_period.getSimulationState() not in (\'delivered\', \'cancelled\') and\\\n
other_period.getStartDate() < period.getStartDate():\n
raise ValidationFailed(translateString(\n
"Previous accounting periods has to be closed first."))\n
\n
section = period.getParentValue()\n section = period.getParentValue()\n
while section.getPortalType() == period.getPortalType():\n while section.getPortalType() == period.getPortalType():\n
section = section.getParentValue()\n section = section.getParentValue()\n
...@@ -115,7 +129,9 @@ movement_list = portal.portal_simulation.getMovementHistoryList(\n ...@@ -115,7 +129,9 @@ movement_list = portal.portal_simulation.getMovementHistoryList(\n
if movement_list:\n if movement_list:\n
raise ValidationFailed, translateString(\n raise ValidationFailed, translateString(\n
"All Accounting Transactions for this organisation during the period have to be closed first.")\n "All Accounting Transactions for this organisation during the period have to be closed first.")\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
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