mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
refactor: handle PR's in advance stage
(cherry picked from commit 18c13a2cff)
This commit is contained in:
@@ -691,6 +691,21 @@ def get_amount(ref_doc, payment_account=None):
|
|||||||
frappe.throw(_("Payment Entry is already created"))
|
frappe.throw(_("Payment Entry is already created"))
|
||||||
|
|
||||||
|
|
||||||
|
def get_irequest_status(payment_requests: None | list = None) -> list:
|
||||||
|
IR = frappe.qb.DocType("Integration Request")
|
||||||
|
res = []
|
||||||
|
if payment_requests:
|
||||||
|
res = (
|
||||||
|
frappe.qb.from_(IR)
|
||||||
|
.select(IR.name)
|
||||||
|
.where(IR.reference_doctype.eq("Payment Request"))
|
||||||
|
.where(IR.reference_docname.isin(payment_requests))
|
||||||
|
.where(IR.status.isin(["Authorized", "Completed"]))
|
||||||
|
.run(as_dict=True)
|
||||||
|
)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def cancel_old_payment_requests(ref_dt, ref_dn):
|
def cancel_old_payment_requests(ref_dt, ref_dn):
|
||||||
PR = frappe.qb.DocType("Payment Request")
|
PR = frappe.qb.DocType("Payment Request")
|
||||||
|
|
||||||
@@ -703,6 +718,9 @@ def cancel_old_payment_requests(ref_dt, ref_dn):
|
|||||||
.where(PR.status.isin(["Draft", "Requested"]))
|
.where(PR.status.isin(["Draft", "Requested"]))
|
||||||
.run(as_dict=True)
|
.run(as_dict=True)
|
||||||
):
|
):
|
||||||
|
if get_irequest_status([x.name for x in res]):
|
||||||
|
frappe.throw(_("Another Payment Request is already processed"))
|
||||||
|
else:
|
||||||
for x in res:
|
for x in res:
|
||||||
doc = frappe.get_doc("Payment Request", x.name)
|
doc = frappe.get_doc("Payment Request", x.name)
|
||||||
doc.flags.ignore_permissions = True
|
doc.flags.ignore_permissions = True
|
||||||
|
|||||||
Reference in New Issue
Block a user