Commit 27d44fa4 authored by Jérome Perrin's avatar Jérome Perrin

Accounting: new alarms to check grouping reference

parent d19753d0
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkAccountingGroupingReferenceIsValid</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple>
<string>problem</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>configuration_form_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Check that accounting transaction lines grouped together have a 0 balance</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>check_grouping_reference_validity</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1325379660.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_week_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_week_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Check Accounting Grouping Reference Validity</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkPayableAndReceivableAccountGrouped</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple>
<string>problem</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>configuration_form_id</string> </key>
<value> <string>Alarm_viewPayableAndReceivableAccountGroupedConfiguration</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Check that all transactions on payable and receivable accounts for which balance is 0 are grouped together</string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>check_payable_receivable_account_grouped</string> </value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1325379660.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_week_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_week_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Check Payable and Receivable Accounts Grouped</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>from Products.ZSQLCatalog.SQLCatalog import Query\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
portal = context.getPortalObject()\n
\n
# fixit could remove the grouping reference when lines are grouped together but do not match\n
assert not fixit, NotImplemented\n
\n
# a mapping of currency precision for each section\n
precision_by_section_uid = {}\n
\n
# Check grouping reference for both source and destination.\n
def check(node_uid, section_uid, mirror_section_uid):\n
precision = precision_by_section_uid[section_uid]\n
if mirror_section_uid is None:\n
mirror_section_uid = Query(mirror_section_uid=None)\n
line_list = portal.portal_simulation.getMovementHistoryList(\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
grouping_reference=context.getGroupingReference(),\n
node_uid=node_uid,\n
section_uid=section_uid,\n
mirror_section_uid=mirror_section_uid)\n
if not line_list:\n
return\n
total = round(sum([(l.total_price or 0) for l in line_list]), precision)\n
if total != 0:\n
# XXX if n transactions that do not match are grouped together, the same\n
# problem will be reported n times.\n
portal.restrictedTraverse(active_process).postResult(\n
ActiveResult(summary=script.getId(),\n
detail=\'%s has wrong grouping (%s)\' % (context.getRelativeUrl(), total),\n
result=\'\',\n
severity=100))\n
\n
# XXX we could check this as well\n
"""\n
max_date = max([l.date for l in line_list])\n
for line in line_list:\n
assert line.getGroupingDate() in (max_date, None)\n
"""\n
\n
node_uid = context.getSourceUid(portal_type=\'Account\')\n
section_uid = None\n
section = context.getSourceSectionValue()\n
if section is not None:\n
section = section.Organisation_getMappingRelatedOrganisation()\n
section_uid = section.getUid()\n
precision_by_section_uid[section_uid] = context.getQuantityPrecisionFromResource(\n
section.getPriceCurrency())\n
\n
mirror_section_uid = context.getDestinationSectionUid()\n
\n
if node_uid and section_uid:\n
check(node_uid=node_uid, section_uid=section_uid, mirror_section_uid=mirror_section_uid)\n
\n
node_uid = context.getDestinationUid()\n
section_uid = None\n
section = context.getDestinationSectionValue()\n
if section is not None:\n
section = section.Organisation_getMappingRelatedOrganisation()\n
section_uid = section.getUid()\n
precision_by_section_uid[section_uid] = context.getQuantityPrecisionFromResource(\n
section.getPriceCurrency())\n
mirror_section_uid = context.getSourceSectionUid()\n
\n
if node_uid and section_uid:\n
check(node_uid=node_uid, section_uid=section_uid, mirror_section_uid=mirror_section_uid)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_process, fixit=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionLine_checkGroupingReferenceIsValid</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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 all transactions grouped together have a 0 balance.\n
\n
In other words, check that all transactions grouped together really match.\n
"""\n
\n
active_process = context.newActiveProcess().getRelativeUrl()\n
\n
assert not fixit, NotImplemented\n
\n
context.getPortalObject().portal_catalog.searchAndActivate(\n
method_id=\'AccountingTransactionLine_checkGroupingReferenceIsValid\',\n
method_kw=dict(fixit=fixit, active_process=active_process),\n
activate_kw=dict(tag=tag, priority=5),\n
portal_type=context.getPortalAccountingMovementTypeList(),\n
grouping_reference=\'%\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkAccountingGroupingReferenceIsValid</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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[
"""Check that all transcations on payable and receivable accounts\n
that a 0 balance are grouped.\n
\n
In other words, check that all transactions that can be grouped are grouped.\n
"""\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
active_process = context.newActiveProcess()\n
\n
portal = context.getPortalObject()\n
\n
# Section category & strict have to be configured on alarm\n
section_category = context.getProperty(\'section_category\')\n
assert section_category, "alarm not configured"\n
section_category_strict = context.getProperty(\'section_category_strict\')\n
\n
section_uid_list = portal.Base_getSectionUidListForSectionCategory(section_category, section_category_strict)\n
assert section_uid_list\n
\n
precision = portal.Base_getCurrencyForSectionCategory(section_category, section_category_strict) or 3\n
\n
\n
search_params = dict(\n
node_category=(\'account_type/asset/receivable\',\n
\'account_type/liability/payable\'),\n
section_uid=section_uid_list,\n
simulation_state=(\'stopped\', \'delivered\'),\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
group_by_mirror_section=True,\n
group_by_node=True,\n
grouping_reference=None,\n
)\n
\n
\n
for brain in portal.portal_simulation.getInventoryList(**search_params):\n
if round(brain.total_price, precision) == 0:\n
print \'%s has a 0 balance but some not grouped transactions.\' % brain.mirror_section_relative_url\n
if fixit:\n
tr = brain.getObject().getParentValue()\n
grouped_line_list = tr.AccountingTransaction_guessGroupedLines()\n
if not grouped_line_list:\n
# Group whatever can be grouped. XXX maybe we want to make this optional.\n
grouped_line_list = tr.AccountingTransaction_guessGroupedLines(accounting_transaction_line_uid_list=[\n
line.uid for line in portal.portal_simulation.getMovementHistoryList(\n
node_uid=brain.node_uid,\n
mirror_section_uid=brain.mirror_section_uid,\n
section_uid=section_uid_list,\n
simulation_state=(\'stopped\', \'delivered\'),\n
portal_type=portal.getPortalAccountingMovementTypeList(),\n
grouping_reference=None,)])\n
if grouped_line_list:\n
print \'FIXED\', grouped_line_list\n
else:\n
print \'NOT FIXED\'\n
\n
active_result = ActiveResult(\n
summary=context.getTitle(),\n
severity=str(printed) and 100 or 0,\n
detail=printed,)\n
\n
active_process.postResult(active_result)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkPayableAndReceivableAccountGrouped</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
</pickle>
<pickle>
<dictionary>
<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>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</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>
<string>right</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_section_category</string>
<string>my_section_category_strict</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_viewPayableAndReceivableAccountGroupedConfiguration</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>rid</string> </key>
<value> <int>-1722436585</int> </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>Payable and Receivable Accounts Grouped Check</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>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>required</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_section_category</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_section_category</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_section_category_strict</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>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_section_category_strict</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>AccountModule_viewDialogFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1570 1571
\ No newline at end of file
portal_alarms/check_grouping_reference_validity
portal_alarms/check_payable_receivable_account_grouped
portal_categories/account_type/** portal_categories/account_type/**
portal_categories/financial_section/* portal_categories/financial_section/*
\ 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