SELECT
	SUM(f.amt) AS allocated_budget
FROM
	adempiere.gl_fund f
	INNER JOIN adempiere.gl_budget b ON (( b.gl_budget_id = f.gl_budget_id ))
	INNER JOIN adempiere.vwchart vwc ON (( vwc.c_elementvalue_id = f.c_elementvalue_id ))
WHERE
	f.isactive = 'Y'
	AND
	f.ad_client_id = 1000000
	AND
	b.isactive = 'Y'
	AND
	b.ad_client_id = 1000000
	AND
	b.isprimary = 'Y'
	AND
	b.budgetstatus = 'A'
	AND
	vwc.minorheadvalue = 'A01' -- Employee Related Expenses
	OR
	vwc.minorheadvalue = 'A02' -- Project Preinvestment Analysis
	OR
	vwc.minorheadvalue = 'A03' -- Operating Expenses
	OR
	vwc.minorheadvalue = 'A04' -- Employees' Retirement Benefits
	OR
	vwc.minorheadvalue = 'A06' -- Transfers
	
	