123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262 |
- $PBExportHeader$uo_outware_wfjg.sru
- forward
- global type uo_outware_wfjg from nonvisualobject
- end type
- end forward
- global type uo_outware_wfjg from nonvisualobject
- end type
- global uo_outware_wfjg uo_outware_wfjg
- type variables
- PUBLIC PROTECTEDWRITE Long scid
- PUBLIC PROTECTEDWRITE Long outwareid
- PUBLIC PROTECTEDWRITE String outwarecode
- PUBLIC PROTECTEDWRITE Int billtype
- PUBLIC PROTECTEDWRITE DateTime opdate
- PUBLIC PROTECTEDWRITE String opemp
- PUBLIC PROTECTEDWRITE DateTime moddate
- PUBLIC PROTECTEDWRITE String modemp
- PUBLIC PROTECTEDWRITE Int balcflag
- PUBLIC PROTECTEDWRITE Int flag
- PUBLIC PROTECTEDWRITE DateTime auditingdate
- PUBLIC PROTECTEDWRITE String auditingrep
- PUBLIC PROTECTEDWRITE Decimal sum_amt
- PUBLIC PROTECTEDWRITE Int secflag
- PUBLIC PROTECTEDWRITE DateTime secauditingdate
- PUBLIC PROTECTEDWRITE String secauditingrep
- PUBLIC PROTECTEDWRITE Long ctmint
- Long relid
- DateTime outdate
- String outrep
- String part
- String dscrp
- Long sptid
- String sptname
- Int thflag
- Long banktypeid
- Long refpayid
- Boolean if_getid_ture = TRUE
- Transaction commit_transaction //数据commit事务
- s_outwaremx_wfjg outwaremx[] //明细结构数组
- Long it_mxbt = 0 //明细结构数组末指针
- Boolean it_newbegin = FALSE //新建标志
- Boolean it_updatebegin = FALSE //修改标志
- int uo_option_autocreate_outware,uo_option_2unit
- int uo_option_noauditingqty_mode
- end variables
- forward prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer p_reset ()
- 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 acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, decimal arg_fprice, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_relprintid, long arg_olmtrlid, decimal arg_rate)
- public function integer uof_check_sptpdb_audit (long arg_sptid, ref string arg_msg)
- public function integer uof_noauditingqty_add (ref string arg_msg)
- public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer acceptmx (s_outwaremx_wfjg s_mx, ref string arg_msg)
- end prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF Not (arg_billtype = 4 OR &
- arg_billtype = 7) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'4-仓库外协发出单,'
- arg_msg = arg_msg+'7-外协销售发货单'
- GOTO ext
- END IF
- p_reset()
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = TRUE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
- DateTime server_dt
- Long ls_newid
- String ls_sccode
- IF IsNull(relid) THEN relid = 0
- IF IsNull(outrep) THEN outrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(sptid) THEN sptid = 0
- IF IsNull(sptname) THEN sptname = ''
- IF IsNull(thflag) THEN thflag = 0
- IF IsNull(banktypeid) THEN banktypeid = 0
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "外协发出单没有正确出仓内容"
- GOTO ext
- END IF
- IF f_check_inoutdate(0,outdate,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF f_check_inoutdate_wfjg(scid,sptid,outdate,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 7 THEN
- IF banktypeid = 0 THEN
- arg_msg = '请选择结算方式'
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM cw_banktype
- Where banktypeid = :banktypeid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,结算方式"
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- arg_msg = '结算方式资料不存在'
- rslt = 0
- GOTO ext
- END IF
- END IF
- SELECT name INTO :sptname
- FROM u_spt
- Where sptid = :sptid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,加工商资料"
- GOTO ext
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF outwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"ow_wfjg_out","outwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- IF billtype = 4 THEN
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'WL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid(scid,ls_sccode + 'SL',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- ELSE //销售
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'SW',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid(scid,ls_sccode + 'UW',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- END IF
-
- IF outwarecode = "err" THEN
- outwarecode = ''
- rslt = 0
- arg_msg = "无法获取出仓单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
-
- INSERT INTO ow_wfjg_out (
- scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- outdate,
- outrep,
- part,
- dscrp,
- sptid,
- sptname,
- thflag,
- banktypeid,
- opdate,
- opemp)
- VALUES (
- :scid,
- :ls_newid,
- :outwarecode,
- :billtype,
- :relid,
- :outdate,
- :outrep,
- :part,
- :dscrp,
- :sptid,
- :sptname,
- :thflag,
- :banktypeid,
- :server_dt,
- :publ_operator
- ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新outwareid
- outwareid = ls_newid
-
- // FOR i = 1 TO it_mxbt
- // INSERT INTO ow_wfjgmx_out
- // (scid,
- // storageid,
- // outwareid,
- // mtrlwareid,
- // printid,
- // mtrlid,
- // plancode,
- // status,
- // qty,
- // fprice,
- // rebate,
- // price,
- // mxdscrp,
- // costamt,
- // ifrel,
- // relid,
- // relprintid,
- // woodcode,
- // relcode,
- // pcode,
- // cost,
- // olmtrlid,
- // uqty,
- // uprice,
- // uunit,
- // rate,
- // mtrlcuscode,
- // location)
- // VALUES (
- // :scid,
- // :outwaremx[i].storageid,
- // :ls_newid,
- // :outwaremx[i].mtrlwareid,
- // :outwaremx[i].printid,
- // :outwaremx[i].mtrlid,
- // :outwaremx[i].plancode,
- // :outwaremx[i].status,
- // :outwaremx[i].qty,
- // :outwaremx[i].fprice,
- // :outwaremx[i].rebate,
- // :outwaremx[i].price,
- // :outwaremx[i].mxdscrp,
- // :outwaremx[i].costamt,
- // :outwaremx[i].ifrel,
- // :outwaremx[i].relid,
- // :outwaremx[i].relprintid,
- // :outwaremx[i].woodcode,
- // :outwaremx[i].relcode,
- // :outwaremx[i].pcode,
- // :outwaremx[i].cost,
- // :outwaremx[i].olmtrlid,
- // :outwaremx[i].uqty,
- // :outwaremx[i].uprice,
- // :outwaremx[i].uunit,
- // :outwaremx[i].rate,
- // :outwaremx[i].mtrlcuscode,
- // :outwaremx[i].location) USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // outwareid = 0 //还原outwareid
- // rslt = 0
- // arg_msg = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- // GOTO ext
- // END IF
- // NEXT
- //
- // //更新库存已开单数
- // If uof_noauditingqty_add(arg_msg) = 0 Then
- // rslt = 0
- // Goto ext
- // End If
-
- ELSE //////////////////////////////////////////////// //更新
-
- UPDATE ow_wfjg_out
- SET billtype = :billtype,
- relid = :relid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- sptid = :sptid,
- sptname = :sptname,
- thflag = :thflag,
- banktypeid = :banktypeid,
- moddate = :server_dt,
- modemp = :publ_operator
- WHERE ow_wfjg_out.outwareid = :outwareid
- AND ow_wfjg_out.scid = :scid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //更新库存已开单数(减)
- IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM ow_wfjgmx_out
- WHERE ow_wfjgmx_out.outwareid = :outwareid
- And ow_wfjgmx_out.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- FOR i = 1 To it_mxbt
- INSERT INTO ow_wfjgmx_out
- (scid,
- storageid,
- outwareid,
- mtrlwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- fprice,
- rebate,
- price,
- mxdscrp,
- costamt,
- ifrel,
- relid,
- relprintid,
- woodcode,
- relcode,
- pcode,
- cost,
- olmtrlid,
- uqty,
- uprice,
- uunit,
- rate,
- mtrlcuscode,
- location,
- thtype,
- relprintid2,
- relmtrlid2,
- relqty2)
- VALUES (
- :scid,
- :outwaremx[i].storageid,
- :outwareid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].printid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].plancode,
- :outwaremx[i].status,
- :outwaremx[i].qty,
- :outwaremx[i].fprice,
- :outwaremx[i].rebate,
- :outwaremx[i].price,
- :outwaremx[i].mxdscrp,
- :outwaremx[i].costamt,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].woodcode,
- :outwaremx[i].relcode,
- :outwaremx[i].pcode,
- :outwaremx[i].cost,
- :outwaremx[i].olmtrlid,
- :outwaremx[i].uqty,
- :outwaremx[i].uprice,
- :outwaremx[i].uunit,
- :outwaremx[i].rate,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].location,
- :outwaremx[i].thtype,
- :outwaremx[i].relprintid2,
- :outwaremx[i].relmtrlid2,
- :outwaremx[i].relqty2) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- IF it_newbegin THEN outwareid = 0
- rslt = 0
- arg_msg = "插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- //更新库存已开单数
- IF uof_noauditingqty_add(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- uo_order_wfjg uo_wfjg
- uo_wfjg = Create uo_order_wfjg
- uo_wfjg.commit_transaction = commit_transaction
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = commit_transaction
- uo_out.if_getid_ture = False
- 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 billtype = 4 THEN
- IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- UPDATE ow_wfjg_out
- SET Auditingemp = :publ_operator,
- Auditingdate = getdate(),
- flag = 1
- WHERE ow_wfjg_out.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
- //生成出仓单
- Long lay_storageid[],ll_storageid,rst_outwareid
- Boolean lb_f = False
- Long j,k,ch,chc
- //统计仓库数量,确定出仓单数
- FOR i = 1 To it_mxbt
- FOR j = 1 To UpperBound(lay_storageid)
- IF lay_storageid[j] = outwaremx[i].storageid THEN lb_f = True
- NEXT
- IF lb_f = False THEN
- ch++
- lay_storageid[ch] = outwaremx[i].storageid
- END IF
- lb_f = False
- NEXT
- FOR k = 1 To ch
- ll_storageid = lay_storageid[k]
-
- IF uo_out.newbegin(scid,billtype,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
-
- IF billtype = 4 THEN
- uo_out.cusname = '仓库外协出仓:'+sptname
- ELSE
- uo_out.cusname = '仓库外协销售:'+sptname
- END IF
-
- uo_out.storageid = ll_storageid
- uo_out.cusid = sptid
-
- chc = 0
- FOR i = 1 To it_mxbt
- IF outwaremx[i].storageid <> ll_storageid THEN CONTINUE
- chc++
- IF uo_out.acceptmx(outwaremx[i].mtrlwareid,&
- outwaremx[i].qty,outwaremx[i].price,1,&
- outwaremx[i].mxdscrp,chc,arg_msg,0,0,outwaremx[i].olmtrlid,0,'',0,0,outwaremx[i].uunit,outwaremx[i].uqty,outwaremx[i].rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_out.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- rst_outwareid = uo_out.outwareid
-
- //2.原事务审核出仓单
- IF uo_out.getinfo( scid,rst_outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- //更新供应商库存
- IF billtype = 4 THEN
-
- FOR i = 1 To it_mxbt
- //更新订单已发出数
- IF outwaremx[i].relid > 0 THEN
- IF outwaremx[i].relprintid > 0 THEN
- IF outwaremx[i].thtype = 0 THEN //重新发出
- IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF outwaremx[i].thtype = 1 THEN //终止收货
- IF uo_wfjg.stopaddqty(scid, outwaremx[i].relid, outwaremx[i].relprintid2,'', 0 - outwaremx[i].relqty2,0,'终止收货',arg_msg, False) = 0 THEN
- //arg_msg = '更新行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSE //兼容旧数据,以后可删 20120910
- IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].mtrlid,outwaremx[i].sptid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
-
- IF f_update_mtrlware_spt_out (billtype,thflag,scid,outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, outwaremx[i].plancode,&
- outwaremx[i].status, outwaremx[i].qty, outwaremx[i].costamt,&
- outwaremx[i].planprice, sptid, &
- outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,False,commit_transaction) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- END IF
- //更新库存已开单数(减)
- IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- flag = 1
- ext:
- Destroy uo_out
- Destroy uo_wfjg
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1
- IF uo_option_autocreate_outware = -1000 THEN
- rslt = 0
- arg_msg = '选项:[087]外协订单审核自动生成仓库外协发出单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF Not (arg_billtype = 4 OR &
- arg_billtype = 7) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'4-仓库外协发出单,'
- arg_msg = arg_msg+'7-外协销售发货单'
- GOTO ext
- END IF
- IF arg_outwareid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF billtype = 4 AND relid > 0 AND uo_option_autocreate_outware = 1 THEN //自动生成的外协发出单,不允许修改
- rslt = 0
- arg_msg = '自动生成的单据,不可以修改'
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- outwareid = arg_outwareid
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);Int rslt = 1,i = 1,no_mxcheck = 0
- sum_amt = 0
-
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arg_msg = "非法出仓单唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_inwaermx CURSOR FOR
- SELECT ow_wfjgmx_out.printid,
- ow_wfjgmx_out.mtrlid,
- ow_wfjgmx_out.plancode,
- ow_wfjgmx_out.status,
- ow_wfjgmx_out.qty,
- ow_wfjgmx_out.fprice,
- ow_wfjgmx_out.rebate,
- ow_wfjgmx_out.price,
- ow_wfjgmx_out.mxdscrp,
- u_mtrldef.mtrlcode,
- ow_wfjgmx_out.mtrlwareid,
- ow_wfjgmx_out.storageid,
- ow_wfjgmx_out.costamt,
- ow_wfjgmx_out.ifrel,
- ow_wfjgmx_out.relid,
- ow_wfjgmx_out.relprintid,
- ow_wfjgmx_out.woodcode,
- ow_wfjgmx_out.pcode,
- ow_wfjgmx_out.cost,
- ow_wfjgmx_out.olmtrlid,
- ow_wfjgmx_out.uqty,
- ow_wfjgmx_out.uprice,
- ow_wfjgmx_out.rate,
- ow_wfjgmx_out.uunit,
- ow_wfjgmx_out.mtrlcuscode,
- ow_wfjgmx_out.location,
- ow_wfjgmx_out.thtype,
- ow_wfjgmx_out.relprintid2,
- ow_wfjgmx_out.relmtrlid2,
- ow_wfjgmx_out.relqty2
- FROM ow_wfjgmx_out,u_mtrldef,ow_wfjg_out
- WHERE ow_wfjg_out.outwareid = :arg_outwareid AND
- ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid AND
- ow_wfjg_out.scid = :arg_scid AND
- ow_wfjg_out.outwareid = ow_wfjgmx_out.outwareid AND
- ow_wfjg_out.scid = ow_wfjgmx_out.scid USING commit_transaction;
-
- OPEN cur_inwaermx;
- FETCH cur_inwaermx INTO
- :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,
- :outwaremx[i].cost,:outwaremx[i].olmtrlid,
- :outwaremx[i].uqty,:outwaremx[i].uprice,:outwaremx[i].rate,
- :outwaremx[i].uunit,:outwaremx[i].mtrlcuscode,:outwaremx[i].location,
- :outwaremx[i].thtype,:outwaremx[i].relprintid2,:outwaremx[i].relmtrlid2,:outwaremx[i].relqty2;
- DO WHILE commit_transaction.SQLCode = 0
- sum_amt = sum_amt + round(outwaremx[i].qty * outwaremx[i].price,2) //计算单据总金额
-
- i++
- FETCH cur_inwaermx INTO
- :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,
- :outwaremx[i].cost,:outwaremx[i].olmtrlid,
- :outwaremx[i].uqty,:outwaremx[i].uprice,:outwaremx[i].rate,
- :outwaremx[i].uunit,:outwaremx[i].mtrlcuscode,:outwaremx[i].location,
- :outwaremx[i].thtype,:outwaremx[i].relprintid2,:outwaremx[i].relmtrlid2,:outwaremx[i].relqty2;
- LOOP
- CLOSE cur_inwaermx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM ow_wfjgmx_out
- WHERE ow_wfjgmx_out.outwareid = :arg_outwareid
- AND scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细"
- GOTO ext
- END IF
- outwareid = arg_outwareid
- scid = arg_scid
- it_mxbt = i - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
- //0 FAIL, 1 SUCCESS
- Int rslt = 1
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arG_MSG = "没有删除对象,操作取消"
- GOTO ext
- END IF
- p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- //更新库存已开单数(减)
- If uof_noauditingqty_del(arg_scid,arg_outwareid,arG_MSG) = 0 Then
- rslt = 0
- Goto ext
- End If
- DELETE FROM ow_wfjg_out
- WHERE ow_wfjg_out.outwareid = :arg_outwareid
- AND ow_wfjg_out.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- DELETE FROM ow_wfjgmx_out
- WHERE ow_wfjgmx_out.outwareid = :arg_outwareid
- AND ow_wfjgmx_out.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除单据明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- p_reset()
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN (rslt)
- end function
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
- //0 fail 1 success
- Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF arg_newdescppart = '' THEN
- rslt = 0
- arg_msg = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "非审核状态下不可用"
- GOTO ext
- END IF
- UPDATE ow_wfjg_out
- SET dscrp = ltrim(rtrim(dscrp))+' '+:arg_newdescppart
- WHERE ow_wfjg_out.outwareid = :outwareid
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- ROLLBACK ;
- rslt = 0
- arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- COMMIT USING commit_transaction;
- dscrp = dscrp+' '+arg_newdescppart
- ext: Return (rslt)
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- DateTime null_dt
- SetNull(null_dt)
- uo_order_wfjg uo_wfjg
- uo_wfjg = Create uo_order_wfjg
- uo_wfjg.commit_transaction = commit_transaction
- uo_outware uo_out
- uo_out = Create uo_outware
- uo_out.commit_transaction = commit_transaction
- uo_out.if_getid_ture = False
- 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
- //检查外协商盘点表是否未审
- IF billtype = 4 THEN
- IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- UPDATE ow_wfjg_out
- SET Auditingemp = '',
- Auditingdate = :null_dt,
- flag = 0
- WHERE ow_wfjg_out.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
- Long ay_outwareid[],ll_outwareid,ch
- DECLARE getoutware CURSOR FOR
- SELECT outwareid FROM u_outware WHERE billtype = :billtype
- AND relid = :outwareid
- AND scid = :scid
- Using commit_transaction;
- OPEN getoutware;
- DO WHILE commit_transaction.SQLCode = 0
- FETCH getoutware Into :ll_outwareid;
- IF commit_transaction.SQLCode <> 0 THEN EXIT
- ch++
- ay_outwareid[ch] = ll_outwareid
- LOOP
- CLOSE getoutware;
- IF ch = 0 THEN
- arg_msg = '没有对应的出仓单'
- rslt = 0
- GOTO ext
- END IF
- FOR i = 1 To ch
- IF uo_out.getinfo(scid,ay_outwareid[i],arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_out.del(scid,ay_outwareid[i],0,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- NEXT
- IF billtype = 4 THEN
-
- FOR i = 1 To it_mxbt
- IF f_update_mtrlware_spt_out (billtype,thflag,scid,outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, outwaremx[i].plancode,&
- outwaremx[i].status, 0 - outwaremx[i].qty, 0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, sptid, &
- outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,False,commit_transaction) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF outwaremx[i].relid > 0 THEN
- IF outwaremx[i].thtype = 0 THEN //重新发出
- IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].relprintid,0 - outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSEIF outwaremx[i].thtype = 1 THEN //取消 终止收货
- IF uo_wfjg.stopaddqty(scid, outwaremx[i].relid, outwaremx[i].relprintid2,'', outwaremx[i].relqty2,0,'终止收货',arg_msg, False) = 0 THEN
- //arg_msg = '更新行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- NEXT
- END IF
- //更新库存已开单数
- IF uof_noauditingqty_add(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- flag = 0
- ext:
- Destroy uo_out
- Destroy uo_wfjg
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- return 1
- end function
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- INT rslt=1
- IF arg_outwareid<=0 THEN
- rslt=0
- arG_MSG="非法出仓单唯一码"
- goto ext
- end if
-
- SELECT ow_wfjg_out.outwarecode,
- ow_wfjg_out.billtype,
- ow_wfjg_out.relid,
- ow_wfjg_out.outdate,
- ow_wfjg_out.outrep,
- ow_wfjg_out.part,
- ow_wfjg_out.sptid,
- ow_wfjg_out.sptname,
- ow_wfjg_out.dscrp,
- ow_wfjg_out.thflag,
- ow_wfjg_out.flag,
- ow_wfjg_out.secflag,
- ow_wfjg_out.balcflag ,
- ow_wfjg_out.banktypeid ,
- ow_wfjg_out.refpayid ,
- ow_wfjg_out.ctmint
-
-
- INTO :outwarecode,
- :billtype,
- :relid,
- :outdate,
- :outrep,
- :part,
- :sptid,
- :sptname,
- :dscrp,
- :thflag,
- :flag,
- :secflag,
- :balcflag ,
- :banktypeid,
- :refpayid,
- :ctmint
- FROM ow_wfjg_out
- WHERE ow_wfjg_out.outwareid = :arg_outwareid
- and scid=:arg_scid
- using commit_transaction;
-
- if commit_transaction.sqlcode<>0 then
- rslt=0
- arG_MSG="查询操作失败(错误出仓单唯一码),出仓单"+commit_transaction.sqlerrtext
- goto ext
- end if
- outwareid = arg_outwareid
- scid = arg_scid
- ext:
- IF rslt=0 THEN p_reset()
- return rslt
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid = 0
- outwareid = 0
- outwarecode = ''
- billtype = 0
- opemp = ''
- modemp = ''
- auditingrep = ''
-
- flag = 0
-
- relid = 0
- //storageid = 0
- outrep = ''
- part = ''
- dscrp = ''
- sptid = 0
- sptname = ''
- thflag = 0
-
- it_newbegin = FALSE
- it_updatebegin = FALSE
- //清除明细
- p_clearmx()
- RETURN 1
- end function
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- String ls_about,ls_dscrp
- uo_mustpay uo_pay
- uo_pay = Create uo_mustpay
- Decimal ld_payamt = 0,ld_mstpayamt = 0
- 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
- Long ll_moneyid_native
- 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 ow_wfjg_out
- SET secauditingrep = :publ_operator,
- secauditingdate = getdate(),
- secflag = 1
- WHERE ow_wfjg_out.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 sum_amt <> 0 And billtype = 7 THEN
- SELECT btype,accountsid INTO :li_btype,:ll_accountsid
- FROM cw_banktype
- Where banktypeid = :banktypeid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- SELECT moneyid INTO :ll_moneyid_native
- FROM cw_currency
- Where native = 1;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询本位币资料失败'
- rslt = 0
- GOTO ext
- END IF
-
-
- IF thflag = 1 THEN
- ls_about = outwarecode + "退货款,相关号:"+part
- ELSE
- ls_about = outwarecode + "应收款,相关号:"+part
- END IF
-
- ls_dscrp = ls_about
- ld_mstpayamt = sum_amt
-
- IF li_btype = 1 THEN
- ld_payamt = ld_mstpayamt
- ELSE
- ld_payamt = 0
- END IF
-
- Long ll_dft_itemid
- IF thflag = 1 THEN
- SELECT itemid INTO :ll_dft_itemid
- FROM u_itemdef
- Where dfttype = 9;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询默认外协销售退货项目资料失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- SELECT itemid INTO :ll_dft_itemid
- FROM u_itemdef
- Where dfttype = 8;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询默认外协销售项目资料失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- s_bmstpay s_pay
- s_pay.scid = scid
- s_pay.sptid = sptid
- s_pay.paydate = outdate
- s_pay.inrep = outrep
- s_pay.oriamt = 0 - ld_mstpayamt
- s_pay.mstpayamt = 0 - ld_mstpayamt
- s_pay.payamt = 0 - ld_payamt
- s_pay.dscrp = ls_about
- s_pay.billcode = outwarecode
- s_pay.banktypeid = banktypeid
- // s_pay.viewdate = plandate
- s_pay.opemp = publ_operator
- s_pay.buildtype = 1
- s_pay.inwareid = outwareid
- s_pay.accountsid = ll_accountsid
- s_pay.itemid = ll_dft_itemid
- s_pay.moneyid = ll_moneyid_native
- s_pay.moneyid_cn = ll_moneyid_native
-
- IF uo_pay.add_payrec (s_pay,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- UPDATE ow_wfjg_out
- SET refpayid = :uo_pay.ref_payid
- WHERE ow_wfjg_out.outwareid = :outwareid
- AND scid = :scid
- And flag = 1 Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新外协单相关应收帐ID失败'
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- 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_pay
- RETURN rslt
- end function
- public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- DateTime null_dt
- SetNull(null_dt)
- uo_mustpay uo_pay
- uo_pay = Create uo_mustpay
- String ls_mtrlname
- 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
- UPDATE ow_wfjg_out
- SET secauditingrep = '',
- secauditingdate = :null_dt,
- secflag = 0,
- refpayid = 0
- WHERE ow_wfjg_out.outwareid = :outwareid
- AND secflag = 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 sum_amt <> 0 And billtype = 7 THEN
- IF uo_pay.del_payrec(scid,1,refpayid,sptid,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_pay
- RETURN rslt
- end function
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, decimal arg_fprice, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_relprintid, long arg_olmtrlid, decimal arg_rate);s_outwaremx_wfjg s_mx
- s_mx.mtrlwareid = arg_mtrlwareid
- s_mx.uqty = arg_uqty
- s_mx.uunit = arg_uunit
- s_mx.qty = arg_qty
- s_mx.fprice = arg_fprice
- s_mx.mxdscrp = arg_mxdscrp
- s_mx.printid = arg_printid
- s_mx.ifrel = arg_ifrel
- s_mx.relid = arg_relid
- s_mx.relprintid = arg_relprintid
- s_mx.olmtrlid = arg_olmtrlid
- s_mx.rate = arg_rate
- s_mx.rebate = 1
- return acceptmx(s_mx, arg_msg)
- ///*
- //Long rslt = 1,cnt = 0,LS_i
- //Long i_mtrlid,i_storageid,i_sptid
- //Int i_dxflag
- //String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- //string ls_mtrlcuscode,ls_location
- //Decimal i_planprice
- //Double i_cost
- //Decimal i_notauditqty,i_allouseqty
- //String ls_relcode
- //Decimal ld_rate = 1
- //
- //IF uo_option_2unit = -1000 THEN
- // rslt = 0
- // arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
- // GOTO ext
- //END IF
- //
- //IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- // rslt = 0
- // arg_msg = "非编辑状态不可以使用,操作取消"
- // GOTO ext
- //END IF
- //
- ////清除空值
- //IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
- //IF IsNull(arg_printid) THEN arg_printid = 0
- //IF IsNull(arg_qty) THEN arg_qty = 0
- //IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- //IF IsNull(arg_ifrel) THEN arg_ifrel = 0
- //IF IsNull(arg_relid) THEN arg_relid = 0
- //IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- //IF IsNull(arg_olmtrlid) THEN arg_olmtrlid = 0
- //IF IsNull(arg_uqty) THEN arg_uqty = 0
- //IF IsNull(arg_uunit) THEN arg_uunit = ''
- //IF IsNull(arg_qty) THEN arg_qty = 0
- //IF IsNull(arg_fprice) THEN arg_fprice = 0
- //IF IsNull(arg_rate) THEN arg_rate = 0
- //
- //
- //
- //// 如果出仓数量为 0,或物料编号为空,则不作任何处理
- //IF arg_mtrlwareid = 0 OR arg_qty = 0 THEN
- // rslt = 1
- // GOTO ext
- //END IF
- //
- //IF uo_option_2unit = 1 THEN
- // IF arg_uqty = 0 THEN
- // arg_msg = '行:'+String(arg_printid)+ ',请输入计价数量'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF Trim(arg_uunit) = '' THEN
- // arg_msg = '行:'+String(arg_printid)+ ',请输入计价单位'
- // rslt = 0
- // GOTO ext
- // END IF
- //END IF
- //
- //
- //
- ////检查物料库存ID
- //SELECT u_mtrlware.mtrlid,
- // u_mtrlware.storageid,
- // u_mtrlware.plancode,
- // u_mtrlware.status,
- // u_mtrlware.cost,
- // u_mtrldef.planprice,
- // u_mtrldef.mtrlcode,
- // u_mtrlware.sptid,
- // u_mtrlware.dxflag,
- // u_mtrlware.woodcode,
- // u_mtrlware.pcode,
- // u_mtrlware.noauditingqty,
- // u_mtrlware.noallocqty,
- // u_mtrlware.mtrlcuscode,
- // u_mtrlware.location
- // INTO :i_mtrlid,
- // :i_storageid,
- // :i_plancode,
- // :i_status,
- // :i_cost,
- // :i_planprice,
- // :i_mtrlcode,
- // :i_sptid,
- // :i_dxflag,
- // :i_woodcode,
- // :i_pcode,
- // :i_notauditqty,
- // :i_allouseqty,
- // :ls_mtrlcuscode,
- // :ls_location
- // FROM u_mtrlware ,u_mtrldef
- // WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- // AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- // And ( u_mtrlware.scid = :scid ) USING commit_transaction;
- //
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ",查询操作失败,库存编号错误"
- // GOTO ext
- //END IF
- //
- //IF IsNull(i_cost) THEN i_cost = 0
- //IF IsNull(i_plancode) THEN i_plancode = ''
- //IF IsNull(i_status) THEN i_status = ''
- //IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- //IF IsNull(i_planprice) THEN i_planprice = 0
- //IF IsNull(i_sptid) THEN i_sptid = 0
- //IF IsNull(i_dxflag) THEN i_dxflag = 0
- //IF IsNull(i_woodcode) THEN i_woodcode = ''
- //IF IsNull(i_pcode) THEN i_pcode = ''
- //IF IsNull(ls_mtrlcuscode) THEN ls_mtrlcuscode = ''
- //IF IsNull(ls_location) THEN ls_location = ''
- //
- //IF arg_ifrel = 1 THEN
- // IF arg_relid = 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',请选择加工计划!'
- // GOTO ext
- // END IF
- //
- // SELECT taskcode INTO :ls_relcode
- // FROM u_order_wfjg
- // Where wfjgID = :arg_relid USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',查询加工计划号失败!>>'+commit_transaction.SQLErrText
- // GOTO ext
- // END IF
- //
- // SELECT count(*) INTO :cnt
- // FROM u_order_wfjgMx_out
- // WHERE wfjgid = :arg_relid
- // AND mtrlid = :i_mtrlid
- // AND status = :i_status
- // AND woodcode = :i_woodcode
- // AND orderid = :arg_olmtrlid
- // AND printid = :arg_relprintid USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',查询加工计划出仓明细失败!>'+commit_transaction.SQLErrText
- // GOTO ext
- // END IF
- //
- // IF cnt = 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',出仓物料:'+i_mtrlcode+'不在加工计划出仓明细中!'
- // GOTO ext
- // END IF
- //END IF
- //
- ////*****检查大于未开数不可以开单
- //IF flag = 0 THEN
- // Decimal ol_mtrl_qty = 0
- // Int ls_noallocflag
- //
- // SELECT noallocflag INTO :ls_noallocflag
- // FROM u_storage
- // Where storageid = :i_storageid USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
- // GOTO ext
- // END IF
- //
- // IF ls_noallocflag = 1 THEN
- //
- // IF it_updatebegin THEN
- // SELECT sum(ow_wfjgmx_out.qty)
- // INTO :ol_mtrl_qty
- // FROM ow_wfjgmx_out
- // WHERE ow_wfjgmx_out.outwareid = :outwareid
- // AND ow_wfjgmx_out.mtrlwareid = :arg_mtrlwareid
- // AND scid = :scid USING commit_transaction;
- // IF commit_transaction.SQLCode = -1 THEN
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ',查询原开单数量失败'
- // GOTO ext
- // END IF
- // END IF
- //
- // IF arg_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
- // rslt = 0
- // arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
- // GOTO ext
- // END IF
- // END IF
- //END IF
- //
- ////***********************************************
- //
- //
- //IF i_cost < 0 THEN //检查进仓价
- // rslt = 0
- // arg_msg = '行:'+String(arg_printid)+ ",物料:" + String(i_mtrlcode)+" 单价错误"
- // GOTO ext
- //END IF
- //
- ////写入内容
- //it_mxbt++
- //
- //
- //outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
- //outwaremx[it_mxbt].mtrlid = i_mtrlid
- //outwaremx[it_mxbt].status = i_status
- //outwaremx[it_mxbt].qty = arg_qty
- //outwaremx[it_mxbt].storageid = i_storageid
- //outwaremx[it_mxbt].cost = i_cost
- //outwaremx[it_mxbt].costamt = Round(i_cost * arg_qty,2)
- //outwaremx[it_mxbt].newpriceamt = 0
- //outwaremx[it_mxbt].plancode = i_plancode
- //outwaremx[it_mxbt].planprice = i_planprice
- //outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- //outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
- //outwaremx[it_mxbt].printid = arg_printid
- //outwaremx[it_mxbt].olmtrlid = arg_olmtrlid
- //
- //outwaremx[it_mxbt].rebate = 1
- //IF billtype = 7 THEN
- // outwaremx[it_mxbt].fprice = arg_fprice
- // outwaremx[it_mxbt].price = arg_fprice
- // outwaremx[it_mxbt].uprice = arg_fprice
- //ELSE
- // outwaremx[it_mxbt].fprice = i_cost
- // outwaremx[it_mxbt].price = i_cost
- //
- // IF uo_option_2unit = 0 THEN
- // outwaremx[it_mxbt].uprice = i_cost
- // outwaremx[it_mxbt].uqty = arg_qty
- // ELSE
- // outwaremx[it_mxbt].uprice = Round(arg_qty * i_cost/arg_uqty,5)
- // outwaremx[it_mxbt].uqty = arg_uqty
- // END IF
- //END IF
- //
- //IF arg_uqty <> 0 THEN
- // outwaremx[it_mxbt].rate = arg_qty / arg_uqty
- //ELSE
- // outwaremx[it_mxbt].rate = 0
- //END IF
- //
- //
- //outwaremx[it_mxbt].uunit = arg_uunit
- //
- //outwaremx[it_mxbt].sptid = i_sptid
- //outwaremx[it_mxbt].dxflag = i_dxflag
- //outwaremx[it_mxbt].ifrel = arg_ifrel
- //outwaremx[it_mxbt].relid = arg_relid
- //outwaremx[it_mxbt].relprintid = arg_relprintid
- //
- //outwaremx[it_mxbt].woodcode = i_woodcode
- //outwaremx[it_mxbt].pcode = i_pcode
- //outwaremx[it_mxbt].relcode = ls_relcode
- //outwaremx[it_mxbt].mtrlcuscode = ls_mtrlcuscode
- //outwaremx[it_mxbt].location = ls_location
- //
- //ext:
- //IF rslt = 0 THEN p_clearmx()
- //RETURN rslt
- //*/
- end function
- public function integer uof_check_sptpdb_audit (long arg_sptid, ref string arg_msg);Int rslt = 1
- Long cnt
- if billtype = 9 then goto ext //盘点单不算
-
- SELECT count(*)
- INTO :cnt
- FROM ow_wfjg_sptpdb
- WHERE sptid = :arg_sptid
- And flag = 0 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
- ext:
- RETURN rslt
- end function
- public function integer uof_noauditingqty_add (ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i
- For i = 1 To it_mxbt
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty + :outwaremx[i].qty,
- noauditinguqty = noauditingqty + :outwaremx[i].uqty
- Where scid = :scid
- And mtrlwareid = :outwaremx[i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- ext:
- Return rslt
- end function
- public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i,ll_i
- i = 1
- s_outwaremx_wfjg arg_s_mx[]
- Declare cur_wfjgmx Cursor For
- Select ow_wfjgmx_out.mtrlwareid,
- ow_wfjgmx_out.qty,
- ow_wfjgmx_out.uqty,
- u_mtrldef.mtrlcode
- From ow_wfjgmx_out,u_mtrldef
- Where ow_wfjgmx_out.outwareid = :arg_outwareid And
- ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid And
- ow_wfjgmx_out.scid = :arg_scid Using commit_transaction;
-
- Open cur_wfjgmx;
- Fetch cur_wfjgmx Into :arg_s_mx[i].mtrlwareid,
- :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
- Do While sqlca.SQLCode = 0
- i++
- Fetch cur_wfjgmx Into :arg_s_mx[i].mtrlwareid,
- :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
- Loop
- Close cur_wfjgmx;
- For ll_i = 1 To i - 1
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty - :arg_s_mx[ll_i].qty,
- noauditinguqty = noauditingqty - :arg_s_mx[ll_i].uqty
- Where scid = :arg_scid
- And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(arg_s_mx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- ext:
- Return rslt
- end function
- public function integer acceptmx (s_outwaremx_wfjg s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i
- Long i_mtrlid,i_storageid,i_sptid
- Int i_dxflag
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- String ls_mtrlcuscode,ls_location
- Decimal i_planprice
- Double i_cost
- Decimal i_notauditqty,i_allouseqty
- String ls_relcode
- Decimal ld_rate = 1
- IF uo_option_2unit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(s_mx.mtrlwareid) THEN s_mx.mtrlwareid = 0
- IF IsNull(s_mx.printid) THEN s_mx.printid = 0
- IF IsNull(s_mx.qty) THEN s_mx.qty = 0
- IF IsNull(s_mx.mxdscrp) THEN s_mx.mxdscrp = ''
- IF IsNull(s_mx.ifrel) THEN s_mx.ifrel = 0
- IF IsNull(s_mx.relid) THEN s_mx.relid = 0
- IF IsNull(s_mx.relprintid) THEN s_mx.relprintid = 0
- IF IsNull(s_mx.olmtrlid) THEN s_mx.olmtrlid = 0
- IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
- IF IsNull(s_mx.uunit) THEN s_mx.uunit = ''
- IF IsNull(s_mx.qty) THEN s_mx.qty = 0
- IF IsNull(s_mx.fprice) THEN s_mx.fprice = 0
- IF IsNull(s_mx.rate) THEN s_mx.rate = 0
- IF IsNull(s_mx.thtype) THEN s_mx.thtype = 0
- IF IsNull(s_mx.relprintid2) THEN s_mx.relprintid2 = 0
- //IF IsNull(s_mx.relmtrlid2) THEN s_mx.relmtrlid2 = 0
- //IF IsNull(s_mx.relqty2) THEN s_mx.relqty2 = 0
- // 如果出仓数量为 0,或物料编号为空,则不作任何处理
- IF s_mx.mtrlwareid = 0 Or s_mx.qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF uo_option_2unit = 1 THEN
- IF s_mx.uqty = 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+ ',请输入计价数量'
- rslt = 0
- GOTO ext
- END IF
-
- IF Trim(s_mx.uunit) = '' THEN
- arg_msg = '行:'+String(s_mx.printid)+ ',请输入计价单位'
- rslt = 0
- GOTO ext
- END IF
- END IF
- //检查物料库存ID
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.cost,
- u_mtrldef.planprice,
- u_mtrldef.mtrlcode,
- u_mtrlware.sptid,
- u_mtrlware.dxflag,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- u_mtrlware.noauditingqty,
- u_mtrlware.noallocqty,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location
- INTO :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_planprice,
- :i_mtrlcode,
- :i_sptid,
- :i_dxflag,
- :i_woodcode,
- :i_pcode,
- :i_notauditqty,
- :i_allouseqty,
- :ls_mtrlcuscode,
- :ls_location
- FROM u_mtrlware ,u_mtrldef
- WHERE ( u_mtrlware.mtrlwareid = :s_mx.mtrlwareid )
- AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- And ( u_mtrlware.scid = :scid ) Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ",查询操作失败,库存编号错误"
- GOTO ext
- END IF
- IF IsNull(i_cost) THEN i_cost = 0
- IF IsNull(i_plancode) THEN i_plancode = ''
- IF IsNull(i_status) THEN i_status = ''
- IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- IF IsNull(i_planprice) THEN i_planprice = 0
- IF IsNull(i_sptid) THEN i_sptid = 0
- IF IsNull(i_dxflag) THEN i_dxflag = 0
- IF IsNull(i_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- IF IsNull(ls_mtrlcuscode) THEN ls_mtrlcuscode = ''
- IF IsNull(ls_location) THEN ls_location = ''
- IF s_mx.ifrel = 1 THEN
- IF s_mx.relid = 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',请选择外协订单!'
- GOTO ext
- END IF
-
- SELECT taskcode INTO :ls_relcode
- FROM u_order_wfjg
- Where wfjgID = :s_mx.relid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',查询外协订单号失败!>>'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- SELECT count(*) INTO :cnt
- FROM u_order_wfjgMx_out
- WHERE wfjgid = :s_mx.relid
- AND mtrlid = :i_mtrlid
- AND status = :i_status
- AND woodcode = :i_woodcode
- AND orderid = :s_mx.olmtrlid
- And printid = :s_mx.relprintid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',查询外协订单出仓明细失败!>'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',出仓物料:'+i_mtrlcode+'不在外协订单出仓明细中!'
- GOTO ext
- END IF
-
- IF s_mx.thtype = 1 THEN
- IF s_mx.relprintid2 = 0 THEN
- //先找找是否只有一条, 如果是,自己分配,如果是多条,强制选择
- SELECT count(*) INTO :cnt
- FROM u_order_wfjgMx_out INNER JOIN
- u_order_wfjgmx_out_mx ON
- u_order_wfjgMx_out.scid = u_order_wfjgmx_out_mx.scid AND
- u_order_wfjgMx_out.wfjgID = u_order_wfjgmx_out_mx.wfjgid AND
- u_order_wfjgMx_out.MtrlID = u_order_wfjgmx_out_mx.mtrlid AND
- u_order_wfjgMx_out.status = u_order_wfjgmx_out_mx.status AND
- u_order_wfjgMx_out.woodcode = u_order_wfjgmx_out_mx.woodcode AND
- u_order_wfjgMx_out.pcode = u_order_wfjgmx_out_mx.pcode AND
- u_order_wfjgMx_out.unit = u_order_wfjgmx_out_mx.unit
- WHERE (u_order_wfjgMx_out.wfjgID = :s_mx.relid)
- And (u_order_wfjgMx_out.printid = :s_mx.relprintid) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+',查询外协订单收货明细ID失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 1 THEN
- SELECT u_order_wfjgmx_out_mx.relprintid INTO :s_mx.relprintid2
- FROM u_order_wfjgMx_out INNER JOIN
- u_order_wfjgmx_out_mx ON
- u_order_wfjgMx_out.scid = u_order_wfjgmx_out_mx.scid AND
- u_order_wfjgMx_out.wfjgID = u_order_wfjgmx_out_mx.wfjgid AND
- u_order_wfjgMx_out.MtrlID = u_order_wfjgmx_out_mx.mtrlid AND
- u_order_wfjgMx_out.status = u_order_wfjgmx_out_mx.status AND
- u_order_wfjgMx_out.woodcode = u_order_wfjgmx_out_mx.woodcode AND
- u_order_wfjgMx_out.pcode = u_order_wfjgmx_out_mx.pcode AND
- u_order_wfjgMx_out.unit = u_order_wfjgmx_out_mx.unit
- WHERE (u_order_wfjgMx_out.wfjgID = :s_mx.relid)
- And (u_order_wfjgMx_out.printid = :s_mx.relprintid) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+',查询外协订单收货明细ID失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF s_mx.relprintid2 = 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+',请选择对应的外协订单收货明细'
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- Decimal lde_truerqqty_in_pf, lde_rqqty_out_pf, lde_sonscale
- //得到收货物料 s_mx.relmtrlid2
- SELECT u_order_wfjgMx.mtrlid, u_order_wfjgMx.qty
- INTO :s_mx.relmtrlid2, :lde_truerqqty_in_pf
- FROM u_order_wfjgMx
- WHERE u_order_wfjgMx.scid = :scid
- AND u_order_wfjgMx.wfjgid = :s_mx.relid
- And u_order_wfjgMx.printid = :s_mx.relprintid2 Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+',查询外协订单收货物料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- //得到发出物料
- SELECT top 1 qty
- INTO :lde_rqqty_out_pf
- FROM u_order_wfjgmx_out_mx
- WHERE (u_order_wfjgmx_out_mx.wfjgID = :s_mx.relid)
- AND (u_order_wfjgmx_out_mx.relprintid = :s_mx.relprintid2)
- Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+',查询外协订单收货明细ID失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- //计算收货终止数量 s_mx.relqty2
- s_mx.relqty2 = (lde_truerqqty_in_pf / lde_rqqty_out_pf ) * s_mx.qty
- lde_sonscale = lde_rqqty_out_pf / lde_truerqqty_in_pf
-
- ELSE
- s_mx.relprintid2 = 0
- s_mx.relmtrlid2 = 0
- s_mx.relqty2 = 0
- END IF
- ELSE
- s_mx.relid = 0
- s_mx.relprintid = 0
- s_mx.thtype = 0
- s_mx.relprintid2 = 0
- s_mx.relmtrlid2 = 0
- s_mx.relqty2 = 0
- END IF
- //*****检查大于未开数不可以开单
- IF flag = 0 THEN
- Decimal ol_mtrl_qty = 0
- Int ls_noallocflag
-
- SELECT noallocflag INTO :ls_noallocflag
- FROM u_storage
- Where storageid = :i_storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF ls_noallocflag = 1 THEN
-
- IF it_updatebegin THEN
- SELECT sum(ow_wfjgmx_out.qty)
- INTO :ol_mtrl_qty
- FROM ow_wfjgmx_out
- WHERE ow_wfjgmx_out.outwareid = :outwareid
- AND ow_wfjgmx_out.mtrlwareid = :s_mx.mtrlwareid
- And scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode = -1 THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ',查询原开单数量失败'
- GOTO ext
- END IF
- END IF
-
- IF s_mx.qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
- rslt = 0
- arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
- GOTO ext
- END IF
- END IF
- END IF
- //***********************************************
- IF i_cost < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+ ",物料:" + String(i_mtrlcode)+" 单价错误"
- GOTO ext
- END IF
- //写入内容
- it_mxbt++
- outwaremx[it_mxbt].mtrlwareid = s_mx.mtrlwareid
- outwaremx[it_mxbt].mtrlid = i_mtrlid
- outwaremx[it_mxbt].status = i_status
- outwaremx[it_mxbt].qty = s_mx.qty
- outwaremx[it_mxbt].storageid = i_storageid
- outwaremx[it_mxbt].cost = i_cost
- outwaremx[it_mxbt].costamt = Round(i_cost * s_mx.qty,2)
- outwaremx[it_mxbt].newpriceamt = 0
- outwaremx[it_mxbt].plancode = i_plancode
- outwaremx[it_mxbt].planprice = i_planprice
- outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- outwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
- outwaremx[it_mxbt].printid = s_mx.printid
- outwaremx[it_mxbt].olmtrlid = s_mx.olmtrlid
- outwaremx[it_mxbt].rebate = s_mx.rebate
- IF billtype = 7 THEN
- outwaremx[it_mxbt].fprice = s_mx.fprice
- outwaremx[it_mxbt].price = s_mx.fprice * s_mx.rebate
- outwaremx[it_mxbt].uprice = s_mx.fprice
- ELSE
- outwaremx[it_mxbt].fprice = i_cost
- outwaremx[it_mxbt].price = i_cost
-
- IF uo_option_2unit = 0 THEN
- outwaremx[it_mxbt].uprice = i_cost
- outwaremx[it_mxbt].uqty = s_mx.qty
- ELSE
- outwaremx[it_mxbt].uprice = Round(s_mx.qty * i_cost/s_mx.uqty,5)
- outwaremx[it_mxbt].uqty = s_mx.uqty
- END IF
- END IF
- IF s_mx.uqty <> 0 THEN
- outwaremx[it_mxbt].rate = s_mx.qty / s_mx.uqty
- ELSE
- outwaremx[it_mxbt].rate = 0
- END IF
- outwaremx[it_mxbt].uunit = s_mx.uunit
- outwaremx[it_mxbt].sptid = i_sptid
- outwaremx[it_mxbt].dxflag = i_dxflag
- outwaremx[it_mxbt].ifrel = s_mx.ifrel
- outwaremx[it_mxbt].relid = s_mx.relid
- outwaremx[it_mxbt].relprintid = s_mx.relprintid
- outwaremx[it_mxbt].woodcode = i_woodcode
- outwaremx[it_mxbt].pcode = i_pcode
- outwaremx[it_mxbt].relcode = ls_relcode
- outwaremx[it_mxbt].mtrlcuscode = ls_mtrlcuscode
- outwaremx[it_mxbt].Location = ls_location
- outwaremx[it_mxbt].thtype = s_mx.thtype
- outwaremx[it_mxbt].relprintid2 = s_mx.relprintid2
- outwaremx[it_mxbt].relmtrlid2 = s_mx.relmtrlid2
- outwaremx[it_mxbt].relqty2 = s_mx.relqty2
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- end function
- on uo_outware_wfjg.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_outware_wfjg.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event constructor;String str_optionvalue,arg_msg
- f_get_sys_option_value('087',str_optionvalue,arg_msg)
- uo_option_autocreate_outware = Long(str_optionvalue)
- f_get_sys_option_value('067',str_optionvalue,arg_msg)
- uo_option_2unit = Long(str_optionvalue)
- f_get_sys_option_value('390',str_optionvalue,arg_msg)
- uo_option_noauditingqty_mode = Long(str_optionvalue)
- end event
|