Commit 01778ce9 authored by Jérome Perrin's avatar Jérome Perrin

read preference on organisations not in the removed accounting period module


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5441 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 90d57831
...@@ -72,35 +72,45 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n ...@@ -72,35 +72,45 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
closing_period = state_change.object\n closing_period = state_change.object\n
portal = closing_period.getPortalObject()\n portal = closing_period.getPortalObject()\n
N_ = portal.Base_TranslateString\n N_ = portal.Base_translateString\n
accounting_period_module = portal.accounting_period_module\n
valid_states = [\'planned\', \'confirmed\', \'delivered\']\n valid_states = [\'planned\', \'confirmed\', \'delivered\']\n
\n \n
start_date = closing_period.getStartDate()\n start_date = closing_period.getStartDate()\n
stop_date = closing_period.getStopDate()\n stop_date = closing_period.getStopDate()\n
\n \n
if start_date > stop_date : \n if start_date > stop_date :\n
raise ValidationFailed, "Start Date is After Stop Date"\n raise ValidationFailed, N_("Start Date is After Stop Date")\n
\n \n
period_list = portal.accounting_period_module\\\n period_list = closing_period.getParentValue().searchFolder(\n
.searchFolder( simulation_state = [\'planned\', \'confirmed\', \'delivered\'],\n simulation_state = valid_states,\n
sort_on = \'delivery.start_date\')\n sort_on = \'delivery.start_date\',\n
portal_type = \'Accounting Period\')\n
\n \n
for period in period_list :\n for period in period_list :\n
period = period.getObject()\n period = period.getObject()\n
portal.log("period", "id:%s start:%s stop:%s" % (period.getId(), period.getStartDate(), period.getStopDate()))\n portal.log("AccountingPeriod_CheckDates", "id:%s start:%s stop:%s" % (\n
period.getId(),\n
period.getStartDate(),\n
period.getStopDate()))\n
if period.getSimulationState() in valid_states :\n if period.getSimulationState() in valid_states :\n
if start_date <= period.getStopDate() :\n if start_date <= period.getStopDate() :\n
raise ValidationFailed, N_("%s is already in an opened accounting period") % period.Base_FormatDate(start_date)\n raise ValidationFailed, N_(\n
"${date} is already in an opened accounting period",\n
mapping = {\'date\': period.Base_FormatDate(start_date)})\n
\n
if len(period_list) > 1 :\n if len(period_list) > 1 :\n
last_period = period_list[-1].getObject()\n last_period = period_list[-1].getObject()\n
if last_period.getId() == closing_period.getId() :\n if last_period.getId() == closing_period.getId() :\n
last_period = period_list[-2].getObject() \n last_period = period_list[-2].getObject()\n
if (start_date - last_period.getStopDate()) > 1:\n if (start_date - last_period.getStopDate()) > 1:\n
raise ValidationFailed, N_("Last opened period ends on ${last_openned_date}, this period starts on ${this_period_start_date}."+\n raise ValidationFailed, N_(\n
" Accounting Periods must be consecutive.", \n "Last opened period ends on ${last_openned_date},"+\n
mapping = { \'last_openned_date\' : period.Base_FormatDate(last_period.getStopDate()),\n " this period starts on ${this_period_start_date}."+\n
\'this_period_start_date\' : period.Base_FormatDate(start_date) } )\n " Accounting Periods must be consecutive.",\n
mapping = { \'last_openned_date\' :\n
period.Base_FormatDate(last_period.getStopDate()),\n
\'this_period_start_date\' :\n
period.Base_FormatDate(start_date) } )\n
]]></string> </value> ]]></string> </value>
...@@ -111,9 +121,15 @@ if len(period_list) > 1 :\n ...@@ -111,9 +121,15 @@ if len(period_list) > 1 :\n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/hopital/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_CheckDates</string> </value> <value> <string>Script (Python):/erp5/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_CheckDates</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -150,7 +166,6 @@ if len(period_list) > 1 :\n ...@@ -150,7 +166,6 @@ if len(period_list) > 1 :\n
<string>closing_period</string> <string>closing_period</string>
<string>portal</string> <string>portal</string>
<string>N_</string> <string>N_</string>
<string>accounting_period_module</string>
<string>valid_states</string> <string>valid_states</string>
<string>start_date</string> <string>start_date</string>
<string>stop_date</string> <string>stop_date</string>
...@@ -187,4 +202,25 @@ if len(period_list) > 1 :\n ...@@ -187,4 +202,25 @@ if len(period_list) > 1 :\n
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </ZopeData>
...@@ -72,7 +72,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n ...@@ -72,7 +72,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
closing_period = state_change.object\n closing_period = state_change.object\n
portal = closing_period.getPortalObject()\n portal = closing_period.getPortalObject()\n
N_ = portal.Base_TranslateString\n N_ = portal.Base_translateString\n
accounting_module = portal.accounting_module\n accounting_module = portal.accounting_module\n
valid_states = [\'cancelled\', \'stopped\', \'delivered\']\n valid_states = [\'cancelled\', \'stopped\', \'delivered\']\n
\n \n
...@@ -80,15 +80,26 @@ start_date = closing_period.getStartDate()\n ...@@ -80,15 +80,26 @@ start_date = closing_period.getStartDate()\n
stop_date = closing_period.getStopDate()\n stop_date = closing_period.getStopDate()\n
\n \n
search_params = { \'delivery.start_date\' : \'>= %s\' % start_date,\n search_params = { \'delivery.start_date\' : \'>= %s\' % start_date,\n
\'delivery.stop_date\' : \'<= %s\' % stop_date, }\n \'delivery.stop_date\' : \'<= %s\' % stop_date, \n
transaction_list = accounting_module.searchFolder( **search_params)\n \'simulation_state\' : [\'draft\', \'planned\', \'confirmed\', ] }\n
transaction_list = accounting_module.searchFolder( **search_params )\n
\n \n
for transaction in transaction_list : \n organisation_section = closing_period.getParentValue()\n
for transaction in transaction_list :\n
transaction = transaction.getObject()\n transaction = transaction.getObject()\n
# we only take into account transaction that are related to this\n
# organisation. \n
# FIXME: this approach is not compatible with categories as section.\n
# FIXME: and not compatible with 100 000 transactions.\n
if transaction.getSourceSectionUid() == organisation_section.getUid() or \\\n
transaction.getDestinationSectionUid() == organisation_section.getUid() :\n
if transaction.getSimulationState() not in valid_states :\n if transaction.getSimulationState() not in valid_states :\n
raise ValidationFailed, N_("Transaction ${transaction_path} is in invalid state (${transaction_translated_state})",\n raise ValidationFailed, N_(\n
"Transaction ${transaction_path} is in invalid "+\n
"state (${transaction_translated_state})",\n
mapping = { \'transaction_path\' : transaction.getPath(),\n mapping = { \'transaction_path\' : transaction.getPath(),\n
\'transaction_translated_state\' : unicode(transaction.getTranslatedSimulationStateTitle(), \'utf8\')})\n \'transaction_translated_state\' :\n
unicode(transaction.getTranslatedSimulationStateTitle(), \'utf8\')})\n
]]></string> </value> ]]></string> </value>
...@@ -99,9 +110,15 @@ for transaction in transaction_list : \n ...@@ -99,9 +110,15 @@ for transaction in transaction_list : \n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/hopital/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_CheckTransactionsState</string> </value> <value> <string>Script (Python):/erp5/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_CheckTransactionsState</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -145,6 +162,7 @@ for transaction in transaction_list : \n ...@@ -145,6 +162,7 @@ for transaction in transaction_list : \n
<string>search_params</string> <string>search_params</string>
<string>_apply_</string> <string>_apply_</string>
<string>transaction_list</string> <string>transaction_list</string>
<string>organisation_section</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>transaction</string> <string>transaction</string>
<string>unicode</string> <string>unicode</string>
...@@ -175,4 +193,25 @@ for transaction in transaction_list : \n ...@@ -175,4 +193,25 @@ for transaction in transaction_list : \n
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </ZopeData>
...@@ -72,7 +72,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n ...@@ -72,7 +72,7 @@ from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n \n
closing_period = state_change.object\n closing_period = state_change.object\n
portal = closing_period.getPortalObject()\n portal = closing_period.getPortalObject()\n
N_ = portal.Base_TranslateString\n N_ = portal.Base_translateString\n
accounting_module = portal.accounting_module\n accounting_module = portal.accounting_module\n
valid_states = [\'cancelled\', \'stopped\', \'delivered\']\n valid_states = [\'cancelled\', \'stopped\', \'delivered\']\n
\n \n
...@@ -83,20 +83,39 @@ start_date = closing_period.getStartDate()\n ...@@ -83,20 +83,39 @@ start_date = closing_period.getStartDate()\n
stop_date = closing_period.getStopDate()\n stop_date = closing_period.getStopDate()\n
\n \n
search_params = { \'delivery.start_date\' : \'>= %s\' % start_date,\n search_params = { \'delivery.start_date\' : \'>= %s\' % start_date,\n
\'delivery.stop_date\' : \'<= %s\' % stop_date, }\n \'delivery.stop_date\' : \'<= %s\' % stop_date,\n
transaction_list = accounting_module.searchFolder( **search_params)\n \'simulation_state\' : \'stopped\' }\n
transaction_list = accounting_module.searchFolder( **search_params )\n
\n \n
for transaction in transaction_list : \n #raise \'\\n\'.join([transaction.path for transaction in transaction_list])\n
\n
section_uid = closing_period.getParentValue().getUid()\n
for transaction in transaction_list :\n
transaction = transaction.getObject()\n transaction = transaction.getObject()\n
if transaction.getSimulationState() == \'stopped\' : \n # FIXME: this approach is not compatible with categories as sections.\n
portal.portal_workflow.doActionFor( transaction, \'deliver_action\', \n if transaction.getSourceSectionUid() == section_uid or \\\n
transaction.getDestinationSectionUid() == section_uid :\n
if transaction.getSimulationState() == \'stopped\' :\n
# this action is made in the \'before_script\', even if this is \n
# related to the workflow logic, because we want the user to be\n
# notified of failures\n
\n
# FIXME: this way is not compatible with 100.000 transactions and should\n
# probably be activated.\n
portal.portal_workflow.doActionFor( transaction, \'deliver_action\',\n
wf_id="accounting_workflow",\n wf_id="accounting_workflow",\n
skip_period_validation = 1)\n comment=N_("Closing period ${period_title}",\n
if transaction.getSimulationState() != \'delivered\' : \n mapping={\'period_title\': closing_period.getTitle()}),\n
raise ValidationFailed, N_("Unable to change state for ${transaction_path}, check this transaction history",\n skip_period_validation = 1 )\n
if transaction.getSimulationState() != \'delivered\' :\n
# FIXME: this is not transactional\n
raise ValidationFailed, N_(\n
"Unable to change state for ${transaction_path}, "+\n
"check this transaction history",\n
mapping = {\'transaction_path\' : transaction.getPath()})\n mapping = {\'transaction_path\' : transaction.getPath()})\n
else :\n else :\n
transaction.log(\'AccountingPeriod_DeliverTransaction\', \'deliver %s\' % transaction.getPath())\n transaction.log(\'AccountingPeriod_DeliverTransaction\',\n
\'deliver %s\' % transaction.getPath())\n
]]></string> </value> ]]></string> </value>
...@@ -107,9 +126,15 @@ for transaction in transaction_list : \n ...@@ -107,9 +126,15 @@ for transaction in transaction_list : \n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/hopital/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_DeliverTransactions</string> </value> <value> <string>Script (Python):/erp5/portal_workflow/accounting_period_workflow/scripts/AccountingPeriod_DeliverTransactions</string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
...@@ -154,6 +179,7 @@ for transaction in transaction_list : \n ...@@ -154,6 +179,7 @@ for transaction in transaction_list : \n
<string>search_params</string> <string>search_params</string>
<string>_apply_</string> <string>_apply_</string>
<string>transaction_list</string> <string>transaction_list</string>
<string>section_uid</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>transaction</string> <string>transaction</string>
</tuple> </tuple>
...@@ -183,4 +209,25 @@ for transaction in transaction_list : \n ...@@ -183,4 +209,25 @@ for transaction in transaction_list : \n
</dictionary> </dictionary>
</pickle> </pickle>
</record> </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> </ZopeData>
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