$PBExportHeader$uo_outware_sale.sru forward global type uo_outware_sale from uo_outware end type end forward global type uo_outware_sale from uo_outware end type global uo_outware_sale uo_outware_sale type variables Int uo_option_m_msttake Int uo_option_otheramt_msttake String uo_option_change_otheramt Int uo_option_outware_sale_ifmating Int uo_option_secaudit_notupdate_hisprice end variables forward prototypes public function integer secauditing (boolean arg_ifcommit, ref string arg_msg) public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg) 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 c_priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg) public function integer uof_create_owe (ref string arg_msg) public function integer auditing_th (boolean arg_ifcommit, ref string arg_msg) public function integer c_auditing_th (boolean arg_ifcommit, ref string arg_msg) public function integer uof_check_pt (ref string arg_msg) public function integer priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg, string arg_emp) end prototypes public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j IF uo_option_m_msttake = -1000 THEN rslt = 0 arg_msg = '选项:[045]系统使用多币种应收帐,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_otheramt_msttake = -1000 THEN rslt = 0 arg_msg = '选项:[052]优惠金额多币种,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_change_otheramt = '-1000' THEN rslt = 0 arg_msg = '选项:[050]销售发货单优惠金额文本,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_price_rmb = -1000 THEN rslt = 0 arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_secaudit_notupdate_hisprice = -1000 THEN rslt = 0 arg_msg = '选项:[332]销售发货单财审时不更新客户价格历史,读取初始默认值失败,操作取消!' GOTO ext END IF uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice uo_musttake uo_take uo_take = Create uo_musttake String ls_mtrlname String ls_about Decimal ld_takeamt = 0,ld_msttakeamt = 0,ld_taxamt = 0 Long ll_moneyid,ll_moneyid_yh,ll_moneyid_native Long ll_dft_itemid_take,ll_dft_itemid_yh,ll_dft_itemid_tax Decimal ld_mrate_amt Decimal ld_itemamt = 0 String ls_taskdscrp Decimal ld_taskamt String ls_taskcode[] Decimal ld_saletaskamt[] Long ll_i,k String ls_itemname Decimal ld_mrate,ld_mrate_yh s_bmsttakemx s_takemx_item IF outwareid = 0 THEN rslt = 0 arg_msg = "没有审核对象" 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 Int li_btype Long ll_accountsid SELECT btype,accountsid INTO :li_btype,:ll_accountsid FROM cw_banktype Where banktypeid = :relint_1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText 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_outware SET secauditingrep = :publ_operator, secauditingdate = getdate(), secflag = 1 WHERE u_outware.outwareid = :outwareid AND flag = 1 AND secflag = 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 IF uo_option_secaudit_notupdate_hisprice = 0 THEN FOR i = 1 To it_mxbt IF outwaremx[i].outtype <> '' THEN CONTINUE IF uo_update_cusprice.uof_update_custprice(thflag,0,cusid,& outwaremx[i].mtrlid,outwaremx[i].mtrlcode,outwaremx[i].status,& outwaremx[i].woodcode,outwaremx[i].pcode,& outwareid,outwarecode,outdate,outwaremx[i].enprice,& outwaremx[i].rebate,outwaremx[i].costamt,0,'',& outwaremx[i].printid,0,relint_2,0,0,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT END IF FOR j = 1 To it_mxbt_item IF outware_itemmx[j].IsCusAmt = 1 THEN ld_itemamt = ld_itemamt + outware_itemmx[j].amt END IF NEXT IF sum_amt <> 0 Or ld_itemamt <> 0 THEN IF thflag = 1 THEN ls_about = outwarecode + "退货款,相关号:"+part SELECT itemid INTO :ll_dft_itemid_take FROM u_itemdef Where dfttype = 4 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询默认销售退货项目资料失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF ELSE ls_about = outwarecode + "应收款,相关号:"+part SELECT itemid INTO :ll_dft_itemid_take FROM u_itemdef Where dfttype = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询默认应收项目资料失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF END IF SELECT moneyid INTO :ll_moneyid_native FROM cw_currency Where native = 1; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询本位币资料失败' rslt = 0 GOTO ext END IF IF uo_option_m_msttake = 0 THEN ld_msttakeamt = sum_amt ll_moneyid = ll_moneyid_native ld_taxamt = sum_taxamt ld_mrate = 1 ELSE ld_msttakeamt = sum_amt_en ll_moneyid = relint_2 ld_taxamt = sum_taxamt_en IF uo_option_price_rmb = 0 THEN ld_mrate = mrate ELSE ld_mrate = Round(sum_amt/sum_amt_en,10) END IF END IF IF otheramt <> 0 THEN IF uo_option_otheramt_msttake = 1 THEN ld_mrate_amt = otheramt * mrate ll_moneyid_yh = ll_moneyid_native ld_mrate_yh = mrate ELSE ld_mrate_amt = otheramt ll_moneyid_yh = relint_2 ld_mrate_yh = 1 END IF END IF IF li_btype = 1 THEN ld_takeamt = ld_msttakeamt - ld_mrate_amt + ld_itemamt ELSE ld_takeamt = 0 END IF ll_i = 0 FOR i = 1 To it_mxbt IF outwaremx[i].ifrel = 1 THEN IF uo_option_m_msttake = 0 THEN ld_taskamt = outwaremx[i].saleqty * outwaremx[i].price / (1 + outwaremx[i].taxrate) //计算单据总金额 ELSE ld_taskamt = outwaremx[i].saleqty * outwaremx[i].rebate * outwaremx[i].enprice / (1 + outwaremx[i].taxrate) //计算单据总金额 END IF FOR j = 1 To ll_i IF ls_taskcode[j] = outwaremx[i].relcode THEN ld_saletaskamt[j] = ld_saletaskamt[j] + ld_taskamt GOTO exit_for END IF NEXT ll_i++ ls_taskcode[ll_i] = outwaremx[i].relcode ld_saletaskamt[ll_i] = ld_taskamt END IF exit_for: NEXT FOR k = 1 To ll_i ls_taskdscrp = ls_taskdscrp + '订单'+ls_taskcode[k]+'金额:'+String(ld_saletaskamt[k],'#,##0.00')+',' NEXT IF sum_amt <> 0 THEN s_bmsttake s_take s_take.scid = scid s_take.cusid = cusid s_take.takedate = outdate s_take.inrep = outrep s_take.oriamt = ld_msttakeamt s_take.msttakeamt = ld_msttakeamt s_take.takeamt = ld_takeamt s_take.takeamt_cn = ld_takeamt s_take.dscrp = ls_about s_take.billcode = outwarecode s_take.relcode = part s_take.banktypeid = relint_1 s_take.opemp = publ_operator s_take.buildtype = 1 s_take.outwareid = outwareid s_take.accountsid = ll_accountsid s_take.itemid = ll_dft_itemid_take s_take.moneyid = ll_moneyid s_take.moneyid_cn = ll_moneyid s_take.viewdate = viewdate s_take.taskdscrp = ls_taskdscrp s_take.mrate = ld_mrate s_take.exchangeid = exchangeid IF uo_take.add_takerec(s_take,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF IF otheramt <> 0 THEN ls_about = outwarecode + uo_option_change_otheramt +",相关号:"+part SELECT itemid INTO :ll_dft_itemid_yh FROM u_itemdef Where dfttype = 3 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询默认优惠项目资料失败' rslt = 0 GOTO ext END IF s_bmsttakemx s_takemx s_takemx.scid = scid s_takemx.takeid = uo_take.ref_takeid s_takemx.cusid = cusid s_takemx.takedate = outdate s_takemx.inrep = outrep s_takemx.msttakeamt = 0 - ld_mrate_amt s_takemx.takeamt = 0 s_takemx.dscrp = ls_about s_takemx.billcode = outwarecode s_takemx.relcode = part s_takemx.banktypeid = relint_1 s_takemx.opemp = publ_operator s_takemx.buildtype = 3 s_takemx.outwareid = outwareid s_takemx.salebillid = 0 s_takemx.itemid = ll_dft_itemid_yh s_takemx.moneyid = ll_moneyid_yh s_takemx.mrate = ld_mrate_yh IF uo_take.add_takerecmx(s_takemx,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF IF ld_taxamt <> 0 THEN ls_about = outwarecode + "销售税金,相关号:"+part SELECT itemid INTO :ll_dft_itemid_tax FROM u_itemdef Where dfttype = 12 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询默认销售税金项目资料失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF s_bmsttakemx s_takemx_tax s_takemx_tax.scid = scid s_takemx_tax.takeid = uo_take.ref_takeid s_takemx_tax.cusid = cusid s_takemx_tax.takedate = outdate s_takemx_tax.inrep = outrep s_takemx_tax.msttakeamt = ld_taxamt s_takemx_tax.takeamt = 0 s_takemx_tax.dscrp = ls_about s_takemx_tax.billcode = outwarecode s_takemx_tax.relcode = part s_takemx_tax.banktypeid = relint_1 s_takemx_tax.opemp = publ_operator s_takemx_tax.buildtype = 3 s_takemx_tax.outwareid = outwareid s_takemx_tax.salebillid = 0 s_takemx_tax.itemid = ll_dft_itemid_tax s_takemx_tax.moneyid = ll_moneyid s_takemx_tax.mrate = ld_mrate IF uo_take.add_takerecmx(s_takemx_tax,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF FOR i = 1 To it_mxbt_item IF outware_itemmx[i].amt <> 0 THEN SELECT itemname INTO :ls_itemname FROM u_itemdef Where itemid = :outware_itemmx[i].itemid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询第'+String(i)+'行费用项目信息失败,'+ commit_transaction.SQLErrText GOTO ext END IF IF sum_amt = 0 And i = 1 THEN ls_about = outwarecode + '费用项目金额,相关号:'+part s_bmsttake s_take_it s_take_it.scid = scid s_take_it.cusid = cusid s_take_it.takedate = outdate s_take_it.inrep = outrep s_take_it.oriamt = outware_itemmx[i].amt s_take_it.msttakeamt = outware_itemmx[i].amt s_take_it.takeamt = 0 s_take_it.takeamt_cn = 0 s_take_it.dscrp = ls_about s_take_it.billcode = outwarecode s_take_it.relcode = part s_take_it.banktypeid = relint_1 s_take_it.opemp = publ_operator s_take_it.buildtype = 1 s_take_it.outwareid = outwareid s_take_it.accountsid = ll_accountsid s_take_it.itemid = ll_dft_itemid_take s_take_it.moneyid = ll_moneyid s_take_it.moneyid_cn = ll_moneyid s_take_it.viewdate = viewdate s_take_it.taskdscrp = ls_taskdscrp s_take_it.mrate = ld_mrate IF uo_take.add_takerec(s_take_it,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF ELSE ls_about = outwarecode + '费用项目:'+ls_itemname +",相关号:"+part s_takemx_item.scid = scid s_takemx_item.takeid = uo_take.ref_takeid s_takemx_item.cusid = cusid s_takemx_item.takedate = outdate s_takemx_item.inrep = outrep s_takemx_item.msttakeamt = outware_itemmx[i].amt s_takemx_item.takeamt = 0 s_takemx_item.dscrp = ls_about s_takemx_item.billcode = outwarecode s_takemx_item.relcode = part s_takemx_item.banktypeid = relint_1 s_takemx_item.opemp = publ_operator s_takemx_item.buildtype = 3 s_takemx_item.outwareid = outwareid s_takemx_item.salebillid = 0 s_takemx_item.itemid = outware_itemmx[i].itemid s_takemx_item.moneyid = ll_moneyid s_takemx_item.mrate = ld_mrate IF uo_take.add_takerecmx(s_takemx_item,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF NEXT UPDATE u_outware SET relint_3 = :uo_take.ref_takeid WHERE u_outware.outwareid = :outwareid AND scid = :scid AND flag = 1 And secflag = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '更新相关应收帐id失败' rslt = 0 GOTO ext END IF END IF secflag = 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_update_cusprice Destroy uo_take RETURN rslt end function public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j uo_musttake uo_take uo_take = Create uo_musttake uo_cusprice uo_update_cusprice uo_update_cusprice = Create uo_cusprice IF uo_option_secaudit_notupdate_hisprice = -1000 THEN rslt = 0 arg_msg = '选项:[332]销售发货单财审时不更新客户价格历史,读取初始默认值失败,操作取消!' GOTO ext END IF String ls_mtrlname String ls_cusname DateTime null_datetime Long ll_takeid Decimal ld_itemamt int li_StoreBalcType,li_AmtAuditFlag 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 secflag = 0 THEN rslt = 0 arg_msg = "该单据财务未审,不能进行财务撤审" GOTO ext END IF //检查仓库是否分开结存 IF balcdateint <> 0 THEN SELECT StoreBalcType INTO :li_StoreBalcType FROM u_storage Where storageid = :storageid; IF sqlca.SQLCode <> 0 THEN li_StoreBalcType = 0 END IF //如果分开结存,检查结存表是否已金额结存 IF li_StoreBalcType = 1 THEN SELECT top 1 AmtAuditFlag INTO :li_AmtAuditFlag FROM u_warebalc WHERE storageid = :storageid And balcdateint = :balcdateint; IF sqlca.SQLCode <> 0 THEN li_AmtAuditFlag = 0 END IF IF li_AmtAuditFlag = 1 THEN rslt = 0 arg_msg = '仓库结存日期段已执行过金额结存,不能财撤单据' GOTO ext END IF END IF 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 SetNull(null_datetime) UPDATE u_outware SET secAuditingrep = '', secAuditingdate = :null_datetime, secflag = 0, relint_3 = 0 WHERE u_outware.outwareid = :outwareid 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 IF uo_option_secaudit_notupdate_hisprice = 0 THEN FOR i = 1 To it_mxbt IF outwaremx[i].outtype <> '' THEN CONTINUE IF uo_update_cusprice.uof_del_cusprice_auto(cusid,outwareid,& outwaremx[i].printid,outwaremx[i].mtrlid,outwaremx[i].status,& outwaremx[i].woodcode,outwaremx[i].pcode,& 0,relint_2,0,0,False,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF NEXT END IF FOR j = 1 To it_mxbt_item IF outware_itemmx[j].IsCusAmt = 1 THEN ld_itemamt = ld_itemamt + outware_itemmx[j].amt END IF NEXT If (sum_amt <> 0 Or ld_itemamt <> 0) And relint_3 <> 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 secflag = 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_take Destroy uo_update_cusprice RETURN rslt end function public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 Long cnt = 0,i,j,mx_barcode_cnt,k Long chc Long rst_outwareid // Long rst_inwareid // Long ll_i,ll_j,ll_k,ll_l 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,ld_planprice String ls_uunit,ls_unit_buy,ls_unit Long ll_storageid_arr[] // Decimal ld_assign_outqty,ld_sumnotoutqty,ld_sumnotoutqty_bill Long ll_row Long ll_pda_hh Int li_ifvqty uo_cmpl_packpro uo_pack uo_pack = Create uo_cmpl_packpro uo_pack.commit_transaction = commit_transaction s_inwaremx s_mx s_outwaremx s_mx_out ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 If f_aps_mrp_cklock(scid,arg_msg) = 0 Then rslt = 0 Goto ext End If If uo_option_confirmaudit_sale = -1000 Then rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_outware_saleout = -1000 Then rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_outware_sale_ifmating = -1000 Then rslt = 0 arg_msg = '选项:[188]销售发货单仓审时是否检查配套出仓,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_pda_sale_lock = -1000 Then rslt = 0 arg_msg = '选项:[310]PDA销售发货加锁,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_canpack_ifzanyong = -1000 Then rslt = 0 arg_msg = '选项:[417]通用包件产品可装数选项,读取初始默认值失败,操作取消!' Goto ext End If uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction uo_saletask uo_task uo_task = Create uo_saletask uo_task.commit_transaction = commit_transaction uo_saleout uo_sout uo_sout = Create uo_saleout uo_sout.commit_transaction = commit_transaction uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore ds_out_assign.DataObject = 'ds_outwaremx_assign' ds_out_assign.SetTransObject(commit_transaction) If outwareid = 0 Then rslt = 0 arg_msg = "没有审核对象" Goto ext End If 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 Int li_outtype_storage,li_storagetype Select storagename,outtype,storagetype Into :ls_storagename,:li_outtype_storage,:li_storagetype 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 flag = 1 Then rslt = 0 arg_msg = "单据已经审核" Goto ext End If //yyx2013-4-3 If f_power_ind(3715,sys_msg_pow) And Not sys_power_issuper Then For i = 1 To it_mxbt If outwaremx[i].qty <> outwaremx[i].planqty Then arg_msg = '有实发数与计划发货数不相等的发货明细,你没有权限操作' rslt = 0 Goto ext End If Next End If // If uo_option_pda_sale_lock = 1 And uo_option_inout_type = 2 And li_outtype_storage = 2 Then If pda_flag = 1 Then Select Top 1 DATEDIFF(hh, :pda_date, getdate()) Into :ll_pda_hh From u_user Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "查询单据条码扫描开始时间与当前时间的小时间隔失败,"+commit_transaction.SQLErrText Goto ext End If If ll_pda_hh < 4 Then rslt = 0 arg_msg = "单据正在扫描条码,不能仓审单据,操作取消" Goto ext End If End If End If If uo_option_confirmaudit_sale = 1 Then If priceflag = 0 Then rslt = 0 arg_msg = "销售单要确认后才能审核" Goto ext End If End If //检查配套 If uo_option_outware_sale_ifmating = 1 And li_outtype_storage > 0 Then If uof_check_pt(arg_msg) = 0 Then rslt = 0 Goto ext End If End If Update u_outware Set Auditingrep = :publ_operator, Auditingdate = getdate(), flag = 1, carflag = 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_inware uo_in uo_outware uo_out uo_in = Create uo_inware uo_in.commit_transaction = sqlca uo_in.if_getid_ture = False uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then //yyx20120906包件产品先更新分配出仓数 For i = 1 To it_mxbt //yyx20120825 //仓库是用库存分配,(包件出仓或条码出仓),包件产品扣分配,包件在销售出仓单做 If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = outwaremx[i].qty If ld_sumnotoutqty > 0 And ld_sumnotoutqty_bill > 0 Then ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then ld_assign_outqty = ld_sumnotoutqty_bill If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(发货明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(发货明细)行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] End If Next End If End If //end_20120825 Next //yyx20120906 cnt = 1 For ll_i = 1 To it_mxbt_mx If ll_i = 1 Then ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid Goto _next End If For ll_j = 1 To cnt If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then Goto _next End If Next cnt++ ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid _next: Next For ll_i = 1 To cnt If uo_out.newbegin(scid,21,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_out.relid = outwareid uo_out.outdate = outdate uo_out.outrep = outrep uo_out.part = outwarecode uo_out.dscrp = dscrp uo_out.cusname = '销售发货单包件明细自动出仓' uo_out.storageid = ll_storageid_arr[ll_i] chc = 0 For i = 1 To it_mxbt_mx If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue Select ifpack,ifunit,unit,rate_buy,unit_buy Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy From u_mtrldef Where mtrlid = :outwaremx_mx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(包件明细)'+String(i)+",查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If f_get_planprice_mtrl(outwaremx_mx[i].mtrlid,outwaremx_mx[i].status,outwaremx_mx[i].woodcode,outwaremx_mx[i].pcode,ld_fprice) chc++ If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx_mx[i].qty Else If ld_rate_buy = 0 Then arg_msg = '销售发货单(包件明细)'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx_mx[i].qty /ld_rate_buy End If li_ifvqty = 0 For k = 1 To it_mxbt If outwaremx[k].printid = outwaremx_mx[i].printid Then If outwaremx[k].mtrlid = outwaremx_mx[i].mtrlid And & outwaremx[k].status = outwaremx_mx[i].status And & outwaremx[k].woodcode = outwaremx_mx[i].woodcode And & outwaremx[k].pcode = outwaremx_mx[i].pcode Then li_ifvqty = 1 Else li_ifvqty = 0 End If Exit End If Next s_mx_out.mtrlwareid = outwaremx_mx[i].mtrlwareid s_mx_out.qty = outwaremx_mx[i].qty s_mx_out.fprice = ld_fprice s_mx_out.rebate = 1 s_mx_out.mxdscrp = outwaremx_mx[i].mxdscrp s_mx_out.printid = chc s_mx_out.ifrel = 0 s_mx_out.relid = 0 s_mx_out.olmtrlid = outwaremx_mx[i].printid s_mx_out.packqty = 0 s_mx_out.outtype = '' s_mx_out.planqty = 0 s_mx_out.relprintid = outwaremx_mx[i].mxprintid s_mx_out.unit = ls_uunit s_mx_out.uqty = ld_uqty s_mx_out.rate = ld_rate s_mx_out.pricetype = '' s_mx_out.formula = '' s_mx_out.saleoutid = 0 s_mx_out.saleoutprintid = 0 s_mx_out.mxdscrp2 = '' s_mx_out.net_weight = 0 s_mx_out.gross_weight = 0 s_mx_out.cubage = 0 s_mx_out.taxrate = 0 s_mx_out.priceformula = '' s_mx_out.qtyformula = '' s_mx_out.ifvqty = li_ifvqty s_mx_out.ifnotinout = outwaremx_mx[i].ifnotinout If uo_out.acceptmx(s_mx_out,arg_msg) = 0 Then arg_msg = '销售发货单(包件明细)'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,& // outwaremx_mx[i].qty,ld_fprice,1,& // outwaremx_mx[i].mxdscrp,chc,arg_msg,0,0,outwaremx_mx[i].printid,0,'',0,outwaremx_mx[i].mxprintid,& // ls_uunit,ld_uqty,ld_rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN // arg_msg = '销售发货单(包件明细)'+String(i)+','+arg_msg // rslt = 0 // GOTO ext // END IF Next If uo_out.Save(False,arg_msg) = 0 Then arg_msg = '销售发货单(包件明细),'+arg_msg rslt = 0 Goto ext End If rst_outwareid = uo_out.outwareid //2.原事务审核出仓单 If uo_out.getinfo(scid,rst_outwareid,arg_msg) = 0 Then arg_msg = '销售发货单(包件明细),'+arg_msg rslt = 0 Goto ext End If If uo_out.auditing(False,arg_msg) = 0 Then arg_msg = '销售发货单(包件明细),'+arg_msg rslt = 0 Goto ext End If If uo_option_noauditingqty_mode = 1 Then If UpperBound(uo_out.ins_ref_outwaremx) > 0 Then For ll_l = 1 To UpperBound(uo_out.ins_ref_outwaremx) ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = uo_out.ins_ref_outwaremx[ll_l].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = uo_out.ins_ref_outwaremx[ll_l].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = uo_out.ins_ref_outwaremx[ll_l].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = uo_out.storageid Next End If End If Next If uo_in.newbegin(scid,23,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_in.relid = outwareid uo_in.indate = outdate uo_in.inrep = outrep uo_in.part = outwarecode uo_in.dscrp = dscrp uo_in.sptname = '销售发货单发货明细包件产品自动进仓' uo_in.storageid = storageid chc = 0 For i = 1 To it_mxbt Select ifpackpro,ifunit,unit,rate_buy,unit_buy Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy From u_mtrldef Where mtrlid = :outwaremx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(发货明细)行:'+String(i)+','+"查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If chc++ f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_planprice) If li_ifpackpro = 0 Then Select cost Into :ld_fprice From u_mtrlware Where mtrlwareid = :outwaremx[i].mtrlwareid And scid = :scid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(发货明细)行:'+String(i)+','+"查询库存成本价操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If If ld_fprice = 0 Then ld_fprice = ld_planprice Else If ld_planprice <> 0 Then ld_fprice = ld_planprice Else For j = 1 To it_mxbt_mx If outwaremx_mx[j].printid = outwaremx[i].printid Then f_get_planprice_mtrl(outwaremx_mx[j].mtrlid,outwaremx_mx[j].status,outwaremx_mx[j].woodcode,outwaremx_mx[j].pcode,ld_planprice) If outwaremx[i].planqty <> 0 Then ld_fprice = ld_fprice + outwaremx_mx[j].planqty / outwaremx[i].planqty * ld_planprice End If End If Next End If End If If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx[i].qty ld_uprice = ld_fprice Else If ld_rate_buy = 0 Then arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(发货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx[i].qty /ld_rate_buy ld_uprice = ld_fprice * ld_rate End If s_mx.printid = chc s_mx.mtrlid = outwaremx[i].mtrlid s_mx.mtrlcode = outwaremx[i].mtrlcode s_mx.plancode = outwaremx[i].plancode s_mx.status = outwaremx[i].status s_mx.uqty = ld_uqty s_mx.enprice = ld_uprice s_mx.rebate = 1 s_mx.mxdscrp = outwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.ifrel = 0 s_mx.woodcode = outwaremx[i].woodcode s_mx.pcode = outwaremx[i].pcode s_mx.sptid = outwaremx[i].sptid s_mx.unit = ls_uunit s_mx.rate = ld_rate s_mx.qty = outwaremx[i].qty s_mx.relprintid = 0 s_mx.checkqty = 0 s_mx.result = '' s_mx.waredscrp = '' s_mx.relbillid = 0 s_mx.relbillprintid = 0 s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode s_mx.Location = outwaremx[i].Location s_mx.deliqty = ld_uqty s_mx.tax = 0 If outwaremx[i].ifpackpro = 0 Then s_mx.ifvqty = 1 s_mx.ifnotinout = 1 Else s_mx.ifvqty = 0 s_mx.ifnotinout = 0 End If If uo_in.acceptmx(s_mx, arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_in.acceptmx(chc,& // outwaremx[i].mtrlid,& // outwaremx[i].mtrlcode,& // outwaremx[i].plancode,& // outwaremx[i].status,& // ld_uqty,& // ld_uprice,& // 1,& // outwaremx[i].mxdscrp,& // arg_msg,& // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,& // outwaremx[i].qty,0,0,'','',0,0,& // outwaremx[i].mtrlcuscode,outwaremx[i].Location,& // ld_uqty,& // 0) = 0 THEN // arg_msg = '销售发货单(发货明细),'+arg_msg // rslt = 0 // GOTO ext // END IF Next If uo_in.Save(False,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If rst_inwareid = uo_in.inwareid //4.原事务审核进仓单 If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If If uo_in.auditing(False,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If // END IF End If Long ll_printid_arr[],ll_mtrlwareid_arr[],ll_mtrlid_arr[] String ls_status_arr[],ls_woodcode_arr[],ls_pcode_arr[] Decimal ld_qty_arr[] Long ll_cnt = 1 Long ll_printid Decimal ld_maxqty Long ll_mtrlid Int li_outtype String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[] Int li_ifover[],li_dipztype[] Decimal ld_Sonscale[] Long ll_SonMtrlid[] Long it_mxt = 1 String ls_status_find,ls_woodcode_find,ls_pcode_find String ls_status,ls_woodcode,ls_pcode Decimal ld_pfqty If uo_option_outware_saleout = 1 Then Declare cur_mx Cursor For Select u_outwaremx.relid, u_outwaremx.mtrlwareid, u_outwaremx.mtrlid, u_outwaremx.status, u_outwaremx.woodcode, u_outwaremx.pcode, u_outwaremx.qty From u_outwaremx Inner JOIN u_outware ON u_outwaremx.scid = u_outware.scid And u_outwaremx.outwareid = u_outware.outwareid Where u_outware.relid = :outwareid And u_outware.scid = :scid And u_outware.billtype = 21 Using commit_transaction; Open cur_mx; Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt], :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt]; Do While commit_transaction.SQLCode = 0 ll_cnt++ Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt], :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt]; Loop Close cur_mx; ll_cnt = ll_cnt - 1 For ll_i = 1 To it_mxbt ld_maxqty = 0 it_mxt = 1 ll_printid = outwaremx[ll_i].printid ll_mtrlid = outwaremx[ll_i].mtrlid ls_status = outwaremx[ll_i].status ls_woodcode = outwaremx[ll_i].woodcode ls_pcode = outwaremx[ll_i].pcode Select outtype,ifpackpro Into :li_outtype,:li_ifpackpro From u_mtrldef Where mtrlid = :ll_mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',查询产品出仓类型失败,'+commit_transaction.SQLErrText rslt = 0 Goto ext End If // IF li_outtype = 0 or li_ifpackpro = 0 THEN If Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro = 1) Then For ll_j = 1 To ll_cnt If ll_mtrlwareid_arr[ll_j] = 0 Then Continue If ll_printid_arr[ll_j] = ll_printid Then ld_maxqty = ld_qty_arr[ll_j] Exit End If Next Update u_outwaremx Set qty = :ld_maxqty, saleqty = :ld_maxqty Where outwareid = :outwareid And scid = :scid And printid = :ll_printid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',更新实发数失败,'+commit_transaction.SQLErrText Goto ext End If Else Declare cur_pf Cursor For Select u_PrdPF.SonMtrlid, u_PrdPF.status, u_PrdPF.woodcode, u_PrdPF.pcode, u_PrdPF.ifover, u_prdpf.dipztype, u_prdpf.Sonscale From u_PrdPF,u_mtrl_pf Where ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid ) And ( u_PrdPF.pfcode = u_mtrl_pf.pfcode ) And ( u_PrdPF.mtrlid = :ll_mtrlid ) And ( u_mtrl_pf.ifdi = 1 And :li_ifpackpro = 0 Or u_mtrl_pf.ifdft = 1 And :li_ifpackpro = 1 ); Open cur_pf; Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; Do While sqlca.SQLCode = 0 it_mxt++ Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; Loop it_mxt = it_mxt - 1 Close cur_pf; For ll_k = 1 To it_mxt If li_ifover[ll_k] = 1 Then Choose Case li_dipztype[ll_k] Case 0 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = '' Case 1 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = '' Case 2 ls_status_find = '' ls_woodcode_find = '' ls_pcode_find = ls_pcode Case 3 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = '' Case 4 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode Case 5 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = ls_pcode Case 6 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode End Choose Else ls_status_find = ls_pf_status[ll_k] ls_woodcode_find = ls_pf_woodcode[ll_k] ls_pcode_find = ls_pf_pcode[ll_k] End If ls_status_find = Trim(ls_status_find) ls_woodcode_find = Trim(ls_woodcode_find) ls_pcode_find = Trim(ls_pcode_find) ld_pfqty = 0 For ll_j = 1 To ll_cnt If ll_mtrlwareid_arr[ll_j] = 0 Then Continue If ll_printid_arr[ll_j] = ll_printid And & ll_mtrlid_arr[ll_j] = ll_SonMtrlid[ll_k] And & ls_status_arr[ll_j] = ls_status_find And & ls_woodcode_arr[ll_j] = ls_woodcode_find And & ls_pcode_arr[ll_j] = ls_pcode_find Then ld_pfqty = ld_pfqty + ld_qty_arr[ll_j] / ld_Sonscale[ll_k] End If Next If thflag = 0 Then If ld_pfqty > ld_maxqty Then ld_maxqty = ld_pfqty Else If ld_pfqty < ld_maxqty Then ld_maxqty = ld_pfqty End If Next Update u_outwaremx Set qty = :ld_maxqty, saleqty = :ld_maxqty Where outwareid = :outwareid And scid = :scid And printid = :ll_printid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',更新实发数失败,'+commit_transaction.SQLErrText Goto ext End If End If outwaremx[ll_i].qty = ld_maxqty Next If uo_in.newbegin(scid,23,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_in.relid = outwareid uo_in.indate = outdate uo_in.inrep = outrep uo_in.part = outwarecode uo_in.dscrp = dscrp uo_in.sptname = '销售发货单发货明细包件产品自动进仓' uo_in.storageid = storageid chc = 0 For i = 1 To it_mxbt Select ifpackpro,ifunit,unit,rate_buy,unit_buy,planprice Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy,:ld_fprice From u_mtrldef Where mtrlid = :outwaremx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+",查询物料资料失败"+"~n"+commit_transaction.SQLErrText Goto ext End If chc++ f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice) If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx[i].qty ld_uprice = ld_fprice Else If ld_rate_buy = 0 Then arg_msg = '销售发货单(发货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx[i].qty /ld_rate_buy ld_uprice = ld_fprice * ld_rate End If If ld_uqty <> 0 Or outwaremx[i].qty <> 0 Then s_mx.printid = chc s_mx.mtrlid = outwaremx[i].mtrlid s_mx.mtrlcode = outwaremx[i].mtrlcode s_mx.plancode = outwaremx[i].plancode s_mx.status = outwaremx[i].status s_mx.uqty = ld_uqty s_mx.enprice = ld_uprice s_mx.rebate = 1 s_mx.mxdscrp = outwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.ifrel = 0 s_mx.woodcode = outwaremx[i].woodcode s_mx.pcode = outwaremx[i].pcode s_mx.sptid = outwaremx[i].sptid s_mx.unit = ls_uunit s_mx.rate = ld_rate s_mx.qty = outwaremx[i].qty s_mx.relprintid = 0 s_mx.checkqty = 0 s_mx.result = '' s_mx.waredscrp = '' s_mx.relbillid = 0 s_mx.relbillprintid = 0 s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode s_mx.Location = outwaremx[i].Location s_mx.deliqty = ld_uqty s_mx.tax = 0 If outwaremx[i].ifpackpro = 0 Then s_mx.ifvqty = 1 s_mx.ifnotinout = 1 Else s_mx.ifvqty = 0 s_mx.ifnotinout = 0 End If If uo_in.acceptmx(s_mx, arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_in.acceptmx(chc,& // outwaremx[i].mtrlid,& // outwaremx[i].mtrlcode,& // outwaremx[i].plancode,& // outwaremx[i].status,& // ld_uqty,& // ld_uprice,& // 1,& // outwaremx[i].mxdscrp,& // arg_msg,& // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,& // outwaremx[i].qty,0,0,'','',0,0,& // outwaremx[i].mtrlcuscode,outwaremx[i].Location,& // ld_uqty,& // 0) = 0 THEN // arg_msg = '销售发货单(发货明细)行:'+String(i)+','+arg_msg // rslt = 0 // GOTO ext // END IF End If Next If uo_in.Save(False,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If rst_inwareid = uo_in.inwareid //4.原事务审核进仓单 If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If If uo_in.auditing(False,arg_msg) = 0 Then arg_msg = '销售发货单(发货明细),'+arg_msg rslt = 0 Goto ext End If End If //审核原发货单明细出仓 For i = 1 To it_mxbt //先扣库存分配,再扣库存 //仓库是用库存分配,不是(包件出仓和条码出仓),包件的在销售出仓单做 If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = outwaremx[i].qty If ld_sumnotoutqty_bill > ld_sumnotoutqty Then arg_msg = '发货明细行:'+String(i)+'订单库存分配数不足,请检查库存分配明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then ld_assign_outqty = ld_sumnotoutqty_bill If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] End If Next End If End If //扣库存 Decimal ld_ref_costamt If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,& outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg 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 arg_msg = '发货明细行:'+String(i)+','+arg_msg 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 If billtype = 1 And outwaremx[i].saleoutid > 0 Then If uo_sout.addmxcmpl(outwaremx[i].saleoutid,outwaremx[i].saleoutprintid,outwaremx[i].saleqty,arg_msg,False) <> 1 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If If billtype = 1 And outwaremx[i].saleoutid > 0 Then If uo_sout.trycmpsaleout(outwaremx[i].saleoutid,arg_msg,False) <> 1 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_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].saleqty,arg_msg,False) <> 1 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_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++ Next If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then If uof_p_barcode(1,arg_msg) = 0 Then rslt = 0 Goto ext End If End If If uof_create_owe(arg_msg) = 0 Then rslt = 0 Goto ext End If //更新库存已开单数(减) If uo_option_inout_type = 0 Or (uo_option_inout_type <> 0 And uo_option_outware_saleout = 0) Then If uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //更新通用包件明细已占用数(outqty) Long ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp If uo_option_canpack_ifzanyong = 1 Then For ll_i = 1 To it_mxbt_mx ll_mtrlwareid_fp = 0 ll_mtrlid_fp = 0 ll_cpmtrlwareid_fp = 0 ll_cpmtrlid_fp = 0 If outwaremx_mx[ll_i].ifpack = 1 Then ll_mtrlwareid_fp = outwaremx_mx[ll_i].mtrlwareid ll_mtrlid_fp = outwaremx_mx[ll_i].mtrlid //查找包件明细对应的发货明细 For ll_j = 1 To it_mxbt If outwaremx_mx[ll_i].printid = outwaremx[ll_j].printid Then If outwaremx[ll_j].ifpackpro = 1 Then ll_cpmtrlwareid_fp = outwaremx[ll_j].mtrlwareid ll_cpmtrlid_fp = outwaremx[ll_j].mtrlid Else Goto _next_mx End If End If Next If ll_cpmtrlwareid_fp = 0 Then Goto _next_mx If uo_pack.uof_add_fpqty_out(scid,ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp,outwaremx_mx[ll_i].qty,arg_msg,False) = 0 Then rslt = 0 Goto ext End If End If _next_mx: Next 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 Destroy uo_task Destroy uo_in Destroy uo_out Destroy uo_ma Destroy uo_sout Destroy uo_pro Destroy ds_out_assign Destroy uo_pack Return rslt end function public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1 Long cnt = 0,i,j,mx_barcode_cnt Long ls_newid DateTime null_dt SetNull(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,ll_l,ll_j ins_ref_outwaremx = ins_empty_outwaremx ins_ref_mxbt = 0 If f_aps_mrp_cklock(scid,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction If uo_option_outware_saleout = -1000 Then rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' Goto ext End If uo_saletask uo_task uo_task = Create uo_saletask uo_task.commit_transaction = commit_transaction uo_saleout uo_sout uo_sout = Create uo_saleout uo_sout.commit_transaction = commit_transaction uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction uo_cmpl_packpro uo_pack uo_pack = Create uo_cmpl_packpro uo_pack.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel' ds_out_assign.SetTransObject(commit_transaction) uo_inware uo_in uo_outware uo_out uo_in = Create uo_inware uo_in.commit_transaction = sqlca uo_in.if_getid_ture = False 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 Int li_outtype_storage,li_storagetype Select storagename,outtype,storagetype Into :ls_storagename,:li_outtype_storage,:li_storagetype 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 Select count(*) Into :cnt From u_owegood Where scid = :scid And relid = :outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '因网络或其它原因导致查询是否存在相关欠货单操作失败'+"~n"+commit_transaction.SQLErrText Goto ext End If If cnt > 1 Then rslt = 0 arg_msg = '不合理的欠货单数量(存在多张相关欠货单),请检查' Goto ext ElseIf cnt = 1 Then Select billid,billcode ,flag Into :ll_owebillid,:ls_owecode,:li_oweflag From u_owegood Where scid = :scid And relid = :outwareid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '因网络或其它原因导致查询\相关欠货单信息操作失败'+"~n"+commit_transaction.SQLErrText Goto ext End If If li_oweflag <> 0 Then rslt = 0 arg_msg = '相关欠货单:'+ls_owecode+' 已在进行或完成,不能撤审销售发货单,请检查' Goto ext End If Delete From u_owegoodmx Where billid = :ll_owebillid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除相关欠货单明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If Delete From u_owegood Where billid = :ll_owebillid And flag = 0; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "删除相关欠货单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If End If Update u_outware Set Auditingrep = '', Auditingdate = :null_dt, flag = 0, carflag = 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 arg_msg = '发货明细行:'+String(i)+','+arg_msg 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 And outwaremx[i].saleoutid > 0 Then If uo_sout.addmxcmpl(outwaremx[i].saleoutid,outwaremx[i].saleoutprintid,0 - outwaremx[i].saleqty,arg_msg,False) <> 1 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If If billtype = 1 And outwaremx[i].saleoutid > 0 Then If uo_sout.trycmpsaleout(outwaremx[i].saleoutid,arg_msg,False) <> 1 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_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid, 0 - outwaremx[i].saleqty,arg_msg,False) <> 1 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_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If //更新库存分配 Decimal ld_assign_outqty,ld_sumnotoutqty,ld_outmxqty Long ll_row If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_outmxqty = outwaremx[i].qty If ld_sumnotoutqty > 0 And ld_outmxqty > 0 Then // IF ld_outmxqty > ld_sumnotoutqty THEN // arg_msg = '发货明细行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' // rslt = 0 // GOTO ext // ELSE ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmxqty Then ld_assign_outqty = ld_outmxqty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j] End If Next // END IF End If End If If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++ Next If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then Select count(*) Into :cnt From u_inware Where scid = :scid And relid = :outwareid And billtype = 23 Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If If cnt > 0 Then Select inwareid,inwarecode Into :ll_inwareid_rel,:ls_inwarecode_rel From u_inware Where scid = :scid And relid = :outwareid And billtype = 23 Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If If uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If If uo_in.c_auditing(False,arg_msg) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If If uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If End If Declare cur_mx Cursor For Select outwareid,outwarecode From u_outware Where billtype = 21 And relid = :outwareid And scid = :scid Using commit_transaction; Open cur_mx; Fetch cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx]; Do While commit_transaction.SQLCode = 0 ll_itmx++ Fetch cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx]; Loop ll_itmx = ll_itmx - 1 Close cur_mx; For ll_i = 1 To ll_itmx If uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 Then rslt = 0 arg_msg = '查询相关出仓单失败,' + arg_msg Goto ext End If If uo_out.c_auditing(False,arg_msg) = 0 Then rslt = 0 arg_msg = '撤审相关出仓单失败,' + arg_msg Goto ext End If If uo_out.del(scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 Then arg_msg = '相关出仓单:'+ls_outwarecode_rel+','+arg_msg rslt = 0 Goto ext End If Next //原发货单明细取消分配出仓 For i = 1 To it_mxbt //yyx20120825 If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_outmxqty = outwaremx[i].qty If ld_sumnotoutqty > 0 And ld_outmxqty > 0 Then // IF ld_outmxqty > ld_sumnotoutqty THEN // arg_msg = '发货明细行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' // rslt = 0 // GOTO ext // ELSE ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmxqty Then ld_assign_outqty = ld_outmxqty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j] End If Next End If // END IF End If // Next End If If uo_option_outware_saleout = 1 Then Select count(*) Into :cnt From u_inware Where scid = :scid And relid = :outwareid And billtype = 23 Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If If cnt > 0 Then Select inwareid,inwarecode Into :ll_inwareid_rel,:ls_inwarecode_rel From u_inware Where scid = :scid And relid = :outwareid And billtype = 23; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If If uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If If uo_in.c_auditing(False,arg_msg) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If If uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 Then arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 Goto ext End If End If Declare cur_mx_rel Cursor For Select outwareid From u_outware Where billtype = 21 And relid = :outwareid And scid = :scid Using commit_transaction; Open cur_mx_rel; Fetch cur_mx_rel Into :ll_outwareid[ll_itmx]; Do While commit_transaction.SQLCode = 0 ll_itmx++ Fetch cur_mx_rel Into :ll_outwareid[ll_itmx]; Loop ll_itmx = ll_itmx - 1 Close cur_mx_rel; For ll_i = 1 To ll_itmx If uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 Then rslt = 0 arg_msg = '查询相关出仓单失败,' + arg_msg Goto ext End If If uo_out.c_auditing(False,arg_msg) = 0 Then rslt = 0 arg_msg = '撤审相关出仓单失败,' + arg_msg Goto ext End If If uo_option_noauditingqty_mode = 1 Then If UpperBound(uo_out.ins_ref_outwaremx) > 0 Then For ll_l = 1 To UpperBound(uo_out.ins_ref_outwaremx) ins_ref_mxbt++ ins_ref_outwaremx[ins_ref_mxbt].mtrlid = uo_out.ins_ref_outwaremx[ll_l].mtrlid ins_ref_outwaremx[ins_ref_mxbt].plancode = uo_out.ins_ref_outwaremx[ll_l].plancode ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = uo_out.ins_ref_outwaremx[ll_l].mtrlcuscode ins_ref_outwaremx[ins_ref_mxbt].storageid = uo_out.storageid Next End If End If Next End If If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then If uof_p_barcode(0,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //增加已开单数 If uo_option_inout_type = 0 Or (uo_option_inout_type <> 0 And uo_option_outware_saleout = 0) Then If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then rslt = 0 Goto ext End If End If //更新通用包件明细已占用数(outqty) Long ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp If uo_option_canpack_ifzanyong = 1 Then For ll_i = 1 To it_mxbt_mx ll_mtrlwareid_fp = 0 ll_mtrlid_fp = 0 ll_cpmtrlwareid_fp = 0 ll_cpmtrlid_fp = 0 If outwaremx_mx[ll_i].ifpack = 1 Then ll_mtrlwareid_fp = outwaremx_mx[ll_i].mtrlwareid ll_mtrlid_fp = outwaremx_mx[ll_i].mtrlid //查找包件明细对应的发货明细 For ll_j = 1 To it_mxbt If outwaremx_mx[ll_i].printid = outwaremx[ll_j].printid Then If outwaremx[ll_j].ifpackpro = 1 Then ll_cpmtrlwareid_fp = outwaremx[ll_j].mtrlwareid ll_cpmtrlid_fp = outwaremx[ll_j].mtrlid Else Goto _next_mx End If End If Next If ll_cpmtrlwareid_fp = 0 Then Goto _next_mx If uo_pack.uof_add_fpqty_out(scid,ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp,0 - outwaremx_mx[ll_i].qty,arg_msg,False) = 0 Then rslt = 0 Goto ext End If End If _next_mx: Next 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_task Destroy uo_in Destroy uo_out Destroy uo_ma Destroy uo_sout Destroy uo_pro Destroy ds_out_assign destroy uo_pack Return rslt end function public function integer c_priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i DateTime null_dt Long cnt Long ll_pda_hh IF uo_option_outware_saleout = -1000 THEN rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_checkprice_native = -1000 THEN rslt = 0 arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_inout_type = -1000 THEN rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_confirmaudit_sale = -1000 THEN rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_pda_sale_lock = -1000 THEN rslt = 0 arg_msg = '选项:[310]PDA销售发货加锁,读取初始默认值失败,操作取消!' GOTO ext END IF uo_cusprice uo_price uo_outware uo_out SetNull(null_dt) IF arg_scid < 0 THEN rslt = 0 arg_msg = "错误的分部ID" GOTO ext END IF IF arg_outwareid <= 0 THEN rslt = 0 arg_msg = "没有确认对象" GOTO ext END IF IF getinfo(arg_scid,arg_outwareid,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF IF priceflag = 0 THEN rslt = 0 arg_msg = "单据还未确认,不能反确认" GOTO ext END IF IF uo_option_confirmaudit_sale = 1 THEN IF flag = 1 THEN rslt = 0 arg_msg = "销售单已仓审,不能反确认" GOTO ext END IF END IF Int li_outtype_storage Long mx_barcode_cnt SELECT outtype INTO :li_outtype_storage FROM u_storage Where storageid = :storageid Using commit_transaction ; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,仓库" GOTO ext END IF IF li_outtype_storage = 2 THEN FOR i = 1 To it_mxbt IF li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++ NEXT END IF IF uo_option_pda_sale_lock = 1 And uo_option_inout_type = 2 And li_outtype_storage = 2 THEN IF pda_flag = 1 THEN SELECT Top 1 DATEDIFF(hh, :pda_date, getdate()) Into :ll_pda_hh From u_user Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询单据条码扫描开始时间与当前时间的小时间隔失败,"+commit_transaction.SQLErrText GOTO ext END IF IF ll_pda_hh < 4 THEN rslt = 0 arg_msg = "单据正在扫描条码,不能反确认,操作取消" GOTO ext END IF END IF END IF IF uo_option_inout_type = 2 And li_outtype_storage = 2 And mx_barcode_cnt > 0 THEN SELECT count(*) INTO :cnt FROM u_outwaremx_mx_barcode WHERE scid = :arg_scid AND outwareid = :arg_outwareid And billtype = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询单据是否已扫描条码失败,"+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 0 THEN rslt = 0 arg_msg = "单据已扫描条码,不能反确认,如需反确认请与仓库协商先清除已扫描条码" GOTO ext END IF END IF uo_price = Create uo_cusprice uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False FOR i = 1 To it_mxbt IF outwaremx[i].outtype <> '' THEN CONTINUE IF uo_option_checkprice_native = 1 THEN IF uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,& outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,& outwaremx[i].woodcode,relint_2,outwaremx[i].price,outwaremx[i].uqty,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ELSE IF uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,& outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,& outwaremx[i].woodcode,relint_2,outwaremx[i].enprice * outwaremx[i].enprice,outwaremx[i].uqty,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF NEXT IF uo_option_outware_saleout = 1 THEN cnt = 0 Long ll_outwareid[] Long ll_itmx = 1,ll_i SELECT count(*) INTO :cnt FROM u_outware WHERE billtype = 21 AND relid = :arg_outwareid AND scid = :arg_scid And flag = 1 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询相关出仓单失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 0 THEN rslt = 0 arg_msg = '相关出仓单已仓审,不能反确认,请检查' GOTO ext END IF DECLARE cur_mx CURSOR FOR SELECT outwareid FROM u_outware WHERE billtype = 21 AND relid = :arg_outwareid And scid = :arg_scid Using commit_transaction; OPEN cur_mx; FETCH cur_mx Into :ll_outwareid[ll_itmx]; DO WHILE commit_transaction.SQLCode = 0 ll_itmx++ FETCH cur_mx Into :ll_outwareid[ll_itmx]; LOOP ll_itmx = ll_itmx - 1 FOR ll_i = 1 To ll_itmx IF uo_out.del(arg_scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 THEN rslt = 0 arg_msg = '删除相关出仓单失败,' + arg_msg GOTO ext END IF NEXT END IF If uo_option_outware_saleout > 0 Then //增加库存已开单数 If uof_noauditingqty_add(arg_scid,billtype,relint_1,arg_msg) = 0 Then rslt = 0 Goto ext End If End If UPDATE u_outware SET priceemp = '', pricedate = :null_dt, priceflag = 0 WHERE u_outware.outwareid = :arg_outwareid AND priceflag = 1 And scid = :arg_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 priceflag = 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_price Destroy uo_out RETURN rslt end function public function integer uof_create_owe (ref string arg_msg);Int rslt = 1 Long ll_i,ll_j,ll_k Long ll_printid,ll_mtrlid Int li_ifpackpro,li_outtype String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[] Int li_ifover[],li_dipztype[] Decimal ld_Sonscale[] Long ll_SonMtrlid[] Long it_mxt = 1 String ls_status_find,ls_woodcode_find,ls_pcode_find String ls_status,ls_woodcode,ls_pcode Decimal ld_qty,ld_pfqty Long count Long ll_taskid String ls_taskcode,ls_taskrelcode uo_owegood uo_owe uo_owe = CREATE uo_owegood s_owegood arg_s_owe FOR ll_i = 1 TO it_mxbt ll_mtrlid = outwaremx[ll_i].mtrlid ls_status = outwaremx[ll_i].status ls_woodcode = outwaremx[ll_i].woodcode ls_pcode = outwaremx[ll_i].pcode ll_printid = outwaremx[ll_i].printid ld_qty = outwaremx[ll_i].qty ll_taskid = outwaremx[ll_i].relid IF ll_taskid > 0 THEN SELECT taskcode,relcode INTO :ls_taskcode,:ls_taskrelcode FROM u_saletask WHERE taskid = :ll_taskid AND scid = :scid using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询明细相关订单失败'+commit_transaction.SQLErrText GOTO ext END IF END IF SELECT outtype,ifpackpro INTO :li_outtype,:li_ifpackpro FROM u_mtrldef Where mtrlid = :ll_mtrlid using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '查询产品出仓类型失败'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF it_mxt = 1 //yyx20100424 IF li_outtype <> 0 THEN DECLARE cur_pf CURSOR FOR SELECT u_PrdPF.SonMtrlid, u_PrdPF.status, u_PrdPF.woodcode, u_PrdPF.pcode, u_PrdPF.ifover, u_prdpf.dipztype, u_prdpf.Sonscale FROM u_PrdPF,u_mtrl_pf WHERE ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid ) AND ( u_PrdPF.pfcode = u_mtrl_pf.pfcode ) AND ( u_PrdPF.mtrlid = :ll_mtrlid ) AND ( u_mtrl_pf.ifdi = 1 AND :li_ifpackpro = 0 OR u_mtrl_pf.ifdft = 1 AND :li_ifpackpro = 1 ) using commit_transaction; OPEN cur_pf; FETCH cur_pf INTO :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; DO WHILE sqlca.SQLCode = 0 it_mxt++ FETCH cur_pf INTO :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; LOOP it_mxt = it_mxt - 1 CLOSE cur_pf; FOR ll_k = 1 TO it_mxt IF li_ifover[ll_k] = 1 THEN CHOOSE CASE li_dipztype[ll_k] CASE 0 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = '' CASE 1 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = '' CASE 2 ls_status_find = '' ls_woodcode_find = '' ls_pcode_find = ls_pcode CASE 3 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = '' CASE 4 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode CASE 5 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = ls_pcode CASE 6 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode END CHOOSE ELSE ls_status_find = ls_pf_status[ll_k] ls_woodcode_find = ls_pf_woodcode[ll_k] ls_pcode_find = ls_pf_pcode[ll_k] END IF ls_status_find = Trim(ls_status_find) ls_woodcode_find = Trim(ls_woodcode_find) ls_pcode_find = Trim(ls_pcode_find) ld_pfqty = 0 FOR ll_j = 1 TO it_mxbt_mx IF outwaremx_mx[ll_j].printid = ll_printid AND & outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] AND & outwaremx_mx[ll_j].status = ls_status_find AND & outwaremx_mx[ll_j].woodcode = ls_woodcode_find AND & outwaremx_mx[ll_j].pcode = ls_pcode_find THEN ld_pfqty = ld_pfqty + outwaremx_mx[ll_j].qty END IF NEXT IF ld_qty * ld_Sonscale[ll_k] > ld_pfqty THEN count++ arg_s_owe.arg_s_mx[count].printid = count arg_s_owe.arg_s_mx[count].taskid = ll_taskid arg_s_owe.arg_s_mx[count].taskprintid = ll_printid arg_s_owe.arg_s_mx[count].taskcode = ls_taskcode arg_s_owe.arg_s_mx[count].taskrelcode = ls_taskrelcode arg_s_owe.arg_s_mx[count].taskmtrlid = ll_mtrlid arg_s_owe.arg_s_mx[count].mtrlid = ll_SonMtrlid[ll_k] arg_s_owe.arg_s_mx[count].status = ls_status_find arg_s_owe.arg_s_mx[count].woodcode = ls_woodcode_find arg_s_owe.arg_s_mx[count].pcode = ls_pcode_find arg_s_owe.arg_s_mx[count].plancode = outwaremx[ll_i].plancode arg_s_owe.arg_s_mx[count].qty = ld_qty * ld_Sonscale[ll_k] - ld_pfqty arg_s_owe.arg_s_mx[count].mxdscrp = '' IF ll_taskid > 0 THEN arg_s_owe.arg_s_mx[count].ifrel = 1 ELSE arg_s_owe.arg_s_mx[count].ifrel = 0 END IF END IF NEXT END IF NEXT IF count > 0 THEN arg_s_owe.scid = scid arg_s_owe.billid = 0 arg_s_owe.cusid = cusid arg_s_owe.loandate = outdate arg_s_owe.relcode = outwarecode arg_s_owe.dscrp = '销售发货单仓审自动生成' arg_s_owe.assignemp = outrep arg_s_owe.storageid = storageid arg_s_owe.ifaddware = 0 arg_s_owe.relid = outwareid IF uo_owe.Save(arg_s_owe,publ_operator,arg_msg,FALSE) = 0 THEN rslt = 0 GOTO ext END IF END IF ext: IF rslt = 0 THEN ROLLBACK; END IF DESTROY uo_owe RETURN rslt end function public function integer auditing_th (boolean arg_ifcommit, ref string arg_msg); Long rslt = 1,cnt = 0,i,j,k 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 mx_barcode_cnt Decimal ld_ref_costamt Int li_flag Int li_ifvqty s_inwaremx s_mx s_outwaremx s_mx_out uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel' ds_out_assign.SetTransObject(commit_transaction) uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction If uo_option_outware_saleout = -1000 Then rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_inout_type = -1000 Then rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_confirmaudit_sale = -1000 Then rslt = 0 arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!' Goto ext End If uo_saletask uo_task uo_task = Create uo_saletask uo_task.commit_transaction = commit_transaction 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 Int li_outtype_storage,li_storagetype Select storagename,outtype,storagetype Into :ls_storagename,:li_outtype_storage,:li_storagetype 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_inware uo_in uo_outware uo_out uo_in = Create uo_inware uo_in.commit_transaction = sqlca uo_in.if_getid_ture = False uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False For i = 1 To it_mxbt ld_ref_costamt = 0 If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,& outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then arg_msg = '退货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If If ld_ref_costamt = 0 Then ld_ref_costamt = Round(outwaremx[i].qty * outwaremx[i].planprice,2) 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 arg_msg = '退货明细行:'+String(i)+','+arg_msg 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 If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then If uo_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].qty,arg_msg,False) <> 1 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 Select status Into :li_flag From u_saletask Where scid = :scid And taskid = :outwaremx[i].relid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '查询相关订单状态失败,'+sqlca.SQLErrText arg_msg = '退货明细行:'+String(i)+','+arg_msg Goto ext End If If li_flag = 1 Or li_flag = 5 Then If uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then arg_msg = '退货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If End If End If //更新库存分配yyx20130130 Decimal ld_assign_outqty,ld_sumnotoutqty,ld_outmxqty Long ll_row If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_outmxqty = Abs(outwaremx[i].qty) If ld_outmxqty > ld_sumnotoutqty Then arg_msg = '退货明细行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmxqty Then ld_assign_outqty = ld_outmxqty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '退货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '退货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j] End If Next End If End If If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++ Next If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then cnt = 1 For ll_i = 1 To it_mxbt_mx If ll_i = 1 Then ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid Goto _next End If For ll_j = 1 To cnt If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then Goto _next End If Next cnt++ ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid _next: Next For ll_i = 1 To cnt If uo_out.newbegin(scid,21,arg_msg) = 0 Then arg_msg = '退货单(包件明细),' + arg_msg rslt = 0 Goto ext End If uo_out.relid = outwareid uo_out.outdate = outdate uo_out.outrep = outrep uo_out.part = outwarecode uo_out.dscrp = dscrp uo_out.cusname = '包件明细自动出仓' uo_out.storageid = ll_storageid_arr[ll_i] uo_out.thflag = 1 chc = 0 For i = 1 To it_mxbt_mx If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue Select ifpack,ifunit,unit,rate_buy,unit_buy Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy From u_mtrldef Where mtrlid = :outwaremx_mx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '退货单(包件明细)行:'+String(i)+",因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If chc++ f_get_planprice_mtrl(outwaremx_mx[i].mtrlid,outwaremx_mx[i].status,outwaremx_mx[i].woodcode,outwaremx_mx[i].pcode,ld_fprice) If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx_mx[i].qty Else If ld_rate_buy = 0 Then arg_msg = '退货单(包件明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx_mx[i].qty /ld_rate_buy End If li_ifvqty = 0 For k = 1 To it_mxbt If outwaremx[k].printid = outwaremx_mx[i].printid Then If outwaremx[k].mtrlid = outwaremx_mx[i].mtrlid And & outwaremx[k].status = outwaremx_mx[i].status And & outwaremx[k].woodcode = outwaremx_mx[i].woodcode And & outwaremx[k].pcode = outwaremx_mx[i].pcode Then li_ifvqty = 1 Else li_ifvqty = 0 End If Exit End If Next s_mx_out.mtrlwareid = outwaremx_mx[i].mtrlwareid s_mx_out.qty = outwaremx_mx[i].qty s_mx_out.fprice = ld_fprice s_mx_out.rebate = 1 s_mx_out.mxdscrp = outwaremx_mx[i].mxdscrp s_mx_out.printid = chc s_mx_out.ifrel = 0 s_mx_out.relid = 0 s_mx_out.olmtrlid = outwaremx_mx[i].printid s_mx_out.packqty = 0 s_mx_out.outtype = '' s_mx_out.planqty = 0 s_mx_out.relprintid = outwaremx_mx[i].mxprintid s_mx_out.unit = ls_uunit s_mx_out.uqty = ld_uqty s_mx_out.rate = ld_rate s_mx_out.pricetype = '' s_mx_out.formula = '' s_mx_out.saleoutid = 0 s_mx_out.saleoutprintid = 0 s_mx_out.mxdscrp2 = '' s_mx_out.net_weight = 0 s_mx_out.gross_weight = 0 s_mx_out.cubage = 0 s_mx_out.taxrate = 0 s_mx_out.priceformula = '' s_mx_out.qtyformula = '' s_mx_out.ifnotinout = outwaremx_mx[i].ifnotinout s_mx_out.ifvqty = li_ifvqty If uo_out.acceptmx(s_mx_out,arg_msg) = 0 Then arg_msg = '退货单(包件明细)'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,& // outwaremx_mx[i].qty,ld_fprice,1,& // outwaremx_mx[i].mxdscrp,chc,arg_msg,0,0,outwaremx_mx[i].printid,0,'',0,outwaremx_mx[i].mxprintid,& // ls_uunit,ld_uqty,ld_rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN // arg_msg = '退货单(包件明细)行:'+String(i)+arg_msg // rslt = 0 // GOTO ext // END IF Next If uo_out.Save(False,arg_msg) = 0 Then arg_msg = '退货单(包件明细),' + arg_msg rslt = 0 Goto ext End If rst_outwareid = uo_out.outwareid //2.原事务审核出仓单 If uo_out.getinfo(scid,rst_outwareid,arg_msg) = 0 Then arg_msg = '退货单(包件明细),' + arg_msg rslt = 0 Goto ext End If If uo_out.auditing(False,arg_msg) = 0 Then arg_msg = '退货单(包件明细),' + arg_msg rslt = 0 Goto ext End If Next If uo_in.newbegin(scid,23,arg_msg) = 0 Then arg_msg = '退货单(退货明细),' + arg_msg rslt = 0 Goto ext End If uo_in.relid = outwareid uo_in.indate = outdate uo_in.inrep = outrep uo_in.part = outwarecode uo_in.dscrp = dscrp uo_in.sptname = '银售退货单(退货明细)自动进仓' uo_in.storageid = storageid chc = 0 For i = 1 To it_mxbt Select ifpackpro,ifunit,unit,rate_buy,unit_buy Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy From u_mtrldef Where mtrlid = :outwaremx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '退货单(退货明细)行'+String(i)+",查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If // IF li_ifpackpro = 1 THEN // f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice) ld_ref_costamt = 0 If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,& outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then arg_msg = '退货单(退货明细)行'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF ld_ref_costamt > 0 THEN If outwaremx[i].qty <> 0 Then ld_fprice = Round(ld_ref_costamt/outwaremx[i].qty,uo_option_cost_dec) End If // END IF chc++ If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx[i].qty ld_uprice = ld_fprice Else If ld_rate_buy = 0 Then arg_msg = '退货单(退货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx[i].qty /ld_rate_buy ld_uprice = ld_fprice * ld_rate End If s_mx.printid = chc s_mx.mtrlid = outwaremx[i].mtrlid s_mx.mtrlcode = outwaremx[i].mtrlcode s_mx.plancode = outwaremx[i].plancode s_mx.status = outwaremx[i].status s_mx.uqty = ld_uqty s_mx.enprice = ld_uprice s_mx.rebate = 1 s_mx.mxdscrp = outwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.ifrel = 0 s_mx.woodcode = outwaremx[i].woodcode s_mx.pcode = outwaremx[i].pcode s_mx.sptid = outwaremx[i].sptid s_mx.unit = ls_uunit s_mx.rate = ld_rate s_mx.qty = outwaremx[i].qty s_mx.relprintid = 0 s_mx.checkqty = 0 s_mx.result = '' s_mx.waredscrp = '' s_mx.relbillid = 0 s_mx.relbillprintid = 0 s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode s_mx.Location = outwaremx[i].Location s_mx.deliqty = ld_uqty s_mx.tax = 0 If outwaremx[i].ifpackpro = 0 Then s_mx.ifvqty = 1 s_mx.ifnotinout = 1 Else s_mx.ifvqty = 0 s_mx.ifnotinout = 0 End If If uo_in.acceptmx(s_mx, arg_msg) = 0 Then arg_msg = '退货单(退货明细),行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_in.acceptmx(chc,& // outwaremx[i].mtrlid,& // outwaremx[i].mtrlcode,& // outwaremx[i].plancode,& // outwaremx[i].status,& // ld_uqty,& // ld_uprice,& // 1,& // outwaremx[i].mxdscrp,& // arg_msg,& // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,& // outwaremx[i].qty,0,0,'','',0,0,& // outwaremx[i].mtrlcuscode,outwaremx[i].Location,& // ld_uqty,& // 0) = 0 THEN // arg_msg = '退货单(退货明细)行'+String(i)+','+arg_msg // rslt = 0 // GOTO ext // END IF // END IF Next If uo_in.Save(False,arg_msg) = 0 Then arg_msg = '退货单(退货明细),'+arg_msg rslt = 0 Goto ext End If rst_inwareid = uo_in.inwareid //4.原事务审核进仓单 If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then arg_msg = '退货单(退货明细),'+arg_msg rslt = 0 Goto ext End If If uo_in.auditing(False,arg_msg) = 0 Then arg_msg = '退货单(退货明细),'+arg_msg rslt = 0 Goto ext End If // END IF //原发货单明细取消分配出仓 For i = 1 To it_mxbt //yyx20130130 If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() If ll_row <= 0 Then ld_sumnotoutqty = 0 Else ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] End If ld_outmxqty = Abs(outwaremx[i].qty) If ld_outmxqty > ld_sumnotoutqty Then arg_msg = '退货明细行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细' rslt = 0 Goto ext Else ld_assign_outqty = 0 For j = 1 To ds_out_assign.RowCount() If ds_out_assign.Object.notoutqty[j] >= ld_outmxqty Then ld_assign_outqty = ld_outmxqty If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If Exit Else ld_assign_outqty = ds_out_assign.Object.notoutqty[j] If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j] End If Next End If End If // Next End If Long ll_printid_arr[],ll_mtrlwareid_arr[],ll_mtrlid_arr[] String ls_status_arr[],ls_woodcode_arr[],ls_pcode_arr[] Decimal ld_qty_arr[] Long ll_cnt = 1 Long ll_printid Decimal ld_maxqty Long ll_mtrlid Int li_outtype String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[] Int li_ifover[],li_dipztype[] Decimal ld_Sonscale[] Long ll_SonMtrlid[] Long it_mxt = 1 String ls_status_find,ls_woodcode_find,ls_pcode_find String ls_status,ls_woodcode,ls_pcode Decimal ld_pfqty If uo_option_outware_saleout = 1 Then Declare cur_mx Cursor For Select u_outwaremx.relid, u_outwaremx.mtrlwareid, u_outwaremx.mtrlid, u_outwaremx.status, u_outwaremx.woodcode, u_outwaremx.pcode, u_outwaremx.qty From u_outwaremx Inner JOIN u_outware ON u_outwaremx.scid = u_outware.scid And u_outwaremx.outwareid = u_outware.outwareid Where u_outware.relid = :outwareid And u_outware.scid = :scid And u_outware.billtype = 21 Using commit_transaction; Open cur_mx; Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt], :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt]; Do While commit_transaction.SQLCode = 0 ll_cnt++ Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt], :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt]; Loop Close cur_mx; ll_cnt = ll_cnt - 1 For ll_i = 1 To it_mxbt ld_maxqty = 0 it_mxt = 1 ll_printid = outwaremx[ll_i].printid ll_mtrlid = outwaremx[ll_i].mtrlid ls_status = outwaremx[ll_i].status ls_woodcode = outwaremx[ll_i].woodcode ls_pcode = outwaremx[ll_i].pcode Select outtype,ifpackpro Into :li_outtype,:li_ifpackpro From u_mtrldef Where mtrlid = :ll_mtrlid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then arg_msg = '查询产品出仓类型失败' rslt = 0 Goto ext End If // IF li_outtype = 0 or li_ifpackpro = 0 THEN If Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro = 1) Then For ll_j = 1 To ll_cnt If ll_mtrlwareid_arr[ll_j] = 0 Then Continue If ll_printid_arr[ll_j] = ll_printid Then ld_maxqty = ld_qty_arr[ll_j] Exit End If Next Update u_outwaremx Set qty = :ld_maxqty Where outwareid = :outwareid And scid = :scid And printid = :ll_printid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '更新实发数失败' Goto ext End If Else Declare cur_pf Cursor For Select u_PrdPF.SonMtrlid, u_PrdPF.status, u_PrdPF.woodcode, u_PrdPF.pcode, u_PrdPF.ifover, u_prdpf.dipztype, u_prdpf.Sonscale From u_PrdPF,u_mtrl_pf Where ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid ) And ( u_PrdPF.pfcode = u_mtrl_pf.pfcode ) And ( u_PrdPF.mtrlid = :ll_mtrlid ) And ( u_mtrl_pf.ifdi = 1 And :li_ifpackpro = 0 Or u_mtrl_pf.ifdft = 1 And :li_ifpackpro = 1 ); Open cur_pf; Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; Do While sqlca.SQLCode = 0 it_mxt++ Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt], :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt], :li_dipztype[it_mxt],:ld_Sonscale[it_mxt]; Loop it_mxt = it_mxt - 1 Close cur_pf; For ll_k = 1 To it_mxt If li_ifover[ll_k] = 1 Then Choose Case li_dipztype[ll_k] Case 0 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = '' Case 1 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = '' Case 2 ls_status_find = '' ls_woodcode_find = '' ls_pcode_find = ls_pcode Case 3 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = '' Case 4 ls_status_find = '' ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode Case 5 ls_status_find = ls_status ls_woodcode_find = '' ls_pcode_find = ls_pcode Case 6 ls_status_find = ls_status ls_woodcode_find = ls_woodcode ls_pcode_find = ls_pcode End Choose Else ls_status_find = ls_pf_status[ll_k] ls_woodcode_find = ls_pf_woodcode[ll_k] ls_pcode_find = ls_pf_pcode[ll_k] End If ls_status_find = Trim(ls_status_find) ls_woodcode_find = Trim(ls_woodcode_find) ls_pcode_find = Trim(ls_pcode_find) ld_pfqty = 0 For ll_j = 1 To ll_cnt If ll_mtrlwareid_arr[ll_j] = 0 Then Continue If ll_printid_arr[ll_j] = ll_printid And & ll_mtrlid_arr[ll_j] = ll_SonMtrlid[ll_k] And & ls_status_arr[ll_j] = ls_status_find And & ls_woodcode_arr[ll_j] = ls_woodcode_find And & ls_pcode_arr[ll_j] = ls_pcode_find Then ld_pfqty = ld_pfqty + ld_qty_arr[ll_j] / ld_Sonscale[ll_k] End If Next If thflag = 0 Then If ld_pfqty > ld_maxqty Then ld_maxqty = ld_pfqty Else If ld_pfqty < ld_maxqty Then ld_maxqty = ld_pfqty End If Next Update u_outwaremx Set qty = :ld_maxqty Where outwareid = :outwareid And scid = :scid And printid = :ll_printid Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '更新实发数失败' Goto ext End If End If outwaremx[ll_i].qty = ld_maxqty Next If uo_in.newbegin(scid,23,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_in.relid = outwareid uo_in.indate = outdate uo_in.inrep = outrep uo_in.part = outwarecode uo_in.dscrp = dscrp uo_in.sptname = '包件自动进仓' uo_in.storageid = storageid chc = 0 For i = 1 To it_mxbt Select ifpackpro,ifunit,unit,rate_buy,unit_buy Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy From u_mtrldef Where mtrlid = :outwaremx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If chc++ f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice) If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx[i].qty ld_uprice = ld_fprice Else If ld_rate_buy = 0 Then arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx[i].qty /ld_rate_buy ld_uprice = ld_fprice * ld_rate End If If ld_uqty <> 0 Or outwaremx[i].qty <> 0 Then s_mx.printid = chc s_mx.mtrlid = outwaremx[i].mtrlid s_mx.mtrlcode = outwaremx[i].mtrlcode s_mx.plancode = outwaremx[i].plancode s_mx.status = outwaremx[i].status s_mx.uqty = ld_uqty s_mx.enprice = ld_uprice s_mx.rebate = 1 s_mx.mxdscrp = outwaremx[i].mxdscrp s_mx.jgprice = 0 s_mx.relid = 0 s_mx.ifrel = 0 s_mx.woodcode = outwaremx[i].woodcode s_mx.pcode = outwaremx[i].pcode s_mx.sptid = outwaremx[i].sptid s_mx.unit = ls_uunit s_mx.rate = ld_rate s_mx.qty = outwaremx[i].qty s_mx.relprintid = 0 s_mx.checkqty = 0 s_mx.result = '' s_mx.waredscrp = '' s_mx.relbillid = 0 s_mx.relbillprintid = 0 s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode s_mx.Location = outwaremx[i].Location s_mx.deliqty = ld_uqty s_mx.tax = 0 If outwaremx[i].ifpackpro = 0 Then s_mx.ifvqty = 1 s_mx.ifnotinout = 1 Else s_mx.ifvqty = 0 s_mx.ifnotinout = 0 End If If uo_in.acceptmx(s_mx, arg_msg) = 0 Then arg_msg = '退货单(退货明细),行:'+String(i)+','+arg_msg rslt = 0 Goto ext End If // IF uo_in.acceptmx(chc,& // outwaremx[i].mtrlid,& // outwaremx[i].mtrlcode,& // outwaremx[i].plancode,& // outwaremx[i].status,& // ld_uqty,& // ld_uprice,& // 1,& // outwaremx[i].mxdscrp,& // arg_msg,& // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,& // outwaremx[i].qty,0,0,'','',0,0,& // outwaremx[i].mtrlcuscode,outwaremx[i].Location,& // ld_uqty,& // 0) = 0 THEN // rslt = 0 // GOTO ext // END IF End If Next If uo_in.Save(False,arg_msg) = 0 Then rslt = 0 Goto ext End If rst_inwareid = uo_in.inwareid //4.原事务审核进仓单 If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If If uo_in.auditing(False,arg_msg) = 0 Then rslt = 0 Goto ext End If End If If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then If uof_p_barcode(1,arg_msg) = 0 Then 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 Destroy uo_pro Destroy uo_task Destroy uo_in Destroy uo_out Destroy ds_out_assign Destroy uo_ma Return rslt end function public function integer c_auditing_th (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j 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 mx_barcode_cnt Long ll_outwareid[] Long ll_itmx = 1,ll_i Int li_flag Decimal ld_assign_outqty,ld_sumnotoutqty,ld_sumnotoutqty_bill Long ll_row IF uo_option_outware_saleout = -1000 THEN rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' GOTO ext END IF IF uo_option_inout_type = -1000 THEN rslt = 0 arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!' GOTO ext END IF SetNull(null_dt) uo_saletask uo_task uo_task = Create uo_saletask uo_task.commit_transaction = commit_transaction uo_sqlpro uo_pro uo_pro = Create uo_sqlpro uo_pro.commit_transaction = commit_transaction uo_inware uo_in uo_outware uo_out uo_in = Create uo_inware uo_in.commit_transaction = sqlca uo_in.if_getid_ture = False uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False uo_mtrlware_assign uo_ma uo_ma = Create uo_mtrlware_assign uo_ma.commit_transaction = commit_transaction //库存分配ds datastore ds_out_assign ds_out_assign = Create datastore ds_out_assign.DataObject = 'ds_outwaremx_assign' ds_out_assign.SetTransObject(commit_transaction) 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 Int li_outtype_storage,li_storagetype SELECT storagename,outtype,storagetype INTO :ls_storagename,:li_outtype_storage,:li_storagetype 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 SELECT count(*) INTO :cnt FROM u_owegood WHERE scid = :scid And relid = :outwareid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '因网络或其它原因导致查询是否存在相关欠货单操作失败'+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 1 THEN rslt = 0 arg_msg = '不合理的欠货单数量(存在多张相关欠货单),请检查' GOTO ext ELSEIF cnt = 1 THEN SELECT billid,billcode ,flag INTO :ll_owebillid,:ls_owecode,:li_oweflag FROM u_owegood WHERE scid = :scid And relid = :outwareid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '因网络或其它原因导致查询\相关欠货单信息操作失败'+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF li_oweflag <> 0 THEN rslt = 0 arg_msg = '相关欠货单:'+ls_owecode+' 已在进行或完成,不能撤审销售发货单,请检查' GOTO ext END IF DELETE FROM u_owegoodmx Where billid = :ll_owebillid; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除相关欠货单明细操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF DELETE FROM u_owegood WHERE billid = :ll_owebillid And flag = 0; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "删除相关欠货单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF END IF 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 IF li_outtype_storage <> 0 And uo_option_outware_saleout = 0 THEN //yyx20130130 //仓库是用库存分配,(包件出仓或条码出仓),包件产品扣分配,包件在销售出仓单做 FOR i = 1 To it_mxbt IF billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 THEN ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() IF ll_row <= 0 THEN ld_sumnotoutqty = 0 ELSE ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] END IF ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = Abs(outwaremx[i].qty) IF ld_sumnotoutqty > 0 And ld_sumnotoutqty_bill > 0 THEN ld_assign_outqty = 0 FOR j = 1 To ds_out_assign.RowCount() IF ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill THEN ld_assign_outqty = ld_sumnotoutqty_bill IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(发货明细)行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF EXIT ELSE ld_assign_outqty = ds_out_assign.Object.notoutqty[j] IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(发货明细)行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] END IF NEXT END IF END IF NEXT //end_20130130 SELECT count(*) INTO :cnt FROM u_inware WHERE scid = :scid AND relid = :outwareid And billtype = 23 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 0 THEN SELECT inwareid,inwarecode INTO :ll_inwareid_rel,:ls_inwarecode_rel FROM u_inware WHERE scid = :scid AND relid = :outwareid And billtype = 23 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF IF uo_in.c_auditing(False,arg_msg) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF IF uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF END IF DECLARE cur_mx CURSOR FOR SELECT outwareid,outwarecode FROM u_outware WHERE billtype = 21 AND relid = :outwareid And scid = :scid Using commit_transaction; OPEN cur_mx; FETCH cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx]; DO WHILE commit_transaction.SQLCode = 0 ll_itmx++ FETCH cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx]; LOOP ll_itmx = ll_itmx - 1 CLOSE cur_mx; FOR ll_i = 1 To ll_itmx IF uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 THEN rslt = 0 arg_msg = '查询相关出仓单失败,' + arg_msg GOTO ext END IF IF uo_out.c_auditing(False,arg_msg) = 0 THEN rslt = 0 arg_msg = '撤审相关出仓单失败,' + arg_msg GOTO ext END IF IF uo_out.del(scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 THEN arg_msg = '相关出仓单:'+ls_outwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF NEXT END IF IF uo_option_outware_saleout = 1 THEN SELECT count(*) INTO :cnt FROM u_inware WHERE scid = :scid AND relid = :outwareid And billtype = 23 Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF cnt > 0 THEN SELECT inwareid,inwarecode INTO :ll_inwareid_rel,:ls_inwarecode_rel FROM u_inware WHERE scid = :scid AND relid = :outwareid And billtype = 23; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText GOTO ext END IF IF uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF IF uo_in.c_auditing(False,arg_msg) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF IF uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 THEN arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg rslt = 0 GOTO ext END IF END IF DECLARE cur_mx_rel CURSOR FOR SELECT outwareid FROM u_outware WHERE billtype = 21 AND relid = :outwareid And scid = :scid Using commit_transaction; OPEN cur_mx_rel; FETCH cur_mx_rel Into :ll_outwareid[ll_itmx]; DO WHILE commit_transaction.SQLCode = 0 ll_itmx++ FETCH cur_mx_rel Into :ll_outwareid[ll_itmx]; LOOP ll_itmx = ll_itmx - 1 CLOSE cur_mx_rel; FOR ll_i = 1 To ll_itmx IF uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 THEN rslt = 0 arg_msg = '查询相关出仓单失败,' + arg_msg GOTO ext END IF IF uo_out.c_auditing(False,arg_msg) = 0 THEN rslt = 0 arg_msg = '撤审相关出仓单失败,' + arg_msg GOTO ext END IF NEXT END IF FOR i = 1 To it_mxbt //更新分配 IF billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 THEN ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid) ds_out_assign.AcceptText() IF ll_row <= 0 THEN ld_sumnotoutqty = 0 ELSE ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1] END IF ld_sumnotoutqty_bill = 0 ld_sumnotoutqty_bill = outwaremx[i].qty IF ld_sumnotoutqty_bill > ld_sumnotoutqty THEN arg_msg = '发货明细行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细' rslt = 0 GOTO ext ELSE ld_assign_outqty = 0 FOR j = 1 To ds_out_assign.RowCount() IF ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill THEN ld_assign_outqty = ld_sumnotoutqty_bill IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF EXIT ELSE ld_assign_outqty = ds_out_assign.Object.notoutqty[j] IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN arg_msg = '发货明细行:'+String(i)+','+arg_msg rslt = 0 GOTO ext END IF ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j] END IF NEXT END IF 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, 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_task.addmxcmpl(scid,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 SELECT status INTO :li_flag FROM u_saletask WHERE scid = :scid And taskid = :outwaremx[i].relid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询相关订单状态失败,'+sqlca.SQLErrText GOTO ext END IF IF li_flag = 1 Or li_flag = 5 THEN IF uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF IF li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++ NEXT IF li_outtype_storage = 2 And mx_barcode_cnt > 0 THEN IF uof_p_barcode(0,arg_msg) = 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 Destroy uo_task Destroy uo_in Destroy uo_out Destroy uo_pro Destroy ds_out_assign Destroy uo_ma RETURN rslt end function public function integer uof_check_pt (ref string arg_msg);Int rslt = 1 Long ll_ucrow,cnt Long ll_i,ll_j,ll_k,ll_l Boolean lb_f = False,lb_f2 = False Long ll_mtrlid_child Long ll_printid_child Decimal ld_planqty_child,ld_qty_child Long ll_taskid,ll_printid_task Int li_outtype,li_ifpackpro Decimal ld_planqty_mx_sum Decimal ld_Sonscale[],ld_Sonscale_fm[] Long ll_SonMtrlid[] Long it_mxt = 1 Decimal ld_rqty_mx s_mtrlcfg_expr s_pz[] String ls_status_child,ls_woodcode_child,ls_pcode_child String ls_status[],ls_woodcode[],ls_pcode[] //检查包件明细to包货明细 FOR ll_j = 1 To it_mxbt_mx lb_f2 = False FOR ll_i = 1 To it_mxbt IF outwaremx_mx[ll_j].printid = outwaremx[ll_i].printid THEN lb_f2 = True END IF NEXT IF Not lb_f2 THEN arg_msg = '包件明细行:'+String(outwaremx_mx[ll_j].mxprintid)+',相关发货明细行:'+String(outwaremx_mx[ll_j].printid)+',没有配套发货明细行,请检查' rslt = 0 GOTO ext END IF NEXT //检查发货明细to包件明细 FOR ll_i = 1 To it_mxbt ll_mtrlid_child = outwaremx[ll_i].mtrlid ll_printid_child = outwaremx[ll_i].printid ld_planqty_child = outwaremx[ll_i].qty ls_status_child = outwaremx[ll_i].status ls_woodcode_child = outwaremx[ll_i].woodcode ls_pcode_child = outwaremx[ll_i].pcode ll_taskid = outwaremx[ll_i].relid ll_printid_task = outwaremx[ll_i].relprintid SELECT outtype,ifpackpro INTO :li_outtype,:li_ifpackpro FROM u_mtrldef WHERE mtrlid = :ll_mtrlid_child Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',查询产品出仓类型及包件产品属性失败,'+commit_transaction.SQLErrText rslt = 0 GOTO ext END IF IF Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro > 0) THEN ld_planqty_mx_sum = 0 lb_f = False FOR ll_j = 1 To it_mxbt_mx IF outwaremx_mx[ll_j].printid = ll_printid_child THEN ld_planqty_mx_sum += outwaremx_mx[ll_j].qty lb_f = True END IF NEXT IF Not lb_f THEN arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',没有配套包件明细行,请检查,可能包件库存不足' rslt = 0 GOTO ext END IF IF ld_planqty_child <> ld_planqty_mx_sum THEN arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',与包件明细行配套数量不相符,请检查' rslt = 0 GOTO ext END IF ELSE IF li_ifpackpro = 1 Or li_ifpackpro = 2 THEN it_mxt = 1 cnt = 0 //查是否有换清单 IF li_ifpackpro = 2 And ll_taskid > 0 THEN SELECT count(*) INTO :cnt FROM u_saletaskmx_pf WHERE scid = :scid AND taskid = :ll_taskid And printid = :ll_printid_task; IF sqlca.SQLCode <> 0 THEN arg_msg = '查询发货明细:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',对应订单明细否有换包件失败,'+sqlca.SQLErrText RETURN 0 END IF END IF IF cnt > 0 THEN DECLARE cur_pf_saletaskmx CURSOR FOR SELECT u_saletaskmx_pf.SonMtrlid, u_saletaskmx_pf.Sonscale, u_saletaskmx_pf.Sonscale_fm FROM u_saletaskmx_pf WHERE ( u_saletaskmx_pf.scid = :scid ) AND ( u_saletaskmx_pf.taskid = :ll_taskid ) And ( u_saletaskmx_pf.printid = :ll_printid_task ); OPEN cur_pf_saletaskmx; FETCH cur_pf_saletaskmx Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; DO WHILE sqlca.SQLCode = 0 it_mxt++ FETCH cur_pf_saletaskmx Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; LOOP it_mxt = it_mxt - 1 CLOSE cur_pf_saletaskmx; ELSE DECLARE cur_pf CURSOR FOR SELECT u_PrdPF.SonMtrlid, u_prdpf.Sonscale, 1 FROM u_PrdPF,u_mtrl_pf,u_mtrldef WHERE ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid ) AND ( u_PrdPF.pfcode = u_mtrl_pf.pfcode ) AND ( u_PrdPF.SonMtrlid = u_mtrldef.mtrlid ) AND ( u_PrdPF.mtrlid = :ll_mtrlid_child ) AND ( u_mtrl_pf.ifdi = 1 AND :li_ifpackpro = 0 OR u_mtrl_pf.ifdft = 1 AND (:li_ifpackpro = 1 OR :li_ifpackpro = 2) AND u_mtrldef.ifpack > 0) Order By u_PrdPF.printid; OPEN cur_pf; FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; DO WHILE sqlca.SQLCode = 0 it_mxt++ FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; LOOP it_mxt = it_mxt - 1 CLOSE cur_pf; END IF ELSEIF li_ifpackpro = 5 THEN DECLARE cur_pf5 CURSOR FOR SELECT u_PrdPF.SonMtrlid, u_prdpf.Sonscale, 1 FROM u_PrdPF,u_mtrldef WHERE ( u_PrdPF.pfcode = :ls_status_child ) AND ( u_PrdPF.SonMtrlid = u_mtrldef.mtrlid ) AND ( u_PrdPF.mtrlid = :ll_mtrlid_child ) AND ( u_mtrldef.ifpack > 0) Order By u_PrdPF.printid; OPEN cur_pf5; FETCH cur_pf5 Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; DO WHILE sqlca.SQLCode = 0 it_mxt++ FETCH cur_pf5 Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt]; LOOP it_mxt = it_mxt - 1 CLOSE cur_pf5; ELSEIF li_ifpackpro = 3 Or li_ifpackpro = 4 THEN f_checkpz(ls_status_child,s_pz[]) it_mxt = UpperBound(s_pz) FOR ll_l = 1 To it_mxt ll_SonMtrlid[ll_l] = ll_mtrlid_child ld_Sonscale[ll_l] = Dec(s_pz[ll_l].qty) ld_Sonscale_fm[ll_l] = 1 ls_status[ll_l] = s_pz[ll_l].cfgname ls_woodcode[ll_l] = ls_woodcode_child ls_pcode[ll_l] = ls_pcode_child NEXT END IF FOR ll_k = 1 To it_mxt ld_planqty_mx_sum = 0 lb_f = False ld_rqty_mx = ld_planqty_child * ld_Sonscale[ll_k]/ld_Sonscale_fm[ll_k] IF li_ifpackpro = 1 Or li_ifpackpro = 2 THEN FOR ll_j = 1 To it_mxbt_mx IF outwaremx_mx[ll_j].printid = ll_printid_child And & outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] THEN ld_planqty_mx_sum += outwaremx_mx[ll_j].qty lb_f = True END IF NEXT ELSE FOR ll_j = 1 To it_mxbt_mx IF outwaremx_mx[ll_j].printid = ll_printid_child And & outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] And & outwaremx_mx[ll_j].status = ls_status[ll_k] And & outwaremx_mx[ll_j].woodcode = ls_woodcode[ll_k] And & outwaremx_mx[ll_j].pcode = ls_pcode[ll_k] THEN ld_planqty_mx_sum += outwaremx_mx[ll_j].qty lb_f = True END IF NEXT END IF IF Not lb_f THEN arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',没有配套包件明细行,请检查,可能包件库存不足' rslt = 0 GOTO ext END IF IF ld_rqty_mx <> ld_planqty_mx_sum THEN arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',与包件明细行配套数量不相符,请检查' rslt = 0 GOTO ext END IF NEXT END IF NEXT ext: RETURN rslt end function public function integer priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg, string arg_emp);Long rslt = 1,i uo_cusprice uo_price If uo_option_outware_saleout = -1000 Then rslt = 0 arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!' Goto ext End If If uo_option_checkprice_native = -1000 Then rslt = 0 arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!' Goto ext End If If arg_scid < 0 Then rslt = 0 arg_msg = "错误的分部ID" Goto ext End If If arg_outwareid <= 0 Then rslt = 0 arg_msg = "没有确认对象" Goto ext End If If getinfo(arg_scid,arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If If priceflag = 1 Then rslt = 0 arg_msg = "单据已经确认" Goto ext End If //yyx20150529调整顺序 Update u_outware Set priceemp = :arg_emp, pricedate = getdate(), priceflag = 1 Where u_outware.outwareid = :arg_outwareid And priceflag = 0 And scid = :arg_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_price = Create uo_cusprice For i = 1 To it_mxbt If outwaremx[i].outtype <> '' Then Continue If uo_option_checkprice_native = 1 Then If uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,& outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,& outwaremx[i].woodcode,relint_2,outwaremx[i].price,outwaremx[i].uqty,arg_msg) = 0 Then rslt = 0 Goto ext End If Else If uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,& outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,& outwaremx[i].woodcode,relint_2,outwaremx[i].enprice * outwaremx[i].rebate,outwaremx[i].uqty,arg_msg) = 0 Then rslt = 0 Goto ext End If End If Next If uo_option_outware_saleout > 0 Then //更新库存已开单数(减) If uof_noauditingqty_del(arg_scid,arg_outwareid,arg_msg) = 0 Then rslt = 0 Goto ext End If End If If uo_option_outware_saleout = 1 Then 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 chc,ll_j,ll_i Long ll_storageid_arr[],cnt = 0 li_ifpackcnt = 0 uo_outware uo_out uo_out = Create uo_outware uo_out.commit_transaction = sqlca uo_out.if_getid_ture = False For ll_i = 1 To it_mxbt_mx If ll_i = 1 Then cnt++ ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid Goto _next End If For ll_j = 1 To cnt If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then Goto _next End If Next cnt++ ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid _next: Next For ll_i = 1 To cnt If uo_out.newbegin(scid,21,arg_msg) = 0 Then rslt = 0 Goto ext End If uo_out.relid = outwareid uo_out.outdate = outdate uo_out.outrep = outrep uo_out.part = outwarecode uo_out.dscrp = dscrp uo_out.cusname = '包件明细自动出仓' uo_out.storageid = ll_storageid_arr[ll_i] chc = 0 For i = 1 To it_mxbt_mx If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue Select ifpack,ifunit,unit,rate_buy,unit_buy,planprice Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy,:ld_fprice From u_mtrldef Where mtrlid = :outwaremx_mx[i].mtrlid; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText Goto ext End If chc++ If li_ifunit = 0 Then ls_uunit = ls_unit ld_rate = 1 ld_uqty = outwaremx_mx[i].qty Else If ld_rate_buy = 0 Then arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查' rslt = 0 Goto ext End If ls_uunit = ls_unit_buy ld_rate = ld_rate_buy ld_uqty = outwaremx_mx[i].qty /ld_rate_buy End If If uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,& outwaremx_mx[i].qty,ld_fprice,1,& outwaremx_mx[i].mxdscrp,chc,arg_msg,0,outwaremx_mx[i].printid,0,0,'',outwaremx_mx[i].planqty,outwaremx_mx[i].mxprintid,& ls_uunit,ld_uqty,ld_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 Next End If priceflag = 1 //将相关虚拟库存数设为无效 For i = 1 To it_mxbt Update u_mtrlware_view Set inuse = 0 Where cusid = :cusid And mtrlwareid = :outwaremx[i].mtrlwareid And inuse = 1 Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '更新相关虚拟库存为无效失败'+'~n'+commit_transaction.SQLErrText Goto ext End If Next For i = 1 To it_mxbt_mx Update u_mtrlware_view Set inuse = 0 Where cusid = :cusid And mtrlwareid = :outwaremx_mx[i].mtrlwareid And inuse = 1 Using commit_transaction; If commit_transaction.SQLCode <> 0 Then rslt = 0 arg_msg = '更新相关包件明细虚拟库存为无效失败'+'~n'+commit_transaction.SQLErrText Goto ext End If Next ext: If rslt = 0 Then Rollback Using commit_transaction; ElseIf rslt = 1 And arg_ifcommit Then Commit Using commit_transaction; End If Destroy uo_price Destroy uo_out Return rslt end function on uo_outware_sale.create call super::create end on on uo_outware_sale.destroy call super::destroy end on event constructor;call super::constructor;String str_optionvalue,arg_msg f_get_sys_option_value('045',str_optionvalue,arg_msg) uo_option_m_msttake = Long(str_optionvalue) f_get_sys_option_value('052',str_optionvalue,arg_msg) uo_option_otheramt_msttake = Long(str_optionvalue) f_get_sys_option_value('050',str_optionvalue,arg_msg) uo_option_change_otheramt = trim(str_optionvalue) f_get_sys_option_value('188',str_optionvalue,arg_msg) uo_option_outware_sale_ifmating = Long(str_optionvalue) f_get_sys_option_value('332',str_optionvalue,arg_msg) uo_option_secaudit_notupdate_hisprice = Long(str_optionvalue) end event