Commit f79c8d2d authored by Sebastien Robin's avatar Sebastien Robin

- accounting date improvement made by Vincent

- improved script that checks all open counters

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15262 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 06f2008e
......@@ -51,7 +51,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>4.0</float> </value>
<value> <float>60.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -71,14 +71,18 @@
\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
from DateTime import DateTime\n
\n
if date is None:\n
# get current date\n
from DateTime import DateTime\n
date = DateTime()\n
\n
# Make sure we have a date with no hours\n
date = date.Date()\n
try:\n
date = date.Date()\n
except AttributeError:\n
# Assume that non-date parameter contains the bare date.\n
pass\n
\n
if site is None:\n
# get site from user assignment\n
......@@ -92,11 +96,20 @@ if site is None:\n
# get only the office, not need of vault\n
#context.log(\'Baobab_checkAccountingDateOpen\', \'get site for vault %s\' %(site))\n
site = context.Baobab_getVaultSite(site)\n
error = False\n
if context.portal_catalog.countResults(portal_type=\'Accounting Date\', site_id=site.getId(), simulation_state="opened", limit=1)[0][0] == 0:\n
# If there is no opened accounting date, consider today as an openned accounting day.\n
if DateTime(date) < DateTime(DateTime().Date()):\n
error = True\n
elif context.portal_catalog.countResults(portal_type=\'Accounting Date\', start_date={\'query\':\'<=%s\' % (date, ), \'type\': \'date\', \'format\': \'%Y/%m/%d\'}, site_id=site.getId(), simulation_state="opened", limit=1)[0][0] == 0:\n
# If an accounting date is openned but posterior to checked date, verification fails.\n
error= True\n
\n
if context.portal_catalog.countResults(portal_type=\'Accounting Date\', start_date={\'query\':\'<=%s\' % (date, ), \'type\': \'date\', \'format\': \'%Y/%m/%d\'}, site_id=site.getId(), simulation_state="opened", limit=1)[0][0] == 0:\n
raise Exception, context.portal_catalog.countResults(portal_type=\'Accounting Date\', start_date={\'query\':\'<=%s\' % (date, ), \'type\': \'date\', \'format\': \'%Y/%m/%d\'}, site_id=site.getId(), simulation_state="opened", limit=1, src__=1)\n
if error:\n
msg = Message(domain = "ui", message="Transaction not in the good accounting date")\n
raise ValidationFailed, (msg,)\n
\n
return "ok"\n
]]></string> </value>
......@@ -161,14 +174,17 @@ if context.portal_catalog.countResults(portal_type=\'Accounting Date\', start_da
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>None</string>
<string>DateTime</string>
<string>None</string>
<string>_getattr_</string>
<string>AttributeError</string>
<string>context</string>
<string>site_list</string>
<string>len</string>
<string>_getitem_</string>
<string>Exception</string>
<string>False</string>
<string>error</string>
<string>True</string>
<string>msg</string>
</tuple>
</value>
......
......@@ -65,14 +65,27 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>site = context.Baobab_getVaultSite(counter)\n
counter_list = [x.getObject() for x in context.portal_catalog(portal_type="Counter", simulation_state = \'open\', site_uid = site.getUid())]\n
for counter_ob in counter_list:\n
# context.log(counter.getRelativeUrl(), counter_ob.getSite())\n
if "site/%s" %counter_ob.getSite() in counter.getRelativeUrl() or counter.getRelativeUrl() in "site/%s" %counter_ob.getSite():\n
return 1\n
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
if simulation_state_list is None:\n
simulation_state_list = [\'open\']\n
\n
site = context.Baobab_getVaultSite(counter)\n
counter_list = [x.getObject() for x in context.portal_catalog(portal_type="Counter", \n
simulation_state = simulation_state_list, site_uid = site.getUid())]\n
if same_type(counter, \'a\'):\n
counter_relative_url = counter\n
else:\n
return 0\n
counter_relative_url = counter.getRelativeUrl()\n
found = 0\n
if "guichet" in counter_relative_url:\n
for counter_ob in counter_list:\n
if "site/%s" %counter_ob.getSite() in counter_relative_url or counter_relative_url in "site/%s" %counter_ob.getSite():\n
found = 1\n
if found == 0:\n
msg = Message(domain = "ui", message="Counter is not opened")\n
raise ValidationFailed, (msg,)\n
</string> </value>
</item>
<item>
......@@ -95,7 +108,7 @@ else:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>counter</string> </value>
<value> <string>counter, simulation_state_list=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......@@ -123,13 +136,19 @@ else:\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>counter</string>
<string>simulation_state_list</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>site</string>
......@@ -138,7 +157,11 @@ else:\n
<string>_getiter_</string>
<string>x</string>
<string>counter_list</string>
<string>same_type</string>
<string>counter_relative_url</string>
<string>found</string>
<string>counter_ob</string>
<string>msg</string>
</tuple>
</value>
</item>
......@@ -150,7 +173,9 @@ else:\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
......
<?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>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>return [] # Just a dummy script\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>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>site=None</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>site</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Baobab_checkRemainingAccountingOperation</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -65,8 +65,20 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># Just a dummy for now\n
return []\n
<value> <string># Retrieve the last counter date for a given date\n
\n
from DateTime import DateTime\n
if start_date is None:\n
start_date = DateTime()\n
\n
counter_date_list = context.portal_catalog(portal_type=\'Counter Date\', \n
site_uid=site_uid, \n
start_date={\'query\':start_date,\'range\':\'ngt\'},\n
sort_on=[(\'start_date\',\'descending\')], limit=1)\n
counter_date = None\n
if len(counter_date_list)==1:\n
counter_date = counter_date_list[0]\n
return counter_date\n
</string> </value>
</item>
<item>
......@@ -89,13 +101,7 @@ return []\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>site=None,**kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple/>
</value>
<value> <string>site_uid=None, start_date=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -115,14 +121,22 @@ return []\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>site</string>
<string>kw</string>
<string>site_uid</string>
<string>start_date</string>
<string>DateTime</string>
<string>None</string>
<string>_getattr_</string>
<string>context</string>
<string>counter_date_list</string>
<string>counter_date</string>
<string>len</string>
<string>_getitem_</string>
</tuple>
</value>
</item>
......@@ -136,12 +150,13 @@ return []\n
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingDate_getRemainingOperationList</string> </value>
<value> <string>Base_getCounterDate</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -151,6 +151,7 @@ def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
catalog_kw[\'vault_type_uid\']=vault_type_uid_list\n
site_member_list = context.portal_catalog(portal_type=\'Category\',\n
relative_url=\'%s%%\' % site_object.getRelativeUrl(),\n
limit=None,\n
**catalog_kw\n
)\n
for site_member in site_member_list:\n
......
<?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>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># Check that it is possible to close the accounting date.\n
\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
accounting_date = state_change[\'object\']\n
\n
site = accounting_date.getSiteValue()\n
while True:\n
if getattr(site, \'getVaultTypeList\', None) is None:\n
msg = Message(domain = \'ui\', message = \'The site value is misconfigured; report this to system administrators.\')\n
raise ValidationFailed, (msg,)\n
if \'site\' in site.getVaultTypeList():\n
break\n
site = site.getParentValue()\n
\n
# Check that there is no pending operation\n
accounting_date.Baobab_checkRemainingAccountingOperation(site=site)\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>state_change</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple/>
</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>state_change</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getitem_</string>
<string>accounting_date</string>
<string>_getattr_</string>
<string>site</string>
<string>True</string>
<string>getattr</string>
<string>None</string>
<string>msg</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>checkClosePossible</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -79,19 +79,6 @@ site_uid = accounting_date.getSiteUid()\n
if site_uid is None:\n
msg = Message(domain=\'ui\',message="Sorry, the site is not defined")\n
raise ValidationFailed (msg,)\n
\n
# Check if date defined on the accounting_date is the current date\n
if now.Date() != accounting_date.getStartDate().Date():\n
msg = Message(domain=\'ui\',message="Sorry, the date is not today")\n
raise ValidationFailed (msg,)\n
\n
# Check for any other opened accounting date on the same site\n
accounting_date_uid = accounting_date.getUid()\n
opened_accounting_date_list = accounting_date.portal_catalog(portal_type=\'Accounting Date\', site_uid=site_uid, simulation_state=\'opened\')\n
for opened_accounting_date in opened_accounting_date_list:\n
if opened_accounting_date.getUid() != accounting_date_uid:\n
msg = Message(domain=\'ui\',message="Sorry, there is already an opened accounting date")\n
raise ValidationFailed (msg,)\n
</string> </value>
</item>
<item>
......@@ -147,10 +134,6 @@ for opened_accounting_date in opened_accounting_date_list:\n
<string>site_uid</string>
<string>None</string>
<string>msg</string>
<string>accounting_date_uid</string>
<string>opened_accounting_date_list</string>
<string>_getiter_</string>
<string>opened_accounting_date</string>
</tuple>
</value>
</item>
......
......@@ -51,7 +51,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>checkClosePossible</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -84,13 +84,14 @@ if len(date_list) == 0:\n
else:\n
current_date = date_list[0].getStartDate()\n
\n
site_uid = transaction.getSiteUid()\n
# We should not reject automatically\n
# I (seb) do not recommand this\n
#site_uid = transaction.getSiteUid()\n
\n
operation_list_object = transaction.Baobab_getRemainingOperationList(site_uid=site_uid, date=current_date, simulation_state=[\'confirmed\',])\n
#operation_list_object = transaction.Baobab_getRemainingOperationList(site_uid=site_uid, date=current_date, simulation_state=[\'confirmed\',])\n
\n
for operation in operation_list_object:\n
context.log(\'cancelling operations\', operation.getRelativeUrl())\n
operation.reject()\n
#for operation in operation_list_object:\n
# operation.reject()\n
</string> </value>
</item>
<item>
......@@ -156,9 +157,6 @@ for operation in operation_list_object:\n
<string>current_date</string>
<string>len</string>
<string>msg</string>
<string>site_uid</string>
<string>operation_list_object</string>
<string>operation</string>
</tuple>
</value>
</item>
......
......@@ -48,34 +48,24 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>AccessContentsInformation</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......@@ -92,8 +82,10 @@
<key> <string>View</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......
......@@ -48,34 +48,24 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>AccessContentsInformation</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......@@ -92,8 +82,10 @@
<key> <string>View</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......
......@@ -50,17 +50,14 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
......@@ -70,16 +67,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>AccessContentsInformation</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......@@ -99,6 +87,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......
......@@ -48,34 +48,24 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>AccessContentsInformation</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......@@ -92,8 +82,10 @@
<key> <string>View</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......
313
\ No newline at end of file
315
\ 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