From b0302d71b7a001e1298f3cc5c43c793c6525da32 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Fri, 2 Feb 2024 21:59:53 +0530 Subject: [PATCH] fix(portal): payment amount for orders (cherry picked from commit c18ff5bd253878da2f71690f194e8fedd07b2a87) # Conflicts: # erpnext/templates/pages/order.py --- erpnext/templates/pages/order.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py index dca5a0c7497..dff982ed838 100644 --- a/erpnext/templates/pages/order.py +++ b/erpnext/templates/pages/order.py @@ -4,9 +4,13 @@ import frappe from frappe import _ +<<<<<<< HEAD from erpnext.accounts.doctype.payment_request.payment_request import ( ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST, ) +======= +from erpnext.accounts.doctype.payment_request.payment_request import get_amount +>>>>>>> c18ff5bd25 (fix(portal): payment amount for orders) def get_context(context): @@ -50,11 +54,15 @@ def get_context(context): ) context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points")) +<<<<<<< HEAD context.show_pay_button = ( "payments" in frappe.get_installed_apps() and frappe.db.get_single_value("Buying Settings", "show_pay_button") and context.doc.doctype in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST ) +======= + context.show_pay_button, context.pay_amount = get_payment_details(context.doc) +>>>>>>> c18ff5bd25 (fix(portal): payment amount for orders) context.show_make_pi_button = False if context.doc.get("supplier"): # show Make Purchase Invoice button based on permission @@ -67,3 +75,14 @@ def get_attachments(dt, dn): fields=["name", "file_name", "file_url", "is_private"], filters={"attached_to_name": dn, "attached_to_doctype": dt, "is_private": 0}, ) + + +def get_payment_details(doc): + show_pay_button, amount = ( + "payments" in frappe.get_installed_apps() + and frappe.db.get_single_value("Buying Settings", "show_pay_button") + ), 0 + if not show_pay_button: + return show_pay_button, amount + amount = get_amount(doc) + return bool(amount), amount