Commit 77b4b916 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Introduce Subscription Trade Condition Case

When the Hosting Subscription comes from a Subscription Request, the Trade Condition applied is a different one (slapos_aggregated_subscription_trade_condition).

Update all related scripts to work accordinally.

SPL on this case are started as soon they are created and a payment generated.
parent 03957262
<?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>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>_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_aggregated_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_aggregated_subscription_trade_condition</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_aggregated_subscription_trade_condition</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</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 Aggregated Subscrition 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="Trade Model 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>categories</string> </key>
<value>
<tuple>
<string>resource/service_module/slapos_tax</string>
<string>base_application/base_amount/invoicing/taxable</string>
<string>trade_phase/slapos/tax</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>VAT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Line</string> </value>
</item>
<item>
<key> <string>price</string> </key>
<value> <float>0.2</float> </value>
</item>
<item>
<key> <string>quantity</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>target_delivery</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>VAT</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>
portal = context.getPortalObject()
specialise_uid = [portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid(),
portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid()]
portal.portal_catalog.searchAndActivate(
portal_type='Sale Packing List',
simulation_state='started',
causality_state='solved',
specialise_uid=portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid(),
specialise_uid=specialise_uid,
method_id='Delivery_deliverStartedAggregatedSalePackingList',
activate_kw={'tag': tag},
)
......
if params is None:
params = {}
from DateTime import DateTime
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type='Sale Packing List',
simulation_state='confirmed',
causality_state='solved',
specialise_uid=portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
method_id='Delivery_startConfirmedAggregatedSalePackingList',
activate_kw={'tag': tag},
)
context.activate(after_tag=tag).getId()
<?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>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_startConfirmedAggregatedSubscriptionSalePackingList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
from Products.ERP5Type.DateUtils import getClosestDate
portal = context.getPortalObject()
specialise_uid = [portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid(),
portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid()]
portal.portal_catalog.searchAndActivate(
portal_type='Sale Invoice Transaction',
simulation_state='confirmed',
causality_state='solved',
specialise_uid=portal.restrictedTraverse(portal.portal_preferences.getPreferredAggregatedSaleTradeCondition()).getUid(),
specialise_uid=specialise_uid,
method_id='Delivery_stopConfirmedAggregatedSaleInvoiceTransaction',
activate_kw={'tag': tag}
)
......
......@@ -6,7 +6,8 @@ isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'started' \
and len(context.checkConsistency()) == 0 \
and context.getCausalityState() == 'solved' \
and context.getSpecialise() == portal.portal_preferences.getPreferredAggregatedSaleTradeCondition():
and context.getSpecialise() in [portal.portal_preferences.getPreferredAggregatedSaleTradeCondition(),
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]:
comment = 'Delivered by alarm as all actions in started state are ready.'
if isTransitionPossible(context, 'stop'):
context.stop(comment=comment)
......
......@@ -6,7 +6,9 @@ isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'confirmed' \
and len(context.checkConsistency()) == 0 \
and context.getCausalityState() == 'solved' \
and context.getSpecialise() == portal.portal_preferences.getPreferredAggregatedSaleTradeCondition():
and context.getSpecialise() in [portal.portal_preferences.getPreferredAggregatedSaleTradeCondition(),
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]:
comment = 'Start by alarm as all actions in confirmed state are ready.'
date = DateTime().earliestTime()
context.edit(start_date=date, stop_date=date)
......
......@@ -5,7 +5,8 @@ isTransitionPossible = portal.portal_workflow.isTransitionPossible
if context.getSimulationState() == 'confirmed'\
and len(context.checkConsistency()) == 0\
and context.getCausalityState() == 'solved'\
and context.getSpecialise() == portal.portal_preferences.getPreferredAggregatedSaleTradeCondition():
and context.getSpecialise() in [portal.portal_preferences.getPreferredAggregatedSaleTradeCondition(),
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()]:
comment = 'Stopped by alarm as all actions in confirmed state are ready.'
if isTransitionPossible(context, 'start'):
context.start(comment=comment)
......
......@@ -67,6 +67,8 @@ portal_solvers/Automatic Quantity Adopt Solver/**
sale_packing_list_module/slapos_accounting_instance_delivery_line_template
sale_packing_list_module/slapos_accounting_instance_delivery_line_template/**
sale_packing_list_module/slapos_accounting_instance_delivery_template
sale_trade_condition_module/slapos_aggregated_subscription_trade_condition
sale_trade_condition_module/slapos_aggregated_subscription_trade_condition/**
sale_trade_condition_module/slapos_aggregated_trade_condition
sale_trade_condition_module/slapos_aggregated_trade_condition/1
sale_trade_condition_module/slapos_consumption_trade_condition
......
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