fix: Amount validation in Payment Request against Purchase Order (#34042)
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index fc837c7..52eb29b 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -45,21 +45,20 @@
frappe.throw(_("To create a Payment Request reference document is required"))
def validate_payment_request_amount(self):
- existing_payment_request_amount = get_existing_payment_request_amount(
- self.reference_doctype, self.reference_name
+ existing_payment_request_amount = flt(
+ get_existing_payment_request_amount(self.reference_doctype, self.reference_name)
)
- if existing_payment_request_amount:
- ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
- if not hasattr(ref_doc, "order_type") or getattr(ref_doc, "order_type") != "Shopping Cart":
- ref_amount = get_amount(ref_doc, self.payment_account)
+ ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
+ if not hasattr(ref_doc, "order_type") or getattr(ref_doc, "order_type") != "Shopping Cart":
+ ref_amount = get_amount(ref_doc, self.payment_account)
- if existing_payment_request_amount + flt(self.grand_total) > ref_amount:
- frappe.throw(
- _("Total Payment Request amount cannot be greater than {0} amount").format(
- self.reference_doctype
- )
+ if existing_payment_request_amount + flt(self.grand_total) > ref_amount:
+ frappe.throw(
+ _("Total Payment Request amount cannot be greater than {0} amount").format(
+ self.reference_doctype
)
+ )
def validate_currency(self):
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)