mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 10:36:31 +00:00
* fix(payment-request): populate subscription plans (#57494)
* fix(payment-request): populate subscription plans
* test: add coverage for subscription plans in payment request
---------
Co-authored-by: Dharanidharan2813 <dharanidharans1328@gmail.com>
(cherry picked from commit 1b81db4754)
# Conflicts:
# erpnext/accounts/doctype/payment_request/payment_request.py
# erpnext/accounts/doctype/payment_request/test_payment_request.py
* fix(payment-request): resolve cherry-pick conflicts for version-16-hotfix backport
---------
Co-authored-by: Vishnu Priya Baskaran <145791817+ervishnucs@users.noreply.github.com>
Co-authored-by: ervishnucs <ervishnucs369@gmail.com>
Co-authored-by: Jatin3128 <140256508+Jatin3128@users.noreply.github.com>
This commit is contained in:
@@ -92,6 +92,7 @@ frappe.ui.form.on("Payment Request", "is_a_subscription", function (frm) {
|
|||||||
freeze: true,
|
freeze: true,
|
||||||
callback: function (data) {
|
callback: function (data) {
|
||||||
if (!data.exc) {
|
if (!data.exc) {
|
||||||
|
frm.clear_table("subscription_plans");
|
||||||
$.each(data.message || [], function (i, v) {
|
$.each(data.message || [], function (i, v) {
|
||||||
var d = frappe.model.add_child(
|
var d = frappe.model.add_child(
|
||||||
frm.doc,
|
frm.doc,
|
||||||
|
|||||||
@@ -710,7 +710,7 @@ 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
|
||||||
pr.update(
|
pr.update(
|
||||||
{
|
{
|
||||||
"payment_gateway_account": gateway_account.get("name"),
|
"payment_gateway_account": gateway_account.get("name"),
|
||||||
@@ -742,12 +742,25 @@ 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,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
pr.set(
|
||||||
|
"subscription_plans",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"plan": row.plan,
|
||||||
|
"qty": row.qty,
|
||||||
|
}
|
||||||
|
for row in values
|
||||||
|
],
|
||||||
|
)
|
||||||
# Dimensions
|
# Dimensions
|
||||||
pr.update(
|
pr.update(
|
||||||
{
|
{
|
||||||
@@ -1061,19 +1074,25 @@ def get_dummy_message(doc):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_subscription_details(reference_doctype, reference_name):
|
def get_subscription_details(reference_doctype: str, reference_name: str):
|
||||||
if reference_doctype == "Sales Invoice":
|
if reference_doctype != "Sales Invoice":
|
||||||
subscriptions = frappe.db.sql(
|
return []
|
||||||
"""SELECT parent as sub_name FROM `tabSubscription Invoice` WHERE invoice=%s""",
|
|
||||||
reference_name,
|
subscription = frappe.db.get_value("Sales Invoice", reference_name, "subscription")
|
||||||
as_dict=1,
|
|
||||||
)
|
if not subscription:
|
||||||
subscription_plans = []
|
return []
|
||||||
for subscription in subscriptions:
|
|
||||||
plans = frappe.get_doc("Subscription", subscription.sub_name).plans
|
subscription_plan = frappe.get_all(
|
||||||
for plan in plans:
|
"Subscription Plan Detail",
|
||||||
subscription_plans.append(plan)
|
filters={"parent": subscription, "parenttype": "Subscription", "parentfield": "plans"},
|
||||||
return subscription_plans
|
fields=[
|
||||||
|
"plan",
|
||||||
|
"qty",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
return subscription_plan
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
Reference in New Issue
Block a user