diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 4b885a401328..5ceb6e53af83 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -148,6 +148,14 @@ def validate_subscription_details(self): ) def on_submit(self): + advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( + "advance_payment_supplier_doctypes" + ) + ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) + if self.reference_doctype in advance_payment_doctypes: + # set advance payment status + ref_doc.set_total_advance_paid() + if self.payment_request_type == "Outward": self.db_set("status", "Initiated") return @@ -155,7 +163,6 @@ def on_submit(self): self.db_set("status", "Requested") send_mail = self.payment_gateway_validation() if self.payment_gateway else None - ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name) if ( hasattr(ref_doc, "order_type") and ref_doc.order_type == "Shopping Cart" @@ -170,13 +177,6 @@ def on_submit(self): elif self.payment_channel == "Phone": self.request_phone_payment() - advance_payment_doctypes = frappe.get_hooks("advance_payment_customer_doctypes") + frappe.get_hooks( - "advance_payment_supplier_doctypes" - ) - if self.reference_doctype in advance_payment_doctypes: - # set advance payment status - ref_doc.set_total_advance_paid() - def request_phone_payment(self): controller = _get_payment_gateway_controller(self.payment_gateway) request_amount = self.get_request_amount() diff --git a/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py b/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py index 7612294a85ca..a9e7c6708d71 100644 --- a/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py +++ b/erpnext/accounts/doctype/unreconcile_payment/unreconcile_payment.py @@ -84,7 +84,11 @@ def on_submit(self): update_voucher_outstanding( alloc.reference_doctype, alloc.reference_name, alloc.account, alloc.party_type, alloc.party ) - if doc.doctype in frappe.get_hooks("advance_payment_doctypes"): + + advance_payment_doctypes = frappe.get_hooks( + "advance_payment_customer_doctypes" + ) + frappe.get_hooks("advance_payment_supplier_doctypes") + if doc.doctype in advance_payment_doctypes: doc.set_total_advance_paid() frappe.db.set_value("Unreconcile Payment Entries", alloc.name, "unlinked", True)