fix: better validation for Integration Request (#28186)

This commit is contained in:
Sagar Vora 2021-11-16 20:31:18 +05:30 committed by GitHub
parent 0c9acc799b
commit c00d0a3e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -548,10 +548,14 @@ def make_payment_order(source_name, target_doc=None):
return doclist
def validate_payment(doc, method=""):
if not frappe.db.has_column(doc.reference_doctype, 'status'):
def validate_payment(doc, method=None):
if doc.reference_doctype != "Payment Request" or (
frappe.db.get_value(doc.reference_doctype, doc.reference_docname, 'status')
!= "Paid"
):
return
status = frappe.db.get_value(doc.reference_doctype, doc.reference_docname, 'status')
if status == 'Paid':
frappe.throw(_("The Payment Request {0} is already paid, cannot process payment twice").format(doc.reference_docname))
frappe.throw(
_("The Payment Request {0} is already paid, cannot process payment twice")
.format(doc.reference_docname)
)