Commit 49e1a4b6 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_panel: Render payment list as listbox

   Introduce a listbox rather them a page template or HTML for a more
   future-proof approach.

   Some logic could be generalized for shorten the test/get scripts,
   but for now it is better keep them as is.
parent b5ac95c6
......@@ -242,7 +242,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_panel/InstanceNode_addSlapOSAllocationSupply',
'slapos_panel/InstanceTreeModule_selectRequestProject',
'slapos_panel/InstanceTree_redirectToManualDepositPayment',
'slapos_panel/InstanceTree_viewCreateDirectDepositPaymentTransactionOnSlaposPanelHTML',
'slapos_panel/InstanceTree_addSlapOSInstanceNode',
'slapos_panel/InstanceTree_getConnectionParameterList',
'slapos_panel/InstanceTree_getMonitorParameterDict',
......@@ -280,9 +279,15 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_panel/Ticket_addSlapOSEvent',
'slapos_panel/Ticket_closeSlapOS',
'slapos_panel/Ticket_suspendSlapOS',
'slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionList',
'slapos_panel/AccountingTransactionModule_testCreateExternalPaymentTransactionPending',
'slapos_panel/Base_getExternalPaymentTransactionUrl',
'slapos_panel/Base_getSupportedExternalPaymentList',
'slapos_panel/Base_isExternalPaymentConfigured',
'slapos_panel/InstanceTree_getCreateDirectDepositPaymentTransactionList',
'slapos_panel/InstanceTree_testCreateDirectDepositPaymentTransaction',
'slapos_panel/UpgradeDecision_acceptOnSlaposPanel',
'slapos_panel/UpgradeDecision_rejectOnSlaposPanel',
'slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML',
'slapos_panel/SaleInvoiceTransaction_getInvoicePrintoutUrl',
'slapos_panel/InstanceTree_proposeUpgradeDecision',
'slapos_panel/InstanceTree_searchUpgradableSoftwareReleaseList',
......
from DateTime import DateTime
from zExceptions import Unauthorized
portal = context.getPortalObject()
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
raise Unauthorized
payment_dict_list = []
kw = {'ledger_uid' : portal.portal_categories.ledger.automated.getUid()}
for currency_uid, secure_service_relative_url in portal.Base_getSupportedExternalPaymentList():
is_payment_configured = 1
if secure_service_relative_url is None:
is_payment_configured = 0
kw['resource_uid'] = currency_uid
for method in [entity.Entity_getOutstandingAmountList,
entity.Entity_getOutstandingDepositAmountList]:
for outstanding_amount in method(**kw):
if 0 < outstanding_amount.total_price:
if not is_payment_configured:
raise ValueError("Payment system is not properly configured")
as_context_kw = {
'total_price': outstanding_amount.total_price
}
if outstanding_amount.getPortalType() == "Subscription Request":
as_context_kw['reference'] = "Subscriptions pre-payment"
as_context_kw['stop_date'] = DateTime()
payment_dict_list.append(
outstanding_amount.asContext(**as_context_kw))
return payment_dict_list
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML</string> </value>
<value> <string>AccountingTransactionModule_getCreateExternalPaymentTransactionList</string> </value>
</item>
</dictionary>
</pickle>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
web_site = context.getWebSiteValue()
assert web_site is not None
ledger_uid = portal.portal_categories.ledger.automated.getUid()
# This script will be used to generate the payment
# compatible with external providers
html_content = ''
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
return '<p>Nothing to pay with your account</p>'
for currency_uid, secure_service_relative_url in [
(portal.currency_module.EUR.getUid(), portal.Base_getPayzenServiceRelativeUrl()),
# (portal.currency_module.CNY.getUid(), portal.Base_getWechatServiceRelativeUrl())
]:
is_payment_configured = 1
if secure_service_relative_url is None:
is_payment_configured = 0
for method in [entity.Entity_getOutstandingAmountList,
entity.Entity_getOutstandingDepositAmountList]:
for outstanding_amount in method(
ledger_uid=ledger_uid, resource_uid=currency_uid):
if 0 < outstanding_amount.total_price:
if not is_payment_configured:
return '<p>Please contact us to handle your payment</p>'
html_content += """
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
""" % {
'total_price': outstanding_amount.total_price,
'currency': outstanding_amount.getPriceCurrencyReference(),
'payment_url': '%s/Base_createExternalPaymentTransactionFromOutstandingAmountAndRedirect' % outstanding_amount.absolute_url()
}
if not html_content:
html_content = '<p>Nothing to pay</p>'
return html_content
"""
Test if there is something to pay.
If `return_message` is true, return "nothing to pay or contact us to pay",
otherwise the form should display a listbox, and not rely on the message.
"""
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
NOTHING_TO_PAY = context.Base_translateString('Nothing to pay')
NOTHING_TO_PAY_NO_PERSON = context.Base_translateString('Nothing to pay with your account')
PLEASE_CONTACT_US = context.Base_transalteString('Please contact us to handle your payment')
# This script will be used to generate the payment
# compatible with external providers
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
if return_message:
return NOTHING_TO_PAY_NO_PERSON
return False
kw = {'ledger_uid': portal.portal_categories.ledger.automated.getUid()}
for currency_uid, secure_service_relative_url in context.Base_getSupportedExternalPaymentList():
if not return_message and secure_service_relative_url is None:
# We should never get message from an unconfigured site,
# else we will over calculate, so return as early as possible.
return False
kw['resource_uid'] = currency_uid
for method in [
entity.Entity_getOutstandingAmountList,
entity.Entity_getOutstandingDepositAmountList]:
for outstanding_amount in method(**kw):
if 0 < outstanding_amount.total_price:
if return_message:
assert secure_service_relative_url is not None, \
"Payment is configured (and should not)"
return PLEASE_CONTACT_US
return True
if return_message:
return NOTHING_TO_PAY
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>_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>return_message=False, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_testCreateExternalPaymentTransactionPending</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,7 +58,8 @@
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_pay_action_html</string>
<string>your_message</string>
<string>listbox</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_pay_action_html</string> </value>
<value> <string>your_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -148,7 +148,9 @@
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -299,7 +301,20 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML()</string> </value>
<value> <string>python: context.AccountingTransactionModule_testCreateExternalPaymentTransactionPending(return_message=True)</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: not context.AccountingTransactionModule_testCreateExternalPaymentTransactionPending()</string> </value>
</item>
</dictionary>
</pickle>
......
if brain is None:
brain = context
if brain.getPortalType() == "Instance Tree":
url = '%s/InstanceTree_redirectToManualDepositPayment' % brain.absolute_url()
else:
url = '%s/Base_createExternalPaymentTransactionFromOutstandingAmountAndRedirect' % brain.absolute_url()
if url_dict:
return {'command': 'raw',
'options': {
'url': url
}
}
return url
<?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>url_dict=False, brain=None, selection=None, selection_name=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getExternalPaymentTransactionUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
# Keep a simple list so we can extend/reduce until we have a proper configuration
# mapping for this.
return [
(portal.currency_module.EUR.getUid(), portal.Base_getPayzenServiceRelativeUrl()),
# (portal.currency_module.CNY.getUid(), portal.Base_getWechatServiceRelativeUrl())
]
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_viewCreateDirectDepositPaymentTransactionOnSlaposPanelHTML</string> </value>
<value> <string>Base_getSupportedExternalPaymentList</string> </value>
</item>
</dictionary>
</pickle>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
for uid, secure_service_relative_url in context.Base_getSupportedExternalPaymentList():
if currency_uid == uid and secure_service_relative_url is not None:
return 1
return 0
<?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>currency_uid, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_isExternalPaymentConfigured</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
from DateTime import DateTime
portal = context.getPortalObject()
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
return Unauthorized
# Fetch to know if the subscription request is already created
subscription_request = portal.portal_catalog.getResultValue(
portal_type='Subscription Request',
aggregate__uid=context.getUid())
price = 0
payment_list = []
if subscription_request is None:
subscription_request = context.Item_createSubscriptionRequest(temp_object=True)
# Include temp object on the outstanting total price
price = subscription_request.getPrice(None)
if price is not None and price != 0:
balance = entity.Entity_getDepositBalanceAmount([subscription_request])
if balance > price:
return payment_list
elif subscription_request.getSimulationState() != 'submitted':
# No need to continue if the subscription is already processed.
return payment_list
def getUidWithShadow(portal, source_section):
# Source Section can be one organisation, so shadow is required
# Shadow has no access to freshly created or temp subscription requests
return portal.restrictedTraverse(source_section).getUid()
currency_uid = subscription_request.getPriceCurrencyUid()
section_section_uid = entity.Person_restrictMethodAsShadowUser(
shadow_document=entity,
callable_object=getUidWithShadow,
argument_list=[portal, subscription_request.getSourceSection()])
outstanding_amount_list = entity.Entity_getOutstandingDepositAmountList(
ledger_uid=subscription_request.getLedgerUid(),
source_section_uid=section_section_uid,
resource_uid=currency_uid)
assert len(outstanding_amount_list) in [0, 1]
outstanting_total_price = sum([i.total_price for i in outstanding_amount_list])
outstanting_total_price += price
if outstanting_total_price > 0:
if not context.Base_isExternalPaymentConfigured(currency_uid):
raise ValueError("External Payment support is not configured")
payment_list.append(outstanding_amount_list[0].asContext(
reference="Subscriptions pre-payment",
# Format by hand is not a good idea probably
stop_date=DateTime().strftime('%d/%m/%Y'),
total_price=outstanting_total_price,
))
return payment_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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_getCreateDirectDepositPaymentTransactionList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
NOTHING_TO_PAY = context.Base_translateString('Nothing to pay')
NOTHING_TO_PAY_NO_PERSON = context.Base_translateString('Nothing to pay with your account')
PLEASE_CONTACT_US = context.Base_transalteString('Please contact us to handle your payment')
portal = context.getPortalObject()
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
if return_message:
return NOTHING_TO_PAY_NO_PERSON
return False
# Fetch to know if the subscription request is already created
subscription_request = portal.portal_catalog.getResultValue(
portal_type='Subscription Request',
aggregate__uid=context.getUid())
price = 0
if subscription_request is None:
subscription_request = context.Item_createSubscriptionRequest(temp_object=True)
# Include temp object on the outstanting total price
price = subscription_request.getPrice(None)
if price is not None and price != 0:
balance = entity.Entity_getDepositBalanceAmount([subscription_request])
if balance > price:
if return_message:
return NOTHING_TO_PAY
return False
elif subscription_request.getSimulationState() != 'submitted':
# No need to continue if the subscription is already processed.
if return_message:
return NOTHING_TO_PAY
return False
currency_uid = subscription_request.getPriceCurrencyUid()
if not return_message:
# Return as early as possible if payment isnt configured
if not context.Base_isExternalPaymentConfigured(currency_uid):
return False
def getUidWithShadow(portal, source_section):
# Source Section can be one organisation, so shadow is required
# Shadow has no access to freshly created or temp subscription requests
return portal.restrictedTraverse(source_section).getUid()
section_section_uid = entity.Person_restrictMethodAsShadowUser(
shadow_document=entity, callable_object=getUidWithShadow,
argument_list=[portal, subscription_request.getSourceSection()])
outstanding_amount_list = entity.Entity_getOutstandingDepositAmountList(
ledger_uid=subscription_request.getLedgerUid(),
source_section_uid=section_section_uid,
resource_uid=currency_uid)
assert len(outstanding_amount_list) in [0, 1]
outstanting_total_price = sum([i.total_price for i in outstanding_amount_list])
outstanting_total_price += price
if outstanting_total_price > 0:
if return_message:
assert context.Base_isExternalPaymentConfigured(currency_uid), \
"Payment is configured (and should not)"
return PLEASE_CONTACT_US
return True
if return_message:
return NOTHING_TO_PAY
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>_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>return_message=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InstanceTree_testCreateDirectDepositPaymentTransaction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,7 +58,8 @@
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_pay_action_html</string>
<string>listbox</string>
<string>your_message</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_pay_action_html</string> </value>
<value> <string>your_message</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -148,7 +148,9 @@
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -299,7 +301,24 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.InstanceTree_viewCreateDirectDepositPaymentTransactionOnSlaposPanelHTML()</string> </value>
<value> <string encoding="cdata"><![CDATA[
python: "<p>%s</p>" % context.InstanceTree_testCreateDirectDepositPaymentTransaction(return_message=True)
]]></string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: not context.InstanceTree_testCreateDirectDepositPaymentTransaction()</string> </value>
</item>
</dictionary>
</pickle>
......
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
web_site = context.getWebSiteValue()
assert web_site is not None
# This script will be used to generate the payment
# compatible with external providers
html_content = ''
entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if entity is None:
return '<p>Nothing to pay with your account</p>'
def isPaymentConfigured(currency_uid):
for uid, secure_service_relative_url in [
(portal.currency_module.EUR.getUid(), portal.Base_getPayzenServiceRelativeUrl()),
# (portal.currency_module.CNY.getUid(), portal.Base_getWechatServiceRelativeUrl())
]:
if currency_uid == uid and secure_service_relative_url is not None:
return 1
return 0
# Fetch to know if the subscription request is already created
subscription_request = portal.portal_catalog.getResultValue(
portal_type='Subscription Request',
aggregate__uid=context.getUid())
if subscription_request is not None:
if subscription_request.getSimulationState() != 'submitted':
# No need to continue if the subscription is already processed.
return '<p>Nothing to pay</p>'
else:
subscription_request = context.Item_createSubscriptionRequest(temp_object=True)
if subscription_request is not None:
currency_uid = subscription_request.getPriceCurrencyUid()
# Subscription is indexed so we just calculate like usual
price = 0
if subscription_request.isTempObject():
# Include temp object on the outstanting total price
price = subscription_request.getPrice(None)
if price is not None and price != 0:
balance = entity.Entity_getDepositBalanceAmount([subscription_request])
if balance > price:
return '<p>Nothing to Pay </p>'
def getUidWithShadow(portal, source_section):
# Source Section can be one organisation, so shadow is required
# Shadow has no access to freshly created or temp subscription requests
return (
portal.restrictedTraverse(source_section).getUid(),
)
section_section_uid = entity.Person_restrictMethodAsShadowUser(
shadow_document=entity,
callable_object=getUidWithShadow,
argument_list=[portal, subscription_request.getSourceSection()])
outstanding_amount_list = entity.Entity_getOutstandingDepositAmountList(
ledger_uid=subscription_request.getLedgerUid(),
source_section_uid=section_section_uid,
resource_uid=currency_uid)
assert len(outstanding_amount_list) in [0, 1]
outstanting_total_price = sum([i.total_price for i in outstanding_amount_list])
outstanting_total_price += price
if outstanting_total_price > 0:
if not isPaymentConfigured(currency_uid):
return '<p>Please contact us to handle your payment</p>'
payment_url = subscription_request.absolute_url() + "/Base_createExternalPaymentTransactionFromOutstandingAmountAndRedirect"
if subscription_request.isTempObject():
payment_url = context.absolute_url() + "/InstanceTree_redirectToManualDepositPayment"
html_content += """
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
""" % {
'total_price': outstanting_total_price,
'currency': subscription_request.getPriceCurrencyReference(),
'payment_url': payment_url
}
if not html_content:
html_content = '<p>Nothing to pay</p>'
return html_content
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