f_rst_dept_bbala.srf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $PBExportHeader$f_rst_dept_bbala.srf
  2. global type f_rst_dept_bbala from function_object
  3. end type
  4. forward prototypes
  5. global function decimal f_rst_dept_bbala (long arg_accsetid, long arg_cmonth, string arg_subid, long arg_deptid)
  6. end prototypes
  7. global function decimal f_rst_dept_bbala (long arg_accsetid, long arg_cmonth, string arg_subid, long arg_deptid);//返回部门总帐期初数
  8. decimal rst_dept_bbala
  9. decimal init_dept_bala,cur_dept_bala
  10. SELECT isnull(sum(uv_dept_bala.credit),0) - isnull(sum(uv_dept_bala.debit),0)
  11. into :cur_dept_bala
  12. FROM uv_dept_bala
  13. WHERE ( uv_dept_bala.accsetid = :arg_accsetid ) AND
  14. ( uv_dept_bala.cmonth < :arg_cmonth ) AND
  15. ( uv_dept_bala.subid = :arg_subid ) and
  16. ( uv_dept_bala.deptid = :arg_deptid )
  17. GROUP BY uv_dept_bala.cmonth,
  18. uv_dept_bala.subid,
  19. uv_dept_bala.deptid ;
  20. SELECT isnull(uv_dept_init.balance,0)
  21. into :init_dept_bala
  22. FROM uv_dept_init
  23. WHERE ( uv_dept_init.accsetid = :arg_accsetid ) AND
  24. ( uv_dept_init.subid = :arg_subid ) and
  25. ( uv_dept_init.deptid = :arg_deptid ) ;
  26. if isnull(cur_dept_bala) then cur_dept_bala=0
  27. if isnull(init_dept_bala) then init_dept_bala=0
  28. rst_dept_bbala=cur_dept_bala + init_dept_bala
  29. return rst_dept_bbala
  30. end function