Commit 6995e47e authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Rafael Monnerat

slapos_subscription_request: add audit constraint to Subscription Request

parent 8f4e02e7
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_form_id</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>catalog_query_string</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>module_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>incremental_check</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>int</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_activateUpdateValidationStateFromConsistencyResult</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>catalog_query_string</string> </key>
<value> <string>validation_state:!=deleted</string> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>configuration_form_id</string> </key>
<value> <string>Alarm_viewConsistencyCheckConfiguration</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_update_subscription_request_consistency_state</string> </value>
</item>
<item>
<key> <string>incremental_check</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>module_list</string> </key>
<value>
<tuple>
<string>subscription_request_module</string>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>3</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>25</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>1</int> </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_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1230768000.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>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>report_method_id</string> </key>
<value> <string>Alarm_viewConsistencyCheckReport</string> </value>
</item>
<item>
<key> <string>solve_method_id</string> </key>
<value> <string>Alarm_activateFixConsistency</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Subscription Request Update Validation State From Consistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<item>Person</item> <item>Person</item>
<item>Price</item> <item>Price</item>
<item>Reference</item> <item>Reference</item>
<item>SlaposSubscriptionRequestAuditConstraint</item>
<item>SoftwareInstance</item> <item>SoftwareInstance</item>
<item>Task</item> <item>Task</item>
<item>TextDocument</item> <item>TextDocument</item>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</chain> </chain>
<chain> <chain>
<type>Subscription Request</type> <type>Subscription Request</type>
<workflow>edit_workflow, subscription_request_workflow</workflow> <workflow>edit_workflow, subscription_request_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Trial Condition</type> <type>Trial Condition</type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SlaposSubscriptionRequestAuditConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/audit</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequestCheckRelatedAccounting_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>SubscriptionRequest_checkRelatedAccounting</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>all_columns</string>
<string>columns</string> <string>columns</string>
<string>selection_name</string> <string>selection_name</string>
<string>title</string> <string>title</string>
...@@ -73,6 +74,29 @@ ...@@ -73,6 +74,29 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>all_columns</string> </key>
<value>
<list>
<tuple>
<string>creation_date</string>
<string>Creation Date</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>Modification Date</string>
</tuple>
<tuple>
<string>owner_title</string>
<string>Owner</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>Consistency State</string>
</tuple>
</list>
</value>
</item>
<item> <item>
<key> <string>columns</string> </key> <key> <string>columns</string> </key>
<value> <value>
......
subscription_request = context
portal = context.getPortalObject()
translate = portal.Base_translateString
status_list = []
def addToStatusList(status_text, mapping={}):
status_list.append(translate(
status_text,
mapping=mapping
))
if not context.getSimulationState() in ("ordered", "confirmed", "started", "stopped", "delivered"):
return []
subscription_trade_condition = portal.sale_trade_condition_module.slapos_aggregated_subscription_trade_condition
refund_service = portal.service_module.slapos_reservation_refund
sale_packing_list_list = portal.portal_catalog(
portal_type="Sale Packing List",
strict_causality_uid=subscription_request.getUid(),
strict_destination_uid=subscription_request.getDestinationSectionUid(),
strict_destination_section_uid=subscription_request.getDestinationSectionUid(),
strict_specialise_uid=subscription_trade_condition.getUid(),
simulation_state="delivered",
)
if sale_packing_list_list:
sale_invoice_list = portal.portal_catalog(
portal_type="Sale Invoice Transaction",
strict_causality_uid=[x.getUid() for x in sale_packing_list_list],
)
subscription_currency = subscription_request.getPriceCurrency()
for sale_invoice in sale_invoice_list:
sale_invoice = sale_invoice.getObject()
if sale_invoice.getPriceCurrency() != subscription_currency:
addToStatusList(
"${invoice_relative_url} Sale Invoice currency ${invoice_currency} do not match subscription currency ${subscription_currency}",
{
"invoice_relative_url": sale_invoice.getRelativeUrl(),
"invoice_currency": sale_invoice.getPriceCurrency(),
"subscription_currency": subscription_currency,
}
)
if sale_invoice.getSimulationState() not in ("stopped", "delivered", "cancelled"):
addToStatusList(
"${invoice_relative_url} Sale Invoice in unexpected simulation state: ${invoice_simulation_state}",
{
"invoice_relative_url": sale_invoice.getRelativeUrl(),
"invoice_simulation_state": sale_invoice.getSimulationState(),
}
)
return status_list
<?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>_params</string> </key>
<value> <string>fixit=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_checkRelatedAccounting</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<string>my_start_date</string> <string>my_start_date</string>
<string>my_stop_date</string> <string>my_stop_date</string>
<string>my_translated_simulation_state_title</string> <string>my_translated_simulation_state_title</string>
<string>my_translated_validation_state_title</string>
<string>my_subject_list</string> <string>my_subject_list</string>
</list> </list>
</value> </value>
......
<?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>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_translated_validation_state_title</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>
</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>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_translated_workflow_state_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Consistency State</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -9,3 +9,4 @@ accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transact ...@@ -9,3 +9,4 @@ accounting_module/template_wechat_pre_payment_subscription_sale_invoice_transact
notification_message_module/slapos-free-trial-token notification_message_module/slapos-free-trial-token
portal_alarms/slapos_subscription_request_process_** portal_alarms/slapos_subscription_request_process_**
portal_alarms/slapos_trial_process_** portal_alarms/slapos_trial_process_**
portal_alarms/slapos_update_subscription_request_consistency_state
\ No newline at end of file
...@@ -11,6 +11,7 @@ Subscription Request | HostingSubscription ...@@ -11,6 +11,7 @@ Subscription Request | HostingSubscription
Subscription Request | Person Subscription Request | Person
Subscription Request | Price Subscription Request | Price
Subscription Request | Reference Subscription Request | Reference
Subscription Request | SlaposSubscriptionRequestAuditConstraint
Subscription Request | SoftwareInstance Subscription Request | SoftwareInstance
Subscription Request | Task Subscription Request | Task
Subscription Request | TextDocument Subscription Request | TextDocument
......
...@@ -3,6 +3,7 @@ Subscription Condition | commerce_validation_workflow ...@@ -3,6 +3,7 @@ Subscription Condition | commerce_validation_workflow
Subscription Condition | edit_workflow Subscription Condition | edit_workflow
Subscription Request | edit_workflow Subscription Request | edit_workflow
Subscription Request | subscription_request_workflow Subscription Request | subscription_request_workflow
Subscription Request | validation_workflow
Trial Condition | commerce_validation_workflow Trial Condition | commerce_validation_workflow
Trial Condition | edit_workflow Trial Condition | edit_workflow
Trial Request | edit_workflow Trial Request | edit_workflow
......
TrialCondition TrialCondition
SlapOSSubscriptionCondition SlapOSSubscriptionCondition
SlaposSubscriptionRequestAuditConstraint
\ 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