Skip to content

Instantly share code, notes, and snippets.

@ranafaraz
Created March 11, 2021 20:04
Show Gist options
  • Save ranafaraz/c26ef1edb4ccf14ec0b3e0a831e8072c to your computer and use it in GitHub Desktop.
Save ranafaraz/c26ef1edb4ccf14ec0b3e0a831e8072c to your computer and use it in GitHub Desktop.
This query will get the allocated budget for
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment