mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-05 13:24:47 +00:00
refactor(sales_invoice): replace sql with qb in get_mode_of_payments_… (#55376)
This commit is contained in:
@@ -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}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user