Commit c81133a9 authored by Romain Courteaud's avatar Romain Courteaud

Add a direct link to pay from the invoice.

parent 4a1f6e61
......@@ -59,9 +59,10 @@ elif simulation_state in ("planned", "confirmed", "ordered", "started"):\n
result = "Ongoing"\n
\n
else:\n
portal = context.getPortalObject()\n
\n
paid = True\n
for line in context.getMovementList(context.getPortalObject().getPortalAccountingMovementTypeList()):\n
for line in context.getMovementList(portal.getPortalAccountingMovementTypeList()):\n
node_value = line.getSourceValue(portal_type=\'Account\')\n
if node_value.getAccountType() == \'asset/receivable\':\n
if not line.hasGroupingReference():\n
......@@ -73,7 +74,26 @@ else:\n
elif context.getTotalPrice() == 0:\n
result = "Free!"\n
else:\n
result = "Waiting for payment"\n
# Check if there is an ongoing payzen payment\n
payment = portal.portal_catalog.getResultValue(\n
portal_type="Payment Transaction",\n
simulation_state="started",\n
default_causality_uid=context.getUid(),\n
default_payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),\n
)\n
if payment is None:\n
result = "Unpaid"\n
else:\n
# Check if mapping exists\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
payzen_id = person.Person_restrictMethodAsShadowUser(\n
shadow_document=person,\n
callable_object=payment.PaymentTransaction_getPayzenId,\n
argument_list=[])[0]\n
if payzen_id is None:\n
result = "Pay now"\n
else:\n
result = "Waiting for payment confirmation"\n
\n
return result\n
</string> </value>
......
<?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>result = None\n
if context.AccountingTransaction_getPaymentState() == "Pay now":\n
portal = context.getPortalObject()\n
payment = portal.portal_catalog.getResultValue(\n
portal_type="Payment Transaction",\n
simulation_state="started",\n
default_causality_uid=context.getUid(),\n
default_payment_mode_uid=portal.portal_categories.payment_mode.payzen.getUid(),\n
)\n
if payment is not None:\n
result = "%s/PaymentTransaction_redirectToManualPayzenPayment" % payment.absolute_url()\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_getPayzenPaymentLink</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -180,7 +180,7 @@
</tuple>
<tuple>
<string>AccountingTransaction_getPaymentState</string>
<string></string>
<string>SaleInvoiceTransaction_getPayzenPaymentLink</string>
</tuple>
<tuple>
<string>download</string>
......
26
\ No newline at end of file
27
\ 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