f_check_billdate.srf 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. $PBExportHeader$f_check_billdate.srf
  2. global type f_check_billdate from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_check_billdate (datetime arg_billdate)
  6. global function integer f_check_billdate (datetime arg_billdate, ref string arg_msg)
  7. end prototypes
  8. global function integer f_check_billdate (datetime arg_billdate);int rslt = 1
  9. return rslt
  10. end function
  11. global function integer f_check_billdate (datetime arg_billdate, ref string arg_msg);Int rslt = 1
  12. Long li_cmonth,cnt
  13. IF Not sys_accsetbegin THEN
  14. rslt = 1
  15. GOTO ext
  16. END IF
  17. SELECT count(*) Into :cnt From cw_calendar;
  18. IF sqlca.SQLCode <> 0 THEN
  19. arg_msg = '查询会计日历失败,原因:'+sqlca.SQLErrText
  20. rslt = 0
  21. GOTO ext
  22. END IF
  23. IF cnt = 0 THEN
  24. rslt = 1
  25. GOTO ext
  26. END IF
  27. SELECT cmonth Into :li_cmonth From cw_calendar Where sdate <= :arg_billdate And dateadd(d, 1, edate) > :arg_billdate;
  28. IF sqlca.SQLCode <> 0 THEN
  29. arg_msg = '非法日期,不在本年会计期间范围内,请检查'
  30. rslt = 0
  31. GOTO ext
  32. END IF
  33. IF li_cmonth < sys_curyearmon THEN
  34. arg_msg = '日期所属会计期间会计已经结帐,不能在本期间内增加单据'
  35. rslt = 0
  36. GOTO ext
  37. END IF
  38. ext:
  39. RETURN rslt
  40. end function