mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-09 23:39:28 +00:00
fix(accounts): resolve subscription plans for any reference doctype in Payment Request (backport #58438) (#58450)
Co-authored-by: jatin3128 <jatinsarna64@gmail.com>
This commit is contained in:
@@ -710,7 +710,8 @@ def make_payment_request(**args):
|
|||||||
if not party_account_currency:
|
if not party_account_currency:
|
||||||
party_account = get_party_account(party_type, ref_doc.get(party_type.lower()), ref_doc.company)
|
party_account = get_party_account(party_type, ref_doc.get(party_type.lower()), ref_doc.company)
|
||||||
party_account_currency = get_account_currency(party_account)
|
party_account_currency = get_account_currency(party_account)
|
||||||
is_a_subscription = 1 if ref_doc.get("subscription") else 0
|
|
||||||
|
subscription_plans = get_subscription_details(ref_doc.doctype, ref_doc.name)
|
||||||
pr.update(
|
pr.update(
|
||||||
{
|
{
|
||||||
"payment_gateway_account": gateway_account.get("name"),
|
"payment_gateway_account": gateway_account.get("name"),
|
||||||
@@ -742,15 +743,14 @@ def make_payment_request(**args):
|
|||||||
or gateway_account.get("payment_channel", "Email") != "Email"
|
or gateway_account.get("payment_channel", "Email") != "Email"
|
||||||
),
|
),
|
||||||
"phone_number": args.get("phone_number") if args.get("phone_number") else None,
|
"phone_number": args.get("phone_number") if args.get("phone_number") else None,
|
||||||
"is_a_subscription": is_a_subscription,
|
"is_a_subscription": 1 if subscription_plans else 0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if selected_payment_schedules:
|
if selected_payment_schedules:
|
||||||
apply_payment_references(pr, payment_reference)
|
apply_payment_references(pr, payment_reference)
|
||||||
if is_a_subscription:
|
|
||||||
values = get_subscription_details(ref_doc.doctype, ref_doc.name)
|
|
||||||
|
|
||||||
|
if subscription_plans:
|
||||||
pr.set(
|
pr.set(
|
||||||
"subscription_plans",
|
"subscription_plans",
|
||||||
[
|
[
|
||||||
@@ -758,7 +758,7 @@ def make_payment_request(**args):
|
|||||||
"plan": row.plan,
|
"plan": row.plan,
|
||||||
"qty": row.qty,
|
"qty": row.qty,
|
||||||
}
|
}
|
||||||
for row in values
|
for row in subscription_plans
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
# Dimensions
|
# Dimensions
|
||||||
@@ -1074,16 +1074,18 @@ def get_dummy_message(doc):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_subscription_details(reference_doctype: str, reference_name: str):
|
def get_subscription_details(reference_doctype: str, reference_name: str) -> list[dict]:
|
||||||
if reference_doctype != "Sales Invoice":
|
frappe.has_permission(reference_doctype, "read", reference_name, throw=True)
|
||||||
|
|
||||||
|
if not frappe.get_meta(reference_doctype).has_field("subscription"):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
subscription = frappe.db.get_value("Sales Invoice", reference_name, "subscription")
|
subscription = frappe.db.get_value(reference_doctype, reference_name, "subscription")
|
||||||
|
|
||||||
if not subscription:
|
if not subscription:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
subscription_plan = frappe.get_all(
|
return frappe.get_all(
|
||||||
"Subscription Plan Detail",
|
"Subscription Plan Detail",
|
||||||
filters={"parent": subscription, "parenttype": "Subscription", "parentfield": "plans"},
|
filters={"parent": subscription, "parenttype": "Subscription", "parentfield": "plans"},
|
||||||
fields=[
|
fields=[
|
||||||
@@ -1092,8 +1094,6 @@ def get_subscription_details(reference_doctype: str, reference_name: str):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
return subscription_plan
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_payment_order(source_name, target_doc=None):
|
def make_payment_order(source_name, target_doc=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user