refactor(postgres): port payment_setup_certification query to the query builder

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mihir Kandoi
2026-06-19 21:21:13 +05:30
parent fbcec6e75f
commit be21f56771

View File

@@ -1,4 +1,5 @@
import frappe
from frappe.query_builder.functions import IfNull
no_cache = 1
@@ -12,13 +13,15 @@ def get_context(context):
def get_all_certifications_of_a_member():
"""Returns all certifications"""
all_certifications = []
all_certifications = frappe.db.sql(
""" select cc.name,cc.from_date,cc.to_date,ca.amount,ca.currency
from `tabCertified Consultant` cc
inner join `tabCertification Application` ca
on cc.certification_application = ca.name
where paid = 1 and email = %(user)s order by cc.to_date desc""",
{"user": frappe.session.user},
as_dict=True,
cc = frappe.qb.DocType("Certified Consultant")
ca = frappe.qb.DocType("Certification Application")
all_certifications = (
frappe.qb.from_(cc)
.inner_join(ca)
.on(cc.certification_application == ca.name)
.select(cc.name, cc.from_date, cc.to_date, ca.amount, ca.currency)
.where((cc.paid == 1) & (cc.email == frappe.session.user))
.orderby(IfNull(cc.to_date, "0001-01-01"), order=frappe.qb.desc)
.run(as_dict=True)
)
return all_certifications