Commit f0d4abf5 authored by Sebastien Robin's avatar Sebastien Robin

add many more checks with the counter date when we open and close it.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11578 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cc6a4003
<?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># Make sure there is not any operation wich is not finished yet\n
# This is usefull when we close a counter date\n
\n
not_closed_state_list = (\'ordered\',\'planned\',\'confirmed\',\'started\',\'stopped\')\n
if site is None:\n
root_site_url = context.Baobab_getUserAssignedRootSiteList()[0]\n
site = context.portal_categories.restrictedTraverse(root_site_url)\n
root_site_uid = site.getUid()\n
document_list = [x.getObject() for x in context.portal_catalog(\n
simulation_state=not_closed_state_list,\n
source_uid=root_site_uid)]\n
document_list.extend([x.getObject() for x in context.portal_catalog(\n
simulation_state=not_closed_state_list,\n
destination_uid=root_site_uid)])\n
for document in document_list:\n
# Cash movement in ordered stated are allowed\n
if document.getPortalType() in (\'Cash Movement\',):\n
if document.getSimulationState()==\'planned\':\n
continue\n
from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
portal_type = document.getTranslatedPortalType()\n
reference = document.getReference()\n
if reference is None:\n
reference = Message(domain=\'ui\',message=\'Not defined\')\n
message = Message(domain="ui", \n
message="Sorry, the $portal_type (reference:$reference) is not finished",\n
mapping={\'portal_type\':portal_type,\'reference\':reference})\n
raise ValidationFailed,message\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
<string>not_closed_state_list</string>
<string>None</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>context</string>
<string>root_site_url</string>
<string>root_site_uid</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>document_list</string>
<string>document</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>portal_type</string>
<string>reference</string>
<string>message</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_checkRemainingOperation</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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[
# Make sure that there is no stock on counters and that there\n
# is not too much money into the usual cash\n
# This is usefull when we close a counter date\n
\n
from Products.ERP5Type.Message import Message\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
if site is None:\n
root_site_url = context.Baobab_getUserAssignedRootSiteList()[0]\n
site = context.portal_categories.restrictedTraverse(root_site_url)\n
\n
resource_uid_list = [x.uid for x in context.currency_cash_module.searchFolder()]\n
\n
\n
counter_vault_list = context.Delivery_getVaultItemList(\n
user_site=0,base_site=site.getRelativeUrl(),all=1,\n
vault_type=(\'site/surface/banque_interne\',\'site/surface/gros_paiement\',\n
\'site/surface/gros_versement\',\'site/surface/operations_diverses\'))\n
for counter_vault in counter_vault_list:\n
counter_vault_url = counter_vault[1]\n
if counter_vault_url==\'\':\n
continue\n
counter_title = counter_vault[0]\n
inventory_list = context.portal_simulation.getCurrentInventoryList(\n
node=counter_vault_url,\n
resource_uid=resource_uid_list,\n
ignore_variation=0)\n
if len(inventory_list)>0:\n
message = Message(domain=\'ui\',\n
message=\'Sorry, some resources are still remaining here : $counter_title\',\n
mapping={\'counter_title\':counter_title})\n
raise ValidationFailed,message\n
\n
max_price = context.portal_preferences.getPreferredUsualCashMaxRenderingPrice()\n
if max_price is None:\n
message = Message(domain=\'ui\',\n
message=\'Sorry, you must defined the max price for the usual cash in your preference\')\n
raise ValidationFailed,message\n
\n
usual_cash = site.getRelativeUrl() + \'/surface/caisse_courante/encaisse_des_billets_et_monnaies\'\n
inventory_list = context.portal_simulation.getCurrentInventoryList(\n
node=usual_cash,\n
resource_uid=resource_uid_list)\n
total_price = sum([x.total_price for x in inventory_list])\n
context.log(\'current_price\',total_price)\n
\n
if total_price > max_price:\n
message = Message(domain=\'ui\',\n
message=\'Sorry, the amount in the usual cash is too high\')\n
raise ValidationFailed,message\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>None</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>context</string>
<string>root_site_url</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>resource_uid_list</string>
<string>counter_vault_list</string>
<string>counter_vault</string>
<string>counter_vault_url</string>
<string>counter_title</string>
<string>inventory_list</string>
<string>len</string>
<string>message</string>
<string>max_price</string>
<string>usual_cash</string>
<string>sum</string>
<string>total_price</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_checkStockBeforeClosingDate</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -145,10 +145,10 @@ vault_inventory_list = context.portal_simulation.getCurrentInventoryList( node=v
, ignore_variation=0\n
,**inventory_kw\n
)\n
context.log(\'CounterMOdule_getVaultTransactionList, sql src:\',context.portal_simulation.getCurrentInventoryList( node=vault\n
, ignore_variation=0,src__=1\n
,**inventory_kw\n
))\n
#context.log(\'CounterMOdule_getVaultTransactionList, sql src:\',context.portal_simulation.getCurrentInventoryList( node=vault\n
# , ignore_variation=0,src__=1\n
# ,**inventory_kw\n
# ))\n
\n
#context.log(\'len(vault_inventory_list:\',len(vault_inventory_list))\n
for vault_inventory in vault_inventory_list:\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </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>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_preferred_usual_cash_max_rendering_price</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Preference_viewBanking</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Preference_viewBanking</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</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>Banking Preference</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>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>FloatField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_usual_cash_max_rendering_price</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>
<item>
<key> <string>not_float</string> </key>
<value> <string>You did not enter a floating point number.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</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>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</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>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</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>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</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>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</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> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </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>input_style</string> </key>
<value> <string>-1 234.5</string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Usual Cash Max Rendering Price</string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -83,6 +83,12 @@ while True:\n
break\n
site = site.getParentValue()\n
\n
# First make sure there is nothing any more on counters\n
transaction.Baobab_checkStockBeforeClosingDate(site=site)\n
\n
# Then make sure there is not any pending operation\n
transaction.Baobab_checkRemainingOperation(site=site)\n
\n
current_date = transaction.getStartDate()\n
counter_list = [x.getObject() for x in context.portal_catalog(portal_type="Counter", simulation_state = [\'open\', \'closing\'], site_uid = site.getUid())]\n
\n
......
......@@ -70,12 +70,20 @@
<key> <string>_body</string> </key>
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
counter_date = state_change[\'object\']\n
\n
listbox = state_change.kwargs.get(\'listbox\')\n
# First, make sure there is not any counter date open for this site\n
site_uid = context.getSiteUid()\n
counter_date_list = [x.getObject() for x in context.portal_catalog(portal_type=\'Counter Date\',site_uid=site_uid,simulation_state=\'open\')]\n
for other_counter in counter_date_list:\n
if other_counter.getUid()!=counter_date.getUid():\n
msg = Message(domain=\'ui\',message="Sorry, there is already a counter date opened")\n
raise ValidationFailed (msg,)\n
\n
listbox = state_change.kwargs.get(\'listbox\',None)\n
\n
# First make sure we can open a counter date only\n
# if the date defined on the document is the current date\n
counter_date = state_change[\'object\']\n
start_date = counter_date.getStartDate()\n
from DateTime import DateTime\n
now = DateTime()\n
......@@ -84,10 +92,11 @@ if now.Date() != start_date.Date():\n
msg = Message(domain=\'ui\',message="Sorry, the date is not today")\n
raise ValidationFailed (msg,)\n
\n
for line in listbox:\n
if line["choice"] == "open":\n
counter = context.restrictedTraverse("%s" %(line[\'listbox_key\'],))\n
counter.open()\n
if listbox is not None:\n
for line in listbox:\n
if line["choice"] == "open":\n
counter = context.restrictedTraverse("%s" %(line[\'listbox_key\'],))\n
counter.open()\n
</string> </value>
</item>
<item>
......@@ -143,17 +152,24 @@ for line in listbox:\n
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getattr_</string>
<string>listbox</string>
<string>_getitem_</string>
<string>counter_date</string>
<string>_getattr_</string>
<string>context</string>
<string>site_uid</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>counter_date_list</string>
<string>other_counter</string>
<string>msg</string>
<string>None</string>
<string>listbox</string>
<string>start_date</string>
<string>DateTime</string>
<string>now</string>
<string>msg</string>
<string>_getiter_</string>
<string>line</string>
<string>context</string>
<string>counter</string>
</tuple>
</value>
......
2006-12-01 Seb
* add many more checks with the counter date when we open and close it.
2006-11-30 aurel
* fix z_catalog_item_list
......
68
\ No newline at end of file
72
\ 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