mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 02:34:41 +00:00
fix: Amount validation in Payment Request against Purchase Order (#34042)
fix: Amount validation in Payment Request against Purchase Order (#34042)
(cherry picked from commit ce748cec3a)
Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
@@ -45,21 +45,20 @@ class PaymentRequest(Document):
|
|||||||
frappe.throw(_("To create a Payment Request reference document is required"))
|
frappe.throw(_("To create a Payment Request reference document is required"))
|
||||||
|
|
||||||
def validate_payment_request_amount(self):
|
def validate_payment_request_amount(self):
|
||||||
existing_payment_request_amount = get_existing_payment_request_amount(
|
existing_payment_request_amount = flt(
|
||||||
self.reference_doctype, self.reference_name
|
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)
|
||||||
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":
|
||||||
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_amount = get_amount(ref_doc, self.payment_account)
|
|
||||||
|
|
||||||
if existing_payment_request_amount + flt(self.grand_total) > ref_amount:
|
if existing_payment_request_amount + flt(self.grand_total) > ref_amount:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Total Payment Request amount cannot be greater than {0} amount").format(
|
_("Total Payment Request amount cannot be greater than {0} amount").format(
|
||||||
self.reference_doctype
|
self.reference_doctype
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def validate_currency(self):
|
def validate_currency(self):
|
||||||
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
|
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user