123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958 |
- $PBExportHeader$uo_giveback.sru
- forward
- global type uo_giveback from nonvisualobject
- end type
- end forward
- global type uo_giveback from nonvisualobject
- end type
- global uo_giveback uo_giveback
- type variables
- PUBLIC PROTECTEDWRITE Long scid = 0 //分部id
- PUBLIC PROTECTEDWRITE Long givebackid //进仓单表自动增量id
- PUBLIC PROTECTEDWRITE String givebackcode //单据的唯一编号
- PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
- PUBLIC PROTECTEDWRITE String opemp //建立操作员
- PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动
- PUBLIC PROTECTEDWRITE String modemp //修改操作员
- PUBLIC PROTECTEDWRITE Int flag = 0 //仓库审核标志
- PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间
- PUBLIC PROTECTEDWRITE String auditingrep //审核操作员
- string relcode=''
- DateTime givebackdate
- String dscrp = '' //备注
- String assign_emp = '' //经手人
- Long cusid = 0 //客户id
- datetime startdate //开始日
- datetime enddate //结束日
- decimal givebackrate=0 //返利率
- decimal sumamt=0 //单据总金额
- long banktypeid=0 //结算方式
- long relint_3=0
- long moneyid=0
- dec mrate=0
- long itemid = 0
- Transaction commit_transaction //数据commit事务
- Boolean if_getid_ture = TRUE
- s_givebackmx givebackmx[] //明细结构数组
- Long it_mxbt = 0 //明细结构数组末指针
- Boolean it_newbegin = FALSE //新建标志
- Boolean it_updatebegin = FALSE //修改标志
- end variables
- forward prototypes
- public function integer p_clearmx ()
- public function integer p_reset ()
- public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg)
- public function integer newbegin (long arg_scid, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg)
- public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate)
- end prototypes
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- sumamt = 0
- return 1
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid=0
- givebackid=0
- givebackcode=''
- opemp=''
- modemp=''
- auditingrep=''
- flag=0
- assign_emp=''
- relcode=''
- dscrp=''
- cusid=0
- givebackrate=0
- sumamt=0
- it_newbegin=false
- it_updatebegin=false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- INT rslt=1
- IF arg_givebackid<=0 THEN
- rslt=0
- arG_MSG="非法返利单唯一码"
- goto ext
- end if
-
- SELECT givebackcode,
- cusid,
- givebackdate,
- startdate,
- enddate,
- givebackrate,
- sumamt,
- assign_emp,
- relcode,
- dscrp,
- flag,
- banktypeid,
- relint_3,
- moneyid,
- mrate,
- itemid
- INTO :givebackcode,
- :cusid,
- :givebackdate,
- :startdate,
- :enddate,
- :givebackrate,
- :sumamt,
- :assign_emp,
- :relcode,
- :dscrp,
- :flag,
- :banktypeid,
- :relint_3,
- :moneyid,
- :mrate,
- :itemid
- FROM u_giveback
- WHERE u_giveback.givebackid = :arg_givebackid
- and scid=:arg_scid using commit_transaction;
-
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误返利单唯一码),返利单"+commit_transaction.sqlerrtext
- goto ext
- end if
- givebackid = arg_givebackid
- scid = arg_scid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//getinfo(arg_scid,arg_givebackid,arg_msg)
- //0 失败 1成功
- int rslt = 1,i = 1,no_mxcheck = 0
- if arg_givebackid <= 0 then
- rslt = 0
- arg_msg = "非法返利单唯一码"
- goto ext
- end if
- rslt = p_getinfo(arg_scid,arg_givebackid,arg_msg)
- if rslt = 0 then goto ext
- //用游标读取明细
- declare cur_inwaermx cursor for
- SELECT givebackdate,
- relcode,
- printid,
- norebateamt,
- childsumamt,
- mxDscrp,
- outwareid
- from u_givebackmx
- where u_givebackmx.givebackid = :arg_givebackid and
- u_givebackmx.scid = :arg_scid using commit_transaction;
-
- open cur_inwaermx;
- fetch cur_inwaermx into :givebackmx[i].givebackdate,
- :givebackmx[i].relcode,:givebackmx[i].printid,
- :givebackmx[i].norebateamt,:givebackmx[i].childsumamt,
- :givebackmx[i].mxdscrp,
- :givebackmx[i].outwareid;
- do while commit_transaction.sqlcode = 0
- i++
- fetch cur_inwaermx into :givebackmx[i].givebackdate,
- :givebackmx[i].relcode,:givebackmx[i].printid,
- :givebackmx[i].norebateamt,:givebackmx[i].childsumamt,
- :givebackmx[i].mxdscrp,
- :givebackmx[i].outwareid;
- loop
- close cur_inwaermx;
- //检验明细是否读入完整
- select count(*) into :no_mxcheck
- from u_givebackmx
- where u_givebackmx.givebackid = :arg_givebackid
- and scid = :arg_scid using commit_transaction;
- if commit_transaction.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
- givebackid = arg_givebackid
- scid = arg_scid
- it_mxbt = i - 1
- it_newbegin = false
- it_updatebegin = false
- ext:
- if rslt = 0 then p_reset()
- return rslt
- end function
- public function integer newbegin (long arg_scid, ref string arg_msg);//====================================================================
- // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
- //--------------------------------------------------------------------
- // Description: 从置对象,设定业务类型,准备建立新进仓单
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_scid
- // value integer arg_billtype
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- int rslt=1
- if arg_scid < 0 then
- arg_msg = '请选择分部'
- rslt = 0
- goto ext
- end if
- p_reset()
- scid=arg_scid
- it_newbegin=true
- it_updatebegin=false
- ext:
- if rslt=0 then p_reset()
- return rslt
- end function
- public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg);//====================================================================
- // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
- //--------------------------------------------------------------------
- // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_scid
- // value long arg_inwareid
- // value integer arg_billtype
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- long rslt=1
- if arg_scid < 0 then
- arg_msg = '请选择分部'
- rslt = 0
- goto ext
- end if
- if arg_givebackid<=0 then
- rslt=0
- goto ext
- end if
- rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg)
- if rslt=0 then goto ext
- if flag=1 then
- rslt=0
- arg_msg='单据已经审核,不可以修改'
- goto ext
- end if
- givebackid=arg_givebackid
- scid=arg_scid
- it_newbegin=false
- it_updatebegin=true
- p_clearmx() //清除明细
- ext:
- if rslt=0 then p_reset()
- return rslt
- end function
- public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
- //0 fail 1 success
- int rslt=1
- arg_newdescppart=trim(arg_newdescppart)
- if it_updatebegin or it_newbegin then
- rslt=0
- arg_msg="编辑状态下不可用"
- goto ext
- end if
- if arg_newdescppart='' then
- rslt=0
- arg_msg="要添加内容为空,操作取消"
- goto ext
- end if
- rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg)
- if rslt=0 then goto ext
- if flag=0 then
- rslt=0
- arg_msg="非审核状态下不可用"
- goto ext
- end if
- update u_giveback
- set dscrp = dscrp+' '+:arg_newdescppart
- where u_giveback.givebackid = :givebackid
- and scid=:scid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rollback ;
- rslt=0
- arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
- goto ext
- end if
- commit using commit_transaction;
- dscrp = dscrp+' '+arg_newdescppart
- ext: return (rslt)
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
- DateTime server_dt
- Long ls_newid
- String ls_sccode
- IF IsNull(givebackrate) THEN givebackrate = 0
- IF IsNull(cusid) THEN cusid = 0
- IF IsNull(assign_emp) THEN assign_emp = ''
- if isnull(sumamt) then sumamt=0
- if isnull(relcode) then relcode=''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(itemid) THEN itemid = 0
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确明细内容"
- GOTO ext
- END IF
- IF Year(Date(givebackdate)) < 2000 OR IsNull(givebackdate) THEN
- rslt = 0
- arg_msg = "缺少返利发生时间或不合理"
- GOTO ext
- END IF
- //====================================================================
- // Script - save ( boolean arg_ifcommit, ref string arg_msg )
- // Reason:
- //--------------------------------------------------------------------
- // Modified By: yyx Date: 2004.01.02
- //--------------------------------------------------------------------
- IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(givebackdate,'yyyy-mm-dd'))) > 30 THEN
- rslt = 0
- arg_msg = '返利日期错误,日期不能超前系统日期'
- GOTO ext
- END IF
- IF DaysAfter(Date(String(givebackdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > 30 THEN
- rslt = 0
- arg_msg = '返利日期错误,日期不能落后系统日期'
- GOTO ext
- END IF
- IF banktypeid = 0 THEN
- arg_msg = '请选择结算方式'
- rslt = 0
- GOTO ext
- END IF
- ////////////////////////////////////////////////开始区分:新建/更新 处理
- IF givebackid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_giveback","givebackid",arg_msg,if_getid_ture,commit_transaction)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- givebackcode = getid(scid,ls_sccode + 'FL',Date(server_dt),if_getid_ture,commit_transaction)
-
- IF givebackcode = "err" THEN
- givebackcode = ''
- rslt = 0
- arg_msg = "无法获取返利单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_giveback (
- scid,
- givebackid,
- givebackcode,
- cusid,
- givebackdate,
- startdate,
- enddate,
- givebackrate,
- sumamt,
- assign_emp,
- relcode,
- dscrp,
- opdate,
- opemp,
- flag,
- banktypeid,
- moneyid,
- mrate,
- itemid)
- VALUES (
- :scid,
- :ls_newid,
- :givebackcode,
- :cusid,
- :givebackdate,
- :startdate,
- :enddate,
- :givebackrate,
- :sumamt,
- :assign_emp,
- :relcode,
- :dscrp,
- :server_dt,
- :publ_operator,
- :flag,
- :banktypeid,
- :moneyid,
- :mrate,
- :itemid) USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新givebackid
- givebackid = ls_newid
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_givebackmx
- (scid,
- givebackid,
- givebackdate,
- outwareid,
- relcode,
- printid,
- norebateamt,
- childsumamt,
- mxDscrp)
- VALUES (
- :scid,
- :ls_newid,
- :givebackmx[i].givebackdate,
- :givebackmx[i].outwareid,
- :givebackmx[i].relcode,
- :givebackmx[i].printid,
- :givebackmx[i].norebateamt,
- :givebackmx[i].childsumamt,
- :givebackmx[i].mxdscrp) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- givebackid = 0 //还原givebackid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////////更新
- UPDATE u_giveback
- SET cusid=:cusid,
- givebackdate=:givebackdate,
- startdate=:startdate,
- enddate=:enddate,
- givebackrate=:givebackrate,
- sumamt=:sumamt,
- assign_emp=:assign_emp,
- relcode=:relcode,
- dscrp=:dscrp,
- moddate=: server_dt,
- modemp=:publ_operator,
- banktypeid=:banktypeid,
- moneyid=:moneyid,
- mrate=:mrate,
- itemid = :itemid
- WHERE u_giveback.givebackid = :givebackid
- AND u_giveback.scid = :scid
- AND flag = 0 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_givebackmx
- WHERE u_givebackmx.givebackid = :givebackid
- AND u_givebackmx.scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- INSERT INTO u_givebackmx
- (scid,
- givebackid,
- givebackdate,
- outwareid,
- relcode,
- printid,
- norebateamt,
- childsumamt,
- mxDscrp)
- VALUES (
- :scid,
- :givebackid,
- :givebackmx[i].givebackdate,
- :givebackmx[i].outwareid,
- :givebackmx[i].relcode,
- :givebackmx[i].printid,
- :givebackmx[i].norebateamt,
- :givebackmx[i].childsumamt,
- :givebackmx[i].mxdscrp) USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- end if
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
- //0 FAIL, 1 SUCCESS
- Int rslt = 1
- IF arg_givebackid <= 0 THEN
- rslt = 0
- arG_MSG = "没有删除对象,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_givebackid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- DELETE FROM u_giveback
- WHERE u_giveback.givebackid = :arg_givebackid
- AND u_giveback.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除返利单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_givebackmx
- WHERE u_givebackmx.givebackid = :arg_givebackid
- AND u_givebackmx.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除返利单明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- p_reset()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN (rslt)
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);//====================================================================
- // Function: auditing(arg_ifcommit,arg_msg)
- //--------------------------------------------------------------------
- // Description: 审核单据
- //--------------------------------------------------------------------
- // Arguments:
- // value boolean arg_ifcommit
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1,cnt=0
- uo_musttake uo_take
- uo_take = CREATE uo_musttake
- Decimal ld_takeamt = 0,ld_msttakeamt = 0
- IF givebackid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin OR it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败,操作员"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arG_MSG = "操作员姓名未登记或已取消"
- GOTO ext
- END IF
- Int li_btype
- Long ll_accountsid
- SELECT btype,accountsid INTO :li_btype,:ll_accountsid
- FROM cw_banktype
- Where banktypeid = :banktypeid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- UPDATE u_giveback
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_giveback.givebackid = :givebackid
- AND flag = 0
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- string ls_about='',ls_dscrp=''
- decimal sum_amt
- sum_amt=0 - round(sumamt*givebackrate,2)
- IF sum_amt <> 0 THEN
- ls_about = givebackcode + "返利款" + ' ' + dscrp
- ls_dscrp = ls_about
- ld_msttakeamt = sum_amt
- IF li_btype = 1 THEN
- ld_takeamt = ld_msttakeamt
- ELSE
- ld_takeamt = 0
- END IF
-
- Long ll_dft_itemid
- SELECT itemid INTO :ll_dft_itemid
- FROM u_itemdef
- Where dfttype = 1;
- IF sqlca.SQLCode <> 0 THEN
- arG_MSG = '查询默认应收项目资料失败'
- rslt = 0
- GOTO ext
- END IF
-
- // datetime plandate
- // setnull(plandate)
- // if uo_take.add_takerec (scid,cusid,givebackdate,assign_emp,ld_msttakeamt,ld_msttakeamt,ld_takeamt,ls_about,&
- // givebackcode,banktypeid,1,publ_operator,givebackid,0,arg_msg,false,plandate,ll_accountsid,ll_dft_itemid,moneyid)=0 then
- // rslt=0
- // goto ext
- // end if
- //givebackid 改为零 //20090725
- if uo_take.add_takerec (scid,cusid,givebackdate,assign_emp,ld_msttakeamt,ld_msttakeamt,ld_takeamt,ls_about,&
- givebackcode,banktypeid,1,publ_operator,0,0,arg_msg,false,givebackdate,ll_accountsid,ll_dft_itemid,moneyid,relcode)=0 then
- rslt=0
- goto ext
- end if
- UPDATE u_giveback
- SET relint_3 = :uo_take.ref_takeid
- WHERE u_giveback.givebackid = :givebackid
- AND scid = :scid
- AND flag = 1 USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arG_MSG = '更新返利单相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
- end if
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);//====================================================================
- // Function: c_auditing(arg_ifcommit,arg_msg)
- //--------------------------------------------------------------------
- // Description:
- //--------------------------------------------------------------------
- // Arguments:
- // value boolean arg_ifcommit
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.19
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1,cnt=0
- DateTime null_dt
- SetNull(null_dt)
- uo_musttake uo_take
- uo_take = CREATE uo_musttake
- IF givebackid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin OR it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未审核"
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败,操作员"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arG_MSG = "操作员姓名未登记或已取消"
- GOTO ext
- END IF
- UPDATE u_giveback
- SET Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0,
- relint_3 = 0
- WHERE u_giveback.givebackid = :givebackid
- AND flag = 1
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- decimal sum_amt
- sum_amt=0 - round(sumamt*givebackrate,2)
- if sum_amt<>0 then
- if uo_take.del_takerec(scid,1,relint_3,cusid,arg_msg,false)=0 then
- rslt=0
- goto ext
- end if
- end if
- flag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate);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_norebateamt) THEN arg_norebateamt = 0
- IF IsNull(arg_childsumamt) THEN arg_childsumamt = 0
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_outwareid) THEN arg_outwareid = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_relcode) THEN arg_relcode = ''
- if arg_norebateamt<0 then
- rslt = 0
- arg_msg = "有明细单据金额小于零,操作取消"
- GOTO ext
- END IF
- ////检查相关销售单
- //select count(*)
- //into :cnt
- //FROM u_outware INNER JOIN
- // u_outwaremx ON u_outware.scid = u_outwaremx.scid AND
- // u_outware.outwareid = u_outwaremx.outwareid
- //where u_outware.outwareid=:arg_outwareid and u_outware.scid=:scid
- // and u_outwaremx.rebate=1 using commit_transaction;
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arG_MSG = "查询操作失败,相关销售单"
- // GOTO ext
- //END IF
- //IF cnt = 0 THEN
- // rslt = 0
- // arG_MSG = "错误的销售单: "+String(arg_relcode)
- // GOTO ext
- //END IF
- //写入内容
- it_mxbt++
- sumamt=sumamt+arg_norebateamt
- givebackmx[it_mxbt].outwareid = arg_outwareid
- givebackmx[it_mxbt].norebateamt = arg_norebateamt
- givebackmx[it_mxbt].childsumamt = arg_childsumamt
- givebackmx[it_mxbt].relcode = arg_relcode
- givebackmx[it_mxbt].givebackdate = arg_givebackdate
- givebackmx[it_mxbt].mxdscrp = arg_mxdscrp
- givebackmx[it_mxbt].printid = arg_printid
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- end function
- on uo_giveback.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_giveback.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|