Commit 7495a8db authored by Rafael Monnerat's avatar Rafael Monnerat

[slapos_accouting] [wip] Daily Hosting Invoicing

Implement sample code for Charge resilience hosting on public servers (logic present on what is free or not at HostingSubscription_isFreeHosted)

This is work in progress code.
parent c13a6ee3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Business Process" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>slapos_hosting_business_process</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_hosting_business_process</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Business Process</string> </value>
</item>
<item>
<key> <string>referential_date</string> </key>
<value> <string>start_date</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Hosting Business Process</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>1</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="Business Link" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>modification_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>creation_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
</tuple>
</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>trade_phase/slapos/delivery</string>
<string>successor/trade_state/delivered</string>
</tuple>
</value>
</item>
<item>
<key> <string>completed_state</string> </key>
<value>
<tuple>
<string>delivered</string>
<string>stopped</string>
</tuple>
</value>
</item>
<item>
<key> <string>creation_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1324249200.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>deliverable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>frozen_state</string> </key>
<value>
<tuple>
<string>delivered</string>
<string>stopped</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>deliver</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>lead_time</string> </key>
<value> <float>10.0</float> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1324249200.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Business Link</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>deliver</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Trade Model Path" 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>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>modification_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>creation_date</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>date</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>wait_time</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>lead_time</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</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>trade_phase/slapos/delivery</string>
<string>end_of/day</string>
</tuple>
</value>
</item>
<item>
<key> <string>creation_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1324249200.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-DELIVERY</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>delivery_path</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>lead_time</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1324249200.0</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>payment_additional_term</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>payment_term</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Delivery</string> </value>
</item>
<item>
<key> <string>wait_time</string> </key>
<value> <float>3.0</float> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Sale Trade Condition" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>specialise/business_process_module/slapos_hosting_business_process</string>
</tuple>
</value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>slapos_hosting_trade_condition</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_hosting_trade_condition</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Trade Condition</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Hosting Trade Condition</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</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="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>start_date</string> </key>
<value>
<tuple>
<none/>
<none/>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<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="Sale Supply Line" 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>base_price</string> </key>
<value> <float>1.68</float> </value>
</item>
<item>
<key> <string>base_unit_price</string> </key>
<value> <float>0.01</float> </value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>resource/service_module/slapos_instance_hosting</string>
<string>price_currency/currency_module/EUR</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_ssl</string> </value>
</item>
<item>
<key> <string>index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>mapped_value_property_list</string> </key>
<value>
<tuple>
<string>base_price</string>
<string>additional_price</string>
<string>discount_ratio</string>
<string>exclusive_discount_ratio</string>
<string>surcharge_ratio</string>
<string>variable_additional_price</string>
<string>non_discountable_additional_price</string>
<string>priced_quantity</string>
<string>base_unit_price</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Sale Supply Line</string> </value>
</item>
<item>
<key> <string>priced_quantity</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>quantity_step</string> </key>
<value>
<tuple/>
</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>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>path</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <int>0</int> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -58,7 +58,9 @@ portal = context.getPortalObject()\n ...@@ -58,7 +58,9 @@ portal = context.getPortalObject()\n
\n \n
business_process_uid_list = [\n business_process_uid_list = [\n
portal.business_process_module.slapos_consumption_business_process.getUid(),\n portal.business_process_module.slapos_consumption_business_process.getUid(),\n
portal.business_process_module.slapos_subscription_business_process.getUid()]\n portal.business_process_module.slapos_subscription_business_process.getUid(), \n
portal.business_process_module.slapos_hosting_business_process.getUid(),\n
]\n
specialise_reference_list = [q.getReference() for q in portal.portal_catalog(specialise_uid=business_process_uid_list,\n specialise_reference_list = [q.getReference() for q in portal.portal_catalog(specialise_uid=business_process_uid_list,\n
portal_type=\'Sale Trade Condition\')]\n portal_type=\'Sale Trade Condition\')]\n
\n \n
...@@ -93,6 +95,8 @@ for movement in movement_list:\n ...@@ -93,6 +95,8 @@ for movement in movement_list:\n
)\n )\n
if movement.getResource() == \'service_module/slapos_instance_subscription\':\n if movement.getResource() == \'service_module/slapos_instance_subscription\':\n
temp_movement.edit(price=0.83612040133800003)\n temp_movement.edit(price=0.83612040133800003)\n
elif movement.getResource() == \'service_module/slapos_instance_hosting\':\n
temp_movement.edit(price=1.672240802676)\n
else:\n else:\n
temp_movement.edit(price=0.0)\n temp_movement.edit(price=0.0)\n
temp_movement_list.append(temp_movement)\n temp_movement_list.append(temp_movement)\n
......
<?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>portal = context.getPortalObject()\n
\n
portal.portal_catalog.searchAndActivate(\n
portal_type="Hosting Subscription", \n
slap_state=["start_requested", "stop_requested"], \n
validation_state=\'validated\', \n
method_id="HostingSubscription_solveInvoicingGeneration",\n
activate_kw={\'tag\': tag},\n
)\n
\n
context.activate(after_tag=tag).getId()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_updateHostingSubscriptionInvoicing</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>"""\n
Sample script which charges for resilient setups on public computers.\n
"""\n
if context.getSlapState() not in ["start_requested", "stop_requested"]: \n
return 1\n
\n
# the "resilient" and "kvm-resilient" should come from Product Individual Variation,\n
# of the sofware product.\n
# XXX Hardcoded\n
if context.getSourceReference() not in ["resilient", "kvm-resilient"]:\n
return 1\n
\n
free = 1\n
# We don\'t charge for unpublished SR.\n
software_release_url = context.getUrlString()\n
software_release = context.portal_catalog.getResultValue(\n
url_string=software_release_url, \n
validation_state="published")\n
\n
if software_release is not None:\n
software_product = software_release.getAggregateValue()\n
if software_product.getValidationState() == "published":\n
free = 0\n
\n
if free:\n
return 0\n
\n
# Only charge if HS is hosted in public servers.\n
software_instance_list = context.getSpecialiseRelatedValueList(portal_type="Software Instance")\n
for software_instance in software_instance_list:\n
computer_partition = software_instance.getAggregateValue()\n
if computer_partition is not None and computer_partition.getAllocationScope() == "open/public":\n
return 0\n
\n
return 1\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_isFreeHosted</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[
from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
from DateTime import DateTime\n
portal = context.getPortalObject()\n
result = []\n
\n
if not context.HostingSubscription_isFreeHosted():\n
\n
# XXX TODO: serialize probably missing\n
# hosting_subscription.serialise()\n
\n
sale_trade_condition = context.sale_trade_condition.slapos_hosting_business_process\n
specialise_reference = sale_trade_condition.getReference()\n
\n
service = context.service_module.slapos_instance_hosting\n
person = context.getDestinationSectionValue(portal_type="Person")\n
\n
kw = dict(\n
portal_type=\'Sale Packing List Line\',\n
default_resource_uid=service.getUid(), \n
default_aggregate_uid=context.getUid(),\n
parent_specialise_reference=specialise_reference,\n
parent_specialise_portal_type="Sale Trade Condition",\n
parent_destination_section=person.getRelativeUrl(),\n
)\n
\n
delivery_line = portal.portal_catalog.getResultValue(sort_on=(("movement.stop_date",\'descending\'),),\n
simulation_state=["started", "stopped"],**kw)\n
\n
if delivery_line is None:\n
start_date = context.HostingSubscription_calculateSubscriptionStartDate()\n
else:\n
start_date = delivery_line.getStopDate()\n
\n
stop_date = DateTime().earliestTime() \n
\n
consumed_day_amount = int(stop_date-start_date)\n
if consumed_day_amount < 1:\n
return "We don\'t create consumption per smaller them 1"\n
\n
delivery_template = portal.restrictedTraverse(\n
portal.portal_preferences.getPreferredInstanceDeliveryTemplate())\n
\n
delivery = delivery_template.Base_createCloneDocument(batch_mode=1)\n
\n
delivery.edit(\n
title="%s Daily Hosting" % context.getReference(),\n
destination=person.getRelativeUrl(),\n
destination_decision=person.getRelativeUrl(),\n
destination_section=person.getRelativeUrl(),\n
source=person.getRelativeUrl(),\n
start_date=start_date,\n
specialise_value=sale_trade_condition,\n
stop_date=stop_date)\n
\n
delivery_line = delivery.newContent(\n
portal_type="Sale Packing List Line",\n
title="%s" % context.getTitle(),\n
aggregate_value=context,\n
resource_value=service,\n
price=0.0,\n
quantity_unit=service.getQuantityUnit(),\n
quantity=consumed_day_amount\n
)\n
\n
delivery.confirm(comment="Created from %s" % context.getRelativeUrl())\n
delivery.start()\n
delivery.stop()\n
delivery.deliver()\n
delivery.startBuilding()\n
\n
result.append((delivery_line.getRelativeUrl(), delivery.getRelativeUrl()))\n
\n
return result\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>HostingSubscription_solveInvoicingGeneration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
264 265
\ No newline at end of file \ No newline at end of file
...@@ -7,4 +7,5 @@ service_module/slapos_instance_setup ...@@ -7,4 +7,5 @@ service_module/slapos_instance_setup
service_module/slapos_instance_update service_module/slapos_instance_update
service_module/slapos_instance_subscription service_module/slapos_instance_subscription
service_module/slapos_netdrive_consumption service_module/slapos_netdrive_consumption
service_module/slapos_instance_hosting
service_module/slapos_account_validation service_module/slapos_account_validation
\ No newline at end of file
...@@ -4,6 +4,7 @@ service_module/slapos_instance_cleanup ...@@ -4,6 +4,7 @@ service_module/slapos_instance_cleanup
service_module/slapos_instance_setup service_module/slapos_instance_setup
service_module/slapos_instance_update service_module/slapos_instance_update
service_module/slapos_netdrive_consumption service_module/slapos_netdrive_consumption
service_module/slapos_instance_hosting
service_module/slapos_account_validation service_module/slapos_account_validation
account_module/bank account_module/bank
account_module/capital account_module/capital
......
...@@ -15,6 +15,8 @@ business_process_module/slapos_aggregated_business_process ...@@ -15,6 +15,8 @@ business_process_module/slapos_aggregated_business_process
business_process_module/slapos_aggregated_business_process/** business_process_module/slapos_aggregated_business_process/**
business_process_module/slapos_consumption_business_process business_process_module/slapos_consumption_business_process
business_process_module/slapos_consumption_business_process/** business_process_module/slapos_consumption_business_process/**
business_process_module/slapos_hosting_business_process
business_process_module/slapos_hosting_business_process/**
business_process_module/slapos_subscription_business_process business_process_module/slapos_subscription_business_process
business_process_module/slapos_subscription_business_process/** business_process_module/slapos_subscription_business_process/**
currency_module/EUR currency_module/EUR
...@@ -71,11 +73,15 @@ sale_packing_list_module/slapos_accounting_instance_delivery_template ...@@ -71,11 +73,15 @@ sale_packing_list_module/slapos_accounting_instance_delivery_template
sale_trade_condition_module/slapos_aggregated_trade_condition sale_trade_condition_module/slapos_aggregated_trade_condition
sale_trade_condition_module/slapos_aggregated_trade_condition/1 sale_trade_condition_module/slapos_aggregated_trade_condition/1
sale_trade_condition_module/slapos_consumption_trade_condition sale_trade_condition_module/slapos_consumption_trade_condition
sale_trade_condition_module/slapos_hosting_trade_condition
sale_trade_condition_module/slapos_hosting_trade_condition/**
sale_trade_condition_module/slapos_subscription_trade_condition sale_trade_condition_module/slapos_subscription_trade_condition
sale_trade_condition_module/slapos_subscription_trade_condition/** sale_trade_condition_module/slapos_subscription_trade_condition/**
service_module/slapos_account_validation service_module/slapos_account_validation
service_module/slapos_discount service_module/slapos_discount
service_module/slapos_instance_cleanup service_module/slapos_instance_cleanup
service_module/slapos_instance_hosting
service_module/slapos_instance_hosting/default_ssl
service_module/slapos_instance_setup service_module/slapos_instance_setup
service_module/slapos_instance_subscription service_module/slapos_instance_subscription
service_module/slapos_instance_subscription/default_ssl service_module/slapos_instance_subscription/default_ssl
......
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