f_rst_dept_sub_bbalc.srf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. $PBExportHeader$f_rst_dept_sub_bbalc.srf
  2. global type f_rst_dept_sub_bbalc from function_object
  3. end type
  4. forward prototypes
  5. global function decimal f_rst_dept_sub_bbalc (long arg_deptid, string arg_subid, long arg_cmonth, integer arg_postflag)
  6. end prototypes
  7. global function decimal f_rst_dept_sub_bbalc (long arg_deptid, string arg_subid, long arg_cmonth, integer arg_postflag);//部门科目期初数
  8. //1.计算初始化数
  9. //2.计算期间发生数
  10. decimal rst_bbalc,init_bbalc,ins_bbalc
  11. //1.
  12. select uv_dept_init.balance into :init_bbalc from uv_dept_init
  13. where uv_dept_init.accsetid=:sys_accsetid
  14. and uv_dept_init.deptid=:arg_deptid
  15. and uv_dept_init.subid=:arg_subid;
  16. if sqlca.sqlcode<>0 or isnull(init_bbalc) then
  17. init_bbalc=0.00
  18. end if
  19. //2.
  20. select sum(uv_dept_bala.debit)-sum(uv_dept_bala.credit) into :ins_bbalc from uv_dept_bala
  21. where uv_dept_bala.accsetid=:sys_accsetid
  22. and ( uv_dept_bala.subaccsetid=:sys_subaccsetid or :sys_subaccsetid = -1)
  23. and uv_dept_bala.deptid=:arg_deptid
  24. and uv_dept_bala.subid=:arg_subid
  25. and uv_dept_bala.cmonth < :arg_cmonth
  26. and ( uv_dept_bala.postflag=:arg_postflag or :arg_postflag = -1) ;
  27. if sqlca.sqlcode<>0 or isnull(ins_bbalc) then
  28. ins_bbalc=0.00
  29. end if
  30. rst_bbalc=init_bbalc + ins_bbalc
  31. return rst_bbalc
  32. end function