You cannot use return in server script… the output has to be assigned to data
Your code is working in System Console… so it should work in script report… use same code as before…
columns = [
"Project:Link/Project:150",
"Project Name::300",
"Budget Amount:Currency:150",
"TotWages:Currency:150",
]
rows = frappe.db.sql(""",
SELECT
b.project,
p.project_name,
ba.budget_amount,
att.TotWages
FROM tabBudget b
INNER JOIN tabBudget Account ba ON ba.parent = b.name
INNER JOIN tabProject p ON p.name = b.project
LEFT JOIN (
SELECT
sda.project,
SUM(sda.hourly_rate * sda.total_hours) AS TotWages
FROM tabSite Daily Attendance sda
WHERE sda.docstatus = 1
GROUP BY sda.project
) att ON att.project = b.project
WHERE ba.account = 'Wages - VE';
""", as_dict=True)
data = (columns, rows)
the other option is to define columns in the UI and in py do result = [..]
. refer this