1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072 |
- $PBExportHeader$uo_inware_wfjg.sru
- forward
- global type uo_inware_wfjg from nonvisualobject
- end type
- end forward
- global type uo_inware_wfjg from nonvisualobject
- end type
- global uo_inware_wfjg uo_inware_wfjg
- type variables
- Public ProtectedWrite Long scid
- Public ProtectedWrite Long inwareid
- Public ProtectedWrite String inwarecode
- Public ProtectedWrite Int billtype
- Public ProtectedWrite DateTime opdate
- Public ProtectedWrite String opemp
- Public ProtectedWrite DateTime moddate
- Public ProtectedWrite String modemp
- Public ProtectedWrite Int flag
- Public ProtectedWrite Int balcflag
- Public ProtectedWrite DateTime auditingdate
- Public ProtectedWrite String auditingrep
- Public ProtectedWrite Decimal jgsum_amt
- Public ProtectedWrite Decimal tax_amt
- Public ProtectedWrite Int secflag
- Public ProtectedWrite DateTime secauditingdate
- Public ProtectedWrite String secauditingrep
- Public ProtectedWrite Long ctmint
- Long relid
- Long storageid
- DateTime indate
- DateTime plandate
- String inrep
- String part
- String dscrp
- Long sptid
- String sptname
- Int dxflag
- Int thflag
- Decimal otheramt
- Long relint_1
- Long relint_2
- Long relint_3
- String relstr_1
- String relstr_2
- String relstr_3
- decimal dec_round = 10 //计算发出明细保留小数位, 取自外协订单界面
- Boolean if_getid_ture = True
- Transaction commit_transaction //数据commit事务
- s_wfjgmx_in_aft inwaremx[] //明细结构数组
- s_wfjgmx_in_bef inwaremx_bef[] //明细结构数组
- Long it_mxbt = 0 //明细结构数组末指针
- Long it_mxbt_bef = 0 //明细结构数组末指针
- Boolean it_newbegin = False //新建标志
- Boolean it_updatebegin = False //修改标志
- Int uo_option_wfjg_outmx,uo_option_wfjg_sptprice_sec
- Int uo_option_check_wfjgin,uo_option_wfjg_zero
- Int uo_option_2unit
- String uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode
- Int uo_option_ifovertask
- Int uo_option_wfjg_th_ifnotorder
- int uo_option_cost_notax
- end variables
- forward prototypes
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_inwareid, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer del (long arg_scid, long arg_inwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_inwareid, 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_inwareid, ref string arg_msg)
- public function integer p_reset ()
- public function integer p_create_inware (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_destroy_inware (boolean arg_ifcommit, ref string arg_msg)
- 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 newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_inwareid, integer arg_billtype, ref string arg_msg)
- public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, long arg_printid, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit)
- public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_uqty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, ref string arg_msg, decimal arg_jgprice, long arg_relid, integer arg_ifrel, string arg_woodcode, string arg_pcode, long arg_cusid_sptid, string arg_unit, decimal arg_rate, decimal arg_qty, long arg_storageid, string arg_jgdscrp, long arg_relprintid, integer arg_mxtype, decimal arg_checkqty, string arg_result, long arg_relbillid, long arg_relbillprintid, string arg_mtrlcuscode, string arg_location, decimal arg_taxrate)
- public function integer acceptmx_bef (long arg_mtrlwareid, decimal arg_qty, string arg_mxdscrp, long arg_printid, string arg_unit, decimal arg_uqty, decimal arg_rate, long arg_relprintid, ref string arg_msg)
- public function integer acceptmx (s_wfjgmx_in_aft s_mx, ref string arg_msg)
- public function integer acceptmx_bef (s_wfjgmx_in_bef s_mx, ref string arg_msg)
- public function integer p_create_wfjgorder (string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
- public function integer p_destroy_wfjgorder (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_check_sptpdb_audit (long arg_sptid, ref string arg_msg)
- public function integer mod_price (long arg_scid, long arg_inwareid, long arg_printid, decimal arg_fprice, decimal arg_jgprice, decimal arg_taxrate, decimal arg_rebate, ref string arg_msg, boolean arg_ifcommit)
- end prototypes
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i, j
- DateTime server_dt
- Long ls_newid
- String ls_sccode
- IF uo_option_wfjg_outmx = -1000 THEN
- rslt = 0
- arg_msg = '选项:[086]外协订单,收货单必须有外协商库存明细,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF IsNull(relid) THEN relid = 0
- IF IsNull(storageid) THEN storageid = 0
- IF IsNull(inrep) THEN inrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(sptid) THEN sptid = 0
- IF IsNull(sptname) THEN sptname = ''
- IF IsNull(dxflag) THEN dxflag = 0
- IF IsNull(thflag) THEN thflag = 0
- IF IsNull(relint_1) THEN relint_1 = 0
- IF IsNull(relint_2) THEN relint_2 = 0
- IF IsNull(relint_3) THEN relint_3 = 0
- IF IsNull(relstr_1) THEN relstr_1 = ''
- IF IsNull(relstr_2) THEN relstr_2 = ''
- IF IsNull(relstr_3) THEN relstr_3 = ''
- 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
- CHOOSE CASE billtype
- CASE 4,5,6
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- IF billtype = 4 Or billtype = 5 THEN
- arg_msg = "没有正确进仓内容"
- ELSE
- arg_msg = "没有正确计费内容"
- END IF
- GOTO ext
- END IF
-
- IF billtype = 4 Or billtype = 5 THEN
- IF uo_option_wfjg_outmx = 1 THEN
- //检查收货, 必须有对应外协商库存
- FOR i = 1 To it_mxbt
- FOR j = 1 To it_mxbt_bef
- IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
- GOTO _next_check
- END IF
- NEXT
-
- rslt = 0
- arg_msg = '收货明细第'+String(inwaremx[i].printid)+'行,没有对应的外协商库存明细,请检查'
- GOTO ext
- _next_check:
- NEXT
- //检查外协商库存, 必须有收货对应
- FOR j = 1 To it_mxbt_bef
- FOR i = 1 To it_mxbt
- IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
- GOTO _next_check2
- END IF
- NEXT
- rslt = 0
- arg_msg = '外协商库存明细第'+String(inwaremx_bef[j].printid)+'行,没有对应的收货明细,请检查'
- GOTO ext
- _next_check2:
- NEXT
-
- //必须使用有发出明细的选项 sys_option_wfjg_outmx = 1
- //必须选物料清单或计划 而且 比较清单数量也必须相应; 2013-09-13
- IF sys_option_wfjg_out_cmp = 1 THEN
- Long ll_mtrlid_in, ll_mtrlid_out
- Decimal lde_qty_in, lde_qty_out, lde_qty_out_pf
- String ls_pfcode
- Decimal lde_truerqqty_in_pf, lde_rqqty_out_pf
- Boolean lb_find = False
- decimal lde_sonscale
-
- //检查收货, 必须有对应外协商库存
- FOR i = 1 To it_mxbt //收货
- ll_mtrlid_in = inwaremx[i].mtrlid
- lde_qty_in = abs(inwaremx[i].qty)
- ls_pfcode = "[常规]" //inwaremx[i].pfcode
- lb_find = False
-
- FOR j = 1 To it_mxbt_bef //外协商库存
- IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
- ll_mtrlid_out = inwaremx_bef[j].mtrlid
- lde_qty_out = abs(inwaremx_bef[j].qty)
- lde_qty_out_pf = 0
- lb_find = True
-
- IF ll_mtrlid_in = ll_mtrlid_out THEN
- lde_qty_out_pf = lde_qty_in //返工类型, 发出物料和收货物料为同一种的,只检查数量关系
- lde_sonscale = 1
- ELSE
- IF inwaremx[i].relid > 0 THEN //查主计划
-
- SELECT top 1 u_order_wfjgMx.qty
- INTO :lde_truerqqty_in_pf
- FROM u_order_wfjgMx
- WHERE ( scid = :scid)
- AND ( wfjgID = :inwaremx[i].relid)
- AND ( printid = :inwaremx[i].relprintid)
- AND ( mtrlid = :ll_mtrlid_in ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',查询对应的外协订单收货结果资料失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- SELECT top 1 qty
- INTO :lde_rqqty_out_pf
- FROM u_order_wfjgmx_out_mx
- WHERE ( scid = :scid)
- AND ( wfjgid = :inwaremx[i].relid)
- AND ( relprintid = :inwaremx[i].relprintid )
- And ( mtrlid = :ll_mtrlid_out ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',查询对应的外协订单资料失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- lde_qty_out_pf = Round(lde_qty_in * ( lde_rqqty_out_pf / lde_truerqqty_in_pf), dec_round)
-
- lde_sonscale = lde_rqqty_out_pf / lde_truerqqty_in_pf
- ELSE //查BOM
-
-
- SELECT :lde_qty_in * u_prdpf.Sonscale / (1 - u_PrdPF.sonloss) + u_PrdPF.SonDECLoss, u_prdpf.Sonscale
- INTO :lde_qty_out_pf, :lde_sonscale
- FROM u_PrdPF
- WHERE ( u_PrdPF.mtrlid = :ll_mtrlid_in )
- AND ( u_PrdPF.sonmtrlid = :ll_mtrlid_out )
- And ( u_prdpf.pfcode = :ls_pfcode ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',查询对应的物料清单资料失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- lde_qty_out_pf = Round(lde_qty_out_pf, dec_round)
- END IF
- END IF
-
- IF lde_qty_out <> lde_qty_out_pf THEN
- Decimal lde_tmprate
- if lde_sonscale = 1 then
- lde_tmprate = 0
- else
- //临时,比例在99%以上的算正确
- IF lde_qty_out > lde_qty_out_pf THEN
- lde_tmprate = lde_qty_out_pf / lde_qty_out
- ELSE
- lde_tmprate = lde_qty_out / lde_qty_out_pf
- END IF
- end if
- IF lde_tmprate < 0.99 THEN
- rslt = 0
- arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',数量比例与限制不相等,请检查'
- GOTO ext
- END IF
- END IF
- // IF lde_qty_out <> lde_qty_out_pf THEN
- // rslt = 0
- // arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',数量比例与限制不相等,请检查'
- // GOTO ext
- // END IF
-
- END IF
- NEXT
-
- IF Not lb_find THEN
- rslt = 0
- arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',找不到对应的发出明细或供应商库存ID不存在,请检查'
- GOTO ext
- END IF
-
- NEXT
-
- END IF
- END IF
-
-
- END IF //billtype
-
- CASE 9
- IF it_mxbt_bef = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确进仓内容"
- GOTO ext
- END IF
- END CHOOSE
- IF f_check_inoutdate(0,indate,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype <> 6 THEN
- IF f_check_inoutdate_wfjg(scid,sptid,indate,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- plandate = f_findspt_paydate(sptid,indate)
- 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
- String ls_msg_loca
- Long ll_cnt_loca
- Int li_mustloca
- IF billtype = 4 And thflag = 0 THEN
- ll_cnt_loca = 0
- FOR i = 1 To it_mxbt
- SELECT mustloca
- INTO :li_mustloca
- FROM u_storage
- WHERE storageid = :inwaremx[i].storageid
- Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "第"+String(i)+"行,查询仓库操作失败,"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF li_mustloca = 1 THEN
- IF Trim(inwaremx[i].Location) = '' THEN
- ll_cnt_loca++
- IF ll_cnt_loca <= 10 THEN
- IF Trim(ls_msg_loca) = '' THEN
- ls_msg_loca = ls_msg_loca + String(i)
- ELSE
- ls_msg_loca = ls_msg_loca + ','+String(i)
- END IF
- END IF
- END IF
- END IF
- NEXT
-
- IF ll_cnt_loca > 0 THEN
- rslt = 0
- IF ll_cnt_loca <= 10 THEN
- arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'明细中第'+ls_msg_loca+'行没有填仓位,请检查'
- ELSE
- arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'其中第'+ls_msg_loca+'等'+String(ll_cnt_loca)+'行明细没有填仓位,请详细检查'
- END IF
-
- GOTO ext
- END IF
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF inwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"ow_wfjg_in","inwareid",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 thflag = 0 THEN
- IF billtype = 4 THEN
- inwarecode = getid(scid,ls_sccode + 'WI',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF billtype = 5 THEN
- inwarecode = getid(scid,ls_sccode + 'SI',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF billtype = 6 THEN
- inwarecode = getid(scid,ls_sccode + 'MF',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF billtype = 9 THEN
- inwarecode = getid(scid,ls_sccode + 'WK',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- ELSE
- IF billtype = 4 THEN
- inwarecode = getid(scid,ls_sccode + 'WT',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- inwarecode = getid(scid,ls_sccode + 'ST',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- END IF
-
- IF inwarecode = "err" THEN
- inwarecode = ''
- rslt = 0
- arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- INSERT INTO ow_wfjg_in (
- scid,
- inwareid,
- inwarecode,
- billtype,
- relid,
- storageid,
- indate,
- plandate,
- inrep,
- part,
- dscrp,
- sptid,
- sptname,
- thflag,
- dxflag,
- otheramt,
- opdate,
- opemp,
- relint_1,
- relint_2,
- relint_3,
- relstr_1,
- relstr_2,
- relstr_3)
- VALUES (
- :scid,
- :ls_newid,
- :inwarecode,
- :billtype,
- :relid,
- :storageid,
- :indate,
- :plandate,
- :inrep,
- :part,
- :dscrp,
- :sptid,
- :sptname,
- :thflag,
- :dxflag,
- :otheramt,
- :server_dt,
- :publ_operator,
- :relint_1,
- :relint_2,
- :relint_3,
- :relstr_1,
- :relstr_2,
- :relstr_3) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新inwareid
- inwareid = ls_newid
-
- FOR i = 1 To it_mxbt
- INSERT INTO ow_wfjgmx_in_aft
- (scid,
- inwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- jgprice,
- relid,
- ifrel,
- woodcode,
- relcode,
- pcode,
- sptid_cusid,
- cost,
- sptmtrlname,
- unit,
- rate,
- uprice,
- uqty,
- bootqty,
- noauditqty,
- storageid,
- jgdscrp,
- relprintid,
- mxtype,
- checkqty,
- result,
- relbillid,
- relbillprintid,
- relbillcode,
- mtrlcuscode,
- location,
- taxrate)
- VALUES (:scid,
- :ls_newid,
- :inwaremx[i].printid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].qty,
- :inwaremx[i].fprice,
- :inwaremx[i].rebate,
- :inwaremx[i].price,
- :inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].jgprice,
- :inwaremx[i].relid,
- :inwaremx[i].ifrel,
- :inwaremx[i].woodcode,
- :inwaremx[i].relcode,
- :inwaremx[i].pcode,
- :inwaremx[i].sptid,
- :inwaremx[i].cost,
- :inwaremx[i].sptmtrlname,
- :inwaremx[i].unit,
- :inwaremx[i].rate,
- :inwaremx[i].uprice,
- :inwaremx[i].uqty,
- :inwaremx[i].bootqty,
- :inwaremx[i].noauditqty,
- :inwaremx[i].storageid,
- :inwaremx[i].jgdscrp,
- :inwaremx[i].relprintid,
- :inwaremx[i].mxtype,
- :inwaremx[i].checkqty,
- :inwaremx[i].result,
- :inwaremx[i].relbillid,
- :inwaremx[i].relbillprintid,
- :inwaremx[i].relbillcode,
- :inwaremx[i].mtrlcuscode,
- :inwaremx[i].Location,
- :inwaremx[i].taxrate) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- inwareid = 0 //还原inwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt_bef
- INSERT INTO ow_wfjgmx_in_bef
- (scid,
- inwareid,
- mtrlwareid,
- mtrlid,
- status,
- woodcode,
- pcode,
- plancode,
- qty,
- fprice,
- printid,
- mxdscrp,
- unit,
- uqty,
- rate,
- relprintid)
- VALUES (
- :scid,
- :ls_newid,
- :inwaremx_bef[i].mtrlwareid,
- :inwaremx_bef[i].mtrlid,
- :inwaremx_bef[i].status,
- :inwaremx_bef[i].woodcode,
- :inwaremx_bef[i].pcode,
- :inwaremx_bef[i].plancode,
- :inwaremx_bef[i].qty,
- :inwaremx_bef[i].fprice,
- :inwaremx_bef[i].printid,
- :inwaremx_bef[i].mxdscrp,
- :inwaremx_bef[i].unit,
- :inwaremx_bef[i].uqty,
- :inwaremx_bef[i].rate,
- :inwaremx_bef[i].relprintid) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- inwareid = 0 //还原inwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ELSE //////////////////////////////////////////////// //更新
- UPDATE ow_wfjg_in
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- indate = :indate,
- plandate = :plandate,
- inrep = :inrep,
- part = :part,
- dscrp = :dscrp,
- sptid = :sptid,
- sptname = :sptname,
- thflag = :thflag,
- dxflag = :dxflag,
- otheramt = :otheramt,
- moddate = :server_dt,
- modemp = :publ_operator,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- relint_3 = :relint_3,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3
- WHERE ow_wfjg_in.inwareid = :inwareid
- AND ow_wfjg_in.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 ow_wfjgmx_in_aft
- WHERE ow_wfjgmx_in_aft.inwareid = :inwareid
- And ow_wfjgmx_in_aft.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 ow_wfjgmx_in_aft
- (scid,
- inwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- jgprice,
- relid,
- ifrel,
- woodcode,
- relcode,
- pcode,
- sptid_cusid,
- cost,
- sptmtrlname,
- unit,
- rate,
- uprice,
- uqty,
- bootqty,
- noauditqty,
- storageid,
- jgdscrp,
- relprintid,
- mxtype,
- checkqty,
- result,
- relbillid,
- relbillprintid,
- relbillcode,
- mtrlcuscode,
- location,
- taxrate)
- VALUES (:scid,
- :inwareid,
- :inwaremx[i].printid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].qty,
- :inwaremx[i].fprice,
- :inwaremx[i].rebate,
- :inwaremx[i].price,
- :inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].jgprice,
- :inwaremx[i].relid,
- :inwaremx[i].ifrel,
- :inwaremx[i].woodcode,
- :inwaremx[i].relcode,
- :inwaremx[i].pcode,
- :inwaremx[i].sptid,
- :inwaremx[i].cost,
- :inwaremx[i].sptmtrlname,
- :inwaremx[i].unit,
- :inwaremx[i].rate,
- :inwaremx[i].uprice,
- :inwaremx[i].uqty,
- :inwaremx[i].bootqty,
- :inwaremx[i].noauditqty,
- :inwaremx[i].storageid,
- :inwaremx[i].jgdscrp,
- :inwaremx[i].relprintid,
- :inwaremx[i].mxtype,
- :inwaremx[i].checkqty,
- :inwaremx[i].result,
- :inwaremx[i].relbillid,
- :inwaremx[i].relbillprintid,
- :inwaremx[i].relbillcode,
- :inwaremx[i].mtrlcuscode,
- :inwaremx[i].Location,
- :inwaremx[i].taxrate) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //删除原有明细
- DELETE FROM ow_wfjgmx_in_bef
- WHERE ow_wfjgmx_in_bef.inwareid = :inwareid
- And ow_wfjgmx_in_bef.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_bef
- INSERT INTO ow_wfjgmx_in_bef
- (scid,
- inwareid,
- mtrlwareid,
- mtrlid,
- status,
- woodcode,
- pcode,
- plancode,
- qty,
- fprice,
- printid,
- mxdscrp,
- unit,
- uqty,
- rate,
- relprintid)
- VALUES (
- :scid,
- :inwareid,
- :inwaremx_bef[i].mtrlwareid,
- :inwaremx_bef[i].mtrlid,
- :inwaremx_bef[i].status,
- :inwaremx_bef[i].woodcode,
- :inwaremx_bef[i].pcode,
- :inwaremx_bef[i].plancode,
- :inwaremx_bef[i].qty,
- :inwaremx_bef[i].fprice,
- :inwaremx_bef[i].printid,
- :inwaremx_bef[i].mxdscrp,
- :inwaremx_bef[i].unit,
- :inwaremx_bef[i].uqty,
- :inwaremx_bef[i].rate,
- :inwaremx_bef[i].relprintid
- ) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- 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 getinfo (long arg_scid, long arg_inwareid, ref string arg_msg);//getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1,i = 1,no_mxcheck = 0,j = 1,no_mxcheck_bef = 0
- jgsum_amt = 0
- tax_amt = 0
- IF arg_inwareid <= 0 THEN
- rslt = 0
- arg_msg = "非法进仓单唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_inwaermx CURSOR FOR
- SELECT ow_wfjgmx_in_aft.printid,
- ow_wfjgmx_in_aft.mtrlid,
- ow_wfjgmx_in_aft.plancode,
- ow_wfjgmx_in_aft.status,
- ow_wfjgmx_in_aft.qty,
- ow_wfjgmx_in_aft.fprice,
- ow_wfjgmx_in_aft.rebate,
- ow_wfjgmx_in_aft.price,
- ow_wfjgmx_in_aft.planprice,
- ow_wfjgmx_in_aft.mxdscrp,
- u_mtrldef.mtrlcode,
- ow_wfjgmx_in_aft.jgprice,
- ow_wfjgmx_in_aft.relid,
- ow_wfjgmx_in_aft.ifrel,
- ow_wfjgmx_in_aft.woodcode,
- ow_wfjgmx_in_aft.pcode,
- ow_wfjgmx_in_aft.plancode,
- ow_wfjgmx_in_aft.sptid_cusid,
- ow_wfjgmx_in_aft.cost,
- ow_wfjgmx_in_aft.sptmtrlname,
- ow_wfjgmx_in_aft.unit,
- ow_wfjgmx_in_aft.uqty,
- ow_wfjgmx_in_aft.uprice,
- ow_wfjgmx_in_aft.rate,
- ow_wfjgmx_in_aft.bootqty,
- ow_wfjgmx_in_aft.noauditqty,
- ow_wfjgmx_in_aft.storageid,
- ow_wfjgmx_in_aft.jgdscrp ,
- ow_wfjgmx_in_aft.relprintid ,
- ow_wfjgmx_in_aft.mxtype,
- ow_wfjgmx_in_aft.checkqty,
- ow_wfjgmx_in_aft.result,
- ow_wfjgmx_in_aft.relbillid,
- ow_wfjgmx_in_aft.relbillprintid,
- ow_wfjgmx_in_aft.relbillcode,
- ow_wfjgmx_in_aft.mtrlcuscode,
- ow_wfjgmx_in_aft.location,
- ow_wfjgmx_in_aft.taxrate
- FROM ow_wfjgmx_in_aft,u_mtrldef,ow_wfjg_in
- WHERE ow_wfjg_in.inwareid = :arg_inwareid AND
- ow_wfjgmx_in_aft.mtrlid = u_mtrldef.mtrlid AND
- ow_wfjg_in.scid = :arg_scid AND
- ow_wfjg_in.inwareid = ow_wfjgmx_in_aft.inwareid AND
- ow_wfjg_in.scid = ow_wfjgmx_in_aft.scid USING commit_transaction;
-
- OPEN cur_inwaermx;
- FETCH cur_inwaermx INTO :inwaremx[i].printid,:inwaremx[i].mtrlid,:inwaremx[i].plancode,
- :inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice,
- :inwaremx[i].rebate,:inwaremx[i].price,:inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode,:inwaremx[i].jgprice,
- :inwaremx[i].relid,:inwaremx[i].ifrel,:inwaremx[i].woodcode,
- :inwaremx[i].pcode,:inwaremx[i].plancode,:inwaremx[i].sptid,
- :inwaremx[i].cost,:inwaremx[i].sptmtrlname,:inwaremx[i].unit,
- :inwaremx[i].uqty,:inwaremx[i].uprice,:inwaremx[i].rate,
- :inwaremx[i].bootqty,:inwaremx[i].noauditqty,
- :inwaremx[i].storageid,:inwaremx[i].jgdscrp,
- :inwaremx[i].relprintid,:inwaremx[i].mxtype,
- :inwaremx[i].checkqty,:inwaremx[i].result,
- :inwaremx[i].relbillid,:inwaremx[i].relbillprintid,
- :inwaremx[i].relbillcode,:inwaremx[i].mtrlcuscode,
- :inwaremx[i].location,:inwaremx[i].taxrate;
-
- inwaremx[i].dxflag = dxflag
- DO WHILE commit_transaction.SQLCode = 0
- jgsum_amt = jgsum_amt + round((inwaremx[i].uqty * inwaremx[i].jgprice * inwaremx[i].rebate) / (1 + inwaremx[i].taxrate),2) //计算单据总金额
- tax_amt = tax_amt + round((inwaremx[i].uqty * inwaremx[i].jgprice * inwaremx[i].rebate) / (1 + inwaremx[i].taxrate) * inwaremx[i].taxrate,2)
-
- i++
- FETCH cur_inwaermx INTO :inwaremx[i].printid,:inwaremx[i].mtrlid,:inwaremx[i].plancode,
- :inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice,
- :inwaremx[i].rebate,:inwaremx[i].price,:inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode,:inwaremx[i].jgprice,
- :inwaremx[i].relid,:inwaremx[i].ifrel,:inwaremx[i].woodcode,
- :inwaremx[i].pcode,:inwaremx[i].plancode,:inwaremx[i].sptid,
- :inwaremx[i].cost,:inwaremx[i].sptmtrlname,:inwaremx[i].unit,
- :inwaremx[i].uqty,:inwaremx[i].uprice,:inwaremx[i].rate,
- :inwaremx[i].bootqty,:inwaremx[i].noauditqty,
- :inwaremx[i].storageid,:inwaremx[i].jgdscrp,
- :inwaremx[i].relprintid,:inwaremx[i].mxtype,
- :inwaremx[i].checkqty,:inwaremx[i].result,
- :inwaremx[i].relbillid,:inwaremx[i].relbillprintid,
- :inwaremx[i].relbillcode,:inwaremx[i].mtrlcuscode,
- :inwaremx[i].location,:inwaremx[i].taxrate;
-
- inwaremx[i].dxflag = dxflag
- LOOP
- CLOSE cur_inwaermx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM ow_wfjgmx_in_aft
- WHERE ow_wfjgmx_in_aft.inwareid = :arg_inwareid
- AND scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,外协收货单明细数量"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,外协收货单明细"
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_inwaermx_bef CURSOR FOR
- SELECT ow_wfjgmx_in_bef.mtrlwareid,
- ow_wfjgmx_in_bef.printid,
- ow_wfjgmx_in_bef.mtrlid,
- ow_wfjgmx_in_bef.plancode,
- ow_wfjgmx_in_bef.status,
- ow_wfjgmx_in_bef.qty,
- ow_wfjgmx_in_bef.fprice,
- ow_wfjgmx_in_bef.mxdscrp,
- u_mtrldef.mtrlcode,
- ow_wfjgmx_in_bef.woodcode,
- ow_wfjgmx_in_bef.pcode,
- ow_wfjgmx_in_bef.plancode,
- ow_wfjgmx_in_bef.unit,
- ow_wfjgmx_in_bef.uqty,
- ow_wfjgmx_in_bef.rate,
- ow_wfjgmx_in_bef.relprintid
- FROM ow_wfjgmx_in_bef,u_mtrldef,ow_wfjg_in
- WHERE ow_wfjg_in.inwareid = :arg_inwareid AND
- ow_wfjgmx_in_bef.mtrlid = u_mtrldef.mtrlid AND
- ow_wfjg_in.scid = :arg_scid AND
- ow_wfjg_in.inwareid = ow_wfjgmx_in_bef.inwareid AND
- ow_wfjg_in.scid = ow_wfjgmx_in_bef.scid
- USING commit_transaction;
-
- OPEN cur_inwaermx_bef;
- FETCH cur_inwaermx_bef INTO :inwaremx_bef[j].mtrlwareid,
- :inwaremx_bef[j].printid,
- :inwaremx_bef[j].mtrlid,:inwaremx_bef[j].plancode,
- :inwaremx_bef[j].status,:inwaremx_bef[j].qty,:inwaremx_bef[j].fprice,
- :inwaremx_bef[j].mxdscrp,
- :inwaremx_bef[j].mtrlcode,:inwaremx_bef[j].woodcode,
- :inwaremx_bef[j].pcode,:inwaremx_bef[j].plancode,
- :inwaremx_bef[j].unit,:inwaremx_bef[j].uqty,:inwaremx_bef[j].rate,
- :inwaremx_bef[i].relprintid;
-
- DO WHILE commit_transaction.SQLCode = 0
- j++
- FETCH cur_inwaermx_bef INTO :inwaremx_bef[j].mtrlwareid,
- :inwaremx_bef[j].printid,
- :inwaremx_bef[j].mtrlid,:inwaremx_bef[j].plancode,
- :inwaremx_bef[j].status,:inwaremx_bef[j].qty,:inwaremx_bef[j].fprice,
- :inwaremx_bef[j].mxdscrp,
- :inwaremx_bef[j].mtrlcode,:inwaremx_bef[j].woodcode,
- :inwaremx_bef[j].pcode,:inwaremx_bef[j].plancode,
- :inwaremx_bef[j].unit,:inwaremx_bef[j].uqty,:inwaremx_bef[j].rate,
- :inwaremx_bef[i].relprintid;
-
- LOOP
- CLOSE cur_inwaermx_bef;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck_bef
- FROM ow_wfjgmx_in_bef
- WHERE ow_wfjgmx_in_bef.inwareid = :arg_inwareid
- AND scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,外协收货单相关发外明细数量"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF j <> (no_mxcheck_bef+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,外协收货单相关发外明细"
- GOTO ext
- END IF
- inwareid = arg_inwareid
- scid = arg_scid
- it_mxbt = i - 1
- it_mxbt_bef = j - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i
- Long ll_moneyid_native
- Decimal ld_jgprice_notax
- IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_wfjg_sptprice_sec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_check_wfjgin = -1000 THEN
- rslt = 0
- arg_msg = '选项:[131]外协选质检后进仓,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_wfjg_th_ifnotorder = -1000 THEN
- rslt = 0
- arg_msg = '选项:[322]外协返工单限制不能选外协订单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_order_wfjg uo_wfjg
- uo_wfjg = Create uo_order_wfjg
- uo_wfjg.commit_transaction = commit_transaction
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- uo_sptcheck uo_sptch
- uo_sptch = Create uo_sptcheck
- IF inwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- //检查外协商盘点表是否未审
- IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
- rslt = 0
- 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
- UPDATE ow_wfjg_in
- SET auditingrep = :publ_operator,
- auditingdate = getdate(),
- flag = 1
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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 billtype = 4 THEN
- IF thflag = 0 THEN
- IF Not sys_power_issuper and f_power_ind(4135,sys_msg_pow)THEN
- FOR i = 1 To it_mxbt
- IF inwaremx[i].fprice = 0 THEN
- arg_msg = '用户权限限制,行'+string(i)+',材料成本价为0,不能审核'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- ELSE
- IF Not sys_power_issuper and f_power_ind(4136,sys_msg_pow) THEN
- FOR i = 1 To it_mxbt
- IF inwaremx[i].fprice = 0 THEN
- arg_msg = '用户权限限制,行'+string(i)+',材料成本价为0,不能审核'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- END IF
-
- IF p_create_inware( False, arg_msg ) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_option_wfjg_th_ifnotorder = 1 And thflag = 1 THEN
- IF p_create_wfjgorder(publ_operator,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF billtype <> 6 THEN
- FOR i = 1 To it_mxbt_bef
- Decimal ld_ref_cost
-
- IF p_update_cost(inwaremx_bef[i].mtrlwareid,inwaremx_bef[i].mtrlcode,&
- inwaremx_bef[i].printid,ld_ref_cost,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF f_update_mtrlware_spt_in(billtype,&
- thflag,&
- scid,&
- inwaremx_bef[i].mtrlwareid,&
- inwaremx_bef[i].mtrlid,&
- inwaremx_bef[i].mtrlcode,&
- inwaremx_bef[i].plancode,&
- inwaremx_bef[i].status,&
- inwaremx_bef[i].qty,&
- ld_ref_cost,&
- sptid,&
- inwaremx_bef[i].woodcode,&
- inwaremx_bef[i].pcode,&
- arg_msg,False,commit_transaction) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt
- IF uo_option_wfjg_sptprice_sec = 0 THEN
- IF inwaremx[i].mxtype = 0 THEN //正常收货的才更新供应商单价
- ld_jgprice_notax = inwaremx[i].jgprice / ( 1 + inwaremx[i].taxrate)
- IF uo_sptprice.uof_update_sptprice(thflag,sptid,inwaremx[i].mtrlid,inwaremx[i].unit,inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,inwaremx[i].jgdscrp,inwareid,inwaremx[i].jgprice,inwaremx[i].rebate,inwaremx[i].rate,inwaremx[i].jgprice/inwaremx[i].rate,ld_jgprice_notax/inwaremx[i].rate ,indate,inwarecode,0,inwaremx[i].mxdscrp,inwaremx[i].printid,1,ll_moneyid_native,indate,DateTime(9999-01-01),False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
-
- IF inwaremx[i].relid > 0 THEN
- IF billtype = 9 THEN //盘亏单, 终止外协订单对应的收货明细
- IF uo_wfjg.StopAddQty(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].mtrlcode,inwaremx[i].qty, 0, '盘亏自动终止',arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF uo_wfjg.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF rslt = 1 And Trim(arg_msg) <> '' THEN
- f_setsysoplog('外协收货单','外协收货单审核,id:'+String(inwareid)+',单号:'+inwarecode,arg_msg,False)
- END IF
- END IF
-
- IF uo_wfjg.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- //更新质检已进仓数
- IF uo_option_check_wfjgin = 1 And inwaremx[i].relbillid > 0 THEN
- IF uo_sptch.uof_add_inqty(inwaremx[i].relbillid,inwaremx[i].relbillprintid,inwaremx[i].uqty,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- 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_wfjg
- Destroy uo_sptch
- Destroy uo_sptprice
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_inwareid, ref string arg_msg, boolean arg_ifcommit);//del(arg_scid,arg_inwareid,arg_msg)
- //如果单据还没有审核删除单据极其明细
- //0 fail, 1 success
- Int rslt = 1
- IF arg_inwareid = 0 THEN
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- DELETE FROM ow_wfjgmx_in_aft
- WHERE ow_wfjgmx_in_aft.inwareid = :arg_inwareid
- And ow_wfjgmx_in_aft.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_in_bef
- WHERE ow_wfjgmx_in_bef.inwareid = :arg_inwareid
- And ow_wfjgmx_in_bef.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_wfjg_in
- WHERE ow_wfjg_in.inwareid = :arg_inwareid
- 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_inwareid, 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_inwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "非审核状态下不可用"
- GOTO ext
- END IF
- UPDATE ow_wfjg_in
- SET dscrp = dscrp+' '+:arg_newdescppart
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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 c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- Long ll_moneyid_native
- DateTime null_dt
- SetNull(null_dt)
- IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_wfjg_sptprice_sec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_check_wfjgin = -1000 THEN
- rslt = 0
- arg_msg = '选项:[131]外协选质检后进仓,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_wfjg_th_ifnotorder = -1000 THEN
- rslt = 0
- arg_msg = '选项:[322]外协返工单限制不能选外协订单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_order_wfjg uo_wfjg
- uo_wfjg = Create uo_order_wfjg
- uo_wfjg.commit_transaction = commit_transaction
- uo_sptcheck uo_sptch
- uo_sptch = Create uo_sptcheck
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- IF inwareid = 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 balcflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经结存,不能撤审"
- GOTO ext
- END IF
- //检查外协商盘点表是否未审
- IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
- rslt = 0
- 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
- UPDATE ow_wfjg_in
- SET auditingrep = '',
- auditingdate = :null_dt,
- flag = 0
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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 billtype = 4 THEN
- IF p_destroy_inware( False, arg_msg ) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_option_wfjg_th_ifnotorder = 1 And thflag = 1 THEN
- IF p_destroy_wfjgorder( False, arg_msg ) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF billtype <> 6 THEN
- FOR i = 1 To it_mxbt_bef
- IF f_update_mtrlware_spt_in(billtype,&
- thflag,&
- scid,&
- inwaremx_bef[i].mtrlwareid,&
- inwaremx_bef[i].mtrlid,&
- inwaremx_bef[i].mtrlcode,&
- inwaremx_bef[i].plancode,&
- inwaremx_bef[i].status,&
- 0 - inwaremx_bef[i].qty,&
- inwaremx_bef[i].fprice,&
- sptid,&
- inwaremx_bef[i].woodcode,&
- inwaremx_bef[i].pcode,&
- arg_msg,False,commit_transaction) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt
- //更新合同完成数量
- IF inwaremx[i].relid > 0 THEN
- IF billtype = 9 THEN //盘亏单, 终止外协订单对应的收货明细
- IF uo_wfjg.StopAddQty(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].mtrlcode, 0 - inwaremx[i].qty, 0, '盘亏自动终止',arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF uo_wfjg.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,0 - inwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF uo_wfjg.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- //更新质检已进仓数
- IF uo_option_check_wfjgin = 1 And inwaremx[i].relbillid > 0 THEN
- IF uo_sptch.uof_add_inqty(inwaremx[i].relbillid,inwaremx[i].relbillprintid,0 - inwaremx[i].uqty,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF uo_option_wfjg_sptprice_sec = 0 THEN
- IF thflag = 0 And inwaremx[i].mxtype = 0 THEN
- IF uo_sptprice.uof_del_sptprice_auto(sptid,inwareid,inwaremx[i].printid,inwaremx[i].mtrlid,inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,inwaremx[i].jgdscrp,inwaremx[i].unit,ll_moneyid_native,False,arg_msg) = 0 THEN
- arg_msg = '更新行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- 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_sptch
- Destroy uo_wfjg
- Destroy uo_sptprice
- RETURN rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- it_mxbt_bef=0
- return 1
- end function
- public function integer p_getinfo (long arg_scid, long arg_inwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1
- IF arg_inwareid <= 0 THEN
- rslt = 0
- arG_MSG = "非法进仓单唯一码"
- GOTO ext
- END IF
- SELECT ow_wfjg_in.inwarecode,
- ow_wfjg_in.billtype,
- ow_wfjg_in.relid,
- ow_wfjg_in.storageid,
- ow_wfjg_in.indate,
- ow_wfjg_in.plandate,
- ow_wfjg_in.inrep,
- ow_wfjg_in.part,
- ow_wfjg_in.sptid,
- ow_wfjg_in.sptname,
- ow_wfjg_in.dscrp,
- ow_wfjg_in.thflag,
- ow_wfjg_in.secflag,
- ow_wfjg_in.dxflag,
- ow_wfjg_in.flag,
- ow_wfjg_in.balcflag,
- ow_wfjg_in.otheramt,
- ow_wfjg_in.relint_1,
- ow_wfjg_in.relint_2,
- ow_wfjg_in.relint_3,
- ow_wfjg_in.relstr_1,
- ow_wfjg_in.relstr_2,
- ow_wfjg_in.relstr_3,
- ow_wfjg_in.ctmint
- INTO :inwarecode,
- :billtype,
- :relid,
- :storageid,
- :indate,
- :plandate,
- :inrep,
- :part,
- :sptid,
- :sptname,
- :dscrp,
- :thflag,
- :secflag,
- :dxflag,
- :flag,
- :balcflag,
- :otheramt,
- :relint_1,
- :relint_2,
- :relint_3,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :ctmint
- FROM ow_wfjg_in
- WHERE ow_wfjg_in.inwareid = :arg_inwareid
- AND scid = :arg_scid
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败(错误进仓单唯一码),进仓单"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- inwareid = arg_inwareid
- scid = arg_scid
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid=0
- inwareid=0
- inwarecode=''
- billtype=0
- opemp=''
- modemp=''
- auditingrep=''
- secauditingrep = ''
- secflag = 0
- flag=0
- relid=0
- storageid=0
- inrep=''
- part=''
- dscrp=''
- sptid=0
- sptname=''
- Dxflag=0
- thflag=0
- otheramt=0
- relint_1=0
- relint_2=0
- relint_3=0
- relstr_1=''
- relstr_2=''
- relstr_3=''
- jgsum_amt = 0
- tax_amt = 0
- it_newbegin=false
- it_updatebegin=false
- //清除明细
- p_clearmx()
- return 1
- end function
- public function integer p_create_inware (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1,i
- Long rst_inwareid,o_scid
- Decimal ld_inprice
- datastore ds_wfjginware_mx
- ds_wfjginware_mx = Create datastore
- ds_wfjginware_mx.DataObject = "dw_wfjgmx_in_aft_edit"
- ds_wfjginware_mx.SetTransObject(sqlca)
- ds_wfjginware_mx.Retrieve(scid,inwareid,0)
- ds_wfjginware_mx.SetSort("ow_wfjgmx_in_aft_storageid A")
- ds_wfjginware_mx.Sort()
- IF uo_option_cost_notax = -1000 THEN
- rslt = 0
- arg_msg = '选项:[362]采购外协使用不含税价进仓,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- Long ls_rowcount,ll_storageid
- ls_rowcount = ds_wfjginware_mx.RowCount()
- IF ls_rowcount <> it_mxbt THEN
- rslt = 0
- arg_msg = "单据明细数量错误"
- GOTO ext
- END IF
- FOR i = 1 To it_mxbt
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = commit_transaction
- uo_in.if_getid_ture = False
-
- //2.原事务生成进仓单
- ll_storageid = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_storageid[i]
- SELECT scid INTO :o_scid
- FROM u_storage
- Where storageid = :ll_storageid Using commit_transaction;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询进仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.newbegin(scid,4,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- uo_in.relid = inwareid
- uo_in.relint_2 = relint_2
- uo_in.relint_1 = relint_1
- uo_in.sptid = sptid
- uo_in.inrep = inrep
- uo_in.indate = indate
- uo_in.part = inwarecode
- uo_in.dscrp = dscrp
- uo_in.storageid = ll_storageid
- uo_in.mrate = 1
- uo_in.thflag = thflag
-
- ld_inprice = 0
-
- DO While (ll_storageid = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_storageid[i])
-
- IF ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mxtype[i] = 2 THEN //维修
- ld_inprice = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_fprice[i] * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i]
- ELSE
- IF uo_option_cost_notax = 0 THEN
- ld_inprice = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_fprice[i] * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i] + ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_jgprice[i] * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rebate[i]
- ELSE
- ld_inprice = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_fprice[i] * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i] + ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_jgprice[i] / ( 1 + ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_taxrate[i]) * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rebate[i]
- END IF
- END IF
- //ds_wfjginware_mx.Object.printid[i]
- //u_inwaremx.printid 约定为等于外协单的ow_wfjgmx_in_aft.printid, 后面有函数这样默认调用
- IF uo_in.acceptmx(ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_printid[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mtrlid[i],&
- ds_wfjginware_mx.Object.u_mtrldef_mtrlcode[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_plancode[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_status[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uqty[i],&
- ld_inprice,&
- 1,&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mxdscrp[i],&
- arg_msg,&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uprice[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_relid[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_ifrel[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_woodcode[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_pcode[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_sptid_cusid[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_unit[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_qty[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_relprintid[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_checkqty[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_result[i],'',0,0,&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mtrlcuscode[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_location[i],&
- ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uqty[i],&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- i++
- IF i > it_mxbt THEN EXIT
- LOOP
-
- IF uo_in.Save(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- rst_inwareid = uo_in.inwareid
-
- //4.原事务审核进仓单
- IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.auditing(False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- Destroy uo_in
- i = i - 1
- NEXT
- ext:
- Destroy ds_wfjginware_mx
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_destroy_inware (boolean arg_ifcommit, ref string arg_msg);
- Long cnt = 0,i
- Int rslt = 1
- Long chc
- Long in_out
- //Long rst_outwareid[],out_i = 1 //出仓出仓id
- Long rst_inwareid[],in_i = 1 //出仓出仓id
- Long s_scid
- Long o_scid
- Long lay_storageid[],ll_storageid
- DateTime null_dt
- SetNull(null_dt)
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- IF inwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- Boolean lb_f = False
- Long j,k,ch
- //统计仓库数量,确定出或出仓单数
- FOR i = 1 To it_mxbt
- FOR j = 1 To UpperBound(lay_storageid)
- IF lay_storageid[j] = inwaremx[i].storageid THEN lb_f = True
- NEXT
- IF lb_f = False THEN
- ch++
- lay_storageid[ch] = inwaremx[i].storageid
- END IF
- lb_f = False
- NEXT
- IF UpperBound(lay_storageid) = 0 THEN
- rslt = 0
- arg_msg = '查询相关进仓单据失败'
- GOTO ext
- END IF
- //2.查询出仓单相关的入仓单,撤审,删除
- FOR k = 1 To UpperBound(lay_storageid)
-
- ll_storageid = lay_storageid[k]
-
- SELECT scid INTO :o_scid
- FROM u_storage
- Where storageid = :ll_storageid Using commit_transaction;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询仓库所属分部资料失败'
- rslt = 0
- GOTO ext
- END IF
-
- DECLARE cur_in_2 CURSOR FOR
- SELECT inwareid
- FROM u_inware
- WHERE scid = :o_scid
- AND relid = :inwareid
- AND storageid = :ll_storageid
- And billtype = 4 Using commit_transaction;
-
- OPEN cur_in_2;
- FETCH cur_in_2 Into :rst_inwareid[in_i];
- DO WHILE sqlca.SQLCode = 0
- in_i++
- FETCH cur_in_2 Into :rst_inwareid[in_i];
- LOOP
- in_i = in_i - 1
- CLOSE cur_in_2;
-
- IF in_i = 0 THEN
- arg_msg = '查询该外协单相关进仓单失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- FOR in_out = 1 To in_i
- //撤审出仓单,再删除
- IF uo_in.getinfo(o_scid,rst_inwareid[in_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(o_scid,rst_inwareid[in_out],arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- NEXT
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_in
- RETURN rslt
- end function
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- String ls_about,ls_dscrp
- IF uo_option_wfjg_sptprice_sec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_mustpay uo_pay
- uo_pay = Create uo_mustpay
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- Decimal ld_payamt = 0,ld_mstpayamt = 0,ld_taxamt = 0
- IF inwareid = 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
- Long ll_dft_itemid,ll_dft_itemid_tax
- decimal ld_jgprice_notax
- SELECT btype,accountsid INTO :li_btype,:ll_accountsid
- FROM cw_banktype
- Where banktypeid = :relint_1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- SELECT 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
- 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_in
- SET secauditingrep = :publ_operator,
- secauditingdate = getdate(),
- secflag = 1
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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
- FOR i = 1 To it_mxbt
- IF uo_option_wfjg_sptprice_sec = 1 THEN
- IF inwaremx[i].mxtype = 0 THEN //正常收货的才更新供应商单价
- ld_jgprice_notax = inwaremx[i].jgprice / ( 1 + inwaremx[i].taxrate)
- IF uo_sptprice.uof_update_sptprice(thflag,sptid,inwaremx[i].mtrlid,inwaremx[i].unit,inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,inwaremx[i].jgdscrp,inwareid,inwaremx[i].jgprice,inwaremx[i].rebate,inwaremx[i].rate,inwaremx[i].jgprice/inwaremx[i].rate,ld_jgprice_notax / inwaremx[i].rate ,indate,inwarecode,0,inwaremx[i].mxdscrp,inwaremx[i].printid,1,ll_moneyid_native,indate,datetime(9999-01-01),False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- NEXT
- IF jgsum_amt <> 0 THEN
-
- ld_mstpayamt = jgsum_amt - otheramt
- ld_taxamt = tax_amt
-
- IF li_btype = 1 THEN
- ld_payamt = ld_mstpayamt
- ELSE
- ld_payamt = 0
- END IF
-
-
- IF thflag = 1 THEN
- ls_about = inwarecode + "退货款,相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid
- FROM u_itemdef
- Where dfttype = 5 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认采购外协付款项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- ls_about = inwarecode + "应付款,相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid
- FROM u_itemdef
- Where dfttype = 2 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认采购外协退货项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- ls_dscrp = ls_about
-
- s_bmstpay s_pay
- s_pay.scid = scid
- s_pay.sptid = sptid
- s_pay.paydate = indate
- s_pay.inrep = inrep
- s_pay.oriamt = ld_mstpayamt
- s_pay.mstpayamt = ld_mstpayamt
- s_pay.payamt = ld_payamt
- s_pay.payamt_cn = ld_payamt
- s_pay.dscrp = ls_about
- s_pay.billcode = inwarecode
- s_pay.relcode = part
- s_pay.banktypeid = relint_1
- s_pay.viewdate = plandate
- s_pay.opemp = publ_operator
- s_pay.buildtype = 1
- s_pay.inwareid = inwareid
- 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
-
- IF ld_taxamt <> 0 THEN
- ls_about = inwarecode + "税金,相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid_tax
- FROM u_itemdef
- Where dfttype = 13 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认采购外协税金项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- s_bmstpaymx s_paymx_tax
- s_paymx_tax.scid = scid
- s_paymx_tax.payid = uo_pay.ref_payid
- s_paymx_tax.sptid = sptid
- s_paymx_tax.paydate = indate
- s_paymx_tax.inrep = inrep
- s_paymx_tax.mstpayamt = ld_taxamt
- s_paymx_tax.payamt = 0
- s_paymx_tax.dscrp = ls_about
- s_paymx_tax.billcode = inwarecode
- s_paymx_tax.relcode = part
- s_paymx_tax.banktypeid = relint_1
- s_paymx_tax.opemp = publ_operator
- s_paymx_tax.buildtype = 3
- s_paymx_tax.inwareid = inwareid
- s_paymx_tax.itemid = ll_dft_itemid_tax
- s_paymx_tax.moneyid = ll_moneyid_native
-
- IF uo_pay.add_payrecmx (s_paymx_tax,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- UPDATE ow_wfjg_in
- SET relint_2 = :uo_pay.ref_payid
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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
- Destroy uo_sptprice
- 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
- Long ll_moneyid_native
- IF uo_option_wfjg_sptprice_sec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_mustpay uo_pay
- uo_pay = Create uo_mustpay
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- String ls_mtrlname
- SetNull(null_dt)
- IF inwareid = 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
- 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
- UPDATE ow_wfjg_in
- SET secauditingrep = '',
- secauditingdate = :null_dt,
- secflag = 0,relint_3 = 0
- WHERE ow_wfjg_in.inwareid = :inwareid
- 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
- FOR i = 1 To it_mxbt
- IF uo_option_wfjg_sptprice_sec = 1 THEN
- IF thflag = 0 And inwaremx[i].mxtype = 0 THEN
- IF uo_sptprice.uof_del_sptprice_auto(sptid,inwareid,inwaremx[i].printid,inwaremx[i].mtrlid,inwaremx[i].status,inwaremx[i].woodcode,inwaremx[i].pcode,inwaremx[i].jgdscrp,inwaremx[i].unit,ll_moneyid_native,False,arg_msg) = 0 THEN
- arg_msg = '更新行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- NEXT
- IF jgsum_amt <> 0 THEN
- IF uo_pay.del_payrec(scid,1,relint_2,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
- Destroy uo_sptprice
- RETURN rslt
- end function
- 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 = 5 OR &
- arg_billtype = 6 OR &
- arg_billtype = 9) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'4-仓库外协收货单,'
- arg_msg = arg_msg+'5-车间外协收货单,'
- arg_msg = arg_msg+'6-加工计费单,'
- arg_msg = arg_msg+'9-外协商盘亏单'
- GOTO ext
- END IF
- p_reset()
- scid = arg_scid
- billtype = arg_billtype
- 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_inwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_inwareid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF Not (arg_billtype = 4 OR &
- arg_billtype = 5 OR &
- arg_billtype = 6 OR &
- arg_billtype = 9) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'4-仓库外协收货单,'
- arg_msg = arg_msg+'5-车间外协收货单,'
- arg_msg = arg_msg+'6-加工计费单,'
- arg_msg = arg_msg+'9-外协商盘亏单'
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- inwareid = arg_inwareid
- scid = arg_scid
- billtype = arg_billtype
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, long arg_printid, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_cost
- SELECT cost INTO :ld_cost
- FROM ow_wfjgware
- WHERE sptid = :sptid
- AND mtrlwareid = :arg_mtrlwareid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- UPDATE ow_wfjgmx_in_bef
- SET fprice = :ld_cost
- WHERE scid = :scid
- AND inwareid = :inwareid
- AND printid = :arg_printid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '更新'+arg_mtrlcode+'成本价失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- arg_ref_cost = ld_cost
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer acceptmx (long arg_printid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_uqty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, ref string arg_msg, decimal arg_jgprice, long arg_relid, integer arg_ifrel, string arg_woodcode, string arg_pcode, long arg_cusid_sptid, string arg_unit, decimal arg_rate, decimal arg_qty, long arg_storageid, string arg_jgdscrp, long arg_relprintid, integer arg_mxtype, decimal arg_checkqty, string arg_result, long arg_relbillid, long arg_relbillprintid, string arg_mtrlcuscode, string arg_location, decimal arg_taxrate);s_wfjgmx_in_aft s_mx
- s_mx.printid = arg_printid
- s_mx.mtrlid = arg_mtrlid
- s_mx.mtrlcode = arg_mtrlcode
- s_mx.plancode = arg_plancode
- s_mx.status = arg_status
- s_mx.uqty = arg_uqty
- s_mx.fprice = arg_fprice
- s_mx.rebate = arg_rebate
- s_mx.mxdscrp = arg_mxdscrp
- s_mx.jgprice = arg_jgprice
- s_mx.relid = arg_relid
- s_mx.ifrel = arg_ifrel
- s_mx.woodcode = arg_woodcode
- s_mx.pcode = arg_pcode
- s_mx.sptid = arg_cusid_sptid
- s_mx.unit = arg_unit
- s_mx.rate = arg_rate
- s_mx.qty = arg_qty
- s_mx.storageid = arg_storageid
- s_mx.jgdscrp = arg_jgdscrp
- s_mx.relprintid = arg_relprintid
- s_mx.mxtype = arg_mxtype
- s_mx.checkqty = arg_checkqty
- s_mx.result = arg_result
- s_mx.relbillid = arg_relbillid
- s_mx.relbillprintid = arg_relbillprintid
- s_mx.mtrlcuscode = arg_mtrlcuscode
- s_mx.location = arg_location
- s_mx.taxrate = arg_taxrate
- return acceptmx(s_mx, arg_msg)
- /*
- Long rslt = 1,cnt = 0,ls_i
- Decimal ld_planprice,ld_cost
- Decimal ld_noauditqty,ld_bootqty
- String ls_relcode
- Decimal lde_mx_qty
- Decimal lde_orderqty
- Long ll_moneyid_native
- string ls_unit
- IF uo_option_wfjg_zero = -1000 THEN
- rslt = 0
- arg_msg = '选项:[184]外协收货单允许保存零数量,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_2unit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_status = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_woodcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_pcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_ifovertask = -1000 THEN
- rslt = 0
- arg_msg = '选项:[010]超采购,外协订单收货,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- 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_mtrlcode) THEN arg_mtrlcode = ''
- IF IsNull(arg_plancode) THEN arg_plancode = ''
- IF IsNull(arg_status) THEN arg_status = ''
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_relid) THEN arg_relid = 0
- IF IsNull(arg_ifrel) THEN arg_ifrel = 0
- IF IsNull(arg_mxdscrp) THEN arg_woodcode = ''
- IF IsNull(arg_pcode) THEN arg_pcode = ''
- IF IsNull(arg_cusid_sptid) THEN arg_cusid_sptid = 0
- IF IsNull(arg_storageid) THEN arg_storageid = 0
- IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = ''
- IF IsNull(arg_unit) THEN arg_unit = ''
- IF IsNull(arg_jgprice) THEN arg_jgprice = 0
- IF IsNull(arg_uqty) THEN arg_uqty = 0
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_rebate) THEN arg_rebate = 0
- IF IsNull(arg_fprice) THEN arg_fprice = 0
- IF IsNull(arg_mxtype) THEN arg_mxtype = 0
- IF IsNull(arg_checkqty) THEN arg_checkqty = 0
- IF IsNull(arg_result) THEN arg_result = ''
- IF IsNull(arg_rate) THEN arg_rate = 1
- IF arg_rate = 0 THEN arg_rate = 1
- IF IsNull(arg_mtrlcuscode) THEN arg_mtrlcuscode = ''
- IF IsNull(arg_location) THEN arg_location = ''
- IF IsNull(arg_relbillid) THEN arg_relbillid = 0
- IF IsNull(arg_relbillprintid) THEN arg_relbillprintid = 0
- IF IsNull(arg_taxrate) THEN arg_taxrate = 0
- IF arg_mtrlid = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF uo_option_wfjg_zero = 0 THEN
- If ( arg_uqty = 0 And arg_qty = 0 ) THEN
- rslt = 1
- GOTO ext
- END IF
-
- IF arg_checkqty = 0 THEN arg_checkqty = arg_uqty
-
- IF arg_qty = 0 THEN
- arg_msg = '行:'+String(arg_printid)+ ',请输入数量'
- rslt = 0
- 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_unit) = '' THEN
- arg_msg = '行:'+String(arg_printid)+ ',请输入计价单位'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF arg_rebate <= 0 THEN
- arg_msg = '折扣错误,请检查'
- rslt = 0
- GOTO ext
- END IF
- if arg_taxrate < 0 then
- arg_msg = '税率错误,请检查'
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 4 THEN
- cnt = 0
- //检查仓库
- SELECT count(*)
- INTO :cnt
- FROM u_storage
- Where u_storage.storageid = :arg_storageid 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 = "错误的仓库编号: "+String(arg_storageid)
- GOTO ext
- END IF
-
- String ls_storagename
- SELECT storagename
- INTO :ls_storagename
- FROM u_storage
- Where storageid = :arg_storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
-
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_new <> '0' THEN
- IF Pos(sys_user_storagestr_new,','+String(arg_storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
- GOTO ext
- END IF
- END IF //
-
- END IF
- IF f_check_status(1,arg_status) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_status+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_status
- GOTO ext
- END IF
- IF f_check_status(2,arg_woodcode) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_woodcode+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_woodcode
- GOTO ext
- END IF
- IF f_check_status(3,arg_pcode) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_pcode+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_pcode
- GOTO ext
- END IF
- //检查物料id
- SELECT planprice
- INTO :ld_planprice
- FROM u_mtrldef
- Where u_mtrldef.mtrlid = :arg_mtrlid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,物料或产品编号:"+arg_mtrlcode
- GOTO ext
- END IF
- Int li_iflimitprice
- SELECT iflimitprice,unit INTO :li_iflimitprice,:ls_unit
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+arg_mtrlcode+'限价属性失败 '+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ls_unit = trim(ls_unit)
- 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 billtype = 5 Or billtype = 4 THEN
- IF li_iflimitprice = 1 THEN
- IF uo_sptprice.uof_check_price(thflag,sptid,arg_mtrlid,arg_mtrlcode,arg_unit,arg_status,arg_woodcode,arg_pcode,arg_jgdscrp,ll_moneyid_native,arg_jgprice,indate,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF arg_ifrel > 0 THEN
- IF arg_relid = 0 THEN
- arg_msg = '请先择相应的加工计划'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_order_wfjg.taskcode ,sum(u_order_wfjgmx.qty - u_order_wfjgmx.consignedqty),sum(u_order_wfjgmx.qty)
- INTO :ls_relcode,:ld_bootqty,:lde_orderqty
- FROM u_order_wfjgmx,u_order_wfjg
- WHERE u_order_wfjgmx.wfjgid = :arg_relid
- AND u_order_wfjgmx.scid = :scid
- AND u_order_wfjgmx.printid = :arg_relprintid
- AND u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid
- AND u_order_wfjgmx.scid = u_order_wfjg.scid
- GROUP BY u_order_wfjg.taskcode
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询外协计划是否有加工产品:'+arg_mtrlcode+'失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- lde_mx_qty = 0
- FOR ls_i = 1 To it_mxbt
- IF arg_mtrlid = inwaremx[ls_i].mtrlid And &
- arg_relid = inwaremx[ls_i].relid And &
- arg_relprintid = inwaremx[ls_i].relprintid THEN
- lde_mx_qty = lde_mx_qty + inwaremx[ls_i].qty
- END IF
- NEXT
- lde_mx_qty = lde_mx_qty + arg_qty
-
- SELECT isnull(sum(ow_wfjgmx_in_aft.qty),0) INTO :ld_noauditqty
- FROM ow_wfjgmx_in_aft,ow_wfjg_in
- WHERE ow_wfjgmx_in_aft.relid = :arg_relid
- AND ow_wfjgmx_in_aft.scid = :scid
- AND ow_wfjgmx_in_aft.relprintid = :arg_relprintid
- AND ow_wfjgmx_in_aft.inwareid = ow_wfjg_in.inwareid
- AND ow_wfjgmx_in_aft.scid = ow_wfjg_in.scid
- AND ow_wfjg_in.inwareid <> :inwareid
- AND ow_wfjg_in.flag = 0
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+arg_mtrlcode+'相关外协订单已开单数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- Decimal ld_uprate,ld_upqty
- IF uo_option_ifovertask = 1 THEN //不允许超收
-
- IF lde_mx_qty + ld_noauditqty > ld_bootqty THEN
- arg_msg = '物料:'+arg_mtrlcode+'未完成数:'+String(ld_bootqty,'#,##0.0###')+ls_unit+',已开单未审核数:'+String(ld_noauditqty,'#,##0.0###')+ls_unit+',不能收货:'+String(lde_mx_qty,'#,##0.0###')+ls_unit
- rslt = 0
- GOTO ext
- END IF
-
- ELSEIF uo_option_ifovertask = 3 THEN //允许超收但按比例限制
- SELECT uprate , upqty
- INTO :ld_uprate,:ld_upqty
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+Trim(arg_mtrlcode)+'超收货比例失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF lde_mx_qty + ld_noauditqty > ld_bootqty + lde_orderqty * ld_uprate + ld_upqty THEN
- arg_msg = '物料:'+arg_mtrlcode+'未完成数:'+String(ld_bootqty,'#,##0.0###')+ls_unit+',已开单未审核数:'+String(ld_noauditqty,'#,##0.0###')+ls_unit+',允许超收数量:'+String(lde_orderqty * ld_uprate + ld_upqty,'#,##0.0###')+ls_unit+',不能收货:'+String(lde_mx_qty,'#,##0.0###')+ls_unit
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF arg_fprice * arg_rebate < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "物料或产品:" + String(arg_mtrlcode)+",进仓成本价错误"
- GOTO ext
- END IF
- String ls_relbillcode
- ls_relbillcode = ''
- IF arg_relbillid > 0 THEN
- SELECT billcode
- INTO :ls_relbillcode
- FROM u_sptcheck
- Where billid = :arg_relbillid;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询质检单号失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- //写入内容
- it_mxbt++
- inwaremx[it_mxbt].noauditqty = ld_noauditqty
- inwaremx[it_mxbt].printid = arg_printid
- inwaremx[it_mxbt].mtrlid = arg_mtrlid
- inwaremx[it_mxbt].mtrlcode = arg_mtrlcode
- inwaremx[it_mxbt].storageid = arg_storageid
- inwaremx[it_mxbt].jgdscrp = arg_jgdscrp
- inwaremx[it_mxbt].plancode = arg_plancode
- inwaremx[it_mxbt].bootqty = ld_bootqty
- inwaremx[it_mxbt].status = arg_status
- inwaremx[it_mxbt].planprice = ld_planprice
- inwaremx[it_mxbt].mxdscrp = arg_mxdscrp
- inwaremx[it_mxbt].dxflag = dxflag
- inwaremx[it_mxbt].relid = arg_relid
- inwaremx[it_mxbt].ifrel = arg_ifrel
- inwaremx[it_mxbt].woodcode = arg_woodcode
- inwaremx[it_mxbt].pcode = arg_pcode
- inwaremx[it_mxbt].mtrlcuscode = arg_mtrlcuscode
- inwaremx[it_mxbt].Location = arg_location
- inwaremx[it_mxbt].relcode = ls_relcode
- inwaremx[it_mxbt].relprintid = arg_relprintid
- inwaremx[it_mxbt].checkqty = arg_checkqty
- inwaremx[it_mxbt].result = arg_result
- inwaremx[it_mxbt].relbillid = arg_relbillid
- inwaremx[it_mxbt].relbillprintid = arg_relbillprintid
- inwaremx[it_mxbt].relbillcode = ls_relbillcode
- IF dxflag = 0 THEN
- inwaremx[it_mxbt].sptid = arg_cusid_sptid
- ELSE
- inwaremx[it_mxbt].sptid = sptid
- END IF
- inwaremx[it_mxbt].unit = arg_unit
- IF uo_option_2unit = 0 THEN
- arg_uqty = arg_qty
- END IF
- inwaremx[it_mxbt].uqty = arg_uqty
- inwaremx[it_mxbt].jgprice = arg_jgprice
- inwaremx[it_mxbt].rebate = arg_rebate
- IF arg_qty <> 0 THEN
- inwaremx[it_mxbt].uprice = Round(arg_jgprice * arg_uqty/arg_qty,5)
- ELSE
- inwaremx[it_mxbt].uprice = 0
- END IF
- IF arg_uqty <> 0 THEN
- inwaremx[it_mxbt].rate = arg_qty/arg_uqty
- ELSE
- inwaremx[it_mxbt].rate = 0
- END IF
- inwaremx[it_mxbt].qty = arg_qty
- inwaremx[it_mxbt].fprice = arg_fprice
- inwaremx[it_mxbt].price = inwaremx[it_mxbt].uprice * arg_rebate + arg_fprice
- inwaremx[it_mxbt].mxtype = arg_mxtype
- inwaremx[it_mxbt].taxrate = arg_taxrate
- IF billtype = 1 THEN
- String ls_sptmtrlname
- uo_spt_price uo_price
- uo_price = Create uo_spt_price
- IF uo_price.uof_getmtrlname(sptid,arg_mtrlid,ls_sptmtrlname,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- Destroy uo_price
- inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname
- END IF
- IF thflag = 1 THEN
- SELECT cost
- INTO :ld_cost
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlid = :arg_mtrlid
- AND status = :arg_status
- AND plancode = :arg_plancode
- AND woodcode = :arg_woodcode
- AND pcode = :arg_pcode
- AND mtrlcuscode = :arg_mtrlcuscode
- AND location = :arg_location
- AND storageid = :arg_storageid
- AND dxflag = :dxflag
- And sptid = 0;
- IF sqlca.SQLCode <> 0 Or IsNull(ld_cost) THEN ld_cost = 0
- inwaremx[it_mxbt].cost = ld_cost
- ELSE
- inwaremx[it_mxbt].cost = (inwaremx[it_mxbt].uprice * arg_rebate) + inwaremx[it_mxbt].fprice
- END IF
- ext:
- Destroy uo_sptprice
- IF rslt = 0 THEN p_clearmx()
- Return(rslt)
- */
- end function
- public function integer acceptmx_bef (long arg_mtrlwareid, decimal arg_qty, string arg_mxdscrp, long arg_printid, string arg_unit, decimal arg_uqty, decimal arg_rate, long arg_relprintid, ref string arg_msg);s_wfjgmx_in_bef s_mx
- s_mx.mtrlwareid = arg_mtrlwareid
- s_mx.qty = arg_qty
- s_mx.mxdscrp = arg_mxdscrp
- s_mx.printid = arg_printid
- s_mx.unit = arg_unit
- s_mx.uqty = arg_uqty
- s_mx.rate = arg_rate
- s_mx.relprintid = arg_relprintid
- return acceptmx_bef(s_mx, arg_msg)
- /*
- Long rslt = 1,cnt = 0,LS_i
- Long i_mtrlid,i_sptid
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- Double i_cost,i_newprice
- Decimal i_allouseqty
- String ls_relcode
- Decimal ld_rate = 1
- 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_unit) THEN arg_unit = ''
- IF IsNull(arg_uqty) THEN arg_uqty = 0
- IF IsNull(arg_rate) THEN arg_rate = 0
- IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- IF arg_mtrlwareid = 0 OR arg_qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- SELECT ow_wfjgware.mtrlid,
- ow_wfjgware.sptid,
- ow_wfjgware.plancode,
- ow_wfjgware.status,
- ow_wfjgware.cost,
- u_mtrldef.mtrlcode,
- ow_wfjgware.woodcode,
- ow_wfjgware.pcode,
- ow_wfjgware.noallocqty
- INTO :i_mtrlid,
- :i_sptid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_mtrlcode,
- :i_woodcode,
- :i_pcode,
- :i_allouseqty
- FROM ow_wfjgware ,u_mtrldef
- WHERE ( ow_wfjgware.mtrlwareid = :arg_mtrlwareid )
- AND ( ow_wfjgware.mtrlid = u_mtrldef.mtrlid )
- USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,库存编号错误"
- 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_sptid) THEN i_sptid = 0
- IF IsNull(i_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- IF sptid <> i_sptid THEN
- arg_msg = "物料:" + String(i_mtrlcode) + '所属加工商资料不对应'
- rslt = 0
- GOTO ext
- END IF
- IF i_cost < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "物料:" + String(i_mtrlcode)+" 单价错误"
- GOTO ext
- END IF
- //写入内容
- it_mxbt_bef++
- inwaremx_bef[it_mxbt_bef].mtrlwareid = arg_mtrlwareid
- inwaremx_bef[it_mxbt_bef].mtrlid = i_mtrlid
- inwaremx_bef[it_mxbt_bef].status = i_status
- inwaremx_bef[it_mxbt_bef].qty = arg_qty
- inwaremx_bef[it_mxbt_bef].sptid = i_sptid
- inwaremx_bef[it_mxbt_bef].plancode = i_plancode
- inwaremx_bef[it_mxbt_bef].mtrlcode = i_mtrlcode
- inwaremx_bef[it_mxbt_bef].mxdscrp = arg_mxdscrp
- inwaremx_bef[it_mxbt_bef].printid = arg_printid
- inwaremx_bef[it_mxbt_bef].fprice = i_cost
- inwaremx_bef[it_mxbt_bef].woodcode = i_woodcode
- inwaremx_bef[it_mxbt_bef].pcode = i_pcode
- inwaremx_bef[it_mxbt_bef].unit = arg_unit
- inwaremx_bef[it_mxbt_bef].uqty = arg_uqty
- inwaremx_bef[it_mxbt_bef].relprintid = arg_relprintid
- IF arg_uqty <> 0 THEN
- inwaremx_bef[it_mxbt_bef].rate = arg_qty / arg_uqty
- ELSE
- inwaremx_bef[it_mxbt_bef].rate = 0
- END IF
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- */
- end function
- public function integer acceptmx (s_wfjgmx_in_aft s_mx, ref string arg_msg);
- Long rslt = 1,cnt = 0,ls_i
- Decimal ld_planprice,ld_cost
- Decimal ld_noauditqty,ld_bootqty
- String ls_relcode
- Decimal lde_mx_qty
- Decimal lde_orderqty
- Long ll_moneyid_native
- String ls_unit
- IF uo_option_wfjg_zero = -1000 THEN
- rslt = 0
- arg_msg = '选项:[184]外协收货单允许保存零数量,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_2unit = -1000 THEN
- rslt = 0
- arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_status = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_woodcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_pcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_ifovertask = -1000 THEN
- rslt = 0
- arg_msg = '选项:[010]超采购,外协订单收货,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(s_mx.printid) THEN s_mx.printid = 0
- IF IsNull(s_mx.mtrlid) THEN s_mx.mtrlid = 0
- IF IsNull(s_mx.mtrlcode) THEN s_mx.mtrlcode = ''
- IF IsNull(s_mx.plancode) THEN s_mx.plancode = ''
- IF IsNull(s_mx.status) THEN s_mx.status = ''
- IF IsNull(s_mx.mxdscrp) THEN s_mx.mxdscrp = ''
- IF IsNull(s_mx.relid) THEN s_mx.relid = 0
- IF IsNull(s_mx.ifrel) THEN s_mx.ifrel = 0
- IF IsNull(s_mx.mxdscrp) THEN s_mx.woodcode = ''
- IF IsNull(s_mx.pcode) THEN s_mx.pcode = ''
- IF IsNull(s_mx.sptid) THEN s_mx.sptid = 0
- IF IsNull(s_mx.storageid) THEN s_mx.storageid = 0
- IF IsNull(s_mx.relprintid) THEN s_mx.relprintid = 0
- IF IsNull(s_mx.jgdscrp) THEN s_mx.jgdscrp = ''
- IF IsNull(s_mx.unit) THEN s_mx.unit = ''
- IF IsNull(s_mx.jgprice) THEN s_mx.jgprice = 0
- IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
- IF IsNull(s_mx.qty) THEN s_mx.qty = 0
- IF IsNull(s_mx.rebate) THEN s_mx.rebate = 1
- IF IsNull(s_mx.fprice) THEN s_mx.fprice = 0
- IF IsNull(s_mx.mxtype) THEN s_mx.mxtype = 0
- IF IsNull(s_mx.checkqty) THEN s_mx.checkqty = 0
- IF IsNull(s_mx.result) THEN s_mx.result = ''
- IF IsNull(s_mx.rate) THEN s_mx.rate = 1
- IF s_mx.rate = 0 THEN s_mx.rate = 1
- IF IsNull(s_mx.mtrlcuscode) THEN s_mx.mtrlcuscode = ''
- IF IsNull(s_mx.Location) THEN s_mx.Location = ''
- IF IsNull(s_mx.relbillid) THEN s_mx.relbillid = 0
- IF IsNull(s_mx.relbillprintid) THEN s_mx.relbillprintid = 0
- IF IsNull(s_mx.taxrate) THEN s_mx.taxrate = 0
- IF s_mx.mtrlid = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF uo_option_wfjg_zero = 0 THEN
- If ( s_mx.uqty = 0 And s_mx.qty = 0 ) THEN
- rslt = 1
- GOTO ext
- END IF
-
- IF s_mx.checkqty = 0 THEN s_mx.checkqty = s_mx.uqty
-
- IF s_mx.qty = 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+ ',请输入数量'
- rslt = 0
- 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.unit) = '' THEN
- arg_msg = '行:'+String(s_mx.printid)+ ',请输入计价单位'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF s_mx.rebate <= 0 Or s_mx.rebate > 1 THEN
- arg_msg = '行:'+String(s_mx.printid)+',折扣错误,只能取范围(0, 1]'
- rslt = 0
- GOTO ext
- END IF
- IF s_mx.taxrate < 0 THEN
- arg_msg = '税率错误,请检查'
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 4 THEN
- // cnt = 0
- // //检查仓库
- // SELECT count(*)
- // INTO :cnt
- // FROM u_storage
- // WHERE u_storage.storageid = :s_mx.storageid
- // 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 = "错误的仓库编号: "+String(s_mx.storageid)
- // GOTO ext
- // END IF
-
- String ls_storagename
- Int li_if_cus_mtrlware
- SELECT storagename,noallocflag
- INTO :ls_storagename,:li_if_cus_mtrlware
- FROM u_storage
- Where storageid = :s_mx.storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库编号: "+String(s_mx.storageid)
- GOTO ext
- END IF
-
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_new <> '0' THEN
- IF Pos(sys_user_storagestr_new,','+String(s_mx.storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
- GOTO ext
- END IF
- END IF //
-
- //检查库存数是否足够
- Decimal lde_noallocqty
- IF li_if_cus_mtrlware = 1 THEN
- If thflag = 1 THEN
- SELECT sum(noallocqty)
- INTO :lde_noallocqty
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlid = :s_mx.mtrlid
- AND storageid = :s_mx.storageid
- AND plancode = :s_mx.plancode
- AND status = :s_mx.status
- AND woodcode = :s_mx.woodcode
- AND pcode = :s_mx.pcode
- AND dxflag = 0
- AND sptid = :s_mx.sptid
- AND mtrlcuscode = :s_mx.mtrlcuscode
- And Location = :s_mx.Location Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
-
- If (Abs(s_mx.qty) > lde_noallocqty ) THEN
- rslt = 0
- arg_msg = '行:'+String(s_mx.printid)+"物料:" + s_mx.mtrlcode+' 库存数量:'+String(lde_noallocqty,'#,##0.##########')+'少于本次返工数量:'+String(Abs(s_mx.qty),'#,##0.##########')
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- IF f_check_status(1,s_mx.status) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_status+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.status
- GOTO ext
- END IF
- IF f_check_status(2,s_mx.woodcode) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_woodcode+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.woodcode
- GOTO ext
- END IF
- IF f_check_status(3,s_mx.pcode) = 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,可能"+uo_option_change_pcode+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.pcode
- GOTO ext
- END IF
- //检查物料id
- SELECT planprice
- INTO :ld_planprice
- FROM u_mtrldef
- Where u_mtrldef.mtrlid = :s_mx.mtrlid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,物料或产品编号:"+s_mx.mtrlcode
- GOTO ext
- END IF
- Int li_iflimitprice
- SELECT iflimitprice,unit INTO :li_iflimitprice,:ls_unit
- FROM u_mtrldef
- Where mtrlid = :s_mx.mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+s_mx.mtrlcode+'限价属性失败 '+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ls_unit = Trim(ls_unit)
- 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 billtype = 5 Or billtype = 4 THEN
- IF li_iflimitprice = 1 THEN
- IF uo_sptprice.uof_check_price(thflag,sptid,s_mx.mtrlid,s_mx.mtrlcode,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.jgdscrp,ll_moneyid_native,s_mx.jgprice,indate,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF s_mx.ifrel > 0 THEN
- IF s_mx.relid = 0 THEN
- arg_msg = '行:'+String(s_mx.printid)+ ',请先择相应的外协订单'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_order_wfjg.taskcode ,sum(u_order_wfjgmx.qty - u_order_wfjgmx.consignedqty),sum(u_order_wfjgmx.qty)
- INTO :ls_relcode,:ld_bootqty,:lde_orderqty
- FROM u_order_wfjgmx,u_order_wfjg
- WHERE u_order_wfjgmx.wfjgid = :s_mx.relid
- AND u_order_wfjgmx.scid = :scid
- AND u_order_wfjgmx.printid = :s_mx.relprintid
- AND u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid
- AND u_order_wfjgmx.scid = u_order_wfjg.scid
- GROUP BY u_order_wfjg.taskcode
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询外协订单是否有加工产品:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- lde_mx_qty = 0
- FOR ls_i = 1 To it_mxbt
- IF s_mx.mtrlid = inwaremx[ls_i].mtrlid And &
- s_mx.relid = inwaremx[ls_i].relid And &
- s_mx.relprintid = inwaremx[ls_i].relprintid THEN
- lde_mx_qty = lde_mx_qty + inwaremx[ls_i].qty
- END IF
- NEXT
- lde_mx_qty = lde_mx_qty + s_mx.qty
-
- SELECT isnull(sum(ow_wfjgmx_in_aft.qty),0) INTO :ld_noauditqty
- FROM ow_wfjgmx_in_aft,ow_wfjg_in
- WHERE ow_wfjgmx_in_aft.relid = :s_mx.relid
- AND ow_wfjgmx_in_aft.scid = :scid
- AND ow_wfjgmx_in_aft.relprintid = :s_mx.relprintid
- AND ow_wfjgmx_in_aft.inwareid = ow_wfjg_in.inwareid
- AND ow_wfjgmx_in_aft.scid = ow_wfjg_in.scid
- AND ow_wfjg_in.inwareid <> :inwareid
- AND ow_wfjg_in.flag = 0
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+s_mx.mtrlcode+'相关外协订单已开单数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- Decimal ld_uprate,ld_upqty
- IF uo_option_ifovertask = 1 THEN //不允许超收
-
- IF lde_mx_qty + ld_noauditqty > ld_bootqty THEN
- arg_msg = '物料:'+s_mx.mtrlcode+'未完成数:'+String(ld_bootqty,'#,##0.0###')+ls_unit+',已开单未审核数:'+String(ld_noauditqty,'#,##0.0###')+ls_unit+',不能收货:'+String(lde_mx_qty,'#,##0.0###')+ls_unit
- rslt = 0
- GOTO ext
- END IF
-
- ELSEIF uo_option_ifovertask = 3 THEN //允许超收但按比例限制
- SELECT uprate , upqty
- INTO :ld_uprate,:ld_upqty
- FROM u_mtrldef
- Where mtrlid = :s_mx.mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询物料:'+Trim(s_mx.mtrlcode)+'超收货比例失败,'+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF lde_mx_qty + ld_noauditqty > ld_bootqty + lde_orderqty * ld_uprate + ld_upqty THEN
- arg_msg = '物料:'+s_mx.mtrlcode+'未完成数:'+String(ld_bootqty,'#,##0.0###')+ls_unit+',已开单未审核数:'+String(ld_noauditqty,'#,##0.0###')+ls_unit+',允许超收数量:'+String(lde_orderqty * ld_uprate + ld_upqty,'#,##0.0###')+ls_unit+',不能收货:'+String(lde_mx_qty,'#,##0.0###')+ls_unit
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- IF s_mx.fprice * s_mx.rebate < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "物料或产品:" + String(s_mx.mtrlcode)+",进仓成本价错误"
- GOTO ext
- END IF
- String ls_relbillcode
- ls_relbillcode = ''
- IF s_mx.relbillid > 0 THEN
- SELECT billcode
- INTO :ls_relbillcode
- FROM u_sptcheck
- Where billid = :s_mx.relbillid;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询质检单号失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- //写入内容
- it_mxbt++
- inwaremx[it_mxbt].printid = s_mx.printid
- inwaremx[it_mxbt].noauditqty = ld_noauditqty
- inwaremx[it_mxbt].mtrlid = s_mx.mtrlid
- inwaremx[it_mxbt].mtrlcode = s_mx.mtrlcode
- inwaremx[it_mxbt].jgdscrp = s_mx.jgdscrp
- inwaremx[it_mxbt].status = s_mx.status
- inwaremx[it_mxbt].woodcode = s_mx.woodcode
- inwaremx[it_mxbt].pcode = s_mx.pcode
- inwaremx[it_mxbt].storageid = s_mx.storageid
- inwaremx[it_mxbt].dxflag = dxflag
- inwaremx[it_mxbt].mtrlcuscode = s_mx.mtrlcuscode
- inwaremx[it_mxbt].Location = s_mx.Location
- inwaremx[it_mxbt].plancode = s_mx.plancode
- IF dxflag = 0 THEN
- inwaremx[it_mxbt].sptid = s_mx.sptid
- ELSE
- inwaremx[it_mxbt].sptid = sptid
- END IF
- inwaremx[it_mxbt].bootqty = ld_bootqty
- inwaremx[it_mxbt].planprice = ld_planprice
- inwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
- inwaremx[it_mxbt].ifrel = s_mx.ifrel
- inwaremx[it_mxbt].relid = s_mx.relid
- inwaremx[it_mxbt].relprintid = s_mx.relprintid
- inwaremx[it_mxbt].relcode = ls_relcode
- inwaremx[it_mxbt].checkqty = s_mx.checkqty
- inwaremx[it_mxbt].result = s_mx.result
- inwaremx[it_mxbt].relbillid = s_mx.relbillid
- inwaremx[it_mxbt].relbillprintid = s_mx.relbillprintid
- inwaremx[it_mxbt].relbillcode = ls_relbillcode
- inwaremx[it_mxbt].unit = s_mx.unit
- IF uo_option_2unit = 0 THEN
- s_mx.uqty = s_mx.qty
- END IF
- inwaremx[it_mxbt].uqty = s_mx.uqty
- IF s_mx.uqty <> 0 THEN
- inwaremx[it_mxbt].rate = s_mx.qty/s_mx.uqty
- ELSE
- inwaremx[it_mxbt].rate = 0
- END IF
- inwaremx[it_mxbt].qty = s_mx.qty
- inwaremx[it_mxbt].jgprice = s_mx.jgprice //加工价, 本位币, 外协单位
- inwaremx[it_mxbt].rebate = s_mx.rebate
- inwaremx[it_mxbt].taxrate = s_mx.taxrate
- IF s_mx.qty <> 0 THEN
- inwaremx[it_mxbt].uprice = Round(s_mx.jgprice * s_mx.uqty/s_mx.qty,5) //加工价, 本位币, 库存单位
- ELSE
- inwaremx[it_mxbt].uprice = 0
- END IF
- inwaremx[it_mxbt].fprice = s_mx.fprice //材料成本价, 本位币, 库存单位
- inwaremx[it_mxbt].price = inwaremx[it_mxbt].uprice * s_mx.rebate + s_mx.fprice //材料实价,本位币,库存单位(进仓成本价)
- inwaremx[it_mxbt].mxtype = s_mx.mxtype
- IF billtype = 1 THEN
- String ls_sptmtrlname
- uo_spt_price uo_price
- uo_price = Create uo_spt_price
- IF uo_price.uof_getmtrlname(sptid,s_mx.mtrlid,ls_sptmtrlname,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- Destroy uo_price
- inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname
- END IF
- IF thflag = 1 THEN
- SELECT cost
- INTO :ld_cost
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlid = :s_mx.mtrlid
- AND status = :s_mx.status
- AND plancode = :s_mx.plancode
- AND woodcode = :s_mx.woodcode
- AND pcode = :s_mx.pcode
- AND mtrlcuscode = :s_mx.mtrlcuscode
- AND location = :s_mx.location
- AND storageid = :s_mx.storageid
- AND dxflag = :dxflag
- And sptid = 0;
- IF sqlca.SQLCode <> 0 Or IsNull(ld_cost) THEN ld_cost = 0
- inwaremx[it_mxbt].cost = ld_cost
- ELSE
- inwaremx[it_mxbt].cost = (inwaremx[it_mxbt].uprice * s_mx.rebate) + inwaremx[it_mxbt].fprice //进仓成本价,本位币,库存单位
- END IF
- ext:
- Destroy uo_sptprice
- IF rslt = 0 THEN p_clearmx()
- Return(rslt)
- end function
- public function integer acceptmx_bef (s_wfjgmx_in_bef s_mx, ref string arg_msg);
- Long rslt = 1,cnt = 0,LS_i
- Long i_mtrlid,i_sptid
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- Double i_cost,i_newprice
- Decimal i_allouseqty
- String ls_relcode
- Decimal ld_rate = 1
- 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.unit) THEN s_mx.unit = ''
- IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
- IF IsNull(s_mx.rate) THEN s_mx.rate = 0
- IF IsNull(s_mx.relprintid) THEN s_mx.relprintid = 0
- IF s_mx.mtrlwareid = 0 Or s_mx.qty = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- SELECT ow_wfjgware.mtrlid,
- ow_wfjgware.sptid,
- ow_wfjgware.plancode,
- ow_wfjgware.status,
- ow_wfjgware.cost,
- u_mtrldef.mtrlcode,
- ow_wfjgware.woodcode,
- ow_wfjgware.pcode,
- ow_wfjgware.noallocqty
- INTO :i_mtrlid,
- :i_sptid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_mtrlcode,
- :i_woodcode,
- :i_pcode,
- :i_allouseqty
- FROM ow_wfjgware ,u_mtrldef
- WHERE ( ow_wfjgware.mtrlwareid = :s_mx.mtrlwareid )
- AND ( ow_wfjgware.mtrlid = u_mtrldef.mtrlid )
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,库存编号错误"
- 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_sptid) THEN i_sptid = 0
- IF IsNull(i_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- IF sptid <> i_sptid THEN
- arg_msg = "物料:" + String(i_mtrlcode) + '所属加工商资料不对应'
- rslt = 0
- GOTO ext
- END IF
- IF i_cost < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "物料:" + String(i_mtrlcode)+" 单价错误"
- GOTO ext
- END IF
- //外协收货,检查供应商库存是否足够;
- //外协返工,检查仓库是否足够;
- IF sys_option_wfjg_in_chksptware = 1 THEN
- IF s_mx.qty > 0 THEN //
- IF i_allouseqty < s_mx.qty THEN //检查库存数
- rslt = 0
- arg_msg = "物料:" + String(i_mtrlcode)+' 外协商库存数量:'+String(i_allouseqty,'#,##0.##########')+'少于本次扣减数量:'+String(s_mx.qty,'#,##0.##########')
- GOTO ext
- END IF
- END IF
- END IF
- //写入内容
- it_mxbt_bef++
- inwaremx_bef[it_mxbt_bef].mtrlwareid = s_mx.mtrlwareid
- inwaremx_bef[it_mxbt_bef].mtrlid = i_mtrlid
- inwaremx_bef[it_mxbt_bef].status = i_status
- inwaremx_bef[it_mxbt_bef].qty = s_mx.qty
- inwaremx_bef[it_mxbt_bef].sptid = i_sptid
- inwaremx_bef[it_mxbt_bef].plancode = i_plancode
- inwaremx_bef[it_mxbt_bef].mtrlcode = i_mtrlcode
- inwaremx_bef[it_mxbt_bef].mxdscrp = s_mx.mxdscrp
- inwaremx_bef[it_mxbt_bef].printid = s_mx.printid
- inwaremx_bef[it_mxbt_bef].fprice = i_cost
- inwaremx_bef[it_mxbt_bef].woodcode = i_woodcode
- inwaremx_bef[it_mxbt_bef].pcode = i_pcode
- inwaremx_bef[it_mxbt_bef].unit = s_mx.unit
- inwaremx_bef[it_mxbt_bef].uqty = s_mx.uqty
- inwaremx_bef[it_mxbt_bef].relprintid = s_mx.relprintid
- IF s_mx.uqty <> 0 THEN
- inwaremx_bef[it_mxbt_bef].rate = s_mx.qty / s_mx.uqty
- ELSE
- inwaremx_bef[it_mxbt_bef].rate = 0
- END IF
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- end function
- public function integer p_create_wfjgorder (string arg_opemp, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1,i
- Long rst_wfjgid
- uo_order_wfjg uo_wforder
- uo_wforder = Create uo_order_wfjg
- uo_wforder.commit_transaction = commit_transaction
- IF uo_wforder.newbegin(scid,arg_msg) = 0 THEN //
- rslt = 0
- GOTO ext
- END IF
- uo_wforder.Requiredate = indate
- uo_wforder.Assign_emp = inrep
- uo_wforder.sptID = sptID
- uo_wforder.dscrp = '返工单审核自动生成的外协订单'
- uo_wforder.billtype = 4
- uo_wforder.reason = ''
- uo_wforder.relcode = inwarecode
- FOR i = 1 To it_mxbt
- IF uo_wforder.acceptmx(0,&
- 0,&
- '',&
- inwaremx[i].mtrlid,&
- abs(inwaremx[i].qty),&
- inwaremx[i].jgprice,&
- inwaremx[i].mxdscrp,&
- inwaremx[i].mtrlcode,&
- arg_msg,&
- i,&
- indate,&
- 0,&
- inwaremx[i].jgdscrp,&
- inwaremx[i].status,&
- inwaremx[i].woodcode,&
- inwaremx[i].pcode,&
- 0,&
- 0,&
- 0,&
- '[常规]',&
- inwaremx[i].unit,&
- abs(inwaremx[i].uqty),&
- inwaremx[i].rate,&
- 0,&
- inwaremx[i].plancode,&
- 0,0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- FOR i = 1 To it_mxbt
- IF uo_wforder.acceptmx_out(0,&
- 0,&
- '',&
- inwaremx_bef[i].mtrlid,&
- abs(inwaremx_bef[i].qty),&
- inwaremx_bef[i].fprice,&
- inwaremx_bef[i].mxdscrp,&
- inwaremx_bef[i].mtrlcode,&
- arg_msg,&
- i,&
- 0,&
- inwaremx_bef[i].status,&
- inwaremx_bef[i].woodcode,&
- inwaremx_bef[i].pcode,&
- inwaremx_bef[i].unit,&
- abs(inwaremx_bef[i].uqty),&
- inwaremx_bef[i].rate,&
- i,&
- 0) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- IF uo_wforder.savesubmit(arg_opemp,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- rst_wfjgid = uo_wforder.wfjgid
- IF uo_wforder.firstpermit(scid,rst_wfjgid,arg_opemp,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- UPDATE ow_wfjg_in
- SET relint_3 = :rst_wfjgid
- WHERE scid = :scid
- And inwareid = :inwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '记录相关返工外协订单id失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_wforder
- RETURN rslt
- end function
- public function integer p_destroy_wfjgorder (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- uo_order_wfjg uo_wforder
- uo_wforder = Create uo_order_wfjg
- uo_wforder.commit_transaction = commit_transaction
- uo_wforder.caudit_checkauto = 1
- IF inwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF relint_3 = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- IF uo_wforder.cancelpermit(scid,relint_3,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF uo_wforder.Cancel(scid,relint_3,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- UPDATE ow_wfjg_in
- SET relint_3 = 0
- WHERE scid = :scid
- And inwareid = :inwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '清除相关返工外协订单id失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_wforder
- 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 mod_price (long arg_scid, long arg_inwareid, long arg_printid, decimal arg_fprice, decimal arg_jgprice, decimal arg_taxrate, decimal arg_rebate, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- uo_inware uo_in
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- IF p_getinfo(arg_scid,arg_inwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = '进仓单待审核状态下不能执行修改单价功能'
- GOTO ext
- END IF
- Decimal ld_jgprice,ld_fprice,ld_uqty,ld_rate,ld_qty,ld_rebate,ld_taxrate
- Long ll_mtrlid
- String ls_status,ls_woodcode,ls_pcode
- Long ll_storageid
- SELECT jgprice,
- fprice,
- uqty,
- qty,
- rebate,
- mtrlid,
- status,
- woodcode,
- pcode,
- storageid,
- rate,
- taxrate
- INTO :ld_jgprice,
- :ld_fprice,
- :ld_uqty,
- :ld_qty,
- :ld_rebate,
- :ll_mtrlid,
- :ls_status,
- :ls_woodcode,
- :ls_pcode,
- :ll_storageid,
- :ld_rate,
- :ld_taxrate
- FROM ow_wfjgmx_in_aft
- WHERE scid = :arg_scid
- AND inwareid = :arg_inwareid
- AND printid = :arg_printid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询单据明细内容失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF arg_taxrate = -1 THEN arg_taxrate = ld_taxrate
- IF arg_rebate = -1 THEN arg_rebate = ld_rebate
- IF secflag = 1 THEN
- IF arg_jgprice <> ld_jgprice Or arg_taxrate <> ld_taxrate or arg_rebate = ld_rebate THEN //可以修改材料成本价
- rslt = 0
- arg_msg = '进仓单已财审,不能执行修改加工价、折扣、税率'
- GOTO ext
- END IF
- END IF
- IF arg_jgprice = ld_jgprice And arg_fprice = ld_fprice And arg_taxrate = ld_taxrate and arg_rebate = ld_rebate THEN //没有修改,成功返回
- rslt = 1
- //arg_msg = '单价或税率没有任何修改,不能保存'
- GOTO ext
- END IF
- Long ll_inwareid, ll_balcdateint, ll_cnt
- Int li_balcflag
- Int li_StoreBalcType
- Int li_storagetype
- IF billtype = 4 THEN //仓库外协需更新仓库进仓单, 车间外协不需要
- SELECT storagetype, StoreBalcType
- INTO :li_storagetype, :li_StoreBalcType
- FROM u_storage
- Where storageid = :ll_storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库属性"
- GOTO ext
- END IF
-
- SELECT inwareid,balcflag,balcdateint
- INTO :ll_inwareid,:li_balcflag,:ll_balcdateint
- FROM u_inware
- WHERE scid = :arg_scid
- AND relid = :arg_inwareid
- AND storageid = :ll_storageid
- And billtype = 4 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询相关进仓单失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF li_StoreBalcType = 0 THEN
- IF li_balcflag = 1 THEN
- rslt = 0
- arg_msg = '外协收货单相关进仓单已结存,期间['+string(ll_balcdateint)+'],不能修改'
- GOTO ext
- END IF
- ELSE
- SELECT count(*)
- INTO :ll_cnt
- FROM u_warebalc
- WHERE storageid = :ll_storageid
- AND balcdateint = :ll_balcdateint
- AND AmtAuditFlag = 1
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库属性"
- GOTO ext
- END IF
-
- IF ll_cnt > 0 THEN
- rslt = 0
- arg_msg = '外协收货单相关进仓仓库已金额结存,期间['+string(ll_balcdateint)+'],不能修改'
- GOTO ext
- END IF
- END IF
- END IF
- Decimal ld_uprice_new,ld_price_new,ld_cost_new
- IF ld_qty <> 0 THEN
- ld_uprice_new = Round(arg_jgprice * ld_uqty/ld_qty,5)
- ELSE
- ld_uprice_new = 0
- END IF
- ld_cost_new = ld_uprice_new * arg_rebate + arg_fprice
- ld_price_new = ld_uprice_new * arg_rebate + arg_fprice
- UPDATE ow_wfjgmx_in_aft
- SET jgprice = :arg_jgprice,
- fprice = :arg_fprice,
- uprice = :ld_uprice_new,
- price = :ld_price_new,
- cost = :ld_cost_new,
- taxrate = :arg_taxrate,
- rebate = :arg_rebate
- WHERE scid = :arg_scid
- AND inwareid = :arg_inwareid
- And printid = :arg_printid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新单据明细失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF billtype = 4 THEN
- IF uo_in.mod_price(arg_scid,ll_inwareid,arg_printid,arg_jgprice * arg_rebate + arg_fprice * ld_rate,arg_jgprice,0,1,arg_msg,arg_ifcommit) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- Destroy uo_in
- 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_inware_wfjg.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_inware_wfjg.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event constructor;String str_optionvalue,arg_msg
- f_get_sys_option_value('086',str_optionvalue,arg_msg)
- uo_option_wfjg_outmx = Long(str_optionvalue)
- f_get_sys_option_value('169',str_optionvalue,arg_msg)
- uo_option_wfjg_sptprice_sec = Long(str_optionvalue)
- f_get_sys_option_value('131',str_optionvalue,arg_msg)
- uo_option_check_wfjgin = Long(str_optionvalue)
- f_get_sys_option_value('184',str_optionvalue,arg_msg)
- uo_option_wfjg_zero = Long(str_optionvalue)
- f_get_sys_option_value('067',str_optionvalue,arg_msg)
- uo_option_2unit = Long(str_optionvalue)
- f_get_sys_option_value('029',str_optionvalue,arg_msg)
- uo_option_change_status = str_optionvalue
- f_get_sys_option_value('027',str_optionvalue,arg_msg)
- uo_option_change_woodcode = str_optionvalue
- f_get_sys_option_value('028',str_optionvalue,arg_msg)
- uo_option_change_pcode = str_optionvalue
- f_get_sys_option_value('010',str_optionvalue,arg_msg)
- uo_option_ifovertask = Long(str_optionvalue)
- f_get_sys_option_value('322',str_optionvalue,arg_msg)
- uo_option_wfjg_th_ifnotorder = Long(str_optionvalue)
- f_get_sys_option_value('362',str_optionvalue,arg_msg)
- uo_option_cost_notax = long(str_optionvalue)
- end event
|