refactor(sales_invoice): replace sql with qb in get_mode_of_payments_… (#55376)

This commit is contained in:
Loic Oberle
2026-06-03 08:57:08 +02:00
committed by GitHub
parent 86726bbd85
commit a2a2e1020b

View File

@@ -3161,24 +3161,26 @@ def get_all_mode_of_payments(doc):
def get_mode_of_payments_info(mode_of_payments, company): def get_mode_of_payments_info(mode_of_payments, company):
data = frappe.db.sql( ModeOfPaymentAccount = frappe.qb.DocType("Mode of Payment Account")
""" ModeOfPayment = frappe.qb.DocType("Mode of Payment")
select
mpa.default_account, mpa.parent as mop, mp.type as type query = (
from frappe.qb.from_(ModeOfPaymentAccount)
`tabMode of Payment Account` mpa,`tabMode of Payment` mp .join(ModeOfPayment)
where .on(ModeOfPaymentAccount.parent == ModeOfPayment.name)
mpa.parent = mp.name and .select(
mpa.company = %s and ModeOfPaymentAccount.default_account,
mp.enabled = 1 and ModeOfPaymentAccount.parent.as_("mop"),
mp.name in %s ModeOfPayment.type.as_("type"),
group by )
mp.name .where(ModeOfPaymentAccount.company == company)
""", .where(ModeOfPayment.enabled == 1)
(company, mode_of_payments), .where(ModeOfPayment.name.isin(mode_of_payments))
as_dict=1, .groupby(ModeOfPayment.name)
) )
data = query.run(as_dict=1)
return {row.get("mop"): row for row in data} return {row.get("mop"): row for row in data}