123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690 |
- $PBExportHeader$uo_asset.sru
- forward
- global type uo_asset from nonvisualobject
- end type
- type s_attachastmx from structure within uo_asset
- end type
- end forward
- type s_attachastmx from structure
- string attachastname
- string spectype
- string unit
- decimal {0} amount
- decimal {0} sumcount
- datetime startdate
- string memo
- end type
- global type uo_asset from nonvisualobject
- end type
- global uo_asset uo_asset
- type variables
- Long assetcardid //固定资产自动增量ID
- String assetcardcode //固定资产编号
- String assetcardname//固定资产名称
- String spectype//规格型号
- Long assetypeid//固定资产类别
- Long deptid//所属部门
- Long incrdecrid//增减方式
- String Location//存放位置
- Long usedtypeid//使用状况
- Long deprediateid//折旧方法
- DateTime startdate//入帐日期
- Long workload//预计使用月份
- Long usedall//已计提月份
- String unit//工作量单位
- Decimal rawvalue//入帐原值
- Decimal usedvalue//累计折旧
- Decimal remainrate//预计残值率
- Decimal remainvalue//预计剩残值
- Decimal deprrate//月折旧率
- Decimal deprvalue//月折旧额
- String subid //对应折旧科目
- Int initflag //初始化标记
- String othersubid //对方科目
- String dscrp //摘要
- String assetsubid //固定资产会计科目
- String deprsubid //累计折旧会计科目
- Long credid
- PRIVATE:
- S_attachastmx attachastmx[] //明细结构数组
- Long it_MXBT = 0 //明细结构数组末指针
- Boolean IT_NEWBEGIN = FALSE //新建标志
- Boolean IT_UPDATEBEGIN = FALSE//修改标志
- end variables
- forward prototypes
- public function integer newbegin ()
- public function integer p_clearmx ()
- public function integer p_reset ()
- public function integer acceptmx (string arg_attachastname, string arg_spectype, string arg_unit, decimal arg_amount, decimal arg_sumcount, datetime arg_startdate, string arg_memo, ref string arg_msg)
- public function integer getinfo (long arg_assetcardid, ref string arg_msg)
- public function integer updatebegin (long arg_assetcardid, string arg_msg)
- public function integer del (long arg_assetcardid, ref string arg_msg, boolean arg_ifcommit)
- public function integer save (long arg_assetcardid, ref string arg_msg, boolean arg_ifcommit)
- public function integer check_data (ref string arg_msg)
- public function integer update_clearflag (long arg_assetcardid, int arg_flag, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer newbegin ();//newbegin()
- //从置对象,准备建立新凭证
- //0 fail 1 success
- LONG RSLT=1,CNT=0
- p_reset()
- it_newbegin=TRUE
- it_updatebegin=FALSE
- IF RSLT=0 THEN p_reset()
- return RSLT
- end function
- public function integer p_clearmx ();//INT p_clearmx()
- //清除明细
- it_mxbt=0
- RETURN 1
- end function
- public function integer p_reset ();//INT p_RESET()
- //清除对象及其明细
- assetcardid=0
- it_newbegin=FALSE
- it_updatebegin=FALSE
- //清除明细
- P_CLEARMX()
- RETURN 1
- end function
- public function integer acceptmx (string arg_attachastname, string arg_spectype, string arg_unit, decimal arg_amount, decimal arg_sumcount, datetime arg_startdate, string arg_memo, ref string arg_msg);//acceptmx(arg_attachastname,arg_spectype,arg_unit,arg_amount,
- // arg_sumcount,arg_startdate,arg_memo,arg_msg)
- //RETURN 0 fail 1 success
- // 函数增加固定资产附加设备
- long rslt=1,cnt=0
- IF it_newbegin=FALSE AND it_updatebegin=FALSE THEN
- rslt=0
- arG_MSG="非编辑状态不可以使用,操作取消"
- goto ext
- END IF
- //清除空值
- IF ISNULL(arg_attachastname) THEN arg_attachastname=''
- IF ISNULL(arg_spectype) THEN arg_spectype=''
- IF ISNULL(arg_unit) THEN arg_unit=''
- IF ISNULL(arg_amount) THEN arg_amount=0
- IF ISNULL(arg_sumcount)then arg_sumcount=0
- IF ISNULL(arg_memo)THEN arg_memo=''
- if arg_attachastname='' then
- rslt=0
- arg_msg='请输入附属设备名称'
- goto ext
- end if
- if arg_amount=0 then
- rslt=0
- arg_msg='请输入附属设备数量'
- goto ext
- end if
- if arg_amount=0 then
- rslt=0
- arg_msg='请输入附属设备金额'
- goto ext
- end if
- //写入内容
- it_mxbt++
- attachastmx[it_mxbt].attachastname=arg_attachastname
- attachastmx[it_mxbt].spectype=arg_spectype
- attachastmx[it_mxbt].unit=arg_unit
- attachastmx[it_mxbt].amount=arg_amount
- attachastmx[it_mxbt].sumcount=arg_sumcount
- attachastmx[it_mxbt].startdate=arg_startdate
- attachastmx[it_mxbt].memo=arg_memo
- ext:
- IF rslt=0 THEN p_clearmx()
- return(rslt)
- end function
- public function integer getinfo (long arg_assetcardid, ref string arg_msg);//取固定资产信息
- int rslt=1
- IF arg_assetcardid<=0 THEN
- rslt=0
- assetcardid=0
- arg_msg='固定资产ID错误'
- goto ext
- end if
- SELECT cw_assetcard.assetcardcode,
- cw_assetcard.assetcardname,
- cw_assetcard.spectype,
- cw_assetcard.assetypeid,
- cw_assetcard.deptid,
- cw_assetcard.incrdecrid,
- cw_assetcard.location,
- cw_assetcard.usedtypeid,
- cw_assetcard.deprediateid,
- cw_assetcard.startdate,
- cw_assetcard.workload,
- cw_assetcard.usedall,
- cw_assetcard.unit,
- cw_assetcard.rawvalue,
- cw_assetcard.usedvalue,
- cw_assetcard.remainrate,
- cw_assetcard.remainvalue,
- cw_assetcard.deprrate,
- cw_assetcard.deprvalue,
- cw_assetcard.subid,
- cw_assetcard.initflag,
- cw_assetcard.othersubid,
- cw_assetcard.assetsubid,
- cw_assetcard.dscrp
- INTO :assetcardcode,
- :assetcardname,
- :spectype,
- :assetypeid,
- :deptid,
- :incrdecrid,
- :location,
- :usedtypeid,
- :deprediateid,
- :startdate,
- :workload,
- :usedall,
- :unit,
- :rawvalue,
- :usedvalue,
- :remainrate,
- :remainvalue,
- :deprrate,
- :deprvalue,
- :subid,
- :initflag,
- :othersubid,
- :assetsubid,
- :dscrp
- FROM cw_assetcard
- WHERE cw_assetcard.assetcardid = :arg_assetcardid
- and cw_assetcard.accsetid=:sys_accsetid;
-
- if sqlca.sqlcode<>0 then
- rslt=0
- ARG_MSG='查询数据操作失败,固定资产'
- goto ext
- end if
- it_newbegin=false
- it_updatebegin=false
- ext:
- return rslt
- end function
- public function integer updatebegin (long arg_assetcardid, string arg_msg);//UPDATEbegin(long arg_ssetcardid,ref string arg_msg)
- //从置对象,准备更新固定资产
- //0 fail 1 success
- int rslt=1
- if getinfo(arg_assetcardid,arg_msg)=0 then
- rslt=0
- goto ext
- end if
- //if checkflag=1 then
- // rslt=0
- // ARG_MSG='凭证已经过审核,不可以修改'
- // goto ext
- //end if
- assetcardid=arg_assetcardid
- //if checkflag=0 then p_CLEARMX()
- it_newbegin=FALSE
- it_updatebegin=TRUE
- ext:
- IF rslt=0 THEN p_RESET()
- return rslt
- end function
- public function integer del (long arg_assetcardid, ref string arg_msg, boolean arg_ifcommit);//del(arg_assetcardid,ref arg_msg,arg_ifcommit)
- //如果固定资产还没有对应凭证和还没有计提折旧则删除及其附属设备
- //0 FAIL, 1 SUCCESS
- Int rslt = 1
- IF getinfo(arg_assetcardid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- DELETE FROM cw_assetcard
- WHERE cw_assetcard.assetcardid = :arg_assetcardid
- AND cw_assetcard.accsetid = :sys_accsetid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除固定资产操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM cw_attachast
- WHERE cw_attachast.assetcardid = :arg_assetcardid
- AND cw_attachast.accsetid = :sys_accsetid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除固定资产附属设备操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- DELETE FROM cw_astbalance
- WHERE cw_astbalance.assetcardid = :arg_assetcardid
- AND cw_astbalance.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 save (long arg_assetcardid, ref string arg_msg, boolean arg_ifcommit);//save(ref string arg_msg,boolean arg_ifcommit)
- // 新建(assetcardid=0)\更新(assetcardid>0)
- //0 fail 1 success
- //
- // 函数执行固定资产操作
- // 函数在表 cw_assetcard、cw_attachast 记帐
- // 1 检查固定资产信息合法性
- // 2 新建-新建固定资产\读取固定资产唯一码\插入明细
- // 2 修改-更新固定资产\删除旧明细\插入明细
- // 3 提交,修改状态标志
- Integer rslt = 1,cnt = 0,i
- DateTime server_datetime
- Long ls_newid
- String errmsg = ''
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arG_MSG = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF check_data(arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF it_newbegin THEN
- cnt = 0
- SELECT count(assetcardcode) INTO :cnt FROM cw_assetcard
- WHERE cw_assetcard.accsetid = :sys_accsetid
- AND cw_assetcard.assetcardcode = :assetcardcode;
- 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
- END IF
- //////////////////////////////////////////////////开始区分:新建/更新 处理
- IF assetcardid = 0 THEN //新建
- ls_newid = arg_assetcardid
-
- IF ls_newid = 0 THEN
- ls_newid = f_sys_scidentity(sys_accsetid,"cw_assetcard","assetcardid",arG_MSG,TRUE,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
-
- INSERT INTO cw_assetcard (
- accsetid,
- assetcardid,
- assetcardcode,
- assetcardname,
- spectype,
- assetypeid,
- deptid,
- incrdecrid,
- location,
- usedtypeid,
- deprediateid,
- startdate,
- workload,
- usedall,
- unit,
- rawvalue,
- usedvalue,
- remainrate,
- remainvalue,
- deprrate,
- deprvalue,
- subid,
- initflag,
- dscrp,
- othersubid,
- assetsubid,
- deprsubid,
- credid)
- VALUES ( :sys_accsetid,
- :ls_newid,
- :assetcardcode,
- :assetcardname,
- :spectype,
- :assetypeid,
- :deptid,
- :incrdecrid,
- :Location,
- :usedtypeid,
- :deprediateid,
- :startdate,
- :workload,
- :usedall,
- :unit,
- :rawvalue,
- :usedvalue,
- :remainrate,
- :remainvalue,
- :deprrate,
- :deprvalue,
- :subid,
- :initflag,
- :dscrp,
- :othersubid,
- :assetsubid,
- :deprsubid,
- :credid) ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建固定资产操作失败"+"~n"+sqlca.SQLErrText
- ROLLBACK ;
- GOTO ext
- END IF
-
- IF it_mxbt > 0 THEN
- FOR i = 1 TO it_mxbt
- INSERT INTO cw_attachast
- ( accsetid,
- assetcardid,
- attachastname,
- spectype,
- unit,
- amount,
- sumcount,
- startdate)
- VALUES (:sys_accsetid,
- :ls_newid,
- :attachastmx[i].attachastname,
- :attachastmx[i].spectype,
- :attachastmx[i].unit,
- :attachastmx[i].amount,
- :attachastmx[i].sumcount,
- :attachastmx[i].startdate);
- IF sqlca.SQLCode <> 0 THEN
- assetcardid = 0 //还原outWAREID
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建凭证明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- assetcardid = ls_newid
-
- ELSE //////////////////////////////////////////////////更新
- UPDATE cw_assetcard
- SET assetcardcode = :assetcardcode,
- assetcardname = :assetcardname,
- spectype = :spectype,
- assetypeid = :assetypeid,
- deptid = :deptid,
- incrdecrid = :incrdecrid,
- location = :Location,
- usedtypeid = :usedtypeid,
- deprediateid = :deprediateid,
- startdate = :startdate,
- workload = :workload,
- usedall = :usedall,
- unit = :unit,
- rawvalue = :rawvalue,
- usedvalue = :usedvalue,
- remainrate = :remainrate,
- remainvalue = :remainvalue,
- deprrate = :deprrate,
- deprvalue = :deprvalue,
- subid = :subid,
- dscrp = :dscrp,
- othersubid = :othersubid,
- assetsubid = :assetsubid,
- deprsubid = :deprsubid,
- credid = :credid
- WHERE cw_assetcard.accsetid = :sys_accsetid
- AND cw_assetcard.assetcardid = :assetcardid ;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "因网络或其它原因导致更新固定资产操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- //删除原有明细
- DELETE FROM cw_attachast
- Where cw_attachast.accsetid = :sys_accsetid AND assetcardid = :assetcardid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除旧有固定资产附属设备操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF it_mxbt > 0 THEN
- FOR i = 1 TO it_mxbt
- INSERT INTO cw_attachast
- ( accsetid,
- assetcardid,
- attachastname,
- spectype,
- unit,
- amount,
- sumcount,
- startdate)
- VALUES (:sys_accsetid,
- :assetcardid,
- :attachastmx[i].attachastname,
- :attachastmx[i].spectype,
- :attachastmx[i].unit,
- :attachastmx[i].amount,
- :attachastmx[i].sumcount,
- :attachastmx[i].startdate);
- IF sqlca.SQLCode <> 0 THEN
- assetcardid = 0 //还原outWAREID
- rslt = 0
- arG_MSG = "因网络或其它原因导致新建凭证明细操作失败"+"~n"+sqlca.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- assetcardid = 0
- p_clearmx()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN(rslt)
- end function
- public function integer check_data (ref string arg_msg);//校验数据
- //check_data(arg_msg)
- Int rslt = 1
- IF IsNull(assetcardcode) THEN assetcardcode = ''
- IF IsNull(assetcardname) THEN assetcardname = ''
- IF IsNull(spectype) THEN spectype = ''
- IF IsNull(assetypeid) THEN assetypeid = 0
- IF IsNull(deptid) THEN deptid = 0
- IF IsNull(incrdecrid) THEN incrdecrid = 0
- IF IsNull(Location) THEN Location = ''
- IF IsNull(usedtypeid) THEN usedtypeid = 0
- IF IsNull(deprediateid) THEN deprediateid = 0
- IF IsNull(workload) THEN workload = 0
- IF IsNull(usedall) THEN usedall = 0
- IF IsNull(unit) THEN unit = ''
- IF IsNull(rawvalue) THEN rawvalue = 0
- IF IsNull(usedvalue) THEN usedvalue = 0
- IF IsNull(remainrate) THEN remainrate = 0
- IF IsNull(remainvalue) THEN remainvalue = 0
- IF IsNull(deprrate) THEN deprrate = 0
- IF IsNull(deprvalue) THEN deprvalue = 0
- IF IsNull(subid) THEN subid = ''
- IF Trim(assetcardcode) = '' THEN
- rslt = 0
- arg_msg = '请输入固定资产编号!'
- GOTO ext
- END IF
- IF Trim(assetcardname) = '' THEN
- rslt = 0
- arg_msg = '请输入固定资产名称!'
- GOTO ext
- END IF
- IF usedtypeid = 0 THEN
- rslt = 0
- arg_msg = '请选择使用状况!'
- GOTO ext
- END IF
- IF rawvalue <= 0 THEN
- rslt = 0
- arg_msg = '入帐原值必须大于0!'
- GOTO ext
- END IF
- IF startdate < DateTime(1900-01-01,Now()) THEN
- rslt = 0
- arg_msg = '不合理入帐日期!'
- GOTO ext
- END IF
- IF sys_accsetbegin THEN
- IF startdate < DateTime(f_rst_mon_1st(1,sys_curyearmon)) THEN
- arg_msg = '入帐日期不能在当前会计期间之前!'
- rslt = 0
- GOTO ext
- END IF
-
- IF startdate > DateTime(f_rst_mon_1st(3,sys_curyearmon)) THEN
- arg_msg = '入帐日期不能在当前会计期间之后!'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF startdate >= DateTime(f_rst_mon_1st(1,sys_startyearmon)) THEN
- arg_msg = '入帐日期不能在启用帐套期间之后或相同的期间!'
- rslt = 0
- GOTO ext
- END IF
- END IF
- //if deprediateid=0 then
- // arg_msg='请选择折旧方法!'
- // goto ext
- //end if
- IF workload <= 0 THEN
- rslt = 0
- arg_msg = '预计使用月份或工作总量必须大于0!'
- GOTO ext
- END IF
- IF Trim(subid) = '' THEN
- rslt = 0
- arg_msg = '请输入对应折旧科目!'
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
- public function integer update_clearflag (long arg_assetcardid, int arg_flag, ref string arg_msg, boolean arg_ifcommit);//更新固定资产清理标记
- Int rslt = 1
- UPDATE cw_assetcard
- Set clearflag = :arg_flag
- Where accsetid = :sys_accsetid
- AND assetcardid = :arg_assetcardid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新固定资产清理标记失败'
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- on uo_asset.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_asset.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|