refactor(postgres): port Share Ledger report 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-17 17:36:01 +05:30
parent 058be399c3
commit 1332ad7583

View File

@@ -62,15 +62,10 @@ def get_columns(filters):
def get_all_transfers(date, shareholder):
condition = " "
# if company:
# condition = 'AND company = %(company)s '
return frappe.db.sql(
f"""SELECT * FROM `tabShare Transfer`
WHERE ((DATE(date) <= %(date)s AND from_shareholder = %(shareholder)s {condition})
OR (DATE(date) <= %(date)s AND to_shareholder = %(shareholder)s {condition}))
AND docstatus = 1
ORDER BY date""",
{"date": date, "shareholder": shareholder},
as_dict=1,
return frappe.get_all(
"Share Transfer",
filters={"date": ["<=", date], "docstatus": 1},
or_filters=[["from_shareholder", "=", shareholder], ["to_shareholder", "=", shareholder]],
fields=["*"],
order_by="date",
)