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

Refactor the use of Accounting Period. Closing a period will new create a balance transaction.

Balance Transaction also changed, it now uses destination by default, because BalanceTransaction will in the near future be catalogued as inventories.
Accounting Period workflow was also simplified a lot.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15786 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3e419fe
......@@ -81,7 +81,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/AccountingTransactionLine_view</string> </value>
<value> <string>string:${object_url}/AccountingTransactionLine_viewDestination</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -263,7 +263,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Comments</string> </value>
<value> <string>Description</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......
<?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>Workflow_statusModify</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_comment</string>
<string>my_workflow_action</string>
<string>your_profit_and_loss_account</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingPeriod_viewDeliverWorkflowActionDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewWorkflowActionDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view_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>Validate Workflow Action</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</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>
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>simulation_state</string> </value>
<value> <string>my_workflow_action</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -217,23 +217,7 @@
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>editable_expression</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable_permission</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable_role</string> </key>
<value>
<list/>
</value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
......@@ -249,27 +233,19 @@
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>not_viewable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>read_only</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>State</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
......@@ -279,22 +255,6 @@
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>viewable_expression</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>viewable_permission</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>viewable_role</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
......@@ -319,7 +279,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.portal_workflow.getInfoFor(here, \'simulation_state\')</string> </value>
<value> <string>request/workflow_action | nothing</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -91,12 +91,12 @@
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_source_payment</string>
<string>listbox_resource</string>
<string>listbox_source</string>
<string>listbox_source_debit</string>
<string>listbox_source_credit</string>
<string>listbox_destination_section_title</string>
<string>listbox_source_section_title</string>
<string>listbox_destination</string>
<string>listbox_destination_credit</string>
<string>listbox_destination_debit</string>
<string>listbox_destination_payment</string>
</list>
</value>
</item>
......@@ -104,8 +104,10 @@
<key> <string>left</string> </key>
<value>
<list>
<string>my_source_section</string>
<string>my_destination_section</string>
<string>my_destination_reference</string>
<string>my_title</string>
<string>my_resource</string>
</list>
</value>
</item>
......@@ -115,7 +117,8 @@
<list>
<string>my_start_date</string>
<string>my_description</string>
<string>simulation_state</string>
<string>my_translated_portal_type</string>
<string>my_translated_simulation_state_title</string>
</list>
</value>
</item>
......
......@@ -338,15 +338,15 @@
<string>ID</string>
</tuple>
<tuple>
<string>source</string>
<string>destination</string>
<string>Account</string>
</tuple>
<tuple>
<string>source_payment</string>
<string>destination_payment</string>
<string>Bank Account</string>
</tuple>
<tuple>
<string>getDestinationSectionTitle</string>
<string>source_section_title</string>
<string>Third Party</string>
</tuple>
<tuple>
......@@ -354,11 +354,11 @@
<string>Currency</string>
</tuple>
<tuple>
<string>source_debit</string>
<string>destination_debit</string>
<string>Debit</string>
</tuple>
<tuple>
<string>source_credit</string>
<string>destination_credit</string>
<string>Credit</string>
</tuple>
</list>
......@@ -405,11 +405,11 @@
<value>
<list>
<tuple>
<string>source</string>
<string>destination</string>
<string>Account</string>
</tuple>
<tuple>
<string>source_payment</string>
<string>destination_payment</string>
<string>Bank Account</string>
</tuple>
<tuple>
......@@ -417,11 +417,11 @@
<string>Currency</string>
</tuple>
<tuple>
<string>source_debit</string>
<string>destination_debit</string>
<string>Debit</string>
</tuple>
<tuple>
<string>source_credit</string>
<string>destination_credit</string>
<string>Credit</string>
</tuple>
</list>
......@@ -454,12 +454,7 @@
<item>
<key> <string>global_attributes</string> </key>
<value>
<list>
<tuple>
<string>source_section</string>
<string>source_section</string>
</tuple>
</list>
<list/>
</value>
</item>
<item>
......@@ -468,7 +463,7 @@
</item>
<item>
<key> <string>lines</string> </key>
<value> <int>20</int> </value>
<value> <int>30</int> </value>
</item>
<item>
<key> <string>list_action</string> </key>
......@@ -552,12 +547,23 @@
<item>
<key> <string>stat_columns</string> </key>
<value>
<list/>
<list>
<tuple>
<string>destination_debit</string>
<string>AccountingTransactionLine_statSourceCredit</string>
</tuple>
<tuple>
<string>destination_credit</string>
<string>AccountingTransactionLine_statSourceDebit</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>stat_method</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -610,4 +616,23 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.MethodField</string>
<string>Method</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>AccountingTransaction_getInvoiceTransactionLineList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_source</string> </value>
<value> <string>listbox_destination</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -251,7 +251,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_source</string> </value>
<value> <string>Destination</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_source_debit</string> </value>
<value> <string>listbox_destination_credit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_source_debit</string> </value>
<value> <string>Credit</string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_source_credit</string> </value>
<value> <string>listbox_destination_debit</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_source_credit</string> </value>
<value> <string>Debit</string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_source_payment</string> </value>
<value> <string>listbox_destination_payment</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -251,7 +251,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_source_payment</string> </value>
<value> <string>Payment</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......@@ -281,7 +281,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.getObject().AccountingTransaction_getSourcePaymentItemList()</string> </value>
<value> <string>python: cell.getObject().AccountingTransaction_getDestinationPaymentItemList()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -251,7 +251,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_resource</string> </value>
<value> <string>Currency</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_destination_section_title</string> </value>
<value> <string>listbox_source_section_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>listbox_destination_section_title</string> </value>
<value> <string>Third Party</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
......
......@@ -14,7 +14,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_source_section</string> </value>
<value> <string>my_destination_section</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -71,48 +71,43 @@
<value> <string encoding="cdata"><![CDATA[
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
closing_period = state_change[\'object\']\n
portal = closing_period.getPortalObject()\n
N_ = portal.Base_translateString\n
valid_states = [\'planned\', \'confirmed\', \'delivered\']\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
valid_state_list = [\'started\', \'stopped\', \'delivered\']\n
\n
start_date = closing_period.getStartDate()\n
stop_date = closing_period.getStopDate()\n
\n
if start_date > stop_date :\n
if start_date > stop_date:\n
raise ValidationFailed, N_("Start Date is After Stop Date")\n
\n
period_list = closing_period.getParentValue().searchFolder(\n
simulation_state = valid_states,\n
sort_on = [(\'delivery.start_date\', \'asc\')],\n
portal_type = \'Accounting Period\')\n
simulation_state=valid_state_list,\n
sort_on=[(\'delivery.start_date\', \'asc\')],\n
portal_type=\'Accounting Period\')\n
\n
for period in period_list :\n
for period in period_list:\n
period = period.getObject()\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 start_date <= period.getStopDate() :\n
if period.getSimulationState() in valid_state_list:\n
if start_date <= period.getStopDate():\n
raise ValidationFailed, N_(\n
"${date} is already in an opened accounting period",\n
mapping = {\'date\': period.Base_FormatDate(start_date)})\n
mapping={\'date\': start_date})\n
\n
if len(period_list) > 1 :\n
if len(period_list) > 1:\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
if (start_date - last_period.getStopDate()) > 1:\n
raise ValidationFailed, N_(\n
raise ValidationFailed, N_(\n
"Last opened period ends on ${last_openned_date},"+\n
" this period starts on ${this_period_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
mapping = { \'last_openned_date\': last_period.getStopDate(),\n
\'this_period_start_date\': start_date } )\n
]]></string> </value>
......@@ -160,12 +155,14 @@ if len(period_list) > 1 :\n
<string>state_change</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>_getitem_</string>
<string>closing_period</string>
<string>_getattr_</string>
<string>portal</string>
<string>N_</string>
<string>valid_states</string>
<string>valid_state_list</string>
<string>start_date</string>
<string>stop_date</string>
<string>period_list</string>
......@@ -189,7 +186,7 @@ if len(period_list) > 1 :\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingPeriod_CheckDates</string> </value>
<value> <string>checkDates</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -68,43 +68,41 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n
\n
closing_period = state_change[\'object\']\n
portal = closing_period.getPortalObject()\n
N_ = portal.Base_translateString\n
accounting_module = portal.accounting_module\n
valid_states = [\'cancelled\', \'stopped\']\n
period = state_change[\'object\']\n
portal = period.getPortalObject()\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
\n
start_date = closing_period.getStartDate()\n
stop_date = closing_period.getStopDate()\n
\n
search_params = { \'delivery.start_date\' : \'>= %s\' % start_date,\n
\'delivery.stop_date\' : \'<= %s\' % stop_date,\n
\'simulation_state\' : \'stopped\' }\n
transaction_list = accounting_module.searchFolder( **search_params )\n
valid_simulation_state_list = [\'cancelled\', \'delivered\', \'delivered\']\n
all_state_list = [x[1] for x in\n
portal.Base_getTranslatedWorkflowStateItemList(wf_id=\'accounting_workflow\')]\n
invalid_simulation_state_list = [state for state in all_state_list\n
if state not in valid_simulation_state_list]\n
\n
comment=N_("Closing period ${period_title}",\n
mapping={\'period_title\': unicode(closing_period.getTitle(), \'utf8\')})\n
section_uid = period.getParentUid()\n
search_params = {\n
\'delivery.start_date\': dict(query=period.getStartDate(),\n
range=\'min\'),\n
\'delivery.stop_date\': dict(query=period.getStopDate(),\n
range=\'ngt\'),\n
\'simulation_state\': invalid_simulation_state_list,\n
\'portal_type\': portal.getPortalAccountingTransactionTypeList(),\n
\'query\': ComplexQuery(Query(source_section_uid=section_uid),\n
Query(destination_section_uid=section_uid),\n
operator=\'OR\')\n
}\n
\n
section_uid = closing_period.getParentValue().getUid()\n
for transaction in transaction_list :\n
transaction = transaction.getObject()\n
# FIXME: this approach is not compatible with categories as sections.\n
if transaction.getSourceSectionUid() == section_uid or \\\n
transaction.getDestinationSectionUid() == section_uid :\n
transaction.activate().AccountingTransaction_closeByAccountingPeriod(\n
comment = comment, closing_period_path = closing_period.getPath() )\n
\n
# if a transaction validation fails, it puts the Closing Period object back to confirmed state\n
closing_period.activate( \n
after_method_id = [\'AccountingTransaction_closeByAccountingPeriod\']\n
).deliver()\n
]]></string> </value>
transaction_list = portal.portal_catalog.searchResults(**search_params)\n
if transaction_list:\n
raise ValidationFailed, N_(\n
"All Accounting Transactions for this organisation during the period have"\n
" to be closed first")\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -149,23 +147,29 @@ closing_period.activate( \n
<string>state_change</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string>
<string>Message</string>
<string>Products.ZSQLCatalog.SQLCatalog</string>
<string>Query</string>
<string>ComplexQuery</string>
<string>_getitem_</string>
<string>closing_period</string>
<string>period</string>
<string>_getattr_</string>
<string>portal</string>
<string>N_</string>
<string>accounting_module</string>
<string>valid_states</string>
<string>start_date</string>
<string>stop_date</string>
<string>valid_simulation_state_list</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>all_state_list</string>
<string>state</string>
<string>invalid_simulation_state_list</string>
<string>section_uid</string>
<string>dict</string>
<string>search_params</string>
<string>_apply_</string>
<string>transaction_list</string>
<string>unicode</string>
<string>comment</string>
<string>section_uid</string>
<string>_getiter_</string>
<string>transaction</string>
</tuple>
</value>
</item>
......@@ -182,7 +186,7 @@ closing_period.activate( \n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingPeriod_DeliverTransactions</string> </value>
<value> <string>checkTransactionsState</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -68,25 +68,17 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""Deliver the transaction and \'notify\' the closing_period on failure."""\n
<value> <string>"""Create a balance transaction\n
"""\n
from DateTime import DateTime\n
\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
N_ = context.Base_translateString\n
accounting_period = sci[\'object\']\n
portal = accounting_period.getPortalObject()\n
profit_and_loss_account = portal.portal_workflow.getInfoFor(\n
accounting_period, \'profit_and_loss_account\')\n
\n
try : \n
context.portal_workflow.doActionFor( context,\n
\'deliver_action\', \n
skip_period_validation = 1,\n
comment=comment )\n
except ValidationFailed, message :\n
closing_period = context.getPortalObject().restrictedTraverse(closing_period_path)\n
if closing_period.getSimulationState() != \'confirmed\' :\n
closing_period.failClosing()\n
closing_period.portal_workflow.doActionFor( closing_period,\n
\'edit_action\', \n
comment=N_(\'unable to deliver ${transaction_path} : ${error_message}\',\n
mapping={\'transaction_path\':context.getPath(),\n
\'error_message\': unicode(str(message), \'utf8\') } ))\n
accounting_period.AccountingPeriod_createBalanceTransaction(\n
profit_and_loss_account=profit_and_loss_account)\n
</string> </value>
</item>
<item>
......@@ -101,9 +93,15 @@ except ValidationFailed, message :\n
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>comment, closing_period_path, **kw</string> </value>
<value> <string>sci</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -123,24 +121,19 @@ except ValidationFailed, message :\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>comment</string>
<string>closing_period_path</string>
<string>kw</string>
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>sci</string>
<string>DateTime</string>
<string>_getitem_</string>
<string>accounting_period</string>
<string>_getattr_</string>
<string>context</string>
<string>N_</string>
<string>message</string>
<string>closing_period</string>
<string>unicode</string>
<string>str</string>
<string>portal</string>
<string>profit_and_loss_account</string>
</tuple>
</value>
</item>
......@@ -157,7 +150,7 @@ except ValidationFailed, message :\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransaction_closeByAccountingPeriod</string> </value>
<value> <string>createBalanceTransaction</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>The Accounting Period is cancelled, a new one should be defined.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -42,6 +42,12 @@
<tuple/>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......@@ -77,9 +83,7 @@
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.States</string>
<string>StateDefinition</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Closing is the state used when the activity of delivering transaction happens.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>closing</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Closing</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>deliver</string>
<string>fail_closing</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -20,7 +20,9 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>The Accounting Period is closed.\r\n
\r\n
It is no longer possible to add accounting transactions in this period. A balance transaction has been created.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>The Accounting Period is not openned yet.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -42,11 +42,17 @@
<tuple>
<string>cancel</string>
<string>cancel_action</string>
<string>plan</string>
<string>plan_action</string>
<string>start</string>
<string>start_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
......
......@@ -18,13 +18,21 @@
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>The Accounting Period is openned.\r\n
\r\n
It is therefore possible to post accounting accounting transactions with dates during this period.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>planned</string> </value>
<value> <string>started</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
......@@ -34,14 +42,14 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Open</string> </value>
<value> <string>Openned</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>confirm</string>
<string>confirm_action</string>
<string>stop</string>
<string>stop_action</string>
</tuple>
</value>
</item>
......@@ -78,7 +86,6 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
</tuple>
</value>
......@@ -97,9 +104,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
</tuple>
</value>
</item>
......
......@@ -18,13 +18,20 @@
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>The Accounting Period is temporary closed, but can be openned back.\r\n
In this state it is not possible to post transactions during this period.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>confirmed</string> </value>
<value> <string>stopped</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
......@@ -34,16 +41,16 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Temporally Closed Accounting Period</string> </value>
<value> <string>Temporary Closed</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>close</string>
<string>close_action</string>
<string>plan</string>
<string>reopen_action</string>
<string>deliver</string>
<string>deliver_action</string>
<string>restart_action</string>
<string>start</string>
</tuple>
</value>
</item>
......@@ -80,7 +87,6 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
</tuple>
</value>
......@@ -99,9 +105,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
</tuple>
</value>
</item>
......
......@@ -84,7 +84,6 @@
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.Transitions</string>
<string>TransitionDefinition</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>AccountingPeriod_DeliverTransactions</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>close</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>closing</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -32,7 +32,7 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
<value> <string>createBalanceTransaction</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -18,6 +18,12 @@
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
......@@ -28,25 +34,25 @@
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=close_action</string> </value>
<value> <string>%(content_url)s/AccountingPeriod_viewDeliverWorkflowActionDialog?workflow_action=deliver_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>close</string> </value>
<value> <string>deliver</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Closing accounting period is made in an activity. if it fails, the Accounting Period object remains in confirmed state, otherwise it goes to delivered state, depending on the result of passing workflow transitions.</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>close_action</string> </value>
<value> <string>deliver_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
......@@ -54,7 +60,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
<value> <string>checkTransactionsState</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -64,6 +70,12 @@
<key> <string>trigger_type</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>var_exprs</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
......@@ -71,8 +83,8 @@
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.Guard</string>
<string>Guard</string>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
......@@ -80,15 +92,38 @@
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<key> <string>_container</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
<dictionary>
<item>
<key> <string>profit_and_loss_account</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.Expression</string>
<string>Expression</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>kwargs/profit_and_loss_account | nothing</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.Transitions</string>
<string>TransitionDefinition</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>fail_closing</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>confirmed</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -28,11 +28,11 @@
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=reopen_action</string> </value>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=restart_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>plan</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -46,11 +46,11 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>reopen_action</string> </value>
<value> <string>restart_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
<value> <string>started</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
......@@ -84,7 +84,6 @@
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
......
......@@ -46,11 +46,11 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>confirm</string> </value>
<value> <string>start</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>confirmed</string> </value>
<value> <string>started</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
......
......@@ -28,11 +28,11 @@
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=plan_action</string> </value>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=start_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>plan</string> </value>
<value> <string>start</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>plan_action</string> </value>
<value> <string>start_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>AccountingPeriod_CheckDates</string> </value>
<value> <string>checkDates</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -84,7 +84,6 @@
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
......
......@@ -46,11 +46,11 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>plan</string> </value>
<value> <string>stop</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>planned</string> </value>
<value> <string>stopped</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
......
......@@ -24,15 +24,15 @@
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Temporally Close Accounting Period</string> </value>
<value> <string>Temporary Close Accounting Period</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=confirm_action</string> </value>
<value> <string>%(content_url)s/Base_viewWorkflowActionDialog?workflow_action=stop_action</string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>confirm</string> </value>
<value> <string>stop</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -46,7 +46,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>confirm_action</string> </value>
<value> <string>stop_action</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>AccountingPeriod_CheckTransactionsState</string> </value>
<value> <string>checkTransactionsState</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -84,7 +84,6 @@
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
......
......@@ -18,15 +18,21 @@
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_expr</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<none/>
</value>
</item>
<item>
<key> <string>default_value</string> </key>
<value> <string>Associate</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -38,11 +44,11 @@
</item>
<item>
<key> <string>for_status</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>zz</string> </value>
<value> <string>profit_and_loss_account</string> </value>
</item>
<item>
<key> <string>info_guard</string> </key>
......@@ -52,26 +58,7 @@
</item>
<item>
<key> <string>update_always</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.CMFCore.Expression</string>
<string>Expression</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:[\'Order Assignee\', \'Invoice Assignee\']</string> </value>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
......
......@@ -79,7 +79,7 @@ from Products.ERP5Type.Message import Message\n
transaction = state_change[\'object\']\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
\n
# do we have to check transaction is in openned periods ?\n
# do we have to check transaction is in openned periods ? \n
skip_period_validation = state_change[\'kwargs\'].get(\n
\'skip_period_validation\', 0)\n
transition = state_change[\'transition\']\n
......@@ -94,36 +94,34 @@ check_destination = (transaction.getPortalType() in\n
source_section = transaction.getSourceSectionValue(\n
portal_type=[\'Organisation\', \'Person\'])\n
if source_section is None:\n
raise ValidationFailed(\'Source Section is not Defined.\')\n
raise ValidationFailed(N_(\'Source Section is not Defined.\'))\n
\n
destination_section = transaction.getDestinationSectionValue(\n
portal_type=[\'Organisation\', \'Person\'])\n
# if it\'s not an invoice, then we can validate without destination\n
if destination_section is None and check_destination :\n
raise ValidationFailed(\'Destination Section is not Defined.\')\n
raise ValidationFailed(N_(\'Destination Section is not Defined.\'))\n
\n
currency = transaction.getResource(portal_type = \'Currency\')\n
if not currency :\n
raise ValidationFailed(\'Currency is not Defined.\')\n
raise ValidationFailed(N_(\'Currency is not Defined.\'))\n
\n
# XXX manually default start date to stop date\n
if not transaction.getStartDate() and transaction.getStopDate():\n
transaction.setStartDate(transaction.getStopDate())\n
\n
if not transaction.getStartDate() :\n
raise ValidationFailed(\'Date is not Defined\')\n
raise ValidationFailed(N_(\'Date is not Defined\'))\n
else:\n
if not skip_period_validation :\n
valid_date = False\n
# check the date is in an opened period\n
transaction_date = DateTime( transaction.getStartDate().year(),\n
transaction.getStartDate().month(),\n
transaction.getStartDate().day(),\n
# we don\'t care about hour:minutes\n
)\n
transaction_date = transaction.getStartDate().earliestTime()\n
\n
openned_accounting_period_list = source_section.searchFolder(\n
portal_type = "Accounting Period",\n
simulation_state = "planned")\n
portal_type="Accounting Period",\n
# planned is for b/w compatibility\n
simulation_state=("planned", \'started\'))\n
if len(openned_accounting_period_list) == 0 :\n
# if the entity doesn\'t have any accounting period, we can\n
# consider that they do not want to use accounting periods or\n
......@@ -134,19 +132,15 @@ else:\n
if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
valid_date = True\n
if not valid_date :\n
raise ValidationFailed("Date is not in an openned Accounting Period "\n
"for source section")\n
raise ValidationFailed(N_("Date is not in an opened Accounting Period "\n
"for source section"))\n
# do the same for destination section \n
if check_destination :\n
valid_date = False\n
transaction_date = DateTime( transaction.getStopDate().year(),\n
transaction.getStopDate().month(),\n
transaction.getStopDate().day(),\n
# we don\'t care about hour:minutes\n
)\n
transaction_date = transaction.getStopDate().earliestTime()\n
openned_accounting_period_list = destination_section.searchFolder(\n
portal_type = "Accounting Period",\n
simulation_state = "planned")\n
simulation_state = (\'planned\', \'started\'))\n
if len(openned_accounting_period_list) == 0:\n
valid_date = True\n
for apd in openned_accounting_period_list:\n
......@@ -154,8 +148,8 @@ else:\n
if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
valid_date = True\n
if not valid_date :\n
raise ValidationFailed("Date is not in an openned Accounting Period "\n
"for destination section")\n
raise ValidationFailed(N_("Date is not in an opened Accounting Period "\n
"for destination section"))\n
]]></string> </value>
......@@ -236,7 +230,6 @@ else:\n
<string>currency</string>
<string>False</string>
<string>valid_date</string>
<string>DateTime</string>
<string>transaction_date</string>
<string>openned_accounting_period_list</string>
<string>len</string>
......
380
\ No newline at end of file
386
\ 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