Commit 338682fe by Rafael Monnerat

slapos_subscription: Implement check and test Payment Balance

If the first 3 months are payed, the subscription request is confirmed (allowing allocation).
1 parent a4b8b535
# If Hosting subscription is None, make the request
context.SubscriptionRequest_processRequest()
hosting_subscription = context.getAggregateValue()
# Don't continue if instance wasnt there.
if context.getAggregate() is None:
return
# Don't request again if it is already requested.
if hosting_subscription is None:
context.SubscriptionRequest_processRequest()
hosting_subscription = context.getAggregateValue()
#if context.SubscriptionRequest_testPaymentBalance():
# context.confirm()
if hosting_subscription is not None:
instance = hosting_subscription.getPredecessorValue()
# This ensure that the user has a valid cloud contract
user_contract = instance.SoftwareInstance_requestValidationPayment()
if context.SubscriptionRequest_testPaymentBalance():
context.confirm()
# Search by SPL for the first period
portal = context.getPortalObject()
# This is normally one, but we navegate in case
for packing_list in portal.portal_catalog(
portal_type="Sale Packing List",
causality_uid=context.getUid(),
specialise_uid=portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
):
for invoice in packing_list.getCausalityRelatedValueList(
portal_type="Sale Invoice Transaction"):
payment = invoice.getCausalityRelatedValue(
portal_type="Payment Transaction")
if payment is not None and payment.getSimulationState() in ["stopped", "delivered"]:
return True
return False
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_testPaymentBalance</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!