/*	Date Updated:	09/21/2005
	Updated by:		Loren Cook
	Description:	Selects detail Actual Cash Balances.  Enter Period and Budget Purpose below.*/
ACCEPT Period PROMPT 'Enter the PERIOD (Format: Mon-YY or June-30-YY):'
ACCEPT Budget_Purpose PROMPT 'Enter the BUDGET PURPOSE (Format: ######)'

select
  segment1 as Fund,
  --segment2 as Unit,
  segment3 as BP,
  --segment4 as DA1,
  --segment5 as DA2,
  --segment6 as Fn,
  --segment7 as NA,
  --segment8 as Obj,
  --segment9 as SOF,
  --segment10 as FFY,
  --segment11 as IA,
  --segment12 as Future,
  gl_balances.period_name as Period,
  sum(gl_balances.begin_balance_DR - gl_balances.begin_balance_CR
   + gl_balances.period_net_DR - gl_balances.period_net_CR) as Balance
  --gl_balances.actual_flag as Flag

from  gl.gl_balances, gl.gl_code_combinations

WHERE gl_balances.code_combination_id = gl_code_combinations.code_combination_id

  and  gl.gl_balances.period_name = '&Period'

  and  gl_balances.actual_flag = 'A'

  and gl_code_combinations.segment1 <> '2150000'

  and gl_code_combinations.segment3 = '&Budget_Purpose'

  and  gl_code_combinations.segment7 between '11000' and '11999'

  and not(gl_balances.begin_balance_DR - gl_balances.begin_balance_CR
	+ gl_balances.period_net_DR - gl_balances.period_net_CR) = '0'

	and gl.gl_balances.ledger_id = '1'

group by segment1, segment3, gl_balances.period_name
order by segment3
