12345678910111213141516171819202122232425262728293031323334353637383940 |
- $PBExportHeader$f_rst_dept_sub_bbalc.srf
- global type f_rst_dept_sub_bbalc from function_object
- end type
- forward prototypes
- global function decimal f_rst_dept_sub_bbalc (long arg_deptid, string arg_subid, long arg_cmonth, integer arg_postflag)
- end prototypes
- global function decimal f_rst_dept_sub_bbalc (long arg_deptid, string arg_subid, long arg_cmonth, integer arg_postflag);//部门科目期初数
- //1.计算初始化数
- //2.计算期间发生数
- decimal rst_bbalc,init_bbalc,ins_bbalc
- //1.
- select uv_dept_init.balance into :init_bbalc from uv_dept_init
- where uv_dept_init.accsetid=:sys_accsetid
- and uv_dept_init.deptid=:arg_deptid
- and uv_dept_init.subid=:arg_subid;
- if sqlca.sqlcode<>0 or isnull(init_bbalc) then
- init_bbalc=0.00
- end if
- //2.
- select sum(uv_dept_bala.debit)-sum(uv_dept_bala.credit) into :ins_bbalc from uv_dept_bala
- where uv_dept_bala.accsetid=:sys_accsetid
- and ( uv_dept_bala.subaccsetid=:sys_subaccsetid or :sys_subaccsetid = -1)
- and uv_dept_bala.deptid=:arg_deptid
- and uv_dept_bala.subid=:arg_subid
- and uv_dept_bala.cmonth < :arg_cmonth
- and ( uv_dept_bala.postflag=:arg_postflag or :arg_postflag = -1) ;
- if sqlca.sqlcode<>0 or isnull(ins_bbalc) then
- ins_bbalc=0.00
- end if
- rst_bbalc=init_bbalc + ins_bbalc
- return rst_bbalc
- end function
|