$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