1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725 |
- $PBExportHeader$uo_mtrlware_trans.sru
- forward
- global type uo_mtrlware_trans from nonvisualobject
- end type
- end forward
- global type uo_mtrlware_trans from nonvisualobject
- end type
- global uo_mtrlware_trans uo_mtrlware_trans
- type variables
- PUBLIC PROTECTEDWRITE Long scid
- PUBLIC PROTECTEDWRITE Long billid
- PUBLIC PROTECTEDWRITE String billcode
- PUBLIC PROTECTEDWRITE DateTime opdate
- PUBLIC PROTECTEDWRITE String opemp
- PUBLIC PROTECTEDWRITE DateTime moddate
- PUBLIC PROTECTEDWRITE String modemp
- PUBLIC PROTECTEDWRITE Int fflag = 0
- PUBLIC PROTECTEDWRITE Int flag = 0
- PUBLIC PROTECTEDWRITE DateTime auditingdate
- PUBLIC PROTECTEDWRITE String auditingrep
- PUBLIC PROTECTEDWRITE Decimal sum_transqty = 0
- PUBLIC PROTECTEDWRITE Decimal sum_transamt = 0
- PUBLIC PROTECTEDWRITE Int priceflag = 0 //确认标志
- PUBLIC PROTECTEDWRITE DateTime pricedate //确认时间
- PUBLIC PROTECTEDWRITE String priceemp //确认操作员
- Long mtrlwareid
- Long storageid
- Long mtrlid
- Long relid
- String plancode
- String status
- DateTime billdate
- String inrep
- String part
- String dscrp
- Decimal transqty
- Decimal cost
- String woodcode
- String pcode
- string mtrlcuscode
- string location
- Int ifunit
- String uunit,unit
- Decimal rate
- string waredscrp
- Int billtype
- // 0 - 正常
- // 1 - 异常
- String transreason
- int kind
- // 0 - 一调多
- // 1 - 多调一
- // 2 - 借货
- // 3 - 还货
- // 4 - 多产品调一客户
- // 5 - 一产品调一客户
- Boolean if_getid_ture = TRUE
- Transaction commit_transaction //数据commit事务
- PRIVATE:
- s_transmx billmx[] //明细结构数组
- s_outwaremx_barcode s_mx_barcode[]
- Long it_mxbt = 0 //明细结构数组末指针
- Long it_mxbt_barcode = 0
- Boolean it_newbegin = FALSE //新建标志
- Boolean it_updatebegin = FALSE //修改标志
- end variables
- forward prototypes
- public function integer p_reset ()
- public function integer p_clearmx ()
- public function integer newbegin (long arg_scid, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer p_getinfo (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_billid, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_add_returnqty (long arg_scid, long arg_relid, long arg_relprintid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_finish (integer arg_finishtype, integer arg_fflag, long arg_scid, long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_trycmpl (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg)
- public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_rel_cusid_sptid, ref string arg_msg, string arg_woodcode, string arg_pcode, long arg_relid, long arg_relprintid, string arg_mtrlcuscode, string arg_location, string arg_waredscrp, string arg_plancode2, string arg_location2, string arg_mtrlcuscode2)
- public function integer priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer c_priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid = 0
- billid = 0
- billcode = ''
- opemp = ''
- modemp = ''
- auditingrep = ''
- flag = 0
- inrep = ''
- part = ''
- dscrp = ''
- relid = 0
- storageid = 0
- mtrlwareid = 0
- mtrlid = 0
- plancode = ''
- status = ''
- transqty = 0
- cost = 0
- Kind = 0
- mtrlcuscode = ''
- location = ''
- waredscrp = ''
- sum_transqty = 0
- sum_transamt = 0
- it_newbegin = FALSE
- it_updatebegin = FALSE
- //清除明细
- p_clearmx()
- RETURN 1
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt = 0
- sum_transqty = 0
- sum_transamt = 0
- RETURN 1
- end function
- public function integer newbegin (long arg_scid, ref string arg_msg);Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- p_reset()
- scid = arg_scid
- it_newbegin = TRUE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_billid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF Kind = 5 AND priceflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经确认,不可以修改'
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- billid = arg_billid
- 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 p_getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
- IF arg_billid <= 0 THEN
- rslt = 0
- arG_MSG = "非法单据唯一码"
- GOTO ext
- END IF
- SELECT u_mtrlware_trans.billcode,
- u_mtrlware_trans.mtrlwareid,
- u_mtrlware_trans.storageid,
- u_mtrlware_trans.mtrlid,
- u_mtrlware_trans.relid,
- u_mtrlware_trans.plancode,
- u_mtrlware_trans.status,
- u_mtrlware_trans.transqty,
- u_mtrlware_trans.billdate,
- u_mtrlware_trans.inrep,
- u_mtrlware_trans.flag,
- u_mtrlware_trans.fflag,
- u_mtrlware_trans.dscrp,
- u_mtrlware_trans.part,
- u_mtrlware_trans.cost,
- u_mtrlware_trans.woodcode,
- u_mtrlware_trans.pcode,
- u_mtrlware_trans.billtype,
- u_mtrlware_trans.transreason,
- u_mtrlware_trans.kind,
- u_mtrldef.ifunit,
- u_mtrldef.rate_buy,
- u_mtrldef.unit_buy,
- u_mtrldef.unit,
- u_mtrlware_trans.mtrlcuscode,
- u_mtrlware_trans.location,
- u_mtrlware_trans.waredscrp,
- u_mtrlware_trans.priceflag,
- u_mtrlware_trans.pricedate,
- u_mtrlware_trans.priceemp
- INTO :billcode,
- :mtrlwareid,
- :storageid,
- :mtrlid,
- :relid,
- :plancode,
- :status,
- :transqty,
- :billdate,
- :inrep,
- :flag,
- :fflag,
- :dscrp,
- :part,
- :cost,
- :woodcode,
- :pcode,
- :billtype,
- :transreason,
- :Kind,
- :ifunit,
- :rate,
- :uunit,
- :unit,
- :mtrlcuscode,
- :location,
- :waredscrp,
- :priceflag,
- :pricedate,
- :priceemp
- FROM u_mtrlware_trans,u_mtrldef
- WHERE u_mtrlware_trans.billid = :arg_billid
- AND u_mtrlware_trans.scid = :arg_scid
- and u_mtrlware_trans.mtrlid *= u_mtrldef.mtrlid
- USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败(错误调货单唯一码),调货单"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- billid = arg_billid
- scid = arg_scid
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_billid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF Kind = 5 AND priceflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经确认,不可以删除'
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_transmx
- WHERE u_mtrlware_transmx.billid = :arg_billid
- AND scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除单据明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_mtrlware_trans
- WHERE u_mtrlware_trans.billid = :arg_billid
- AND 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;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- RETURN rslt
- end function
- public function integer add_dscrp (long arg_scid, long arg_billid, string arg_newdescppart, ref string arg_msg);int rslt=1
- arg_newdescppart=trim(arg_newdescppart)
- if it_updatebegin or it_newbegin then
- rslt=0
- arg_msg="编辑状态下不可用"
- goto ext
- end if
- if arg_newdescppart='' then
- rslt=0
- arg_msg="要添加内容为空,操作取消"
- goto ext
- end if
- rslt=p_getinfo(arg_scid,arg_billid,arg_msg)
- if rslt=0 then goto ext
- if flag=0 then
- rslt=0
- arg_msg="非审核状态下不可用"
- goto ext
- end if
- update u_mtrlware_trans
- set dscrp = dscrp+' '+:arg_newdescppart
- where u_mtrlware_trans.billid = :billid
- and scid=:scid using commit_transaction;
- if commit_transaction.sqlcode<>0 then
- rollback using commit_transaction;
- 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 getinfo (long arg_scid, long arg_billid, ref string arg_msg);Int rslt = 1
- long i = 1,no_mxcheck = 0,no_mxcheck_barcode = 0,k = 1
- Int li_outtype
- sum_transqty = 0
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = "非法单据唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_billid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- SELECT outtype
- INTO :li_outtype
- FROM u_storage
- Where storageid = :storageid;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库出仓类型,"+sqlca.SQLErrText
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_transmx CURSOR FOR
- SELECT u_mtrlware_transmx.printid,
- u_mtrlware_transmx.mtrlid,
- u_mtrlware_transmx.plancode,
- u_mtrlware_transmx.status,
- u_mtrlware_transmx.qty,
- u_mtrlware_transmx.fprice,
- u_mtrlware_transmx.rebate,
- u_mtrlware_transmx.price,
- u_mtrlware_transmx.mxdscrp,
- u_mtrldef.mtrlcode,
- u_mtrlware_transmx.rel_cusid_sptid,
- u_mtrlware_transmx.woodcode,
- u_mtrlware_transmx.pcode,
- u_mtrlware_transmx.relid,
- u_mtrlware_transmx.relprintid,
- u_mtrldef.ifunit,
- u_mtrldef.rate_buy,
- u_mtrldef.unit_buy,
- u_mtrldef.unit,
- u_mtrlware_transmx.mtrlcuscode,
- u_mtrlware_transmx.location,
- u_mtrlware_transmx.waredscrp,
- u_mtrlware_transmx.mtrlcuscode2,
- u_mtrlware_transmx.location2,
- u_mtrlware_transmx.plancode2,
- u_mtrlware_transmx.mtrlwareid
- FROM u_mtrlware_transmx,u_mtrldef
- WHERE u_mtrlware_transmx.billid = :arg_billid AND
- u_mtrlware_transmx.mtrlid = u_mtrldef.mtrlid AND
- u_mtrlware_transmx.scid = :arg_scid USING commit_transaction;
-
- OPEN cur_transmx;
- FETCH cur_transmx INTO :billmx[i].printid,:billmx[i].mtrlid,:billmx[i].plancode,
- :billmx[i].status,:billmx[i].qty,:billmx[i].fprice,
- :billmx[i].rebate,:billmx[i].price,
- :billmx[i].mxdscrp,:billmx[i].mtrlcode,
- :billmx[i].rel_cusid_sptid,
- :billmx[i].woodcode,
- :billmx[i].pcode,
- :billmx[i].relid,
- :billmx[i].relprintid,
- :billmx[i].ifunit,
- :billmx[i].rate,
- :billmx[i].uunit,
- :billmx[i].unit,
- :billmx[i].mtrlcuscode,
- :billmx[i].location,
- :billmx[i].waredscrp,
- :billmx[i].mtrlcuscode2,
- :billmx[i].location2,
- :billmx[i].plancode2,
- :billmx[i].mtrlwareid;
-
- DO WHILE commit_transaction.SQLCode = 0
- sum_transqty = sum_transqty + billmx[i].qty
- i++
- FETCH cur_transmx INTO :billmx[i].printid,:billmx[i].mtrlid,:billmx[i].plancode,
- :billmx[i].status,:billmx[i].qty,:billmx[i].fprice,
- :billmx[i].rebate,:billmx[i].price,
- :billmx[i].mxdscrp,:billmx[i].mtrlcode,
- :billmx[i].rel_cusid_sptid,
- :billmx[i].woodcode,
- :billmx[i].pcode,
- :billmx[i].relid,
- :billmx[i].relprintid,
- :billmx[i].ifunit,
- :billmx[i].rate,
- :billmx[i].uunit,
- :billmx[i].unit,
- :billmx[i].mtrlcuscode,
- :billmx[i].location,
- :billmx[i].waredscrp,
- :billmx[i].mtrlcuscode2,
- :billmx[i].location2,
- :billmx[i].plancode2,
- :billmx[i].mtrlwareid;
-
- LOOP
- CLOSE cur_transmx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_mtrlware_transmx
- WHERE u_mtrlware_transmx.billid = :arg_billid
- 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
- //用游标读取条码明细
- IF li_outtype = 2 or li_outtype = 3 THEN
- DECLARE cur_outwaremx_barcode CURSOR FOR
- SELECT u_outwaremx_mx_barcode.barcode,
- u_outwaremx_mx_barcode.qty,
- u_mtrlware_mx.packqty
- FROM u_outwaremx_mx_barcode,u_mtrlware_mx
- WHERE u_outwaremx_mx_barcode.barcode = u_mtrlware_mx.barcode and
- u_outwaremx_mx_barcode.outwareid = :arg_billid AND
- u_outwaremx_mx_barcode.scid = :arg_scid and
- u_outwaremx_mx_barcode.billtype = 51
- Order By u_outwaremx_mx_barcode.barcode;
-
- OPEN cur_outwaremx_barcode;
- FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,:s_mx_barcode[k].packqty;
-
- DO WHILE sqlca.SQLCode = 0
- k++
- FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,:s_mx_barcode[k].packqty;
- LOOP
- CLOSE cur_outwaremx_barcode;
-
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck_barcode
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_billid
- AND u_outwaremx_mx_barcode.scid = :arg_scid
- and u_outwaremx_mx_barcode.billtype = 51;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细数量"
- GOTO ext
- END IF
-
- IF k <> (no_mxcheck_barcode+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单条码明细"
- GOTO ext
- END IF
-
- it_mxbt_barcode = k - 1
- END IF
- billid = arg_billid
- 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 save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
- Long cnt = 0,i
- DateTime server_dt
- Long ls_newid
- String ls_sccode
- Long i_mtrlid
- Long i_relid
- String i_plancode
- String i_status
- Long i_storageid
- String i_woodcode
- String i_pcode
- String i_mtrlcuscode
- String i_location
- String i_waredscrp
- Int li_outtype,li_storagetype
- Int li_noallocflag
- Decimal ld_noallocqty,ld_notauditqty,ld_allocqty
- IF IsNull(mtrlwareid) THEN mtrlwareid = 0
- IF IsNull(storageid) THEN storageid = 0
- IF IsNull(cost) THEN cost = 0
- IF IsNull(inrep) THEN inrep = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(transqty) THEN transqty = 0
- IF IsNull(billtype) THEN billtype = 0
- IF IsNull(transreason) THEN transreason = ''
- IF IsNull(waredscrp) THEN waredscrp = ''
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF Kind <> 0 And Kind <> 1 And Kind <> 2 And Kind <> 3 And Kind <> 4 And Kind <> 5 THEN
- arg_msg = '错误的单据类型'
- rslt = 0
- GOTO ext
- END IF
- SELECT outtype,noallocflag,storagetype
- INTO :li_outtype,:li_noallocflag,:li_storagetype
- FROM u_storage
- Where storageid = :storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF Kind = 5 THEN
- IF li_outtype <> 2 And li_outtype <> 3 THEN
- arg_msg = '仓库出仓类型不是条码出仓,请使用其它调货单进行操作'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF li_outtype = 2 Or li_outtype = 3 THEN
- arg_msg = '仓库出仓类型为条码出仓,请使用条码调货单进行操作'
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF li_storagetype = 1 And Kind <> 5 THEN
- arg_msg = '仓库使用库存分配策略,请使用库存分配调货单进行操作'
- rslt = 0
- 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(storageid,billdate,True,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 1 THEN
- IF transreason = '' THEN
- arg_msg = '请输入调货原因'
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF Kind <> 4 THEN
- IF transqty <= 0 THEN
- arg_msg = '请输入正确的转换数量'
- rslt = 0
- GOTO ext
- END IF
-
- IF transqty <> sum_transqty THEN
- arg_msg = '转换与被转换数量不相等'
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF Kind = 0 Or Kind = 3 Or Kind = 5 THEN //1调n
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.sptid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location,
- u_mtrlware.dscrp,
- u_mtrlware.noallocqty,
- u_mtrlware.noauditingqty,
- u_mtrlware.allocqty
- INTO :i_mtrlid,
- :i_relid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_woodcode,
- :i_pcode,
- :i_mtrlcuscode,
- :i_location,
- :i_waredscrp,
- :ld_noallocqty,
- :ld_notauditqty,
- :ld_allocqty
- FROM u_mtrlware
- WHERE u_mtrlware.scid = :scid
- AND u_mtrlware.mtrlwareid = :mtrlwareid
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询相关转换库存失败>>' + commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- IF IsNull(i_relid) THEN i_relid = 0
- IF IsNull(i_storageid) THEN i_storageid = 0
- IF IsNull(i_plancode) THEN i_plancode = ''
- IF IsNull(i_status) THEN i_status = ''
- IF IsNull(i_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- IF IsNull(i_mtrlcuscode) THEN i_mtrlcuscode = ''
- IF IsNull(i_location) THEN i_location = ''
- IF IsNull(i_waredscrp) THEN i_waredscrp = ''
- IF IsNull(ld_notauditqty) THEN ld_notauditqty = 0
- IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
-
- IF i_storageid <> storageid THEN
- arg_msg = '仓库与库存不符'
- rslt = 0
- GOTO ext
- END IF
-
- IF li_noallocflag = 1 THEN
- IF ld_noallocqty - ld_notauditqty < transqty THEN
- arg_msg = '库存未开单数不足,不能调货,请检查'
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF Kind = 5 THEN
- IF ld_noallocqty - ld_allocqty < transqty THEN
- arg_msg = '库存未分配数量不足,不能调货,请检查'
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- mtrlid = i_mtrlid
- relid = i_relid
- storageid = i_storageid
- plancode = i_plancode
- status = i_status
- woodcode = i_woodcode
- pcode = i_pcode
- mtrlcuscode = i_mtrlcuscode
- Location = i_location
- waredscrp = i_waredscrp
- ELSEIF Kind = 4 THEN //多产品调一客户
- IF relid = 0 THEN
- arg_msg = '请选择客户'
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :relid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败,请检查,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- arg_msg = '客户资料不存在,请检查'
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt > 1 THEN
- arg_msg = '客户资料重复,请检查'
- rslt = 0
- GOTO ext
- END IF
- ELSE // n调1
- cost = sum_transamt / sum_transqty
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF billid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_mtrlware_trans","billid",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
-
- CHOOSE CASE Kind
- CASE 0,1
- billcode = getid(scid,ls_sccode + 'MT',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 2
- billcode = getid(scid,ls_sccode + 'ML',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 3
- billcode = getid(scid,ls_sccode + 'MR',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 4
- billcode = getid(scid,ls_sccode + 'MH',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 5
- billcode = getid(scid,ls_sccode + 'MB',Date(server_dt),if_getid_ture,commit_transaction)
- END CHOOSE
-
- IF billcode = "err" THEN
- billcode = ''
- rslt = 0
- arg_msg = "无法获取单据编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO u_mtrlware_trans
- ( scid,
- billid,
- billcode,
- mtrlwareid,
- storageid,
- mtrlid,
- relid,
- plancode,
- status,
- transqty,
- billdate,
- inrep,
- part,
- dscrp,
- cost,
- opdate,
- opemp,
- woodcode,
- pcode,
- billtype,
- transreason,
- kind,
- mtrlcuscode,
- location,
- waredscrp)
- VALUES (:scid,
- :ls_newid,
- :billcode,
- :mtrlwareid,
- :storageid,
- :mtrlid,
- :relid,
- :plancode,
- :status,
- :transqty,
- :billdate,
- :inrep,
- :part,
- :dscrp,
- :cost,
- :server_dt,
- :publ_operator,
- :woodcode,
- :pcode,
- :billtype,
- :transreason,
- :Kind,
- :mtrlcuscode,
- :Location,
- :waredscrp) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新inwareid
- billid = ls_newid
-
- FOR i = 1 To it_mxbt
- INSERT INTO u_mtrlware_transmx
- (scid,
- billid,
- printid,
- mtrlid,
- plancode,
- plancode2,
- status,
- qty,
- fprice,
- rebate,
- price,
- mxdscrp,
- rel_cusid_sptid,
- woodcode,
- pcode,
- mtrlwareid,
- relid,
- relprintid,
- mtrlcuscode,
- location,
- mtrlcuscode2,
- location2,
- waredscrp)
- VALUES (
- :scid,
- :ls_newid,
- :billmx[i].printid,
- :billmx[i].mtrlid,
- :billmx[i].plancode,
- :billmx[i].plancode2,
- :billmx[i].status,
- :billmx[i].qty,
- :billmx[i].fprice,
- :billmx[i].rebate,
- :billmx[i].price,
- :billmx[i].mxdscrp,
- :billmx[i].rel_cusid_sptid,
- :billmx[i].woodcode,
- :billmx[i].pcode,
- :billmx[i].mtrlwareid,
- :billmx[i].relid,
- :billmx[i].relprintid,
- :billmx[i].mtrlcuscode,
- :billmx[i].Location,
- :billmx[i].mtrlcuscode2,
- :billmx[i].Location2,
- :billmx[i].waredscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- billid = 0 //还原billid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_mtrlware_trans
- SET mtrlwareid = :mtrlwareid,
- storageid = :storageid,
- mtrlid = :mtrlid,
- relid = :relid,
- plancode = :plancode,
- status = :status,
- transqty = :transqty,
- billdate = :billdate,
- inrep = :inrep,
- part = :part,
- dscrp = :dscrp,
- cost = :cost,
- moddate = :server_dt,
- modemp = :publ_operator,
- woodcode = :woodcode,
- pcode = :pcode,
- mtrlcuscode = :mtrlcuscode,
- location = :Location,
- billtype = :billtype,
- transreason = :transreason,
- waredscrp = :waredscrp
- WHERE u_mtrlware_trans.billid = :billid
- AND u_mtrlware_trans.scid = :scid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_mtrlware_transmx
- WHERE u_mtrlware_transmx.billid = :billid
- And u_mtrlware_transmx.scid = :scid Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
- INSERT INTO u_mtrlware_transmx
- (scid,
- billid,
- printid,
- mtrlid,
- plancode,
- plancode2,
- status,
- qty,
- fprice,
- rebate,
- price,
- mxdscrp,
- rel_cusid_sptid,
- woodcode,
- pcode,
- mtrlwareid,
- relid,
- relprintid,
- mtrlcuscode,
- location,
- mtrlcuscode2,
- location2,
- waredscrp)
- VALUES (
- :scid,
- :billid,
- :billmx[i].printid,
- :billmx[i].mtrlid,
- :billmx[i].plancode,
- :billmx[i].plancode2,
- :billmx[i].status,
- :billmx[i].qty,
- :billmx[i].fprice,
- :billmx[i].rebate,
- :billmx[i].price,
- :billmx[i].mxdscrp,
- :billmx[i].rel_cusid_sptid,
- :billmx[i].woodcode,
- :billmx[i].pcode,
- :billmx[i].mtrlwareid,
- :billmx[i].relid,
- :billmx[i].relprintid,
- :billmx[i].mtrlcuscode,
- :billmx[i].Location,
- :billmx[i].mtrlcuscode2,
- :billmx[i].Location2,
- :billmx[i].waredscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,j
- DateTime null_dt
- String ls_mtrlcode
- Decimal ls_planprice
- Long ll_inware_out,ll_inware_in
- int li_inoutflag
- SetNull(null_dt)
- uo_mtrlware_trans uo_trans
- uo_trans = Create uo_mtrlware_trans
- uo_trans.commit_transaction = commit_transaction
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- uo_getbar uo_gb
- uo_gb = Create uo_getbar
- IF billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未审核"
- GOTO ext
- END IF
- UPDATE u_mtrlware_trans
- SET auditingrep = '',
- auditingdate = :null_dt,
- flag = 0
- WHERE u_mtrlware_trans.billid = :billid
- 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 Kind = 3 THEN
- FOR j = 1 To it_mxbt
- IF uof_add_returnqty(scid,&
- billmx[j].relid,&
- billmx[j].relprintid,&
- 0 - billmx[j].qty,&
- arg_msg,&
- False) = 0 THEN
- arg_msg = '行:'+String(billmx[j].printid)+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_trans.uof_trycmpl(scid,billmx[j].relid,arg_msg,False) = 0 THEN
- arg_msg = '行:'+String(billmx[j].printid)+arg_msg
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- //撤审删除相关进仓单(正)
- SELECT inwareid INTO :ll_inware_in
- FROM u_inware
- WHERE scid = :scid
- AND relid = :billid
- AND billtype = 17
- And relint_2 = 1;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询相关进仓单(正)失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.getinfo(scid,ll_inware_in,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.del(scid,ll_inware_in,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //
- //撤审删除相关进仓单(负)
- SELECT inwareid INTO :ll_inware_out
- FROM u_inware
- WHERE scid = :scid
- AND relid = :billid
- AND billtype = 17
- And relint_2 = 0;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询相关进仓单(负)失败'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.getinfo(scid,ll_inware_out,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_in.del(scid,ll_inware_out,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //
- IF Kind = 5 THEN
- FOR i = 1 To it_mxbt_barcode
- select inflag - outflag into :li_inoutflag
- from u_mtrlware_mx
- where barcode = :s_mx_barcode[i].barcode;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询条码:'+s_mx_barcode[i].barcode+'进出仓标记失败,'+sqlca.sqlerrtext
- rslt = 0
- GOTO ext
- END IF
-
- if li_inoutflag <> 1 then
- arg_msg = '条码:'+s_mx_barcode[i].barcode+'不是在未出仓状态,操作取消'
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_gb.uof_barcode_mtrlwareid(s_mx_barcode[i].barcode,&
- scid,mtrlwareid,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- 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_in
- Destroy uo_trans
- Destroy uo_gb
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,j
- String ls_mtrlcode
- Decimal ls_planprice,ld_qty_barcode
- Long ll_inwareid_out,ll_inwareid_in,ll_mx_mtrlwareid
- Int li_outtype,li_inoutflag,li_outtype_mtrl
- uo_mtrlware_trans uo_trans
- uo_trans = CREATE uo_mtrlware_trans
- uo_trans.commit_transaction = commit_transaction
- uo_getbar uo_gb
- uo_gb = CREATE uo_getbar
- IF billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- SELECT outtype INTO :li_outtype
- FROM u_storage
- Where storageid = :storageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF Kind = 5 THEN
- IF priceflag = 0 THEN
- arg_msg = '单据未确认,不能审核'
- rslt = 0
- GOTO ext
- END IF
-
- IF li_outtype <> 2 and li_outtype <> 3 THEN
- arg_msg = '仓库出仓类型不是条码出仓,请使用其它调货单进行操作'
- rslt = 0
- GOTO ext
- END IF
-
- select outtype
- into :li_outtype_mtrl
- from u_mtrldef
- where mtrlid = :mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询物料出仓类型失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- if li_outtype_mtrl = 2 then
- IF it_mxbt_barcode = 0 THEN
- arg_msg = '未扫描条码,请检查'
- rslt = 0
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt_barcode
- ld_qty_barcode += s_mx_barcode[i].qty * s_mx_barcode[i].packqty
- NEXT
-
- IF transqty <> ld_qty_barcode THEN
- arg_msg = '调拨数量与条码对应总数量不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- end if
- ELSE
- IF li_outtype = 2 or li_outtype = 3 THEN
- arg_msg = '仓库出仓类型为条码出仓,请使用条码调货单进行操作'
- rslt = 0
- GOTO ext
- END IF
- END IF
- UPDATE u_mtrlware_trans
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE u_mtrlware_trans.billid = :billid
- 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
- //还货
- IF Kind = 3 THEN
- FOR j = 1 TO it_mxbt
- IF uof_add_returnqty(scid,&
- billmx[j].relid,&
- billmx[j].relprintid,&
- billmx[j].qty,&
- arg_msg,&
- FALSE) = 0 THEN
- arg_msg = '行:'+String(billmx[j].printid)+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_trans.uof_trycmpl(scid,billmx[j].relid,arg_msg,FALSE) = 0 THEN
- arg_msg = '行:'+String(billmx[j].printid)+arg_msg
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- String ls_uunit
- Decimal ld_rate,ld_uqty,ld_uprice
- uo_inware uo_in
- uo_in = CREATE uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = FALSE
- IF Kind = 0 OR Kind = 3 OR Kind = 5 THEN
- //生成进仓单- 负
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 0 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(负)'
-
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF ifunit = 0 THEN
- ls_uunit = unit
- ld_rate = 1
- ld_uqty = transqty
- ld_uprice = cost
- ELSE
- IF rate = 0 THEN
- arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = uunit
- ld_rate = rate
- ld_uqty = transqty /rate
- ld_uprice = cost * rate
- END IF
-
- IF uo_in.acceptmx(1,&
- mtrlid,&
- ls_mtrlcode,&
- plancode,&
- status,&
- 0 - ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,woodcode,&
- pcode,&
- relid,&
- ls_uunit,ld_rate,0 - transqty,0,0,'',waredscrp,0,0,&
- mtrlcuscode,Location,&
- 0 - ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_out = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_out,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
-
- //生成进仓单-正
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 1 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(正)'
-
- FOR i = 1 TO it_mxbt
-
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF billmx[i].ifunit = 0 THEN
- ls_uunit = billmx[i].unit
- ld_rate = 1
- ld_uqty = billmx[i].qty
- ld_uprice = billmx[i].price
- ELSE
- IF billmx[i].rate = 0 THEN
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = billmx[i].uunit
- ld_rate = billmx[i].rate
- ld_uqty = billmx[i].qty/billmx[i].rate
- ld_uprice = billmx[i].price * billmx[i].rate
- END IF
-
- IF uo_in.acceptmx(i,&
- billmx[i].mtrlid,&
- billmx[i].mtrlcode,&
- billmx[i].plancode,&
- billmx[i].status,&
- ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,billmx[i].woodcode,&
- billmx[i].pcode,&
- billmx[i].rel_cusid_sptid,&
- ls_uunit,ld_rate,billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
- billmx[i].mtrlcuscode,billmx[i].Location,&
- ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_in = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_in,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
-
- ELSEIF Kind = 1 OR Kind = 2 THEN
- //生成进仓单- 负
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 0 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(负)'
-
- FOR i = 1 TO it_mxbt
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF billmx[i].ifunit = 0 THEN
- ls_uunit = billmx[i].unit
- ld_rate = 1
- ld_uqty = billmx[i].qty
- ld_uprice = billmx[i].price
- ELSE
- IF billmx[i].rate = 0 THEN
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = billmx[i].uunit
- ld_rate = billmx[i].rate
- ld_uqty = billmx[i].qty/billmx[i].rate
- ld_uprice = billmx[i].price * billmx[i].rate
- END IF
-
- IF uo_in.acceptmx(i,&
- billmx[i].mtrlid,&
- billmx[i].mtrlcode,&
- billmx[i].plancode,&
- billmx[i].status,&
- 0 - ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,billmx[i].woodcode,&
- billmx[i].pcode,&
- billmx[i].rel_cusid_sptid,&
- ls_uunit,ld_rate,0 - billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
- billmx[i].mtrlcuscode,billmx[i].Location,&
- 0 - ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_out = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_out,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
-
- //生成进仓单-正
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 1 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(正)'
-
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF ifunit = 0 THEN
- ls_uunit = unit
- ld_rate = 1
- ld_uqty = transqty
- ld_uprice = cost
- ELSE
- IF rate = 0 THEN
- arg_msg = '调货产品资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = uunit
- ld_rate = rate
- ld_uqty = transqty /rate
- ld_uprice = cost * rate
- END IF
-
- IF uo_in.acceptmx(1,&
- mtrlid,&
- ls_mtrlcode,&
- plancode,&
- status,&
- ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,woodcode,&
- pcode,&
- relid,&
- ls_uunit,ld_rate,transqty,0,0,'',waredscrp,0,0,&
- mtrlcuscode,Location,&
- ld_uqty,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_in = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_in,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
- ELSEIF Kind = 4 THEN
- //生成进仓单- 负
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 0 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(负)'
-
- FOR i = 1 TO it_mxbt
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF billmx[i].ifunit = 0 THEN
- ls_uunit = billmx[i].unit
- ld_rate = 1
- ld_uqty = billmx[i].qty
- ld_uprice = billmx[i].price
- ELSE
- IF billmx[i].rate = 0 THEN
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = billmx[i].uunit
- ld_rate = billmx[i].rate
- ld_uqty = billmx[i].qty/billmx[i].rate
- ld_uprice = billmx[i].price * billmx[i].rate
- END IF
-
- IF uo_in.acceptmx(i,&
- billmx[i].mtrlid,&
- billmx[i].mtrlcode,&
- billmx[i].plancode,&
- billmx[i].status,&
- 0 - ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,billmx[i].woodcode,&
- billmx[i].pcode,&
- billmx[i].rel_cusid_sptid,&
- ls_uunit,ld_rate,0 - billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
- billmx[i].mtrlcuscode,billmx[i].Location,&
- 0 - ld_uqty,&
- 0) = 0 THEN
- arg_msg = '进仓负单,明细行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_out = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_out,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
-
- //生成进仓单-正
- IF uo_in.newbegin(scid,17,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = billid
- uo_in.indate = billdate
- uo_in.inrep = inrep
- uo_in.part = billcode
- uo_in.dscrp = dscrp
- uo_in.relint_2 = 1 // 0 - 负 1 - 正
- uo_in.storageid = storageid
- uo_in.sptname = '客户调货进仓(正)'
-
- FOR i = 1 TO it_mxbt
- //转换
- ls_uunit = ''
- ld_rate = 0
- ld_uqty = 0
- ld_uprice = 0
-
- IF billmx[i].ifunit = 0 THEN
- ls_uunit = billmx[i].unit
- ld_rate = 1
- ld_uqty = billmx[i].qty
- ld_uprice = billmx[i].price
- ELSE
- IF billmx[i].rate = 0 THEN
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- GOTO ext
- END IF
- ls_uunit = billmx[i].uunit
- ld_rate = billmx[i].rate
- ld_uqty = billmx[i].qty/billmx[i].rate
- ld_uprice = billmx[i].price * billmx[i].rate
- END IF
-
- IF uo_in.acceptmx(i,&
- billmx[i].mtrlid,&
- billmx[i].mtrlcode,&
- billmx[i].plancode2,&
- billmx[i].status,&
- ld_uqty,&
- ld_uprice,&
- 1,&
- '',&
- arg_msg,&
- 0,0,0,billmx[i].woodcode,&
- billmx[i].pcode,&
- relid,&
- ls_uunit,ld_rate,billmx[i].qty,0,0,'',billmx[i].waredscrp,0,0,&
- billmx[i].mtrlcuscode2,billmx[i].Location2,&
- ld_uqty,&
- 0) = 0 THEN
- arg_msg = '进仓正单,明细行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- IF uo_in.Save(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ll_inwareid_in = uo_in.inwareid
-
- IF uo_in.getinfo(scid,ll_inwareid_in,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 uof_update_waredate(FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF Kind = 5 and li_outtype_mtrl = 2 THEN
- SELECT mtrlwareid INTO :ll_mx_mtrlwareid
- FROM u_mtrlware
- WHERE scid = :scid
- AND storageid = :storageid
- AND mtrlid = :billmx[1].mtrlid
- AND status = :billmx[1].status
- AND woodcode = :billmx[1].woodcode
- AND pcode = :billmx[1].pcode
- AND plancode = :billmx[1].plancode
- AND mtrlcuscode = :billmx[1].mtrlcuscode
- AND location = :billmx[1].location
- AND sptid = :billmx[1].rel_cusid_sptid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询明细对应库存id失败,请检查,'+sqlca.sqlerrtext
- rslt = 0
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt_barcode
- select inflag - outflag into :li_inoutflag
- from u_mtrlware_mx
- where barcode = :s_mx_barcode[i].barcode;
- if sqlca.sqlcode <> 0 then
- arg_msg = '查询条码:'+s_mx_barcode[i].barcode+'进出仓标记失败,'+sqlca.sqlerrtext
- rslt = 0
- GOTO ext
- END IF
-
- if li_inoutflag <> 1 then
- arg_msg = '条码:'+s_mx_barcode[i].barcode+'不是在未出仓状态,操作取消'
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_gb.uof_barcode_mtrlwareid(s_mx_barcode[i].barcode,&
- scid,ll_mx_mtrlwareid,FALSE,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- 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_in
- DESTROY uo_trans
- DESTROY uo_getbar
- RETURN rslt
- end function
- public function integer uof_add_returnqty (long arg_scid, long arg_relid, long arg_relprintid, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_qty,ld_returnqty
- SELECT qty,returnqty INTO :ld_qty,:ld_returnqty
- FROM u_mtrlware_transmx
- WHERE scid = :arg_scid
- AND billid = :arg_relid
- AND printid = :arg_relprintid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = ',查询已还货数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF ld_qty - ld_returnqty < arg_qty THEN
- arg_msg = ',超还货,借货数:'+String(ld_qty,'#0.0#')+',已还货数:'+String(ld_returnqty,'#0.0#')
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_mtrlware_transmx
- SET returnqty = returnqty + :arg_qty
- WHERE scid = :arg_scid
- AND billid = :arg_relid
- AND printid = :arg_relprintid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = ',更新还货数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer uof_finish (integer arg_finishtype, integer arg_fflag, long arg_scid, long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);//arg_finishtype 1-自动,2-手动
- Int rslt = 1
- Long cnt = 0
- Int ll_fflag
- DateTime null_dt
- SetNull(null_dt)
- IF arg_billid <= 0 THEN
- rslt = 0
- ARG_MSG = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,ARG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- ARG_MSG = '单据未审核,不能操作'
- rslt = 0
- GOTO ext
- END IF
- IF arg_finishtype = 1 THEN
- IF arg_fflag = 1 THEN
- IF fflag = 1 OR fflag = 2 THEN
- ARG_MSG = '单据已完成还货,不能操作'
- rslt = 0
- GOTO ext
- END IF
- ll_fflag = 1
- ELSE
- IF fflag <> 1 THEN
- ARG_MSG = '单据不是自动完成还货,不能操作'
- rslt = 0
- GOTO ext
- END IF
- ll_fflag = 0
- END IF
- ELSE
- IF arg_fflag = 1 THEN
- IF fflag = 1 OR fflag = 2 THEN
- ARG_MSG = '单据已完成还货,不能操作'
- rslt = 0
- GOTO ext
- END IF
- ll_fflag = 2
- ELSE
- IF fflag <> 2 THEN
- ARG_MSG = '单据不是手动完成还货,不能操作'
- rslt = 0
- GOTO ext
- END IF
- ll_fflag = 0
- END IF
- END IF
- IF arg_fflag = 1 THEN
- UPDATE u_mtrlware_trans
- SET fflag = :ll_fflag,
- fdate = getdate(),
- femp = :arg_opemp
- WHERE ( u_mtrlware_trans.billid = :arg_billid ) AND
- ( u_mtrlware_trans.scid = :arg_scid) AND
- ( u_mtrlware_trans.fflag = 0 )
- 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
- ARG_MSG = '单据正在操作,请稍后重试'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- UPDATE u_mtrlware_trans
- SET fflag = :ll_fflag,
- fdate = :null_dt,
- femp = ''
- WHERE ( u_mtrlware_trans.billid = :arg_billid ) AND
- ( u_mtrlware_trans.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
- ARG_MSG = '单据正在操作,请稍后重试'
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF arg_ifcommit AND rslt = 1 THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- RETURN (rslt)
- end function
- public function integer uof_trycmpl (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long cnt = 0
- DateTime null_dt
- SetNull(null_dt)
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = '错误单据唯一码'
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- Decimal ls_zerook
- Boolean if_finish
- if_finish = TRUE
- DECLARE zero_cur CURSOR FOR
- SELECT u_mtrlware_transmx.qty - u_mtrlware_transmx.returnqty
- FROM u_mtrlware_transmx
- WHERE ( u_mtrlware_transmx.billid = :arg_billid )
- AND ( u_mtrlware_transmx.scid = :arg_scid )
- USING commit_transaction;
- OPEN zero_cur;
- FETCH zero_cur INTO :ls_zerook;
- DO WHILE commit_transaction.SQLCode = 0
- IF if_finish THEN
- IF ls_zerook > 0 THEN if_finish = FALSE
- END IF
- FETCH zero_cur INTO :ls_zerook;
- LOOP
- CLOSE zero_cur;
- IF fflag = 0 AND if_finish THEN
- IF uof_finish(1,1,arg_scid,arg_billid,publ_operator,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF fflag = 1 AND NOT if_finish THEN
- IF uof_finish(1,0,arg_scid,arg_billid,publ_operator,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- p_reset()
- RETURN (rslt)
- end function
- public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
- String ls_auditdate,ls_waredate
- Long i
- Long ll_mtrlid,ll_sptid,ll_mtrlwareid
- String ls_status,ls_woodcode ,ls_pcode,ls_plancode
- String ls_mtrlcuscode,ls_location
- DateTime ld_waredate_max
- Decimal ld_qty,ld_wareqty
- SELECT auditingdate INTO :ld_auditingdate
- FROM u_mtrlware_trans
- WHERE billid = :billid
- AND scid = :scid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询单据审核时间失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
- IF Kind = 0 OR Kind = 3 THEN
- SELECT waredate INTO :ld_waredate
- FROM u_mtrlware
- WHERE mtrlwareid = :mtrlwareid
- AND scid = :scid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 TO it_mxbt
- ll_mtrlid = billmx[i].mtrlid
- ll_sptid = billmx[i].rel_cusid_sptid
- ls_status = billmx[i].status
- ls_woodcode = billmx[i].woodcode
- ls_pcode = billmx[i].pcode
- ls_plancode = billmx[i].plancode
- ls_mtrlcuscode = billmx[i].mtrlcuscode
- ls_location = billmx[i].Location
- ld_qty = billmx[i].qty
-
- SELECT waredate,noallocqty
- INTO :ld_waradate_mx,:ld_wareqty
- FROM u_mtrlware
- WHERE scid = :scid
- AND storageid = :storageid
- AND mtrlid = :ll_mtrlid
- AND sptid = :ll_sptid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- AND plancode = :ls_plancode
- AND mtrlcuscode = :ls_mtrlcuscode
- AND Location = :ls_location
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
-
- IF ls_auditdate = ls_waredate OR ld_qty = ld_wareqty OR ld_waradate_mx < ld_waredate THEN
- UPDATE u_mtrlware
- SET waredate = :ld_waredate
- WHERE scid = :scid
- AND storageid = :storageid
- AND mtrlid = :ll_mtrlid
- AND sptid = :ll_sptid
- AND status = :ls_status
- AND woodcode = :ls_woodcode
- AND pcode = :ls_pcode
- AND plancode = :ls_plancode
- AND mtrlcuscode = :ls_mtrlcuscode
- AND Location = :ls_location
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- END IF
- NEXT
- ELSEIF Kind = 1 OR Kind = 2 THEN
- SELECT waredate,noallocqty
- INTO :ld_waredate,:ld_wareqty
- FROM u_mtrlware
- WHERE storageid = :storageid
- AND mtrlid = :mtrlid
- AND sptid = :relid
- AND scid = :scid
- AND status = :status
- AND woodcode = :woodcode
- AND pcode = :pcode
- AND plancode = :plancode
- AND mtrlcuscode = :mtrlcuscode
- AND location = :Location
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- ls_waredate = String(ld_waredate,'yyyy-mm-dd hh:mm')
-
-
- FOR i = 1 TO it_mxbt
- ll_mtrlwareid = billmx[i].mtrlwareid
-
- SELECT waredate INTO :ld_waradate_mx
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlwareid = :ll_mtrlwareid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询明细库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF i = 1 THEN
- ld_waredate_max = ld_waradate_mx
- ELSE
- IF ld_waradate_mx > ld_waredate_max THEN
- ld_waredate_max = ld_waradate_mx
- END IF
- END IF
-
- ld_qty = ld_qty+billmx[i].qty
- NEXT
-
- IF ls_auditdate = ls_waredate OR ld_waredate < ld_waredate_max OR ld_qty = ld_wareqty THEN
- UPDATE u_mtrlware
- SET waredate = :ld_waredate_max
- WHERE storageid = :storageid
- AND mtrlid = :mtrlid
- AND sptid = :relid
- AND scid = :scid
- AND status = :status
- AND woodcode = :woodcode
- AND pcode = :pcode
- AND plancode = :plancode
- AND mtrlcuscode = :mtrlcuscode
- AND location = :Location
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- ELSEIF Kind = 4 THEN
- FOR i = 1 TO it_mxbt
- SELECT waredate INTO :ld_waradate_mx
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlwareid = :billmx[i].mtrlwareid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询明细调出库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- SELECT waredate INTO :ld_waredate
- FROM u_mtrlware
- WHERE scid = :scid
- AND storageid = :storageid
- AND sptid = :relid
- AND mtrlid = :billmx[i].mtrlid
- AND status = :billmx[i].status
- AND woodcode = :billmx[i].woodcode
- AND pcode = :billmx[i].pcode
- AND plancode = :billmx[i].plancode2
- AND mtrlcuscode = :billmx[i].mtrlcuscode2
- AND location = :billmx[i].location2
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询明细调入库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- ls_waredate = String(ld_waredate,'yyyy-mm-dd hh:mm')
-
- IF ls_auditdate = ls_waredate THEN
- UPDATE u_mtrlware
- SET waredate = :ld_waredate_max
- WHERE storageid = :storageid
- AND mtrlid = :mtrlid
- AND sptid = :relid
- AND scid = :scid
- AND status = :status
- AND woodcode = :woodcode
- AND pcode = :pcode
- AND plancode = :plancode
- AND mtrlcuscode = :mtrlcuscode
- AND location = :Location
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新库存最近进仓日期失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
-
- NEXT
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer acceptmx (long arg_printid, long arg_mtrlwareid, long arg_mtrlid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_rel_cusid_sptid, ref string arg_msg, string arg_woodcode, string arg_pcode, long arg_relid, long arg_relprintid, string arg_mtrlcuscode, string arg_location, string arg_waredscrp, string arg_plancode2, string arg_location2, string arg_mtrlcuscode2);Int rslt = 1
- Long cnt = 0
- String i_mtrlcode
- Int li_noallocflag
- Decimal ld_noallocqty,ld_notauditqty
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
- IF IsNull(arg_plancode) THEN arg_plancode = ''
- IF IsNull(arg_status) THEN arg_status = ''
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_fprice) THEN arg_fprice = 0
- IF IsNull(arg_rebate) THEN arg_rebate = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_woodcode) THEN arg_woodcode = ''
- IF IsNull(arg_pcode) THEN arg_pcode = ''
- IF IsNull(arg_rel_cusid_sptid) THEN arg_rel_cusid_sptid = 0
- IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
- IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- IF IsNull(arg_relid) THEN arg_relid = 0
- IF IsNull(arg_mtrlcuscode) THEN arg_mtrlcuscode = ''
- IF IsNull(arg_location) THEN arg_location = ''
- IF IsNull(arg_waredscrp) THEN arg_waredscrp = ''
- IF IsNull(arg_mtrlcuscode2) THEN arg_mtrlcuscode2 = ''
- IF IsNull(arg_location2) THEN arg_location2 = ''
- IF IsNull(arg_plancode2) THEN arg_plancode2 = ''
- // 如果进仓数量为 0,或物料编号为空,则不作任何处理
- IF arg_mtrlid = 0 OR arg_qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF (Kind = 1 OR Kind = 2 OR Kind = 4 ) AND arg_mtrlwareid = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- //检查物料id
- SELECT mtrlcode
- INTO :i_mtrlcode
- FROM u_mtrldef
- Where u_mtrldef.mtrlid = :arg_mtrlid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,物料或产品资料"
- GOTO ext
- END IF
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_cust
- Where cusid = :arg_rel_cusid_sptid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询客户资料失败'
- rslt = 0
- GOTO ext
- END IF
- IF arg_fprice * arg_rebate < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "物料或产品:" + String(i_mtrlcode)+" 单价错误"
- GOTO ext
- END IF
- IF Kind = 3 THEN
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_mtrlware_transmx
- WHERE scid = :scid
- AND billid = :arg_relid
- AND printid = :arg_relprintid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '明细行:'+String(arg_printid)+',查询相关借货单失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSEIF ( Kind = 1 OR Kind = 2 OR Kind = 4 )THEN
- SELECT noallocflag
- INTO :li_noallocflag
- FROM u_storage
- Where storageid = :storageid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询仓库使用未开单库存属性失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF li_noallocflag = 1 THEN
- SELECT u_mtrlware.noallocqty,
- u_mtrlware.noauditingqty
- INTO :ld_noallocqty,
- :ld_notauditqty
- FROM u_mtrlware
- WHERE u_mtrlware.scid = :scid
- AND u_mtrlware.mtrlwareid = :arg_mtrlwareid
- USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询相关转换库存失败>>' + commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF IsNull(ld_notauditqty) THEN ld_notauditqty = 0
- IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
-
- IF ld_noallocqty - ld_notauditqty < arg_qty THEN
- arg_msg = '行:'+String(arg_printid)+'库存未开单数不足,不能调货,请检查'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- //写入内容
- it_mxbt++
- billmx[it_mxbt].printid = arg_printid
- billmx[it_mxbt].mtrlid = arg_mtrlid
- billmx[it_mxbt].mtrlcode = i_mtrlcode
- billmx[it_mxbt].plancode = arg_plancode
- billmx[it_mxbt].status = arg_status
- billmx[it_mxbt].qty = arg_qty
- billmx[it_mxbt].fprice = arg_fprice
- billmx[it_mxbt].rebate = arg_rebate
- billmx[it_mxbt].price = arg_fprice * arg_rebate
- billmx[it_mxbt].mxdscrp = arg_mxdscrp
- billmx[it_mxbt].rel_cusid_sptid = arg_rel_cusid_sptid
- billmx[it_mxbt].woodcode = arg_woodcode
- billmx[it_mxbt].pcode = arg_pcode
- billmx[it_mxbt].mtrlwareid = arg_mtrlwareid
- billmx[it_mxbt].relid = arg_relid
- billmx[it_mxbt].relprintid = arg_relprintid
- billmx[it_mxbt].mtrlcuscode = arg_mtrlcuscode
- billmx[it_mxbt].Location = arg_location
- billmx[it_mxbt].waredscrp = arg_waredscrp
- billmx[it_mxbt].mtrlcuscode2 = arg_mtrlcuscode2
- billmx[it_mxbt].location2 = arg_location2
- billmx[it_mxbt].plancode2 = arg_plancode2
- sum_transqty = sum_transqty + arg_qty
- sum_transamt = sum_transamt + arg_qty * arg_fprice * arg_rebate
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN(rslt)
- end function
- public function integer priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- if kind <> 5 then
- rslt = 0
- arg_msg = "非一调一单据类型不能使用确认功能"
- GOTO ext
- end if
- IF arg_scid < 0 THEN
- rslt = 0
- arg_msg = "错误的分部ID"
- GOTO ext
- END IF
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = "没有确认对象"
- GOTO ext
- END IF
- IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF priceflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经确认"
- GOTO ext
- END IF
- UPDATE u_mtrlware_trans
- SET priceemp = :publ_operator,
- pricedate = getdate(),
- priceflag = 1
- WHERE u_mtrlware_trans.billid = :arg_billid
- 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
- priceflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_priceaudit (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- DateTime null_dt
- SetNull(null_dt)
- IF Kind <> 5 THEN
- rslt = 0
- arg_msg = "非一调一单据类型不能使用确认功能"
- GOTO ext
- END IF
- IF arg_scid < 0 THEN
- rslt = 0
- arg_msg = "错误的分部ID"
- GOTO ext
- END IF
- IF arg_billid <= 0 THEN
- rslt = 0
- arg_msg = "没有反确认对象"
- GOTO ext
- END IF
- IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF priceflag = 0 THEN
- rslt = 0
- arg_msg = "单据还未确认,不能反确认"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已审核,不能反确认"
- GOTO ext
- END IF
- UPDATE u_mtrlware_trans
- SET priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- WHERE u_mtrlware_trans.billid = :arg_billid
- 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
- RETURN rslt
- end function
- on uo_mtrlware_trans.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_mtrlware_trans.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|