123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- $PBExportHeader$uo_outware_sale_owe.sru
- forward
- global type uo_outware_sale_owe from uo_outware_sale
- end type
- end forward
- global type uo_outware_sale_owe from uo_outware_sale
- end type
- global uo_outware_sale_owe uo_outware_sale_owe
- forward prototypes
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);
- Long rslt = 1,cnt = 0,i
- Long chc
- Long rst_outwareid //
- Long rst_inwareid //
- Long ll_i,ll_j,ll_k
- Int li_ifpack,li_ifunit,li_ifpackpro
- Int li_ifpackcnt,li_ifpackprocnt
- Decimal ld_rate,ld_uqty,ld_rate_buy
- Decimal ld_fprice,ld_uprice
- String ls_uunit,ls_unit_buy,ls_unit
- Long ll_storageid_arr[]
- Long ll_outwareid_out
- IF uo_option_confirmaudit_sale = -1000 THEN
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_owegood uo_owe
- uo_owe = Create uo_owegood
- IF storageid = 0 THEN
- rslt = 0
- arg_msg = '没有正确的仓库'
- GOTO ext
- END IF
- IF billtype <> 9 THEN
- IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- String ls_storagename
- SELECT storagename
- INTO :ls_storagename
- FROM u_storage
- Where storageid = :storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_audit <> '0' THEN
- IF Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据'
- GOTO ext
- END IF
- END IF
- //
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- IF uo_option_confirmaudit_sale = 1 THEN
- IF priceflag = 0 THEN
- rslt = 0
- arg_msg = "销售单要确认后才能审核"
- GOTO ext
- END IF
- END IF
- UPDATE u_outware
- SET Auditingrep = :publ_operator,
- Auditingdate = getdate(),
- flag = 1
- WHERE u_outware.outwareid = :outwareid
- 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
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- IF relid = 1 THEN
- IF uo_out.newbegin(scid,22,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_out.relid = outwareid
- uo_out.outdate = outdate
- uo_out.outrep = publ_operator
- uo_out.part = outwarecode
- uo_out.dscrp = ''
- uo_out.cusname = '欠货终止出仓单'
- uo_out.storageid = storageid
-
-
- FOR i = 1 To it_mxbt
- IF uo_out.acceptmx(outwaremx[i].mtrlwareid,&
- 0 - outwaremx[i].qty,&
- outwaremx[i].cost,&
- 1,'',i,arg_msg,0,0,0,0,'',0,0,outwaremx[i].unit,0 - outwaremx[i].uqty,outwaremx[i].rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_out.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_outwareid_out = uo_out.outwareid
-
- //2.原事务审核出仓单
- IF uo_out.getinfo(scid,ll_outwareid_out,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- FOR i = 1 To it_mxbt
- Decimal ld_ref_costamt
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- IF uo_owe.addstopqty(outwaremx[i].relid,outwaremx[i].relprintid,0 - outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- IF uo_owe.tryfinish(outwaremx[i].relid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,&
- outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF sys_option_inout_procedure = 0 THEN
-
- IF p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty, ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].mtrlcuscode,&
- outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_pro
- Destroy uo_out
- Destroy uo_owe
- RETURN rslt
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- Long ls_newid
- DateTime null_dt
- Long ll_inwareid_rel,ll_outwareid_rel
- String ls_inwarecode_rel,ls_outwarecode_rel
- String ls_outwarecode_arr[]
- Long ll_outwareid[]
- Long ll_itmx = 1,ll_i
- Long ll_outwareid_out
- SetNull(null_dt)
- uo_inware uo_in
- uo_outware uo_out
- uo_owegood uo_owe
- uo_owe = Create uo_owegood
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- IF storageid = 0 THEN
- rslt = 0
- arg_msg = '没有正确的仓库'
- GOTO ext
- END IF
- IF billtype <> 9 THEN
- IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- String ls_storagename
- SELECT storagename
- INTO :ls_storagename
- FROM u_storage
- Where storageid = :storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_audit <> '0' THEN
- IF Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据'
- GOTO ext
- END IF
- END IF
- //
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF ctmint > 0 THEN
- arg_msg = '单据已截数,不能操作'
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未审核"
- GOTO ext
- END IF
- IF secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经过财务审核"
- GOTO ext
- END IF
- IF balcflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经日结,不能撤审"
- GOTO ext
- END IF
- String ls_owecode
- Int li_oweflag
- Long ll_owebillid
- cnt = 0
- UPDATE u_outware
- SET Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0
- WHERE u_outware.outwareid = :outwareid
- 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
- FOR i = 1 To it_mxbt
- IF sys_option_inout_procedure = 0 THEN
-
- IF p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode, outwaremx[i].mtrlcuscode,&
- outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
- arg_msg = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
-
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- IF uo_owe.addstopqty(outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- IF uo_owe.tryfinish(outwaremx[i].relid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- NEXT
- IF relid = 1 THEN
- SELECT count(*) INTO :cnt
- FROM u_outware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 22;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询是否有相关出仓单失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 1 THEN
- SELECT outwareid INTO :ll_outwareid_out
- FROM u_outware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 22;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询是否有相关出仓单失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.getinfo(scid,ll_outwareid_out,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.del(scid,ll_outwareid_out,0,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- 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
- Destroy uo_pro
- Destroy uo_out
- Destroy uo_owe
- RETURN rslt
- end function
- on uo_outware_sale_owe.create
- call super::create
- end on
- on uo_outware_sale_owe.destroy
- call super::destroy
- end on
|