Commit 938d65ee authored by Romain Courteaud's avatar Romain Courteaud

slapos_subscription_request:

* subscription scenario needs project now
* project is needed when requesting an instance
* hardcode automated ledger category for the newly created sale packing list
* hardcode automated ledger category for the newly created accounting transactions
* automated ledger path
* add ledger to the accounting template
* only add a project assignment for the existing admin user
* create normal user with the project customer assignment
* update cdn subscription test
  project reference needed
* add project for chinese subscription
* project needed for scenario tests
* all Subscription/Trial object must be linked to a Project
* test: user need to be linked to a project
* propagate source project
* delivery/movement must use source_project instead of follow_up
* set source_project on event
* delivery/movement must use source_project instead of follow_up
* use source_project instead of follow_up
* use source_project instead of follow_up
* test set server allocation_scope/open
* Subscription COndition uses follow_up to link to the Project
* add missing source_project base category on Subscription Request
  XXX Subscription Request must inherit this from ticket instead of defining all of this manually
* Subscription COndition uses follow to link to Project
* also add destination_project on Subscription Request to ensure constraint can be triggered
* fix user account assignment creation from SubscriptionRequest
* create software product/release in test
* improve software product/release
* expect Sale Packing List to use a Software Product
* use Software Product as resource
* drop audit from Subscription Request
parent bb72fbe3
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSContractAlarm</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -97,6 +97,7 @@
<string>source/organisation_module/slapos</string>
<string>price_currency/currency_module/EUR</string>
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
<string>ledger/automated</string>
</tuple>
</value>
</item>
......
......@@ -97,6 +97,7 @@
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
<string>resource/currency_module/CNY</string>
<string>payment_mode/wechat</string>
<string>ledger/automated</string>
</tuple>
</value>
</item>
......
......@@ -95,6 +95,7 @@
<string>price_currency/currency_module/EUR</string>
<string>resource/currency_module/EUR</string>
<string>payment_mode/payzen</string>
<string>ledger/automated</string>
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
</tuple>
</value>
......
......@@ -91,6 +91,7 @@
<value>
<tuple>
<string>source_section/organisation_module/slapos</string>
<string>ledger/automated</string>
<string>source/organisation_module/slapos</string>
<string>payment_mode/wechat</string>
<string>specialise/sale_trade_condition_module/slapos_aggregated_trade_condition</string>
......
......@@ -12,8 +12,10 @@
<portal_type id="Subscription Request">
<item>aggregate</item>
<item>causality</item>
<item>destination_project</item>
<item>destination_section</item>
<item>source</item>
<item>source_project</item>
<item>source_section</item>
<item>specialise</item>
</portal_type>
......
......@@ -3,6 +3,7 @@
<item>InstanceTree</item>
<item>Price</item>
<item>SlapOSSubscriptionCondition</item>
<item>SlapOSVirtualMasterConstraint</item>
<item>SoftwareInstance</item>
<item>TextDocument</item>
<item>Url</item>
......@@ -15,7 +16,7 @@
<item>Person</item>
<item>Price</item>
<item>Reference</item>
<item>SlaposSubscriptionRequestAuditConstraint</item>
<item>SlapOSVirtualMasterSourceProjectConstraint</item>
<item>Task</item>
<item>Url</item>
<item>VariationRange</item>
......
......@@ -9,6 +9,6 @@
</chain>
<chain>
<type>Subscription Request</type>
<workflow>audit_validation_workflow, edit_workflow, subscription_request_workflow</workflow>
<workflow>edit_workflow, subscription_request_workflow</workflow>
</chain>
</workflow_chain>
\ No newline at end of file
<?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>
......@@ -82,6 +82,7 @@ subscription_request = context.subscription_request_module.newContent(
quantity=user_input_dict["amount"],
language=target_language,
specialise_value=subscription_condition,
source_project_value=subscription_condition.getFollowUpValue()
)
subscription_request.setDefaultEmailText(email)
......
......@@ -13,22 +13,22 @@ if person.getLanguage() in [None, ""]:
person.setLanguage(context.getLanguage())
# Should come from subscription condition probably or preference
role_list = ['member', 'subscriber']
function_list = ['customer']
open_assignment_list = person.searchFolder(portal_type="Assignment",
validation_state="open")
current_assignment_list = {}
for assignment in open_assignment_list:
role = assignment.getRole()
if role in current_assignment_list:
current_assignment_list[role].append(assignment)
function = assignment.getFunction()
if function in current_assignment_list:
current_assignment_list[function].append(assignment)
else:
current_assignment_list[role] = [assignment]
current_assignment_list[function] = [assignment]
for role in role_list:
if role in current_assignment_list:
for function in function_list:
if function in current_assignment_list:
# Update assignment (Reset stop/start dates)
for assignment in current_assignment_list[role]:
for assignment in current_assignment_list[function]:
if assignment.getStartDate() is None or \
assignment.getStopDate() is None:
assignment.update()
......@@ -40,8 +40,10 @@ for role in role_list:
# Create assignment
assignment = person.newContent(
portal_type='Assignment',
title = '%s Assignment' % (role.capitalize()),
role = role)
title = '%s Assignment' % (function.capitalize()),
function = function,
destination_project=context.getSourceProject()
)
assignment.open(comment="Created by Subscription Request")
......@@ -68,16 +70,6 @@ try:
except UnsupportedWorkflowMethod:
pass
person.edit(default_career_role_list=role_list)
default_career = getattr(person,'default_career',None)
# Try to validate the default career
try:
default_career.start(comment="Started by Subscription Request")
default_career.setStartDate(DateTime())
except UnsupportedWorkflowMethod:
pass
context.activate(activity='SQLQueue').SubscriptionRequest_sendAcceptedNotification(reference, password)
context.order()
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],
)
trade_condition = subscription_request.getSpecialiseValue().getSpecialiseValue()
subscription_currency = trade_condition.getPriceCurrency()
subscription_source_section = trade_condition.getSourceSection()
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.getSourceSection() != subscription_source_section:
addToStatusList(
"${invoice_relative_url} Sale Invoice Source ${invoice_source_section} do not match subscription source section ${subscription_source_section}",
{
"invoice_relative_url": sale_invoice.getRelativeUrl(),
"invoice_source_section": sale_invoice.getSourceSection(),
"subscription_source_section": subscription_source_section,
}
)
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.absolute_url(),
"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>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>
......@@ -13,6 +13,7 @@ if current_invoice is None:
invoice_template = portal.restrictedTraverse(template)
current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1)
assert current_invoice is not None
current_invoice.manage_delObjects([x for x in
current_invoice.contentIds() if x != "1"])
current_invoice.edit(
......@@ -38,6 +39,8 @@ if current_invoice is None:
payment_transaction = portal.restrictedTraverse(payment)
current_invoice.edit(
title="Reservation Fee",
ledger_value=portal.portal_categories.ledger.automated,
source_project_value=context.getSourceProjectValue(),
destination_value=context.getDestinationSection(),
destination_section_value=context.getDestinationSection(),
destination_decision_value=context.getDestinationSection(),
......
......@@ -61,7 +61,9 @@ delivery.edit(
causality_uid=context.getUid(),
price_currency=sale_invoice_transaction.getPriceCurrency(),
source=sale_invoice_transaction.getSource(),
source_section=sale_invoice_transaction.getSourceSection()
source_section=sale_invoice_transaction.getSourceSection(),
ledger_value=portal.portal_categories.ledger.automated,
source_project_value=sale_invoice_transaction.getSourceProjectValue(),
)
line = delivery.newContent(
......
......@@ -17,7 +17,8 @@ request_kw = dict(
software_type=instance_tree.getSourceReference(),
instance_xml=instance_tree.getTextContent(),
sla_xml=instance_tree.getSlaXml(),
shared=instance_tree.isRootSlave()
shared=instance_tree.isRootSlave(),
project_reference=instance_tree.getFollowUpReference()
)
if not context.SubscriptionRequest_testPaymentBalance():
......
......@@ -32,6 +32,7 @@ request_kw.update(
sla_xml=subscription_condition.getSlaXml(default_xml).strip(),
shared=bool(subscription_condition.getRootSlave(0)),
state="started",
project_reference=subscription_condition.getFollowUpReference()
)
person.requestSoftwareInstance(**request_kw)
......
......@@ -33,6 +33,8 @@ if current_invoice is None:
now = DateTime()
current_payment.edit(
title="Payment for Reservation Fee",
ledger_value=portal.portal_categories.ledger.automated,
source_project_value=context.getSourceProjectValue(),
specialise_value=trade_condition,
destination_value=context.getDestinationSection(),
destination_section_value=context.getDestinationSection(),
......
......@@ -62,13 +62,14 @@ class TestSlapOSSubscriptionCDNScenarioMixin(TestSlapOSSubscriptionScenarioMixin
# now instantiate it on compute_node and set some nice connection dict
self.setServerOpenPersonal(subscription_server)
self.setServerOpenPublic(subscription_server)
self.login(self.admin_user.getUserId())
self.personRequestInstanceNotReady(
software_release=self.subscription_condition.getUrlString(),
software_type=self.subscription_condition.getSourceReference(),
partition_reference="InstanceForSlave%s" % self.new_id
partition_reference="InstanceForSlave%s" % self.new_id,
project_reference=self.subscription_project.getReference()
)
self.stepCallSlaposAllocateInstanceAlarm()
......@@ -77,7 +78,8 @@ class TestSlapOSSubscriptionCDNScenarioMixin(TestSlapOSSubscriptionScenarioMixin
self.personRequestInstance(
software_release=self.subscription_condition.getUrlString(),
software_type=self.subscription_condition.getSourceReference(),
partition_reference="InstanceForSlave%s" % self.new_id
partition_reference="InstanceForSlave%s" % self.new_id,
project_reference=self.subscription_project.getReference()
)
# now instantiate it on compute_node and set some nice connection dict
......@@ -85,7 +87,7 @@ class TestSlapOSSubscriptionCDNScenarioMixin(TestSlapOSSubscriptionScenarioMixin
self.tic()
self.login()
self.setServerOpenSubscription(subscription_server)
#self.setServerOpenSubscription(subscription_server)
self.setAccessToMemcached(subscription_server)
self.tic()
self.simulateSlapgridCP(subscription_server)
......
......@@ -171,7 +171,7 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
name="ABC %s" % self.new_id
self.login()
self.createNormalUser(default_email_text, name, language)
self.createNormalUser(default_email_text, name, language, self.subscription_project)
self.tic()
......
......@@ -58,7 +58,7 @@ class testSlapOSSubscriptionPerUserTradeConditionScenario(TestSlapOSSubscription
name="ABC %s" % self.new_id
self.login()
self.createNormalUser(default_email_text, name, language)
self.createNormalUser(default_email_text, name, language, self.subscription_project)
self.createCustomUserSaleTradeCondition(self.normal_user)
self.tic()
......@@ -144,7 +144,7 @@ class testSlapOSSubscriptionPerUserTradeConditionScenarioDetaxed(TestSlapOSSubsc
name="ABC %s" % self.new_id
self.login()
self.createNormalUser(default_email_text, name, language)
self.createNormalUser(default_email_text, name, language, self.subscription_project)
self.createDetaxedUserSaleTradeCondition(self.normal_user)
self.tic()
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSSubscriptionPerUserTradeConditionScenario</string> </value>
......@@ -61,28 +55,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
......@@ -95,7 +74,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -104,7 +83,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
......@@ -7,7 +7,9 @@ Subscription Condition | specialise
Subscription Request Module | business_application
Subscription Request | aggregate
Subscription Request | causality
Subscription Request | destination_project
Subscription Request | destination_section
Subscription Request | source
Subscription Request | source_project
Subscription Request | source_section
Subscription Request | specialise
\ No newline at end of file
Subscription Condition | InstanceTree
Subscription Condition | Price
Subscription Condition | SlapOSSubscriptionCondition
Subscription Condition | SlapOSVirtualMasterConstraint
Subscription Condition | SoftwareInstance
Subscription Condition | TextDocument
Subscription Condition | Url
......@@ -11,7 +12,7 @@ Subscription Request | InstanceTree
Subscription Request | Person
Subscription Request | Price
Subscription Request | Reference
Subscription Request | SlaposSubscriptionRequestAuditConstraint
Subscription Request | SlapOSVirtualMasterSourceProjectConstraint
Subscription Request | Task
Subscription Request | Url
Subscription Request | VariationRange
\ No newline at end of file
Email | -coordinate_interaction_workflow
Subscription Condition | commerce_validation_workflow
Subscription Condition | edit_workflow
Subscription Request | audit_validation_workflow
Subscription Request | edit_workflow
Subscription Request | subscription_request_workflow
\ No newline at end of file
SlapOSSubscriptionCondition
SlaposSubscriptionRequestAuditConstraint
\ No newline at end of file
SlapOSSubscriptionCondition
\ 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