123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- $PBExportHeader$uo_asset_clear.sru
- forward
- global type uo_asset_clear from nonvisualobject
- end type
- type s_astclear from structure within uo_asset_clear
- end type
- end forward
- type s_astclear from structure
- long assetcardid
- long incrdecid
- decimal {5} earing
- decimal {5} payout
- string dscrp
- datetime cleardate
- end type
- global type uo_asset_clear from nonvisualobject
- end type
- global uo_asset_clear uo_asset_clear
- type variables
- public protectedwrite long accsetid
- public protectedwrite long astclearid
- public protectedwrite datetime opdate
- public protectedwrite string opemp
- datetime billdate//清理日期
- string memo//清理原因
- string relcode
- string dscrp //摘要
- string othersubid //对方科目
- long credid
- private:
- s_astclear astclearmx[]
- long it_mxbt=0
- BOOLEAN IT_NEWBEGIN=FALSE //新建标志
- BOOLEAN IT_UPDATEBEGIN=FALSE//修改标志
- end variables
- forward prototypes
- public function integer newbegin ()
- public function integer p_reset ()
- public function integer getinfo (long arg_astclearid, ref string arg_msg)
- public function integer del (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_clearmx ()
- public function integer save (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_getinfo (long arg_astclearid, ref string arg_msg)
- public function integer updatebegin (long arg_astclearid, string arg_msg)
- public function integer acceptmx (long arg_assetcardid, long arg_incrdecid, decimal arg_earing, decimal arg_payout, ref string arg_msg, string arg_dscrp)
- end prototypes
- public function integer newbegin ();//newbegin()
- //从置对象,准备建立新凭证
- //0 fail 1 success
- LONG RSLT=1
- p_reset()
- it_newbegin=TRUE
- it_updatebegin=FALSE
- IF RSLT=0 THEN p_reset()
- return RSLT
- end function
- public function integer p_reset ();//INT p_RESET()
- //清除对象
- accsetid = 0
- astclearid = 0
- dscrp = ''
- memo = ''
- relcode = ''
- othersubid = ''
- credid = 0
- it_newbegin=FALSE
- it_updatebegin=FALSE
- p_clearmx()
- RETURN 1
- end function
- public function integer getinfo (long arg_astclearid, ref string arg_msg);//取固定资产清理信息
- Int rslt = 1
- Long i = 1,no_mxcheck = 0
- IF arg_astclearid <= 0 THEN
- rslt = 0
- arg_msg = '固定资产清理ID错误'
- GOTO ext
- END IF
- rslt = p_getinfo(arg_astclearid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- DECLARE cur_astclearmx CURSOR FOR
- SELECT cw_astclear.assetcardid,
- cw_astclear.incrdecid,
- cw_astclear.earing,
- cw_astclear.payout,
- cw_astclear.dscrp,
- cw_astclear.cleardate
- FROM cw_astclear
- WHERE cw_astclear.astclearid = :arg_astclearid
- AND cw_astclear.accsetid = :sys_accsetid;
-
- OPEN cur_astclearmx;
- FETCH cur_astclearmx INTO :astclearmx[i].assetcardid,:astclearmx[i].incrdecid,
- :astclearmx[i].earing,:astclearmx[i].payout,:astclearmx[i].dscrp,:astclearmx[i].cleardate;
-
- DO WHILE sqlca.SQLCode = 0
- i++
- FETCH cur_astclearmx INTO :astclearmx[i].assetcardid,:astclearmx[i].incrdecid,
- :astclearmx[i].earing,:astclearmx[i].payout,:astclearmx[i].dscrp,:astclearmx[i].cleardate;
- LOOP
- CLOSE cur_astclearmx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM cw_astclear
- WHERE cw_astclear.astclearid = :arg_astclearid
- AND cw_astclear.accsetid = :sys_accsetid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,单据明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,资产减少单明细"
- GOTO ext
- END IF
- astclearid = arg_astclearid
- accsetid = sys_accsetid
- it_mxbt = i - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer del (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- IF getinfo(arg_astclearid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM cw_astclear
- WHERE cw_astclear.astclearid = :arg_astclearid
- AND cw_astclear.accsetid = :sys_accsetid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除固定资产清理明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM cw_astclear_bill
- WHERE cw_astclear_bill.astclearid = :arg_astclearid
- AND cw_astclear_bill.accsetid = :sys_accsetid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除固定资产清理操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- IF rslt = 0 THEN
- ROLLBACK;
- p_reset()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- ext:
- RETURN (rslt)
- end function
- public function integer p_clearmx ();it_mxbt=0
- return 1
- end function
- public function integer save (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0
- Long ls_astclearid,i
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arG_MSG = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF IsNull(memo) THEN memo = ''
- IF IsNull(othersubid) THEN othersubid = ''
- IF IsNull(relcode) THEN relcode = ''
- IF IsNull(credid) THEN credid = 0
- IF billdate < DateTime(1900-01-01,Now()) THEN
- rslt = 0
- arG_MSG = '不合理减少日期!'
- GOTO ext
- END IF
- IF billdate < DateTime(f_rst_mon_1st(1,sys_curyearmon)) THEN
- arG_MSG = '减少日期不能在当前会计期间之前!'
- rslt = 0
- GOTO ext
- END IF
- IF billdate > DateTime(f_rst_mon_1st(3,sys_curyearmon)) THEN
- arG_MSG = '减少日期不能在当前会计期间之后!'
- rslt = 0
- GOTO ext
- END IF
- IF astclearid = 0 THEN //新建
- ls_astclearid = arg_astclearid
- IF ls_astclearid = 0 THEN
- ls_astclearid = f_sys_scidentity(sys_accsetid,"cw_astclear_bill","astclearid",arG_MSG,TRUE,id_sqlca)
- IF ls_astclearid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- INSERT INTO cw_astclear_bill (
- accsetid,
- astclearid,
- billdate,
- relcode,
- memo,
- dscrp,
- othersubid,
- credid)
- VALUES ( :sys_accsetid,
- :ls_astclearid,
- :billdate,
- :relcode,
- :memo,
- :dscrp,
- :othersubid,
- :credid) ;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建固定资产清理操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO cw_astclear (
- accsetid,
- astclearid,
- assetcardid,
- incrdecid,
- earing,
- payout,
- dscrp,
- cleardate)
- VALUES ( :sys_accsetid,
- :ls_astclearid,
- :astclearmx[i].assetcardid,
- :astclearmx[i].incrdecid,
- :astclearmx[i].earing,
- :astclearmx[i].payout,
- :astclearmx[i].dscrp,
- :astclearmx[i].cleardate) ;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建固定资产清理明细操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- astclearid = ls_astclearid
-
- ELSE //////////////////////////////////////////////////更新
- UPDATE cw_astclear_bill
- SET memo = :memo,
- billdate = :billdate,
- credid = :credid,
- dscrp = :dscrp,
- relcode = :relcode,
- othersubid = :othersubid
- WHERE cw_astclear_bill.accsetid = :sys_accsetid
- AND cw_astclear_bill.astclearid = :astclearid ;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致更新固定资产清理操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM cw_astclear
- WHERE cw_astclear.accsetid = :sys_accsetid
- AND cw_astclear.astclearid = :astclearid ;
-
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除旧有明细操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO cw_astclear (
- accsetid,
- astclearid,
- assetcardid,
- incrdecid,
- earing,
- payout,
- dscrp,
- cleardate)
- VALUES ( :sys_accsetid,
- :astclearid,
- :astclearmx[i].assetcardid,
- :astclearmx[i].incrdecid,
- :astclearmx[i].earing,
- :astclearmx[i].payout,
- :astclearmx[i].dscrp,
- :astclearmx[i].cleardate) ;
- IF SQLCA.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建固定资产清理明细操作失败"+"~n"+SQLCA.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- astclearid = 0
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN(rslt)
- end function
- public function integer p_getinfo (long arg_astclearid, ref string arg_msg);INT rslt=1
- IF arg_astclearid<=0 THEN
- rslt=0
- arG_MSG="非法资产清理单唯一码"
- goto ext
- end if
-
- SELECT cw_astclear_bill.billdate,
- cw_astclear_bill.relcode,
- cw_astclear_bill.dscrp,
- cw_astclear_bill.memo,
- cw_astclear_bill.credid,
- cw_astclear_bill.othersubid
- INTO :billdate,
- :relcode,
- :dscrp,
- :memo,
- :credid,
- :othersubid
- FROM cw_astclear_bill
- WHERE cw_astclear_bill.astclearid = :arg_astclearid
- and cw_astclear_bill.accsetid =:sys_accsetid;
-
- if sqlca.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误资产清理唯一码),资产清理单"+sqlca.sqlerrtext
- goto ext
- end if
- astclearid = arg_astclearid
- accsetid = sys_accsetid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer updatebegin (long arg_astclearid, string arg_msg);Int rslt = 1
- IF getinfo(arg_astclearid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- astclearid = arg_astclearid
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_RESET()
- RETURN rslt
- end function
- public function integer acceptmx (long arg_assetcardid, long arg_incrdecid, decimal arg_earing, decimal arg_payout, ref string arg_msg, string arg_dscrp);Int rslt = 1
- Long cnt = 0
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- IF IsNull(arg_assetcardid) THEN arg_assetcardid = 0
- IF IsNull(arg_incrdecid) THEN arg_incrdecid = 0
- IF IsNull(arg_earing) THEN arg_earing = 0
- IF IsNull(arg_payout) THEN arg_payout = 0
- IF IsNull(arg_dscrp) THEN arg_dscrp = ''
- IF arg_assetcardid = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt FROM cw_assetcard
- WHERE cw_assetcard.accsetid = :sys_accsetid
- AND cw_assetcard.assetcardid = :arg_assetcardid
- AND cw_assetcard.clearflag = 0;
- IF sqlca.SQLCode = -1 THEN
- rslt = 0
- arg_msg = '查询固定资产失败'
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '该帐套已经不存存在该固定资产,请检查'
- GOTO ext
- END IF
- IF arg_incrdecid = 0 THEN
- rslt = 0
- arg_msg = '请选择减少方式!'
- GOTO ext
- END IF
- it_mxbt++
- astclearmx[it_mxbt].assetcardid = arg_assetcardid
- astclearmx[it_mxbt].incrdecid = arg_incrdecid
- astclearmx[it_mxbt].earing = arg_earing
- astclearmx[it_mxbt].payout = arg_payout
- astclearmx[it_mxbt].dscrp = arg_dscrp
- astclearmx[it_mxbt].cleardate = billdate
- ext:
- RETURN rslt
- end function
- on uo_asset_clear.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_asset_clear.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|