mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
refactor: condition check before get_doc
This commit is contained in:
@@ -20,14 +20,6 @@ from erpnext.accounts.party import get_party_account, get_party_bank_account
|
|||||||
from erpnext.accounts.utils import get_account_currency, get_currency_precision
|
from erpnext.accounts.utils import get_account_currency, get_currency_precision
|
||||||
from erpnext.utilities import payment_app_import_guard
|
from erpnext.utilities import payment_app_import_guard
|
||||||
|
|
||||||
|
|
||||||
def _get_payment_gateway_controller(*args, **kwargs):
|
|
||||||
with payment_app_import_guard():
|
|
||||||
from payments.utils import get_payment_gateway_controller
|
|
||||||
|
|
||||||
return get_payment_gateway_controller(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
|
ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
|
||||||
"Sales Order",
|
"Sales Order",
|
||||||
"Purchase Order",
|
"Purchase Order",
|
||||||
@@ -38,6 +30,13 @@ ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _get_payment_gateway_controller(*args, **kwargs):
|
||||||
|
with payment_app_import_guard():
|
||||||
|
from payments.utils import get_payment_gateway_controller
|
||||||
|
|
||||||
|
return get_payment_gateway_controller(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class PaymentRequest(Document):
|
class PaymentRequest(Document):
|
||||||
# begin: auto-generated types
|
# begin: auto-generated types
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
# This code is auto-generated. Do not modify anything in this block.
|
||||||
@@ -533,12 +532,10 @@ def make_payment_request(**args):
|
|||||||
"""Make payment request"""
|
"""Make payment request"""
|
||||||
|
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
ref_doc = args.ref_doc or frappe.get_doc(args.dt, args.dn)
|
if args.dt not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
|
||||||
|
frappe.throw(_("Payment Requests cannot be created against: {0}").format(frappe.bold(args.dt)))
|
||||||
|
|
||||||
if ref_doc.doctype not in ALLOWED_DOCTYPES_FOR_PAYMENT_REQUEST:
|
ref_doc = args.ref_doc or frappe.get_doc(args.dt, args.dn)
|
||||||
frappe.throw(
|
|
||||||
_("Payment Requests cannot be created against: {0}").format(frappe.bold(ref_doc.doctype))
|
|
||||||
)
|
|
||||||
|
|
||||||
gateway_account = get_gateway_details(args) or frappe._dict()
|
gateway_account = get_gateway_details(args) or frappe._dict()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user