uo_inware_wfjg.sru 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072
  1. $PBExportHeader$uo_inware_wfjg.sru
  2. forward
  3. global type uo_inware_wfjg from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_inware_wfjg from nonvisualobject
  7. end type
  8. global uo_inware_wfjg uo_inware_wfjg
  9. type variables
  10. Public ProtectedWrite Long scid
  11. Public ProtectedWrite Long inwareid
  12. Public ProtectedWrite String inwarecode
  13. Public ProtectedWrite Int billtype
  14. Public ProtectedWrite DateTime opdate
  15. Public ProtectedWrite String opemp
  16. Public ProtectedWrite DateTime moddate
  17. Public ProtectedWrite String modemp
  18. Public ProtectedWrite Int flag
  19. Public ProtectedWrite Int balcflag
  20. Public ProtectedWrite DateTime auditingdate
  21. Public ProtectedWrite String auditingrep
  22. Public ProtectedWrite Decimal jgsum_amt
  23. Public ProtectedWrite Decimal tax_amt
  24. Public ProtectedWrite Int secflag
  25. Public ProtectedWrite DateTime secauditingdate
  26. Public ProtectedWrite String secauditingrep
  27. Public ProtectedWrite Long ctmint
  28. Long relid
  29. Long storageid
  30. DateTime indate
  31. DateTime plandate
  32. String inrep
  33. String part
  34. String dscrp
  35. Long sptid
  36. String sptname
  37. Int dxflag
  38. Int thflag
  39. Decimal otheramt
  40. Long relint_1
  41. Long relint_2
  42. Long relint_3
  43. String relstr_1
  44. String relstr_2
  45. String relstr_3
  46. decimal dec_round = 10 //计算发出明细保留小数位, 取自外协订单界面
  47. Boolean if_getid_ture = True
  48. Transaction commit_transaction //数据commit事务
  49. s_wfjgmx_in_aft inwaremx[] //明细结构数组
  50. s_wfjgmx_in_bef inwaremx_bef[] //明细结构数组
  51. Long it_mxbt = 0 //明细结构数组末指针
  52. Long it_mxbt_bef = 0 //明细结构数组末指针
  53. Boolean it_newbegin = False //新建标志
  54. Boolean it_updatebegin = False //修改标志
  55. Int uo_option_wfjg_outmx,uo_option_wfjg_sptprice_sec
  56. Int uo_option_check_wfjgin,uo_option_wfjg_zero
  57. Int uo_option_2unit
  58. String uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode
  59. Int uo_option_ifovertask
  60. Int uo_option_wfjg_th_ifnotorder
  61. int uo_option_cost_notax
  62. end variables
  63. forward prototypes
  64. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  65. public function integer getinfo (long arg_scid, long arg_inwareid, ref string arg_msg)
  66. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  67. public function integer del (long arg_scid, long arg_inwareid, ref string arg_msg, boolean arg_ifcommit)
  68. public function integer add_dscrp (long arg_scid, long arg_inwareid, string arg_newdescppart, ref string arg_msg)
  69. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  70. public function integer p_clearmx ()
  71. public function integer p_getinfo (long arg_scid, long arg_inwareid, ref string arg_msg)
  72. public function integer p_reset ()
  73. public function integer p_create_inware (boolean arg_ifcommit, ref string arg_msg)
  74. public function integer p_destroy_inware (boolean arg_ifcommit, ref string arg_msg)
  75. public function integer secauditing (boolean arg_ifcommit, ref string arg_msg)
  76. public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg)
  77. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
  78. public function integer updatebegin (long arg_scid, long arg_inwareid, integer arg_billtype, ref string arg_msg)
  79. 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)
  80. 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)
  81. 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)
  82. public function integer acceptmx (s_wfjgmx_in_aft s_mx, ref string arg_msg)
  83. public function integer acceptmx_bef (s_wfjgmx_in_bef s_mx, ref string arg_msg)
  84. public function integer p_create_wfjgorder (string arg_opemp, boolean arg_ifcommit, ref string arg_msg)
  85. public function integer p_destroy_wfjgorder (boolean arg_ifcommit, ref string arg_msg)
  86. public function integer uof_check_sptpdb_audit (long arg_sptid, ref string arg_msg)
  87. 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)
  88. end prototypes
  89. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i, j
  90. DateTime server_dt
  91. Long ls_newid
  92. String ls_sccode
  93. IF uo_option_wfjg_outmx = -1000 THEN
  94. rslt = 0
  95. arg_msg = '选项:[086]外协订单,收货单必须有外协商库存明细,读取初始默认值失败,操作取消!'
  96. GOTO ext
  97. END IF
  98. IF IsNull(relid) THEN relid = 0
  99. IF IsNull(storageid) THEN storageid = 0
  100. IF IsNull(inrep) THEN inrep = ''
  101. IF IsNull(dscrp) THEN dscrp = ''
  102. IF IsNull(part) THEN part = ''
  103. IF IsNull(sptid) THEN sptid = 0
  104. IF IsNull(sptname) THEN sptname = ''
  105. IF IsNull(dxflag) THEN dxflag = 0
  106. IF IsNull(thflag) THEN thflag = 0
  107. IF IsNull(relint_1) THEN relint_1 = 0
  108. IF IsNull(relint_2) THEN relint_2 = 0
  109. IF IsNull(relint_3) THEN relint_3 = 0
  110. IF IsNull(relstr_1) THEN relstr_1 = ''
  111. IF IsNull(relstr_2) THEN relstr_2 = ''
  112. IF IsNull(relstr_3) THEN relstr_3 = ''
  113. IF it_newbegin = False And it_updatebegin = False THEN
  114. rslt = 0
  115. arg_msg = "非编辑状态不可以提交"
  116. GOTO ext
  117. END IF
  118. SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
  119. //取得系统时间,借用操作员表
  120. IF commit_transaction.SQLCode <> 0 THEN
  121. rslt = 0
  122. arg_msg = "查询操作失败,日期 "
  123. GOTO ext
  124. END IF
  125. CHOOSE CASE billtype
  126. CASE 4,5,6
  127. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  128. rslt = 0
  129. IF billtype = 4 Or billtype = 5 THEN
  130. arg_msg = "没有正确进仓内容"
  131. ELSE
  132. arg_msg = "没有正确计费内容"
  133. END IF
  134. GOTO ext
  135. END IF
  136. IF billtype = 4 Or billtype = 5 THEN
  137. IF uo_option_wfjg_outmx = 1 THEN
  138. //检查收货, 必须有对应外协商库存
  139. FOR i = 1 To it_mxbt
  140. FOR j = 1 To it_mxbt_bef
  141. IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
  142. GOTO _next_check
  143. END IF
  144. NEXT
  145. rslt = 0
  146. arg_msg = '收货明细第'+String(inwaremx[i].printid)+'行,没有对应的外协商库存明细,请检查'
  147. GOTO ext
  148. _next_check:
  149. NEXT
  150. //检查外协商库存, 必须有收货对应
  151. FOR j = 1 To it_mxbt_bef
  152. FOR i = 1 To it_mxbt
  153. IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
  154. GOTO _next_check2
  155. END IF
  156. NEXT
  157. rslt = 0
  158. arg_msg = '外协商库存明细第'+String(inwaremx_bef[j].printid)+'行,没有对应的收货明细,请检查'
  159. GOTO ext
  160. _next_check2:
  161. NEXT
  162. //必须使用有发出明细的选项 sys_option_wfjg_outmx = 1
  163. //必须选物料清单或计划 而且 比较清单数量也必须相应; 2013-09-13
  164. IF sys_option_wfjg_out_cmp = 1 THEN
  165. Long ll_mtrlid_in, ll_mtrlid_out
  166. Decimal lde_qty_in, lde_qty_out, lde_qty_out_pf
  167. String ls_pfcode
  168. Decimal lde_truerqqty_in_pf, lde_rqqty_out_pf
  169. Boolean lb_find = False
  170. decimal lde_sonscale
  171. //检查收货, 必须有对应外协商库存
  172. FOR i = 1 To it_mxbt //收货
  173. ll_mtrlid_in = inwaremx[i].mtrlid
  174. lde_qty_in = abs(inwaremx[i].qty)
  175. ls_pfcode = "[常规]" //inwaremx[i].pfcode
  176. lb_find = False
  177. FOR j = 1 To it_mxbt_bef //外协商库存
  178. IF inwaremx[i].printid = inwaremx_bef[j].relprintid THEN
  179. ll_mtrlid_out = inwaremx_bef[j].mtrlid
  180. lde_qty_out = abs(inwaremx_bef[j].qty)
  181. lde_qty_out_pf = 0
  182. lb_find = True
  183. IF ll_mtrlid_in = ll_mtrlid_out THEN
  184. lde_qty_out_pf = lde_qty_in //返工类型, 发出物料和收货物料为同一种的,只检查数量关系
  185. lde_sonscale = 1
  186. ELSE
  187. IF inwaremx[i].relid > 0 THEN //查主计划
  188. SELECT top 1 u_order_wfjgMx.qty
  189. INTO :lde_truerqqty_in_pf
  190. FROM u_order_wfjgMx
  191. WHERE ( scid = :scid)
  192. AND ( wfjgID = :inwaremx[i].relid)
  193. AND ( printid = :inwaremx[i].relprintid)
  194. AND ( mtrlid = :ll_mtrlid_in ) Using commit_transaction ;
  195. IF commit_transaction.SQLCode <> 0 THEN
  196. rslt = 0
  197. arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',查询对应的外协订单收货结果资料失败,'+commit_transaction.SQLErrText
  198. GOTO ext
  199. END IF
  200. SELECT top 1 qty
  201. INTO :lde_rqqty_out_pf
  202. FROM u_order_wfjgmx_out_mx
  203. WHERE ( scid = :scid)
  204. AND ( wfjgid = :inwaremx[i].relid)
  205. AND ( relprintid = :inwaremx[i].relprintid )
  206. And ( mtrlid = :ll_mtrlid_out ) Using commit_transaction ;
  207. IF commit_transaction.SQLCode <> 0 THEN
  208. rslt = 0
  209. arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',查询对应的外协订单资料失败,'+commit_transaction.SQLErrText
  210. GOTO ext
  211. END IF
  212. lde_qty_out_pf = Round(lde_qty_in * ( lde_rqqty_out_pf / lde_truerqqty_in_pf), dec_round)
  213. lde_sonscale = lde_rqqty_out_pf / lde_truerqqty_in_pf
  214. ELSE //查BOM
  215. SELECT :lde_qty_in * u_prdpf.Sonscale / (1 - u_PrdPF.sonloss) + u_PrdPF.SonDECLoss, u_prdpf.Sonscale
  216. INTO :lde_qty_out_pf, :lde_sonscale
  217. FROM u_PrdPF
  218. WHERE ( u_PrdPF.mtrlid = :ll_mtrlid_in )
  219. AND ( u_PrdPF.sonmtrlid = :ll_mtrlid_out )
  220. And ( u_prdpf.pfcode = :ls_pfcode ) Using commit_transaction ;
  221. IF commit_transaction.SQLCode <> 0 THEN
  222. rslt = 0
  223. arg_msg = '收货明细行:'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',查询对应的物料清单资料失败,'+commit_transaction.SQLErrText
  224. GOTO ext
  225. END IF
  226. lde_qty_out_pf = Round(lde_qty_out_pf, dec_round)
  227. END IF
  228. END IF
  229. IF lde_qty_out <> lde_qty_out_pf THEN
  230. Decimal lde_tmprate
  231. if lde_sonscale = 1 then
  232. lde_tmprate = 0
  233. else
  234. //临时,比例在99%以上的算正确
  235. IF lde_qty_out > lde_qty_out_pf THEN
  236. lde_tmprate = lde_qty_out_pf / lde_qty_out
  237. ELSE
  238. lde_tmprate = lde_qty_out / lde_qty_out_pf
  239. END IF
  240. end if
  241. IF lde_tmprate < 0.99 THEN
  242. rslt = 0
  243. arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',数量比例与限制不相等,请检查'
  244. GOTO ext
  245. END IF
  246. END IF
  247. // IF lde_qty_out <> lde_qty_out_pf THEN
  248. // rslt = 0
  249. // arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',对应发出明细行:'+String(inwaremx_bef[j].printid)+',数量比例与限制不相等,请检查'
  250. // GOTO ext
  251. // END IF
  252. END IF
  253. NEXT
  254. IF Not lb_find THEN
  255. rslt = 0
  256. arg_msg = '系统选项[086,253]限制收货明细与供应商库存明细必须跟物料清单或主计划运算对应~r~n收货明细行'+String(inwaremx[i].printid)+',找不到对应的发出明细或供应商库存ID不存在,请检查'
  257. GOTO ext
  258. END IF
  259. NEXT
  260. END IF
  261. END IF
  262. END IF //billtype
  263. CASE 9
  264. IF it_mxbt_bef = 0 THEN //如果输入物料资料错则已经清空
  265. rslt = 0
  266. arg_msg = "没有正确进仓内容"
  267. GOTO ext
  268. END IF
  269. END CHOOSE
  270. IF f_check_inoutdate(0,indate,False,arg_msg) = 0 THEN
  271. rslt = 0
  272. GOTO ext
  273. END IF
  274. IF billtype <> 6 THEN
  275. IF f_check_inoutdate_wfjg(scid,sptid,indate,arg_msg) = 0 THEN
  276. rslt = 0
  277. GOTO ext
  278. END IF
  279. END IF
  280. plandate = f_findspt_paydate(sptid,indate)
  281. SELECT name INTO :sptname
  282. FROM u_spt
  283. Where sptid = :sptid Using commit_transaction;
  284. IF commit_transaction.SQLCode <> 0 THEN
  285. rslt = 0
  286. arg_msg = "查询操作失败,供应商资料"
  287. GOTO ext
  288. END IF
  289. String ls_msg_loca
  290. Long ll_cnt_loca
  291. Int li_mustloca
  292. IF billtype = 4 And thflag = 0 THEN
  293. ll_cnt_loca = 0
  294. FOR i = 1 To it_mxbt
  295. SELECT mustloca
  296. INTO :li_mustloca
  297. FROM u_storage
  298. WHERE storageid = :inwaremx[i].storageid
  299. Using commit_transaction ;
  300. IF commit_transaction.SQLCode <> 0 THEN
  301. rslt = 0
  302. arg_msg = "第"+String(i)+"行,查询仓库操作失败,"+commit_transaction.SQLErrText
  303. GOTO ext
  304. END IF
  305. IF li_mustloca = 1 THEN
  306. IF Trim(inwaremx[i].Location) = '' THEN
  307. ll_cnt_loca++
  308. IF ll_cnt_loca <= 10 THEN
  309. IF Trim(ls_msg_loca) = '' THEN
  310. ls_msg_loca = ls_msg_loca + String(i)
  311. ELSE
  312. ls_msg_loca = ls_msg_loca + ','+String(i)
  313. END IF
  314. END IF
  315. END IF
  316. END IF
  317. NEXT
  318. IF ll_cnt_loca > 0 THEN
  319. rslt = 0
  320. IF ll_cnt_loca <= 10 THEN
  321. arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'明细中第'+ls_msg_loca+'行没有填仓位,请检查'
  322. ELSE
  323. arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'其中第'+ls_msg_loca+'等'+String(ll_cnt_loca)+'行明细没有填仓位,请详细检查'
  324. END IF
  325. GOTO ext
  326. END IF
  327. END IF
  328. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  329. IF inwareid = 0 THEN //新建
  330. ls_newid = f_sys_scidentity(scid,"ow_wfjg_in","inwareid",arg_msg,True,id_sqlca)
  331. IF ls_newid <= 0 THEN
  332. rslt = 0
  333. GOTO ext
  334. END IF
  335. //取分部代号
  336. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  337. rslt = 0
  338. GOTO ext
  339. END IF
  340. //取得新单据编号
  341. IF thflag = 0 THEN
  342. IF billtype = 4 THEN
  343. inwarecode = getid(scid,ls_sccode + 'WI',Date(server_dt),if_getid_ture,commit_transaction)
  344. ELSEIF billtype = 5 THEN
  345. inwarecode = getid(scid,ls_sccode + 'SI',Date(server_dt),if_getid_ture,commit_transaction)
  346. ELSEIF billtype = 6 THEN
  347. inwarecode = getid(scid,ls_sccode + 'MF',Date(server_dt),if_getid_ture,commit_transaction)
  348. ELSEIF billtype = 9 THEN
  349. inwarecode = getid(scid,ls_sccode + 'WK',Date(server_dt),if_getid_ture,commit_transaction)
  350. END IF
  351. ELSE
  352. IF billtype = 4 THEN
  353. inwarecode = getid(scid,ls_sccode + 'WT',Date(server_dt),if_getid_ture,commit_transaction)
  354. ELSE
  355. inwarecode = getid(scid,ls_sccode + 'ST',Date(server_dt),if_getid_ture,commit_transaction)
  356. END IF
  357. END IF
  358. IF inwarecode = "err" THEN
  359. inwarecode = ''
  360. rslt = 0
  361. arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText
  362. GOTO ext
  363. END IF
  364. INSERT INTO ow_wfjg_in (
  365. scid,
  366. inwareid,
  367. inwarecode,
  368. billtype,
  369. relid,
  370. storageid,
  371. indate,
  372. plandate,
  373. inrep,
  374. part,
  375. dscrp,
  376. sptid,
  377. sptname,
  378. thflag,
  379. dxflag,
  380. otheramt,
  381. opdate,
  382. opemp,
  383. relint_1,
  384. relint_2,
  385. relint_3,
  386. relstr_1,
  387. relstr_2,
  388. relstr_3)
  389. VALUES (
  390. :scid,
  391. :ls_newid,
  392. :inwarecode,
  393. :billtype,
  394. :relid,
  395. :storageid,
  396. :indate,
  397. :plandate,
  398. :inrep,
  399. :part,
  400. :dscrp,
  401. :sptid,
  402. :sptname,
  403. :thflag,
  404. :dxflag,
  405. :otheramt,
  406. :server_dt,
  407. :publ_operator,
  408. :relint_1,
  409. :relint_2,
  410. :relint_3,
  411. :relstr_1,
  412. :relstr_2,
  413. :relstr_3) Using commit_transaction ;
  414. IF commit_transaction.SQLCode <> 0 THEN
  415. rslt = 0
  416. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  417. GOTO ext
  418. END IF
  419. //读取新inwareid
  420. inwareid = ls_newid
  421. FOR i = 1 To it_mxbt
  422. INSERT INTO ow_wfjgmx_in_aft
  423. (scid,
  424. inwareid,
  425. printid,
  426. mtrlid,
  427. plancode,
  428. status,
  429. qty,
  430. fprice,
  431. rebate,
  432. price,
  433. planprice,
  434. mxdscrp,
  435. jgprice,
  436. relid,
  437. ifrel,
  438. woodcode,
  439. relcode,
  440. pcode,
  441. sptid_cusid,
  442. cost,
  443. sptmtrlname,
  444. unit,
  445. rate,
  446. uprice,
  447. uqty,
  448. bootqty,
  449. noauditqty,
  450. storageid,
  451. jgdscrp,
  452. relprintid,
  453. mxtype,
  454. checkqty,
  455. result,
  456. relbillid,
  457. relbillprintid,
  458. relbillcode,
  459. mtrlcuscode,
  460. location,
  461. taxrate)
  462. VALUES (:scid,
  463. :ls_newid,
  464. :inwaremx[i].printid,
  465. :inwaremx[i].mtrlid,
  466. :inwaremx[i].plancode,
  467. :inwaremx[i].status,
  468. :inwaremx[i].qty,
  469. :inwaremx[i].fprice,
  470. :inwaremx[i].rebate,
  471. :inwaremx[i].price,
  472. :inwaremx[i].planprice,
  473. :inwaremx[i].mxdscrp,
  474. :inwaremx[i].jgprice,
  475. :inwaremx[i].relid,
  476. :inwaremx[i].ifrel,
  477. :inwaremx[i].woodcode,
  478. :inwaremx[i].relcode,
  479. :inwaremx[i].pcode,
  480. :inwaremx[i].sptid,
  481. :inwaremx[i].cost,
  482. :inwaremx[i].sptmtrlname,
  483. :inwaremx[i].unit,
  484. :inwaremx[i].rate,
  485. :inwaremx[i].uprice,
  486. :inwaremx[i].uqty,
  487. :inwaremx[i].bootqty,
  488. :inwaremx[i].noauditqty,
  489. :inwaremx[i].storageid,
  490. :inwaremx[i].jgdscrp,
  491. :inwaremx[i].relprintid,
  492. :inwaremx[i].mxtype,
  493. :inwaremx[i].checkqty,
  494. :inwaremx[i].result,
  495. :inwaremx[i].relbillid,
  496. :inwaremx[i].relbillprintid,
  497. :inwaremx[i].relbillcode,
  498. :inwaremx[i].mtrlcuscode,
  499. :inwaremx[i].Location,
  500. :inwaremx[i].taxrate) Using commit_transaction;
  501. IF commit_transaction.SQLCode <> 0 THEN
  502. inwareid = 0 //还原inwareid
  503. rslt = 0
  504. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  505. GOTO ext
  506. END IF
  507. NEXT
  508. FOR i = 1 To it_mxbt_bef
  509. INSERT INTO ow_wfjgmx_in_bef
  510. (scid,
  511. inwareid,
  512. mtrlwareid,
  513. mtrlid,
  514. status,
  515. woodcode,
  516. pcode,
  517. plancode,
  518. qty,
  519. fprice,
  520. printid,
  521. mxdscrp,
  522. unit,
  523. uqty,
  524. rate,
  525. relprintid)
  526. VALUES (
  527. :scid,
  528. :ls_newid,
  529. :inwaremx_bef[i].mtrlwareid,
  530. :inwaremx_bef[i].mtrlid,
  531. :inwaremx_bef[i].status,
  532. :inwaremx_bef[i].woodcode,
  533. :inwaremx_bef[i].pcode,
  534. :inwaremx_bef[i].plancode,
  535. :inwaremx_bef[i].qty,
  536. :inwaremx_bef[i].fprice,
  537. :inwaremx_bef[i].printid,
  538. :inwaremx_bef[i].mxdscrp,
  539. :inwaremx_bef[i].unit,
  540. :inwaremx_bef[i].uqty,
  541. :inwaremx_bef[i].rate,
  542. :inwaremx_bef[i].relprintid) Using commit_transaction;
  543. IF commit_transaction.SQLCode <> 0 THEN
  544. inwareid = 0 //还原inwareid
  545. rslt = 0
  546. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  547. GOTO ext
  548. END IF
  549. NEXT
  550. ELSE //////////////////////////////////////////////// //更新
  551. UPDATE ow_wfjg_in
  552. SET billtype = :billtype,
  553. relid = :relid,
  554. storageid = :storageid,
  555. indate = :indate,
  556. plandate = :plandate,
  557. inrep = :inrep,
  558. part = :part,
  559. dscrp = :dscrp,
  560. sptid = :sptid,
  561. sptname = :sptname,
  562. thflag = :thflag,
  563. dxflag = :dxflag,
  564. otheramt = :otheramt,
  565. moddate = :server_dt,
  566. modemp = :publ_operator,
  567. relint_1 = :relint_1,
  568. relint_2 = :relint_2,
  569. relint_3 = :relint_3,
  570. relstr_1 = :relstr_1,
  571. relstr_2 = :relstr_2,
  572. relstr_3 = :relstr_3
  573. WHERE ow_wfjg_in.inwareid = :inwareid
  574. AND ow_wfjg_in.scid = :scid
  575. And flag = 0 Using commit_transaction;
  576. IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
  577. rslt = 0
  578. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  579. GOTO ext
  580. END IF
  581. //删除原有明细
  582. DELETE FROM ow_wfjgmx_in_aft
  583. WHERE ow_wfjgmx_in_aft.inwareid = :inwareid
  584. And ow_wfjgmx_in_aft.scid = :scid Using commit_transaction;
  585. IF commit_transaction.SQLCode <> 0 THEN
  586. rslt = 0
  587. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  588. GOTO ext
  589. END IF
  590. FOR i = 1 To it_mxbt
  591. INSERT INTO ow_wfjgmx_in_aft
  592. (scid,
  593. inwareid,
  594. printid,
  595. mtrlid,
  596. plancode,
  597. status,
  598. qty,
  599. fprice,
  600. rebate,
  601. price,
  602. planprice,
  603. mxdscrp,
  604. jgprice,
  605. relid,
  606. ifrel,
  607. woodcode,
  608. relcode,
  609. pcode,
  610. sptid_cusid,
  611. cost,
  612. sptmtrlname,
  613. unit,
  614. rate,
  615. uprice,
  616. uqty,
  617. bootqty,
  618. noauditqty,
  619. storageid,
  620. jgdscrp,
  621. relprintid,
  622. mxtype,
  623. checkqty,
  624. result,
  625. relbillid,
  626. relbillprintid,
  627. relbillcode,
  628. mtrlcuscode,
  629. location,
  630. taxrate)
  631. VALUES (:scid,
  632. :inwareid,
  633. :inwaremx[i].printid,
  634. :inwaremx[i].mtrlid,
  635. :inwaremx[i].plancode,
  636. :inwaremx[i].status,
  637. :inwaremx[i].qty,
  638. :inwaremx[i].fprice,
  639. :inwaremx[i].rebate,
  640. :inwaremx[i].price,
  641. :inwaremx[i].planprice,
  642. :inwaremx[i].mxdscrp,
  643. :inwaremx[i].jgprice,
  644. :inwaremx[i].relid,
  645. :inwaremx[i].ifrel,
  646. :inwaremx[i].woodcode,
  647. :inwaremx[i].relcode,
  648. :inwaremx[i].pcode,
  649. :inwaremx[i].sptid,
  650. :inwaremx[i].cost,
  651. :inwaremx[i].sptmtrlname,
  652. :inwaremx[i].unit,
  653. :inwaremx[i].rate,
  654. :inwaremx[i].uprice,
  655. :inwaremx[i].uqty,
  656. :inwaremx[i].bootqty,
  657. :inwaremx[i].noauditqty,
  658. :inwaremx[i].storageid,
  659. :inwaremx[i].jgdscrp,
  660. :inwaremx[i].relprintid,
  661. :inwaremx[i].mxtype,
  662. :inwaremx[i].checkqty,
  663. :inwaremx[i].result,
  664. :inwaremx[i].relbillid,
  665. :inwaremx[i].relbillprintid,
  666. :inwaremx[i].relbillcode,
  667. :inwaremx[i].mtrlcuscode,
  668. :inwaremx[i].Location,
  669. :inwaremx[i].taxrate) Using commit_transaction;
  670. IF commit_transaction.SQLCode <> 0 THEN
  671. rslt = 0
  672. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  673. GOTO ext
  674. END IF
  675. NEXT
  676. //删除原有明细
  677. DELETE FROM ow_wfjgmx_in_bef
  678. WHERE ow_wfjgmx_in_bef.inwareid = :inwareid
  679. And ow_wfjgmx_in_bef.scid = :scid Using commit_transaction;
  680. IF commit_transaction.SQLCode <> 0 THEN
  681. rslt = 0
  682. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  683. GOTO ext
  684. END IF
  685. FOR i = 1 To it_mxbt_bef
  686. INSERT INTO ow_wfjgmx_in_bef
  687. (scid,
  688. inwareid,
  689. mtrlwareid,
  690. mtrlid,
  691. status,
  692. woodcode,
  693. pcode,
  694. plancode,
  695. qty,
  696. fprice,
  697. printid,
  698. mxdscrp,
  699. unit,
  700. uqty,
  701. rate,
  702. relprintid)
  703. VALUES (
  704. :scid,
  705. :inwareid,
  706. :inwaremx_bef[i].mtrlwareid,
  707. :inwaremx_bef[i].mtrlid,
  708. :inwaremx_bef[i].status,
  709. :inwaremx_bef[i].woodcode,
  710. :inwaremx_bef[i].pcode,
  711. :inwaremx_bef[i].plancode,
  712. :inwaremx_bef[i].qty,
  713. :inwaremx_bef[i].fprice,
  714. :inwaremx_bef[i].printid,
  715. :inwaremx_bef[i].mxdscrp,
  716. :inwaremx_bef[i].unit,
  717. :inwaremx_bef[i].uqty,
  718. :inwaremx_bef[i].rate,
  719. :inwaremx_bef[i].relprintid
  720. ) Using commit_transaction;
  721. IF commit_transaction.SQLCode <> 0 THEN
  722. IF commit_transaction.SQLCode <> 0 THEN
  723. rslt = 0
  724. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  725. GOTO ext
  726. END IF
  727. END IF
  728. NEXT
  729. END IF
  730. it_newbegin = False
  731. it_updatebegin = False
  732. ext:
  733. IF rslt = 0 THEN
  734. ROLLBACK Using commit_transaction;
  735. p_clearmx()
  736. ELSEIF rslt = 1 And arg_ifcommit THEN
  737. COMMIT Using commit_transaction;
  738. END IF
  739. RETURN rslt
  740. end function
  741. public function integer getinfo (long arg_scid, long arg_inwareid, ref string arg_msg);//getinfo(arg_scid,arg_inwareid,arg_msg)
  742. //0 失败 1成功
  743. Int rslt = 1,i = 1,no_mxcheck = 0,j = 1,no_mxcheck_bef = 0
  744. jgsum_amt = 0
  745. tax_amt = 0
  746. IF arg_inwareid <= 0 THEN
  747. rslt = 0
  748. arg_msg = "非法进仓单唯一码"
  749. GOTO ext
  750. END IF
  751. rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
  752. IF rslt = 0 THEN GOTO ext
  753. //用游标读取明细
  754. DECLARE cur_inwaermx CURSOR FOR
  755. SELECT ow_wfjgmx_in_aft.printid,
  756. ow_wfjgmx_in_aft.mtrlid,
  757. ow_wfjgmx_in_aft.plancode,
  758. ow_wfjgmx_in_aft.status,
  759. ow_wfjgmx_in_aft.qty,
  760. ow_wfjgmx_in_aft.fprice,
  761. ow_wfjgmx_in_aft.rebate,
  762. ow_wfjgmx_in_aft.price,
  763. ow_wfjgmx_in_aft.planprice,
  764. ow_wfjgmx_in_aft.mxdscrp,
  765. u_mtrldef.mtrlcode,
  766. ow_wfjgmx_in_aft.jgprice,
  767. ow_wfjgmx_in_aft.relid,
  768. ow_wfjgmx_in_aft.ifrel,
  769. ow_wfjgmx_in_aft.woodcode,
  770. ow_wfjgmx_in_aft.pcode,
  771. ow_wfjgmx_in_aft.plancode,
  772. ow_wfjgmx_in_aft.sptid_cusid,
  773. ow_wfjgmx_in_aft.cost,
  774. ow_wfjgmx_in_aft.sptmtrlname,
  775. ow_wfjgmx_in_aft.unit,
  776. ow_wfjgmx_in_aft.uqty,
  777. ow_wfjgmx_in_aft.uprice,
  778. ow_wfjgmx_in_aft.rate,
  779. ow_wfjgmx_in_aft.bootqty,
  780. ow_wfjgmx_in_aft.noauditqty,
  781. ow_wfjgmx_in_aft.storageid,
  782. ow_wfjgmx_in_aft.jgdscrp ,
  783. ow_wfjgmx_in_aft.relprintid ,
  784. ow_wfjgmx_in_aft.mxtype,
  785. ow_wfjgmx_in_aft.checkqty,
  786. ow_wfjgmx_in_aft.result,
  787. ow_wfjgmx_in_aft.relbillid,
  788. ow_wfjgmx_in_aft.relbillprintid,
  789. ow_wfjgmx_in_aft.relbillcode,
  790. ow_wfjgmx_in_aft.mtrlcuscode,
  791. ow_wfjgmx_in_aft.location,
  792. ow_wfjgmx_in_aft.taxrate
  793. FROM ow_wfjgmx_in_aft,u_mtrldef,ow_wfjg_in
  794. WHERE ow_wfjg_in.inwareid = :arg_inwareid AND
  795. ow_wfjgmx_in_aft.mtrlid = u_mtrldef.mtrlid AND
  796. ow_wfjg_in.scid = :arg_scid AND
  797. ow_wfjg_in.inwareid = ow_wfjgmx_in_aft.inwareid AND
  798. ow_wfjg_in.scid = ow_wfjgmx_in_aft.scid USING commit_transaction;
  799. OPEN cur_inwaermx;
  800. FETCH cur_inwaermx INTO :inwaremx[i].printid,:inwaremx[i].mtrlid,:inwaremx[i].plancode,
  801. :inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice,
  802. :inwaremx[i].rebate,:inwaremx[i].price,:inwaremx[i].planprice,
  803. :inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode,:inwaremx[i].jgprice,
  804. :inwaremx[i].relid,:inwaremx[i].ifrel,:inwaremx[i].woodcode,
  805. :inwaremx[i].pcode,:inwaremx[i].plancode,:inwaremx[i].sptid,
  806. :inwaremx[i].cost,:inwaremx[i].sptmtrlname,:inwaremx[i].unit,
  807. :inwaremx[i].uqty,:inwaremx[i].uprice,:inwaremx[i].rate,
  808. :inwaremx[i].bootqty,:inwaremx[i].noauditqty,
  809. :inwaremx[i].storageid,:inwaremx[i].jgdscrp,
  810. :inwaremx[i].relprintid,:inwaremx[i].mxtype,
  811. :inwaremx[i].checkqty,:inwaremx[i].result,
  812. :inwaremx[i].relbillid,:inwaremx[i].relbillprintid,
  813. :inwaremx[i].relbillcode,:inwaremx[i].mtrlcuscode,
  814. :inwaremx[i].location,:inwaremx[i].taxrate;
  815. inwaremx[i].dxflag = dxflag
  816. DO WHILE commit_transaction.SQLCode = 0
  817. jgsum_amt = jgsum_amt + round((inwaremx[i].uqty * inwaremx[i].jgprice * inwaremx[i].rebate) / (1 + inwaremx[i].taxrate),2) //计算单据总金额
  818. tax_amt = tax_amt + round((inwaremx[i].uqty * inwaremx[i].jgprice * inwaremx[i].rebate) / (1 + inwaremx[i].taxrate) * inwaremx[i].taxrate,2)
  819. i++
  820. FETCH cur_inwaermx INTO :inwaremx[i].printid,:inwaremx[i].mtrlid,:inwaremx[i].plancode,
  821. :inwaremx[i].status,:inwaremx[i].qty,:inwaremx[i].fprice,
  822. :inwaremx[i].rebate,:inwaremx[i].price,:inwaremx[i].planprice,
  823. :inwaremx[i].mxdscrp,:inwaremx[i].mtrlcode,:inwaremx[i].jgprice,
  824. :inwaremx[i].relid,:inwaremx[i].ifrel,:inwaremx[i].woodcode,
  825. :inwaremx[i].pcode,:inwaremx[i].plancode,:inwaremx[i].sptid,
  826. :inwaremx[i].cost,:inwaremx[i].sptmtrlname,:inwaremx[i].unit,
  827. :inwaremx[i].uqty,:inwaremx[i].uprice,:inwaremx[i].rate,
  828. :inwaremx[i].bootqty,:inwaremx[i].noauditqty,
  829. :inwaremx[i].storageid,:inwaremx[i].jgdscrp,
  830. :inwaremx[i].relprintid,:inwaremx[i].mxtype,
  831. :inwaremx[i].checkqty,:inwaremx[i].result,
  832. :inwaremx[i].relbillid,:inwaremx[i].relbillprintid,
  833. :inwaremx[i].relbillcode,:inwaremx[i].mtrlcuscode,
  834. :inwaremx[i].location,:inwaremx[i].taxrate;
  835. inwaremx[i].dxflag = dxflag
  836. LOOP
  837. CLOSE cur_inwaermx;
  838. //检验明细是否读入完整
  839. SELECT count(*) INTO :no_mxcheck
  840. FROM ow_wfjgmx_in_aft
  841. WHERE ow_wfjgmx_in_aft.inwareid = :arg_inwareid
  842. AND scid = :arg_scid USING commit_transaction;
  843. IF commit_transaction.SQLCode <> 0 THEN
  844. rslt = 0
  845. arg_msg = "查询操作失败,外协收货单明细数量"+commit_transaction.SQLErrText
  846. GOTO ext
  847. END IF
  848. IF i <> (no_mxcheck+1) THEN
  849. rslt = 0
  850. arg_msg = "查询操作失败,外协收货单明细"
  851. GOTO ext
  852. END IF
  853. //用游标读取明细
  854. DECLARE cur_inwaermx_bef CURSOR FOR
  855. SELECT ow_wfjgmx_in_bef.mtrlwareid,
  856. ow_wfjgmx_in_bef.printid,
  857. ow_wfjgmx_in_bef.mtrlid,
  858. ow_wfjgmx_in_bef.plancode,
  859. ow_wfjgmx_in_bef.status,
  860. ow_wfjgmx_in_bef.qty,
  861. ow_wfjgmx_in_bef.fprice,
  862. ow_wfjgmx_in_bef.mxdscrp,
  863. u_mtrldef.mtrlcode,
  864. ow_wfjgmx_in_bef.woodcode,
  865. ow_wfjgmx_in_bef.pcode,
  866. ow_wfjgmx_in_bef.plancode,
  867. ow_wfjgmx_in_bef.unit,
  868. ow_wfjgmx_in_bef.uqty,
  869. ow_wfjgmx_in_bef.rate,
  870. ow_wfjgmx_in_bef.relprintid
  871. FROM ow_wfjgmx_in_bef,u_mtrldef,ow_wfjg_in
  872. WHERE ow_wfjg_in.inwareid = :arg_inwareid AND
  873. ow_wfjgmx_in_bef.mtrlid = u_mtrldef.mtrlid AND
  874. ow_wfjg_in.scid = :arg_scid AND
  875. ow_wfjg_in.inwareid = ow_wfjgmx_in_bef.inwareid AND
  876. ow_wfjg_in.scid = ow_wfjgmx_in_bef.scid
  877. USING commit_transaction;
  878. OPEN cur_inwaermx_bef;
  879. FETCH cur_inwaermx_bef INTO :inwaremx_bef[j].mtrlwareid,
  880. :inwaremx_bef[j].printid,
  881. :inwaremx_bef[j].mtrlid,:inwaremx_bef[j].plancode,
  882. :inwaremx_bef[j].status,:inwaremx_bef[j].qty,:inwaremx_bef[j].fprice,
  883. :inwaremx_bef[j].mxdscrp,
  884. :inwaremx_bef[j].mtrlcode,:inwaremx_bef[j].woodcode,
  885. :inwaremx_bef[j].pcode,:inwaremx_bef[j].plancode,
  886. :inwaremx_bef[j].unit,:inwaremx_bef[j].uqty,:inwaremx_bef[j].rate,
  887. :inwaremx_bef[i].relprintid;
  888. DO WHILE commit_transaction.SQLCode = 0
  889. j++
  890. FETCH cur_inwaermx_bef INTO :inwaremx_bef[j].mtrlwareid,
  891. :inwaremx_bef[j].printid,
  892. :inwaremx_bef[j].mtrlid,:inwaremx_bef[j].plancode,
  893. :inwaremx_bef[j].status,:inwaremx_bef[j].qty,:inwaremx_bef[j].fprice,
  894. :inwaremx_bef[j].mxdscrp,
  895. :inwaremx_bef[j].mtrlcode,:inwaremx_bef[j].woodcode,
  896. :inwaremx_bef[j].pcode,:inwaremx_bef[j].plancode,
  897. :inwaremx_bef[j].unit,:inwaremx_bef[j].uqty,:inwaremx_bef[j].rate,
  898. :inwaremx_bef[i].relprintid;
  899. LOOP
  900. CLOSE cur_inwaermx_bef;
  901. //检验明细是否读入完整
  902. SELECT count(*) INTO :no_mxcheck_bef
  903. FROM ow_wfjgmx_in_bef
  904. WHERE ow_wfjgmx_in_bef.inwareid = :arg_inwareid
  905. AND scid = :arg_scid USING commit_transaction;
  906. IF commit_transaction.SQLCode <> 0 THEN
  907. rslt = 0
  908. arg_msg = "查询操作失败,外协收货单相关发外明细数量"+commit_transaction.SQLErrText
  909. GOTO ext
  910. END IF
  911. IF j <> (no_mxcheck_bef+1) THEN
  912. rslt = 0
  913. arg_msg = "查询操作失败,外协收货单相关发外明细"
  914. GOTO ext
  915. END IF
  916. inwareid = arg_inwareid
  917. scid = arg_scid
  918. it_mxbt = i - 1
  919. it_mxbt_bef = j - 1
  920. it_newbegin = FALSE
  921. it_updatebegin = FALSE
  922. ext:
  923. IF rslt = 0 THEN p_reset()
  924. RETURN rslt
  925. end function
  926. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  927. Long cnt = 0,i
  928. Long ll_moneyid_native
  929. Decimal ld_jgprice_notax
  930. IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
  931. rslt = 0
  932. GOTO ext
  933. END IF
  934. IF uo_option_wfjg_sptprice_sec = -1000 THEN
  935. rslt = 0
  936. arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
  937. GOTO ext
  938. END IF
  939. IF uo_option_check_wfjgin = -1000 THEN
  940. rslt = 0
  941. arg_msg = '选项:[131]外协选质检后进仓,读取初始默认值失败,操作取消!'
  942. GOTO ext
  943. END IF
  944. IF uo_option_wfjg_th_ifnotorder = -1000 THEN
  945. rslt = 0
  946. arg_msg = '选项:[322]外协返工单限制不能选外协订单,读取初始默认值失败,操作取消!'
  947. GOTO ext
  948. END IF
  949. uo_order_wfjg uo_wfjg
  950. uo_wfjg = Create uo_order_wfjg
  951. uo_wfjg.commit_transaction = commit_transaction
  952. uo_spt_price uo_sptprice
  953. uo_sptprice = Create uo_spt_price
  954. uo_sptcheck uo_sptch
  955. uo_sptch = Create uo_sptcheck
  956. IF inwareid = 0 THEN
  957. rslt = 0
  958. arg_msg = "没有审核对象"
  959. GOTO ext
  960. END IF
  961. IF flag = 1 THEN
  962. rslt = 0
  963. arg_msg = "单据已经审核"
  964. GOTO ext
  965. END IF
  966. //检查外协商盘点表是否未审
  967. IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
  968. rslt = 0
  969. GOTO ext
  970. END IF
  971. SELECT moneyid INTO :ll_moneyid_native
  972. FROM cw_currency
  973. Where native = 1;
  974. IF commit_transaction.SQLCode <> 0 THEN
  975. arg_msg = '查询本位币资料失败'
  976. rslt = 0
  977. GOTO ext
  978. END IF
  979. UPDATE ow_wfjg_in
  980. SET auditingrep = :publ_operator,
  981. auditingdate = getdate(),
  982. flag = 1
  983. WHERE ow_wfjg_in.inwareid = :inwareid
  984. And flag = 0 And scid = :scid Using commit_transaction;
  985. IF commit_transaction.SQLCode <> 0 THEN
  986. rslt = 0
  987. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  988. GOTO ext
  989. ELSEIF commit_transaction.SQLNRows = 0 THEN
  990. rslt = 0
  991. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  992. GOTO ext
  993. END IF
  994. IF billtype = 4 THEN
  995. IF thflag = 0 THEN
  996. IF Not sys_power_issuper and f_power_ind(4135,sys_msg_pow)THEN
  997. FOR i = 1 To it_mxbt
  998. IF inwaremx[i].fprice = 0 THEN
  999. arg_msg = '用户权限限制,行'+string(i)+',材料成本价为0,不能审核'
  1000. rslt = 0
  1001. GOTO ext
  1002. END IF
  1003. NEXT
  1004. END IF
  1005. ELSE
  1006. IF Not sys_power_issuper and f_power_ind(4136,sys_msg_pow) THEN
  1007. FOR i = 1 To it_mxbt
  1008. IF inwaremx[i].fprice = 0 THEN
  1009. arg_msg = '用户权限限制,行'+string(i)+',材料成本价为0,不能审核'
  1010. rslt = 0
  1011. GOTO ext
  1012. END IF
  1013. NEXT
  1014. END IF
  1015. END IF
  1016. IF p_create_inware( False, arg_msg ) = 0 THEN
  1017. rslt = 0
  1018. GOTO ext
  1019. END IF
  1020. IF uo_option_wfjg_th_ifnotorder = 1 And thflag = 1 THEN
  1021. IF p_create_wfjgorder(publ_operator,False,arg_msg) = 0 THEN
  1022. rslt = 0
  1023. GOTO ext
  1024. END IF
  1025. END IF
  1026. END IF
  1027. IF billtype <> 6 THEN
  1028. FOR i = 1 To it_mxbt_bef
  1029. Decimal ld_ref_cost
  1030. IF p_update_cost(inwaremx_bef[i].mtrlwareid,inwaremx_bef[i].mtrlcode,&
  1031. inwaremx_bef[i].printid,ld_ref_cost,arg_msg,False) = 0 THEN
  1032. rslt = 0
  1033. GOTO ext
  1034. END IF
  1035. IF f_update_mtrlware_spt_in(billtype,&
  1036. thflag,&
  1037. scid,&
  1038. inwaremx_bef[i].mtrlwareid,&
  1039. inwaremx_bef[i].mtrlid,&
  1040. inwaremx_bef[i].mtrlcode,&
  1041. inwaremx_bef[i].plancode,&
  1042. inwaremx_bef[i].status,&
  1043. inwaremx_bef[i].qty,&
  1044. ld_ref_cost,&
  1045. sptid,&
  1046. inwaremx_bef[i].woodcode,&
  1047. inwaremx_bef[i].pcode,&
  1048. arg_msg,False,commit_transaction) = 0 THEN
  1049. rslt = 0
  1050. GOTO ext
  1051. END IF
  1052. NEXT
  1053. FOR i = 1 To it_mxbt
  1054. IF uo_option_wfjg_sptprice_sec = 0 THEN
  1055. IF inwaremx[i].mxtype = 0 THEN //正常收货的才更新供应商单价
  1056. ld_jgprice_notax = inwaremx[i].jgprice / ( 1 + inwaremx[i].taxrate)
  1057. 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
  1058. rslt = 0
  1059. GOTO ext
  1060. END IF
  1061. END IF
  1062. END IF
  1063. IF inwaremx[i].relid > 0 THEN
  1064. IF billtype = 9 THEN //盘亏单, 终止外协订单对应的收货明细
  1065. IF uo_wfjg.StopAddQty(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].mtrlcode,inwaremx[i].qty, 0, '盘亏自动终止',arg_msg,False) <> 1 THEN
  1066. rslt = 0
  1067. GOTO ext
  1068. END IF
  1069. ELSE
  1070. IF uo_wfjg.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].qty,arg_msg,False) <> 1 THEN
  1071. rslt = 0
  1072. GOTO ext
  1073. END IF
  1074. IF rslt = 1 And Trim(arg_msg) <> '' THEN
  1075. f_setsysoplog('外协收货单','外协收货单审核,id:'+String(inwareid)+',单号:'+inwarecode,arg_msg,False)
  1076. END IF
  1077. END IF
  1078. IF uo_wfjg.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN
  1079. rslt = 0
  1080. GOTO ext
  1081. END IF
  1082. END IF
  1083. //更新质检已进仓数
  1084. IF uo_option_check_wfjgin = 1 And inwaremx[i].relbillid > 0 THEN
  1085. IF uo_sptch.uof_add_inqty(inwaremx[i].relbillid,inwaremx[i].relbillprintid,inwaremx[i].uqty,arg_msg,False) = 0 THEN
  1086. rslt = 0
  1087. GOTO ext
  1088. END IF
  1089. END IF
  1090. NEXT
  1091. END IF
  1092. flag = 1
  1093. ext:
  1094. IF rslt = 0 THEN
  1095. ROLLBACK Using commit_transaction;
  1096. ELSEIF rslt = 1 And arg_ifcommit THEN
  1097. COMMIT Using commit_transaction;
  1098. END IF
  1099. Destroy uo_wfjg
  1100. Destroy uo_sptch
  1101. Destroy uo_sptprice
  1102. RETURN rslt
  1103. end function
  1104. public function integer del (long arg_scid, long arg_inwareid, ref string arg_msg, boolean arg_ifcommit);//del(arg_scid,arg_inwareid,arg_msg)
  1105. //如果单据还没有审核删除单据极其明细
  1106. //0 fail, 1 success
  1107. Int rslt = 1
  1108. IF arg_inwareid = 0 THEN
  1109. rslt = 0
  1110. arg_msg = "没有删除对象,操作取消"
  1111. GOTO ext
  1112. END IF
  1113. rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
  1114. IF rslt = 0 THEN GOTO ext
  1115. IF flag = 1 THEN
  1116. rslt = 0
  1117. arg_msg = "单据已经审核,不可以删除"
  1118. GOTO ext
  1119. END IF
  1120. DELETE FROM ow_wfjgmx_in_aft
  1121. WHERE ow_wfjgmx_in_aft.inwareid = :arg_inwareid
  1122. And ow_wfjgmx_in_aft.scid = :arg_scid Using commit_transaction;
  1123. IF commit_transaction.SQLCode <> 0 THEN
  1124. rslt = 0
  1125. arg_msg = "删除外协收货单明细操作失败"+"~n"+commit_transaction.SQLErrText
  1126. GOTO ext
  1127. END IF
  1128. DELETE FROM ow_wfjgmx_in_bef
  1129. WHERE ow_wfjgmx_in_bef.inwareid = :arg_inwareid
  1130. And ow_wfjgmx_in_bef.scid = :arg_scid Using commit_transaction;
  1131. IF commit_transaction.SQLCode <> 0 THEN
  1132. rslt = 0
  1133. arg_msg = "删除外协收货单相关发外明细操作失败"+"~n"+commit_transaction.SQLErrText
  1134. GOTO ext
  1135. END IF
  1136. DELETE FROM ow_wfjg_in
  1137. WHERE ow_wfjg_in.inwareid = :arg_inwareid
  1138. And scid = :arg_scid Using commit_transaction;
  1139. IF commit_transaction.SQLCode <> 0 THEN
  1140. rslt = 0
  1141. arg_msg = "删除进仓单操作失败"+"~n"+commit_transaction.SQLErrText
  1142. GOTO ext
  1143. END IF
  1144. it_newbegin = False
  1145. it_updatebegin = False
  1146. ext:
  1147. IF rslt = 0 THEN
  1148. ROLLBACK Using commit_transaction;
  1149. ELSEIF rslt = 1 And arg_ifcommit THEN
  1150. COMMIT Using commit_transaction;
  1151. END IF
  1152. p_reset()
  1153. RETURN rslt
  1154. end function
  1155. public function integer add_dscrp (long arg_scid, long arg_inwareid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  1156. //0 fail 1 success
  1157. Int rslt = 1
  1158. arg_newdescppart = Trim(arg_newdescppart)
  1159. IF arg_newdescppart = '' THEN
  1160. rslt = 0
  1161. arg_msg = "要添加内容为空,操作取消"
  1162. GOTO ext
  1163. END IF
  1164. rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
  1165. IF rslt = 0 THEN GOTO ext
  1166. IF flag = 0 THEN
  1167. rslt = 0
  1168. arg_msg = "非审核状态下不可用"
  1169. GOTO ext
  1170. END IF
  1171. UPDATE ow_wfjg_in
  1172. SET dscrp = dscrp+' '+:arg_newdescppart
  1173. WHERE ow_wfjg_in.inwareid = :inwareid
  1174. And scid = :scid Using commit_transaction;
  1175. IF commit_transaction.SQLCode <> 0 THEN
  1176. ROLLBACK Using commit_transaction;
  1177. rslt = 0
  1178. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  1179. GOTO ext
  1180. END IF
  1181. COMMIT Using commit_transaction;
  1182. dscrp = dscrp+' '+arg_newdescppart
  1183. ext: Return (rslt)
  1184. end function
  1185. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
  1186. Long ll_moneyid_native
  1187. DateTime null_dt
  1188. SetNull(null_dt)
  1189. IF f_aps_mrp_cklock(scid,arg_msg) = 0 THEN
  1190. rslt = 0
  1191. GOTO ext
  1192. END IF
  1193. IF uo_option_wfjg_sptprice_sec = -1000 THEN
  1194. rslt = 0
  1195. arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
  1196. GOTO ext
  1197. END IF
  1198. IF uo_option_check_wfjgin = -1000 THEN
  1199. rslt = 0
  1200. arg_msg = '选项:[131]外协选质检后进仓,读取初始默认值失败,操作取消!'
  1201. GOTO ext
  1202. END IF
  1203. IF uo_option_wfjg_th_ifnotorder = -1000 THEN
  1204. rslt = 0
  1205. arg_msg = '选项:[322]外协返工单限制不能选外协订单,读取初始默认值失败,操作取消!'
  1206. GOTO ext
  1207. END IF
  1208. uo_order_wfjg uo_wfjg
  1209. uo_wfjg = Create uo_order_wfjg
  1210. uo_wfjg.commit_transaction = commit_transaction
  1211. uo_sptcheck uo_sptch
  1212. uo_sptch = Create uo_sptcheck
  1213. uo_spt_price uo_sptprice
  1214. uo_sptprice = Create uo_spt_price
  1215. IF inwareid = 0 THEN
  1216. rslt = 0
  1217. arg_msg = "没有审核对象"
  1218. GOTO ext
  1219. END IF
  1220. IF ctmint > 0 THEN
  1221. arg_msg = '单据已截数,不能操作'
  1222. rslt = 0
  1223. GOTO ext
  1224. END IF
  1225. IF flag = 0 THEN
  1226. rslt = 0
  1227. arg_msg = "单据还未审核"
  1228. GOTO ext
  1229. END IF
  1230. IF balcflag = 1 THEN
  1231. rslt = 0
  1232. arg_msg = "单据已经结存,不能撤审"
  1233. GOTO ext
  1234. END IF
  1235. //检查外协商盘点表是否未审
  1236. IF uof_check_sptpdb_audit(sptid,arg_msg) = 0 THEN
  1237. rslt = 0
  1238. GOTO ext
  1239. END IF
  1240. SELECT moneyid INTO :ll_moneyid_native
  1241. FROM cw_currency
  1242. Where native = 1;
  1243. IF commit_transaction.SQLCode <> 0 THEN
  1244. arg_msg = '查询本位币资料失败'
  1245. rslt = 0
  1246. GOTO ext
  1247. END IF
  1248. UPDATE ow_wfjg_in
  1249. SET auditingrep = '',
  1250. auditingdate = :null_dt,
  1251. flag = 0
  1252. WHERE ow_wfjg_in.inwareid = :inwareid
  1253. And flag = 1 And scid = :scid Using commit_transaction;
  1254. IF commit_transaction.SQLCode <> 0 THEN
  1255. rslt = 0
  1256. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1257. GOTO ext
  1258. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1259. rslt = 0
  1260. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1261. GOTO ext
  1262. END IF
  1263. IF billtype = 4 THEN
  1264. IF p_destroy_inware( False, arg_msg ) = 0 THEN
  1265. rslt = 0
  1266. GOTO ext
  1267. END IF
  1268. IF uo_option_wfjg_th_ifnotorder = 1 And thflag = 1 THEN
  1269. IF p_destroy_wfjgorder( False, arg_msg ) = 0 THEN
  1270. rslt = 0
  1271. GOTO ext
  1272. END IF
  1273. END IF
  1274. END IF
  1275. IF billtype <> 6 THEN
  1276. FOR i = 1 To it_mxbt_bef
  1277. IF f_update_mtrlware_spt_in(billtype,&
  1278. thflag,&
  1279. scid,&
  1280. inwaremx_bef[i].mtrlwareid,&
  1281. inwaremx_bef[i].mtrlid,&
  1282. inwaremx_bef[i].mtrlcode,&
  1283. inwaremx_bef[i].plancode,&
  1284. inwaremx_bef[i].status,&
  1285. 0 - inwaremx_bef[i].qty,&
  1286. inwaremx_bef[i].fprice,&
  1287. sptid,&
  1288. inwaremx_bef[i].woodcode,&
  1289. inwaremx_bef[i].pcode,&
  1290. arg_msg,False,commit_transaction) = 0 THEN
  1291. rslt = 0
  1292. GOTO ext
  1293. END IF
  1294. NEXT
  1295. FOR i = 1 To it_mxbt
  1296. //更新合同完成数量
  1297. IF inwaremx[i].relid > 0 THEN
  1298. IF billtype = 9 THEN //盘亏单, 终止外协订单对应的收货明细
  1299. IF uo_wfjg.StopAddQty(scid,inwaremx[i].relid,inwaremx[i].relprintid,inwaremx[i].mtrlcode, 0 - inwaremx[i].qty, 0, '盘亏自动终止',arg_msg,False) <> 1 THEN
  1300. rslt = 0
  1301. GOTO ext
  1302. END IF
  1303. ELSE
  1304. IF uo_wfjg.addmxcmpl(scid,inwaremx[i].relid,inwaremx[i].relprintid,0 - inwaremx[i].qty,arg_msg,False) <> 1 THEN
  1305. rslt = 0
  1306. GOTO ext
  1307. END IF
  1308. END IF
  1309. IF uo_wfjg.trycmplbuytask(scid,inwaremx[i].relid,arg_msg,False) = 0 THEN
  1310. rslt = 0
  1311. GOTO ext
  1312. END IF
  1313. END IF
  1314. //更新质检已进仓数
  1315. IF uo_option_check_wfjgin = 1 And inwaremx[i].relbillid > 0 THEN
  1316. IF uo_sptch.uof_add_inqty(inwaremx[i].relbillid,inwaremx[i].relbillprintid,0 - inwaremx[i].uqty,arg_msg,False) = 0 THEN
  1317. rslt = 0
  1318. GOTO ext
  1319. END IF
  1320. END IF
  1321. IF uo_option_wfjg_sptprice_sec = 0 THEN
  1322. IF thflag = 0 And inwaremx[i].mxtype = 0 THEN
  1323. 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
  1324. arg_msg = '更新行:'+String(i)+','+arg_msg
  1325. rslt = 0
  1326. GOTO ext
  1327. END IF
  1328. END IF
  1329. END IF
  1330. NEXT
  1331. END IF
  1332. flag = 0
  1333. ext:
  1334. IF rslt = 0 THEN
  1335. ROLLBACK Using commit_transaction;
  1336. ELSEIF rslt = 1 And arg_ifcommit THEN
  1337. COMMIT Using commit_transaction;
  1338. END IF
  1339. Destroy uo_sptch
  1340. Destroy uo_wfjg
  1341. Destroy uo_sptprice
  1342. RETURN rslt
  1343. end function
  1344. public function integer p_clearmx ();//int p_clearmx()
  1345. //清除明细
  1346. it_mxbt=0
  1347. it_mxbt_bef=0
  1348. return 1
  1349. end function
  1350. public function integer p_getinfo (long arg_scid, long arg_inwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_inwareid,arg_msg)
  1351. //0 失败 1成功
  1352. Int rslt = 1
  1353. IF arg_inwareid <= 0 THEN
  1354. rslt = 0
  1355. arG_MSG = "非法进仓单唯一码"
  1356. GOTO ext
  1357. END IF
  1358. SELECT ow_wfjg_in.inwarecode,
  1359. ow_wfjg_in.billtype,
  1360. ow_wfjg_in.relid,
  1361. ow_wfjg_in.storageid,
  1362. ow_wfjg_in.indate,
  1363. ow_wfjg_in.plandate,
  1364. ow_wfjg_in.inrep,
  1365. ow_wfjg_in.part,
  1366. ow_wfjg_in.sptid,
  1367. ow_wfjg_in.sptname,
  1368. ow_wfjg_in.dscrp,
  1369. ow_wfjg_in.thflag,
  1370. ow_wfjg_in.secflag,
  1371. ow_wfjg_in.dxflag,
  1372. ow_wfjg_in.flag,
  1373. ow_wfjg_in.balcflag,
  1374. ow_wfjg_in.otheramt,
  1375. ow_wfjg_in.relint_1,
  1376. ow_wfjg_in.relint_2,
  1377. ow_wfjg_in.relint_3,
  1378. ow_wfjg_in.relstr_1,
  1379. ow_wfjg_in.relstr_2,
  1380. ow_wfjg_in.relstr_3,
  1381. ow_wfjg_in.ctmint
  1382. INTO :inwarecode,
  1383. :billtype,
  1384. :relid,
  1385. :storageid,
  1386. :indate,
  1387. :plandate,
  1388. :inrep,
  1389. :part,
  1390. :sptid,
  1391. :sptname,
  1392. :dscrp,
  1393. :thflag,
  1394. :secflag,
  1395. :dxflag,
  1396. :flag,
  1397. :balcflag,
  1398. :otheramt,
  1399. :relint_1,
  1400. :relint_2,
  1401. :relint_3,
  1402. :relstr_1,
  1403. :relstr_2,
  1404. :relstr_3,
  1405. :ctmint
  1406. FROM ow_wfjg_in
  1407. WHERE ow_wfjg_in.inwareid = :arg_inwareid
  1408. AND scid = :arg_scid
  1409. Using commit_transaction;
  1410. IF commit_transaction.SQLCode <> 0 THEN
  1411. rslt = 0
  1412. arG_MSG = "查询操作失败(错误进仓单唯一码),进仓单"+commit_transaction.SQLErrText
  1413. GOTO ext
  1414. END IF
  1415. inwareid = arg_inwareid
  1416. scid = arg_scid
  1417. ext:
  1418. IF rslt = 0 THEN p_reset()
  1419. RETURN rslt
  1420. end function
  1421. public function integer p_reset ();//int p_reset()
  1422. //清除对象及其明细
  1423. scid=0
  1424. inwareid=0
  1425. inwarecode=''
  1426. billtype=0
  1427. opemp=''
  1428. modemp=''
  1429. auditingrep=''
  1430. secauditingrep = ''
  1431. secflag = 0
  1432. flag=0
  1433. relid=0
  1434. storageid=0
  1435. inrep=''
  1436. part=''
  1437. dscrp=''
  1438. sptid=0
  1439. sptname=''
  1440. Dxflag=0
  1441. thflag=0
  1442. otheramt=0
  1443. relint_1=0
  1444. relint_2=0
  1445. relint_3=0
  1446. relstr_1=''
  1447. relstr_2=''
  1448. relstr_3=''
  1449. jgsum_amt = 0
  1450. tax_amt = 0
  1451. it_newbegin=false
  1452. it_updatebegin=false
  1453. //清除明细
  1454. p_clearmx()
  1455. return 1
  1456. end function
  1457. public function integer p_create_inware (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1,i
  1458. Long rst_inwareid,o_scid
  1459. Decimal ld_inprice
  1460. datastore ds_wfjginware_mx
  1461. ds_wfjginware_mx = Create datastore
  1462. ds_wfjginware_mx.DataObject = "dw_wfjgmx_in_aft_edit"
  1463. ds_wfjginware_mx.SetTransObject(sqlca)
  1464. ds_wfjginware_mx.Retrieve(scid,inwareid,0)
  1465. ds_wfjginware_mx.SetSort("ow_wfjgmx_in_aft_storageid A")
  1466. ds_wfjginware_mx.Sort()
  1467. IF uo_option_cost_notax = -1000 THEN
  1468. rslt = 0
  1469. arg_msg = '选项:[362]采购外协使用不含税价进仓,读取初始默认值失败,操作取消!'
  1470. GOTO ext
  1471. END IF
  1472. Long ls_rowcount,ll_storageid
  1473. ls_rowcount = ds_wfjginware_mx.RowCount()
  1474. IF ls_rowcount <> it_mxbt THEN
  1475. rslt = 0
  1476. arg_msg = "单据明细数量错误"
  1477. GOTO ext
  1478. END IF
  1479. FOR i = 1 To it_mxbt
  1480. uo_inware uo_in
  1481. uo_in = Create uo_inware
  1482. uo_in.commit_transaction = commit_transaction
  1483. uo_in.if_getid_ture = False
  1484. //2.原事务生成进仓单
  1485. ll_storageid = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_storageid[i]
  1486. SELECT scid INTO :o_scid
  1487. FROM u_storage
  1488. Where storageid = :ll_storageid Using commit_transaction;
  1489. IF sqlca.SQLCode <> 0 THEN
  1490. arg_msg = '查询进仓库所属分部资料失败'
  1491. rslt = 0
  1492. GOTO ext
  1493. END IF
  1494. IF uo_in.newbegin(scid,4,arg_msg) = 0 THEN
  1495. rslt = 0
  1496. GOTO ext
  1497. END IF
  1498. uo_in.relid = inwareid
  1499. uo_in.relint_2 = relint_2
  1500. uo_in.relint_1 = relint_1
  1501. uo_in.sptid = sptid
  1502. uo_in.inrep = inrep
  1503. uo_in.indate = indate
  1504. uo_in.part = inwarecode
  1505. uo_in.dscrp = dscrp
  1506. uo_in.storageid = ll_storageid
  1507. uo_in.mrate = 1
  1508. uo_in.thflag = thflag
  1509. ld_inprice = 0
  1510. DO While (ll_storageid = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_storageid[i])
  1511. IF ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mxtype[i] = 2 THEN //维修
  1512. ld_inprice = ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_fprice[i] * ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i]
  1513. ELSE
  1514. IF uo_option_cost_notax = 0 THEN
  1515. 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]
  1516. ELSE
  1517. 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]
  1518. END IF
  1519. END IF
  1520. //ds_wfjginware_mx.Object.printid[i]
  1521. //u_inwaremx.printid 约定为等于外协单的ow_wfjgmx_in_aft.printid, 后面有函数这样默认调用
  1522. IF uo_in.acceptmx(ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_printid[i],&
  1523. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mtrlid[i],&
  1524. ds_wfjginware_mx.Object.u_mtrldef_mtrlcode[i],&
  1525. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_plancode[i],&
  1526. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_status[i],&
  1527. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uqty[i],&
  1528. ld_inprice,&
  1529. 1,&
  1530. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mxdscrp[i],&
  1531. arg_msg,&
  1532. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uprice[i],&
  1533. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_relid[i],&
  1534. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_ifrel[i],&
  1535. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_woodcode[i],&
  1536. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_pcode[i],&
  1537. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_sptid_cusid[i],&
  1538. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_unit[i],&
  1539. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_rate[i],&
  1540. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_qty[i],&
  1541. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_relprintid[i],&
  1542. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_checkqty[i],&
  1543. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_result[i],'',0,0,&
  1544. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_mtrlcuscode[i],&
  1545. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_location[i],&
  1546. ds_wfjginware_mx.Object.ow_wfjgmx_in_aft_uqty[i],&
  1547. 0) = 0 THEN
  1548. rslt = 0
  1549. GOTO ext
  1550. END IF
  1551. i++
  1552. IF i > it_mxbt THEN EXIT
  1553. LOOP
  1554. IF uo_in.Save(False,arg_msg) = 0 THEN
  1555. rslt = 0
  1556. GOTO ext
  1557. END IF
  1558. rst_inwareid = uo_in.inwareid
  1559. //4.原事务审核进仓单
  1560. IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
  1561. rslt = 0
  1562. GOTO ext
  1563. END IF
  1564. IF uo_in.auditing(False,arg_msg) = 0 THEN
  1565. rslt = 0
  1566. GOTO ext
  1567. END IF
  1568. Destroy uo_in
  1569. i = i - 1
  1570. NEXT
  1571. ext:
  1572. Destroy ds_wfjginware_mx
  1573. IF rslt = 0 THEN
  1574. ROLLBACK Using commit_transaction;
  1575. ELSEIF arg_ifcommit And rslt = 1 THEN
  1576. COMMIT Using commit_transaction;
  1577. END IF
  1578. RETURN rslt
  1579. end function
  1580. public function integer p_destroy_inware (boolean arg_ifcommit, ref string arg_msg);
  1581. Long cnt = 0,i
  1582. Int rslt = 1
  1583. Long chc
  1584. Long in_out
  1585. //Long rst_outwareid[],out_i = 1 //出仓出仓id
  1586. Long rst_inwareid[],in_i = 1 //出仓出仓id
  1587. Long s_scid
  1588. Long o_scid
  1589. Long lay_storageid[],ll_storageid
  1590. DateTime null_dt
  1591. SetNull(null_dt)
  1592. uo_inware uo_in
  1593. uo_in = Create uo_inware
  1594. uo_in.commit_transaction = sqlca
  1595. uo_in.if_getid_ture = False
  1596. IF inwareid = 0 THEN
  1597. rslt = 0
  1598. arg_msg = "没有审核对象"
  1599. GOTO ext
  1600. END IF
  1601. Boolean lb_f = False
  1602. Long j,k,ch
  1603. //统计仓库数量,确定出或出仓单数
  1604. FOR i = 1 To it_mxbt
  1605. FOR j = 1 To UpperBound(lay_storageid)
  1606. IF lay_storageid[j] = inwaremx[i].storageid THEN lb_f = True
  1607. NEXT
  1608. IF lb_f = False THEN
  1609. ch++
  1610. lay_storageid[ch] = inwaremx[i].storageid
  1611. END IF
  1612. lb_f = False
  1613. NEXT
  1614. IF UpperBound(lay_storageid) = 0 THEN
  1615. rslt = 0
  1616. arg_msg = '查询相关进仓单据失败'
  1617. GOTO ext
  1618. END IF
  1619. //2.查询出仓单相关的入仓单,撤审,删除
  1620. FOR k = 1 To UpperBound(lay_storageid)
  1621. ll_storageid = lay_storageid[k]
  1622. SELECT scid INTO :o_scid
  1623. FROM u_storage
  1624. Where storageid = :ll_storageid Using commit_transaction;
  1625. IF sqlca.SQLCode <> 0 THEN
  1626. arg_msg = '查询仓库所属分部资料失败'
  1627. rslt = 0
  1628. GOTO ext
  1629. END IF
  1630. DECLARE cur_in_2 CURSOR FOR
  1631. SELECT inwareid
  1632. FROM u_inware
  1633. WHERE scid = :o_scid
  1634. AND relid = :inwareid
  1635. AND storageid = :ll_storageid
  1636. And billtype = 4 Using commit_transaction;
  1637. OPEN cur_in_2;
  1638. FETCH cur_in_2 Into :rst_inwareid[in_i];
  1639. DO WHILE sqlca.SQLCode = 0
  1640. in_i++
  1641. FETCH cur_in_2 Into :rst_inwareid[in_i];
  1642. LOOP
  1643. in_i = in_i - 1
  1644. CLOSE cur_in_2;
  1645. IF in_i = 0 THEN
  1646. arg_msg = '查询该外协单相关进仓单失败,'+commit_transaction.SQLErrText
  1647. rslt = 0
  1648. GOTO ext
  1649. END IF
  1650. FOR in_out = 1 To in_i
  1651. //撤审出仓单,再删除
  1652. IF uo_in.getinfo(o_scid,rst_inwareid[in_out],arg_msg) = 0 THEN
  1653. rslt = 0
  1654. GOTO ext
  1655. END IF
  1656. IF uo_in.c_auditing(False,arg_msg) = 0 THEN
  1657. rslt = 0
  1658. GOTO ext
  1659. END IF
  1660. IF uo_in.del(o_scid,rst_inwareid[in_out],arg_msg,False) = 0 THEN
  1661. rslt = 0
  1662. GOTO ext
  1663. END IF
  1664. NEXT
  1665. NEXT
  1666. ext:
  1667. IF rslt = 0 THEN
  1668. ROLLBACK Using commit_transaction;
  1669. ELSEIF arg_ifcommit And rslt = 1 THEN
  1670. COMMIT Using commit_transaction;
  1671. END IF
  1672. Destroy uo_in
  1673. RETURN rslt
  1674. end function
  1675. public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
  1676. String ls_about,ls_dscrp
  1677. IF uo_option_wfjg_sptprice_sec = -1000 THEN
  1678. rslt = 0
  1679. arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
  1680. GOTO ext
  1681. END IF
  1682. uo_mustpay uo_pay
  1683. uo_pay = Create uo_mustpay
  1684. uo_spt_price uo_sptprice
  1685. uo_sptprice = Create uo_spt_price
  1686. Decimal ld_payamt = 0,ld_mstpayamt = 0,ld_taxamt = 0
  1687. IF inwareid = 0 THEN
  1688. rslt = 0
  1689. arg_msg = "没有审核对象"
  1690. GOTO ext
  1691. END IF
  1692. IF flag = 0 THEN
  1693. rslt = 0
  1694. arg_msg = "单据还没有经过仓库审核"
  1695. GOTO ext
  1696. END IF
  1697. IF secflag = 1 THEN
  1698. rslt = 0
  1699. arg_msg = "单据已经过财务审核"
  1700. GOTO ext
  1701. END IF
  1702. Int li_btype
  1703. Long ll_accountsid
  1704. Long ll_moneyid_native
  1705. Long ll_dft_itemid,ll_dft_itemid_tax
  1706. decimal ld_jgprice_notax
  1707. SELECT btype,accountsid INTO :li_btype,:ll_accountsid
  1708. FROM cw_banktype
  1709. Where banktypeid = :relint_1 Using commit_transaction;
  1710. IF commit_transaction.SQLCode <> 0 THEN
  1711. rslt = 0
  1712. arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
  1713. GOTO ext
  1714. END IF
  1715. SELECT moneyid INTO :ll_moneyid_native
  1716. FROM cw_currency
  1717. Where native = 1;
  1718. IF commit_transaction.SQLCode <> 0 THEN
  1719. arg_msg = '查询本位币资料失败'
  1720. rslt = 0
  1721. GOTO ext
  1722. END IF
  1723. SELECT count(*) INTO :cnt
  1724. FROM u_user
  1725. Where username = :publ_operator Using commit_transaction ;
  1726. IF commit_transaction.SQLCode <> 0 THEN
  1727. rslt = 0
  1728. arg_msg = "查询操作失败,操作员"
  1729. GOTO ext
  1730. END IF
  1731. IF cnt = 0 THEN
  1732. rslt = 0
  1733. arg_msg = "操作员姓名未登记或已取消"
  1734. GOTO ext
  1735. END IF
  1736. UPDATE ow_wfjg_in
  1737. SET secauditingrep = :publ_operator,
  1738. secauditingdate = getdate(),
  1739. secflag = 1
  1740. WHERE ow_wfjg_in.inwareid = :inwareid
  1741. And flag = 1 And secflag = 0 And scid = :scid Using commit_transaction;
  1742. IF commit_transaction.SQLCode <> 0 THEN
  1743. rslt = 0
  1744. arg_msg = "因网络或其它原因导致财务审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  1745. GOTO ext
  1746. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1747. rslt = 0
  1748. arg_msg = "单据正在财务审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1749. GOTO ext
  1750. END IF
  1751. FOR i = 1 To it_mxbt
  1752. IF uo_option_wfjg_sptprice_sec = 1 THEN
  1753. IF inwaremx[i].mxtype = 0 THEN //正常收货的才更新供应商单价
  1754. ld_jgprice_notax = inwaremx[i].jgprice / ( 1 + inwaremx[i].taxrate)
  1755. 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
  1756. rslt = 0
  1757. GOTO ext
  1758. END IF
  1759. END IF
  1760. END IF
  1761. NEXT
  1762. IF jgsum_amt <> 0 THEN
  1763. ld_mstpayamt = jgsum_amt - otheramt
  1764. ld_taxamt = tax_amt
  1765. IF li_btype = 1 THEN
  1766. ld_payamt = ld_mstpayamt
  1767. ELSE
  1768. ld_payamt = 0
  1769. END IF
  1770. IF thflag = 1 THEN
  1771. ls_about = inwarecode + "退货款,相关号:"+part
  1772. SELECT itemid INTO :ll_dft_itemid
  1773. FROM u_itemdef
  1774. Where dfttype = 5 Using commit_transaction;
  1775. IF commit_transaction.SQLCode <> 0 THEN
  1776. arg_msg = '查询默认采购外协付款项目资料失败,'+commit_transaction.SQLErrText
  1777. rslt = 0
  1778. GOTO ext
  1779. END IF
  1780. ELSE
  1781. ls_about = inwarecode + "应付款,相关号:"+part
  1782. SELECT itemid INTO :ll_dft_itemid
  1783. FROM u_itemdef
  1784. Where dfttype = 2 Using commit_transaction;
  1785. IF commit_transaction.SQLCode <> 0 THEN
  1786. arg_msg = '查询默认采购外协退货项目资料失败,'+commit_transaction.SQLErrText
  1787. rslt = 0
  1788. GOTO ext
  1789. END IF
  1790. END IF
  1791. ls_dscrp = ls_about
  1792. s_bmstpay s_pay
  1793. s_pay.scid = scid
  1794. s_pay.sptid = sptid
  1795. s_pay.paydate = indate
  1796. s_pay.inrep = inrep
  1797. s_pay.oriamt = ld_mstpayamt
  1798. s_pay.mstpayamt = ld_mstpayamt
  1799. s_pay.payamt = ld_payamt
  1800. s_pay.payamt_cn = ld_payamt
  1801. s_pay.dscrp = ls_about
  1802. s_pay.billcode = inwarecode
  1803. s_pay.relcode = part
  1804. s_pay.banktypeid = relint_1
  1805. s_pay.viewdate = plandate
  1806. s_pay.opemp = publ_operator
  1807. s_pay.buildtype = 1
  1808. s_pay.inwareid = inwareid
  1809. s_pay.accountsid = ll_accountsid
  1810. s_pay.itemid = ll_dft_itemid
  1811. s_pay.moneyid = ll_moneyid_native
  1812. s_pay.moneyid_cn = ll_moneyid_native
  1813. IF uo_pay.add_payrec (s_pay,arg_msg,False) = 0 THEN
  1814. rslt = 0
  1815. GOTO ext
  1816. END IF
  1817. IF ld_taxamt <> 0 THEN
  1818. ls_about = inwarecode + "税金,相关号:"+part
  1819. SELECT itemid INTO :ll_dft_itemid_tax
  1820. FROM u_itemdef
  1821. Where dfttype = 13 Using commit_transaction;
  1822. IF commit_transaction.SQLCode <> 0 THEN
  1823. arg_msg = '查询默认采购外协税金项目资料失败,'+commit_transaction.SQLErrText
  1824. rslt = 0
  1825. GOTO ext
  1826. END IF
  1827. s_bmstpaymx s_paymx_tax
  1828. s_paymx_tax.scid = scid
  1829. s_paymx_tax.payid = uo_pay.ref_payid
  1830. s_paymx_tax.sptid = sptid
  1831. s_paymx_tax.paydate = indate
  1832. s_paymx_tax.inrep = inrep
  1833. s_paymx_tax.mstpayamt = ld_taxamt
  1834. s_paymx_tax.payamt = 0
  1835. s_paymx_tax.dscrp = ls_about
  1836. s_paymx_tax.billcode = inwarecode
  1837. s_paymx_tax.relcode = part
  1838. s_paymx_tax.banktypeid = relint_1
  1839. s_paymx_tax.opemp = publ_operator
  1840. s_paymx_tax.buildtype = 3
  1841. s_paymx_tax.inwareid = inwareid
  1842. s_paymx_tax.itemid = ll_dft_itemid_tax
  1843. s_paymx_tax.moneyid = ll_moneyid_native
  1844. IF uo_pay.add_payrecmx (s_paymx_tax,arg_msg,False) = 0 THEN
  1845. rslt = 0
  1846. GOTO ext
  1847. END IF
  1848. END IF
  1849. UPDATE ow_wfjg_in
  1850. SET relint_2 = :uo_pay.ref_payid
  1851. WHERE ow_wfjg_in.inwareid = :inwareid
  1852. AND scid = :scid
  1853. And flag = 1 Using commit_transaction;
  1854. IF commit_transaction.SQLCode <> 0 THEN
  1855. arg_msg = '更新外协单相关应付帐ID失败'
  1856. rslt = 0
  1857. GOTO ext
  1858. END IF
  1859. END IF
  1860. secflag = 1
  1861. ext:
  1862. IF rslt = 0 THEN
  1863. ROLLBACK Using commit_transaction;
  1864. ELSEIF rslt = 1 And arg_ifcommit THEN
  1865. COMMIT Using commit_transaction;
  1866. END IF
  1867. Destroy uo_pay
  1868. Destroy uo_sptprice
  1869. RETURN rslt
  1870. end function
  1871. public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
  1872. DateTime null_dt
  1873. Long ll_moneyid_native
  1874. IF uo_option_wfjg_sptprice_sec = -1000 THEN
  1875. rslt = 0
  1876. arg_msg = '选项:[169]外协收货单财审更新供应商最新价,读取初始默认值失败,操作取消!'
  1877. GOTO ext
  1878. END IF
  1879. uo_mustpay uo_pay
  1880. uo_pay = Create uo_mustpay
  1881. uo_spt_price uo_sptprice
  1882. uo_sptprice = Create uo_spt_price
  1883. String ls_mtrlname
  1884. SetNull(null_dt)
  1885. IF inwareid = 0 THEN
  1886. rslt = 0
  1887. arg_msg = "没有撤审对象"
  1888. GOTO ext
  1889. END IF
  1890. IF ctmint > 0 THEN
  1891. arg_msg = '单据已截数,不能操作'
  1892. rslt = 0
  1893. GOTO ext
  1894. END IF
  1895. IF secflag = 0 THEN
  1896. rslt = 0
  1897. arg_msg = "该单据财务未审,不能进行财务撤审"
  1898. GOTO ext
  1899. END IF
  1900. SELECT moneyid INTO :ll_moneyid_native
  1901. FROM cw_currency
  1902. Where native = 1;
  1903. IF commit_transaction.SQLCode <> 0 THEN
  1904. arg_msg = '查询本位币资料失败'
  1905. rslt = 0
  1906. GOTO ext
  1907. END IF
  1908. UPDATE ow_wfjg_in
  1909. SET secauditingrep = '',
  1910. secauditingdate = :null_dt,
  1911. secflag = 0,relint_3 = 0
  1912. WHERE ow_wfjg_in.inwareid = :inwareid
  1913. And secflag = 1 And scid = :scid Using commit_transaction;
  1914. IF commit_transaction.SQLCode <> 0 THEN
  1915. rslt = 0
  1916. arg_msg = "因网络或其它原因导致财务撤审单据操作失败"+"~n"+commit_transaction.SQLErrText
  1917. GOTO ext
  1918. ELSEIF commit_transaction.SQLNRows = 0 THEN
  1919. rslt = 0
  1920. arg_msg = "单据正在财务撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  1921. GOTO ext
  1922. END IF
  1923. FOR i = 1 To it_mxbt
  1924. IF uo_option_wfjg_sptprice_sec = 1 THEN
  1925. IF thflag = 0 And inwaremx[i].mxtype = 0 THEN
  1926. 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
  1927. arg_msg = '更新行:'+String(i)+','+arg_msg
  1928. rslt = 0
  1929. GOTO ext
  1930. END IF
  1931. END IF
  1932. END IF
  1933. NEXT
  1934. IF jgsum_amt <> 0 THEN
  1935. IF uo_pay.del_payrec(scid,1,relint_2,sptid,arg_msg,False) = 0 THEN
  1936. rslt = 0
  1937. GOTO ext
  1938. END IF
  1939. END IF
  1940. secflag = 0
  1941. ext:
  1942. IF rslt = 0 THEN
  1943. ROLLBACK Using commit_transaction;
  1944. ELSEIF rslt = 1 And arg_ifcommit THEN
  1945. COMMIT Using commit_transaction;
  1946. END IF
  1947. Destroy uo_pay
  1948. Destroy uo_sptprice
  1949. RETURN rslt
  1950. end function
  1951. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);Int rslt = 1
  1952. IF arg_scid < 0 THEN
  1953. arg_msg = '请选择分部'
  1954. rslt = 0
  1955. GOTO ext
  1956. END IF
  1957. IF Not (arg_billtype = 4 OR &
  1958. arg_billtype = 5 OR &
  1959. arg_billtype = 6 OR &
  1960. arg_billtype = 9) THEN
  1961. rslt = 0
  1962. arg_msg = '此单据类型必须为:'
  1963. arg_msg = arg_msg+'4-仓库外协收货单,'
  1964. arg_msg = arg_msg+'5-车间外协收货单,'
  1965. arg_msg = arg_msg+'6-加工计费单,'
  1966. arg_msg = arg_msg+'9-外协商盘亏单'
  1967. GOTO ext
  1968. END IF
  1969. p_reset()
  1970. scid = arg_scid
  1971. billtype = arg_billtype
  1972. it_newbegin = TRUE
  1973. it_updatebegin = FALSE
  1974. ext:
  1975. IF rslt = 0 THEN p_reset()
  1976. RETURN rslt
  1977. end function
  1978. public function integer updatebegin (long arg_scid, long arg_inwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1
  1979. IF arg_scid < 0 THEN
  1980. arg_msg = '请选择分部'
  1981. rslt = 0
  1982. GOTO ext
  1983. END IF
  1984. IF arg_inwareid <= 0 THEN
  1985. rslt = 0
  1986. GOTO ext
  1987. END IF
  1988. IF Not (arg_billtype = 4 OR &
  1989. arg_billtype = 5 OR &
  1990. arg_billtype = 6 OR &
  1991. arg_billtype = 9) THEN
  1992. rslt = 0
  1993. arg_msg = '此单据类型必须为:'
  1994. arg_msg = arg_msg+'4-仓库外协收货单,'
  1995. arg_msg = arg_msg+'5-车间外协收货单,'
  1996. arg_msg = arg_msg+'6-加工计费单,'
  1997. arg_msg = arg_msg+'9-外协商盘亏单'
  1998. GOTO ext
  1999. END IF
  2000. rslt = p_getinfo(arg_scid,arg_inwareid,arg_msg)
  2001. IF rslt = 0 THEN GOTO ext
  2002. IF flag = 1 THEN
  2003. rslt = 0
  2004. arg_msg = '单据已经审核,不可以修改'
  2005. GOTO ext
  2006. END IF
  2007. inwareid = arg_inwareid
  2008. scid = arg_scid
  2009. billtype = arg_billtype
  2010. it_newbegin = FALSE
  2011. it_updatebegin = TRUE
  2012. p_clearmx() //清除明细
  2013. ext:
  2014. IF rslt = 0 THEN p_reset()
  2015. RETURN rslt
  2016. end function
  2017. 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
  2018. Decimal ld_cost
  2019. SELECT cost INTO :ld_cost
  2020. FROM ow_wfjgware
  2021. WHERE sptid = :sptid
  2022. AND mtrlwareid = :arg_mtrlwareid;
  2023. IF sqlca.SQLCode <> 0 THEN
  2024. arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+sqlca.SQLErrText
  2025. rslt = 0
  2026. GOTO ext
  2027. END IF
  2028. UPDATE ow_wfjgmx_in_bef
  2029. SET fprice = :ld_cost
  2030. WHERE scid = :scid
  2031. AND inwareid = :inwareid
  2032. AND printid = :arg_printid;
  2033. IF sqlca.SQLCode <> 0 THEN
  2034. arg_msg = '更新'+arg_mtrlcode+'成本价失败,'+sqlca.SQLErrText
  2035. rslt = 0
  2036. GOTO ext
  2037. END IF
  2038. arg_ref_cost = ld_cost
  2039. ext:
  2040. IF rslt = 0 THEN
  2041. ROLLBACK;
  2042. ELSEIF rslt = 1 AND arg_ifcommit THEN
  2043. COMMIT;
  2044. END IF
  2045. RETURN rslt
  2046. end function
  2047. 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
  2048. s_mx.printid = arg_printid
  2049. s_mx.mtrlid = arg_mtrlid
  2050. s_mx.mtrlcode = arg_mtrlcode
  2051. s_mx.plancode = arg_plancode
  2052. s_mx.status = arg_status
  2053. s_mx.uqty = arg_uqty
  2054. s_mx.fprice = arg_fprice
  2055. s_mx.rebate = arg_rebate
  2056. s_mx.mxdscrp = arg_mxdscrp
  2057. s_mx.jgprice = arg_jgprice
  2058. s_mx.relid = arg_relid
  2059. s_mx.ifrel = arg_ifrel
  2060. s_mx.woodcode = arg_woodcode
  2061. s_mx.pcode = arg_pcode
  2062. s_mx.sptid = arg_cusid_sptid
  2063. s_mx.unit = arg_unit
  2064. s_mx.rate = arg_rate
  2065. s_mx.qty = arg_qty
  2066. s_mx.storageid = arg_storageid
  2067. s_mx.jgdscrp = arg_jgdscrp
  2068. s_mx.relprintid = arg_relprintid
  2069. s_mx.mxtype = arg_mxtype
  2070. s_mx.checkqty = arg_checkqty
  2071. s_mx.result = arg_result
  2072. s_mx.relbillid = arg_relbillid
  2073. s_mx.relbillprintid = arg_relbillprintid
  2074. s_mx.mtrlcuscode = arg_mtrlcuscode
  2075. s_mx.location = arg_location
  2076. s_mx.taxrate = arg_taxrate
  2077. return acceptmx(s_mx, arg_msg)
  2078. /*
  2079. Long rslt = 1,cnt = 0,ls_i
  2080. Decimal ld_planprice,ld_cost
  2081. Decimal ld_noauditqty,ld_bootqty
  2082. String ls_relcode
  2083. Decimal lde_mx_qty
  2084. Decimal lde_orderqty
  2085. Long ll_moneyid_native
  2086. string ls_unit
  2087. IF uo_option_wfjg_zero = -1000 THEN
  2088. rslt = 0
  2089. arg_msg = '选项:[184]外协收货单允许保存零数量,读取初始默认值失败,操作取消!'
  2090. GOTO ext
  2091. END IF
  2092. IF uo_option_2unit = -1000 THEN
  2093. rslt = 0
  2094. arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
  2095. GOTO ext
  2096. END IF
  2097. IF uo_option_change_status = '-1000' THEN
  2098. rslt = 0
  2099. arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
  2100. GOTO ext
  2101. END IF
  2102. IF uo_option_change_woodcode = '-1000' THEN
  2103. rslt = 0
  2104. arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
  2105. GOTO ext
  2106. END IF
  2107. IF uo_option_change_pcode = '-1000' THEN
  2108. rslt = 0
  2109. arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
  2110. GOTO ext
  2111. END IF
  2112. IF uo_option_ifovertask = -1000 THEN
  2113. rslt = 0
  2114. arg_msg = '选项:[010]超采购,外协订单收货,读取初始默认值失败,操作取消!'
  2115. GOTO ext
  2116. END IF
  2117. uo_spt_price uo_sptprice
  2118. uo_sptprice = Create uo_spt_price
  2119. IF it_newbegin = False And it_updatebegin = False THEN
  2120. rslt = 0
  2121. arg_msg = "非编辑状态不可以使用,操作取消"
  2122. GOTO ext
  2123. END IF
  2124. //清除空值
  2125. IF IsNull(arg_printid) THEN arg_printid = 0
  2126. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  2127. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  2128. IF IsNull(arg_plancode) THEN arg_plancode = ''
  2129. IF IsNull(arg_status) THEN arg_status = ''
  2130. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  2131. IF IsNull(arg_relid) THEN arg_relid = 0
  2132. IF IsNull(arg_ifrel) THEN arg_ifrel = 0
  2133. IF IsNull(arg_mxdscrp) THEN arg_woodcode = ''
  2134. IF IsNull(arg_pcode) THEN arg_pcode = ''
  2135. IF IsNull(arg_cusid_sptid) THEN arg_cusid_sptid = 0
  2136. IF IsNull(arg_storageid) THEN arg_storageid = 0
  2137. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  2138. IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = ''
  2139. IF IsNull(arg_unit) THEN arg_unit = ''
  2140. IF IsNull(arg_jgprice) THEN arg_jgprice = 0
  2141. IF IsNull(arg_uqty) THEN arg_uqty = 0
  2142. IF IsNull(arg_qty) THEN arg_qty = 0
  2143. IF IsNull(arg_rebate) THEN arg_rebate = 0
  2144. IF IsNull(arg_fprice) THEN arg_fprice = 0
  2145. IF IsNull(arg_mxtype) THEN arg_mxtype = 0
  2146. IF IsNull(arg_checkqty) THEN arg_checkqty = 0
  2147. IF IsNull(arg_result) THEN arg_result = ''
  2148. IF IsNull(arg_rate) THEN arg_rate = 1
  2149. IF arg_rate = 0 THEN arg_rate = 1
  2150. IF IsNull(arg_mtrlcuscode) THEN arg_mtrlcuscode = ''
  2151. IF IsNull(arg_location) THEN arg_location = ''
  2152. IF IsNull(arg_relbillid) THEN arg_relbillid = 0
  2153. IF IsNull(arg_relbillprintid) THEN arg_relbillprintid = 0
  2154. IF IsNull(arg_taxrate) THEN arg_taxrate = 0
  2155. IF arg_mtrlid = 0 THEN
  2156. rslt = 1
  2157. GOTO ext
  2158. END IF
  2159. IF uo_option_wfjg_zero = 0 THEN
  2160. If ( arg_uqty = 0 And arg_qty = 0 ) THEN
  2161. rslt = 1
  2162. GOTO ext
  2163. END IF
  2164. IF arg_checkqty = 0 THEN arg_checkqty = arg_uqty
  2165. IF arg_qty = 0 THEN
  2166. arg_msg = '行:'+String(arg_printid)+ ',请输入数量'
  2167. rslt = 0
  2168. GOTO ext
  2169. END IF
  2170. IF uo_option_2unit = 1 THEN
  2171. IF arg_uqty = 0 THEN
  2172. arg_msg = '行:'+String(arg_printid)+ ',请输入计价数量'
  2173. rslt = 0
  2174. GOTO ext
  2175. END IF
  2176. IF Trim(arg_unit) = '' THEN
  2177. arg_msg = '行:'+String(arg_printid)+ ',请输入计价单位'
  2178. rslt = 0
  2179. GOTO ext
  2180. END IF
  2181. END IF
  2182. END IF
  2183. IF arg_rebate <= 0 THEN
  2184. arg_msg = '折扣错误,请检查'
  2185. rslt = 0
  2186. GOTO ext
  2187. END IF
  2188. if arg_taxrate < 0 then
  2189. arg_msg = '税率错误,请检查'
  2190. rslt = 0
  2191. GOTO ext
  2192. END IF
  2193. IF billtype = 4 THEN
  2194. cnt = 0
  2195. //检查仓库
  2196. SELECT count(*)
  2197. INTO :cnt
  2198. FROM u_storage
  2199. Where u_storage.storageid = :arg_storageid Using commit_transaction ;
  2200. IF commit_transaction.SQLCode <> 0 THEN
  2201. rslt = 0
  2202. arg_msg = "查询操作失败,仓库"
  2203. GOTO ext
  2204. END IF
  2205. IF cnt = 0 THEN
  2206. rslt = 0
  2207. arg_msg = "错误的仓库编号: "+String(arg_storageid)
  2208. GOTO ext
  2209. END IF
  2210. String ls_storagename
  2211. SELECT storagename
  2212. INTO :ls_storagename
  2213. FROM u_storage
  2214. Where storageid = :arg_storageid Using commit_transaction ;
  2215. IF commit_transaction.SQLCode <> 0 THEN
  2216. rslt = 0
  2217. arg_msg = "查询操作失败,仓库"
  2218. GOTO ext
  2219. END IF
  2220. //检查是否有该仓库的建立权限
  2221. IF sys_user_storagestr_new <> '0' THEN
  2222. IF Pos(sys_user_storagestr_new,','+String(arg_storageid)+',') <= 0 THEN
  2223. rslt = 0
  2224. arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
  2225. GOTO ext
  2226. END IF
  2227. END IF //
  2228. END IF
  2229. IF f_check_status(1,arg_status) = 0 THEN
  2230. rslt = 0
  2231. arg_msg = "查询操作失败,可能"+uo_option_change_status+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_status
  2232. GOTO ext
  2233. END IF
  2234. IF f_check_status(2,arg_woodcode) = 0 THEN
  2235. rslt = 0
  2236. arg_msg = "查询操作失败,可能"+uo_option_change_woodcode+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_woodcode
  2237. GOTO ext
  2238. END IF
  2239. IF f_check_status(3,arg_pcode) = 0 THEN
  2240. rslt = 0
  2241. arg_msg = "查询操作失败,可能"+uo_option_change_pcode+"未定义,物料:"+arg_mtrlcode+",内容:"+arg_pcode
  2242. GOTO ext
  2243. END IF
  2244. //检查物料id
  2245. SELECT planprice
  2246. INTO :ld_planprice
  2247. FROM u_mtrldef
  2248. Where u_mtrldef.mtrlid = :arg_mtrlid Using commit_transaction ;
  2249. IF commit_transaction.SQLCode <> 0 THEN
  2250. rslt = 0
  2251. arg_msg = "查询操作失败,物料或产品编号:"+arg_mtrlcode
  2252. GOTO ext
  2253. END IF
  2254. Int li_iflimitprice
  2255. SELECT iflimitprice,unit INTO :li_iflimitprice,:ls_unit
  2256. FROM u_mtrldef
  2257. Where mtrlid = :arg_mtrlid;
  2258. IF sqlca.SQLCode <> 0 THEN
  2259. arg_msg = '查询物料:'+arg_mtrlcode+'限价属性失败 '+commit_transaction.SQLErrText
  2260. rslt = 0
  2261. GOTO ext
  2262. END IF
  2263. ls_unit = trim(ls_unit)
  2264. SELECT moneyid INTO :ll_moneyid_native
  2265. FROM cw_currency
  2266. Where native = 1;
  2267. IF commit_transaction.SQLCode <> 0 THEN
  2268. arg_msg = '查询本位币资料失败'
  2269. rslt = 0
  2270. GOTO ext
  2271. END IF
  2272. //查询采购限价并检查进仓价
  2273. IF billtype = 5 Or billtype = 4 THEN
  2274. IF li_iflimitprice = 1 THEN
  2275. 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
  2276. rslt = 0
  2277. GOTO ext
  2278. END IF
  2279. END IF
  2280. END IF
  2281. IF arg_ifrel > 0 THEN
  2282. IF arg_relid = 0 THEN
  2283. arg_msg = '请先择相应的加工计划'
  2284. rslt = 0
  2285. GOTO ext
  2286. END IF
  2287. SELECT u_order_wfjg.taskcode ,sum(u_order_wfjgmx.qty - u_order_wfjgmx.consignedqty),sum(u_order_wfjgmx.qty)
  2288. INTO :ls_relcode,:ld_bootqty,:lde_orderqty
  2289. FROM u_order_wfjgmx,u_order_wfjg
  2290. WHERE u_order_wfjgmx.wfjgid = :arg_relid
  2291. AND u_order_wfjgmx.scid = :scid
  2292. AND u_order_wfjgmx.printid = :arg_relprintid
  2293. AND u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid
  2294. AND u_order_wfjgmx.scid = u_order_wfjg.scid
  2295. GROUP BY u_order_wfjg.taskcode
  2296. Using commit_transaction;
  2297. IF commit_transaction.SQLCode <> 0 THEN
  2298. arg_msg = '查询外协计划是否有加工产品:'+arg_mtrlcode+'失败,'+commit_transaction.SQLErrText
  2299. rslt = 0
  2300. GOTO ext
  2301. END IF
  2302. lde_mx_qty = 0
  2303. FOR ls_i = 1 To it_mxbt
  2304. IF arg_mtrlid = inwaremx[ls_i].mtrlid And &
  2305. arg_relid = inwaremx[ls_i].relid And &
  2306. arg_relprintid = inwaremx[ls_i].relprintid THEN
  2307. lde_mx_qty = lde_mx_qty + inwaremx[ls_i].qty
  2308. END IF
  2309. NEXT
  2310. lde_mx_qty = lde_mx_qty + arg_qty
  2311. SELECT isnull(sum(ow_wfjgmx_in_aft.qty),0) INTO :ld_noauditqty
  2312. FROM ow_wfjgmx_in_aft,ow_wfjg_in
  2313. WHERE ow_wfjgmx_in_aft.relid = :arg_relid
  2314. AND ow_wfjgmx_in_aft.scid = :scid
  2315. AND ow_wfjgmx_in_aft.relprintid = :arg_relprintid
  2316. AND ow_wfjgmx_in_aft.inwareid = ow_wfjg_in.inwareid
  2317. AND ow_wfjgmx_in_aft.scid = ow_wfjg_in.scid
  2318. AND ow_wfjg_in.inwareid <> :inwareid
  2319. AND ow_wfjg_in.flag = 0
  2320. Using commit_transaction;
  2321. IF commit_transaction.SQLCode <> 0 THEN
  2322. arg_msg = '查询物料:'+arg_mtrlcode+'相关外协订单已开单数失败,'+commit_transaction.SQLErrText
  2323. rslt = 0
  2324. GOTO ext
  2325. END IF
  2326. Decimal ld_uprate,ld_upqty
  2327. IF uo_option_ifovertask = 1 THEN //不允许超收
  2328. IF lde_mx_qty + ld_noauditqty > ld_bootqty THEN
  2329. 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
  2330. rslt = 0
  2331. GOTO ext
  2332. END IF
  2333. ELSEIF uo_option_ifovertask = 3 THEN //允许超收但按比例限制
  2334. SELECT uprate , upqty
  2335. INTO :ld_uprate,:ld_upqty
  2336. FROM u_mtrldef
  2337. Where mtrlid = :arg_mtrlid;
  2338. IF sqlca.SQLCode <> 0 THEN
  2339. arg_msg = '查询物料:'+Trim(arg_mtrlcode)+'超收货比例失败,'+sqlca.SQLErrText
  2340. rslt = 0
  2341. GOTO ext
  2342. END IF
  2343. IF lde_mx_qty + ld_noauditqty > ld_bootqty + lde_orderqty * ld_uprate + ld_upqty THEN
  2344. 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
  2345. rslt = 0
  2346. GOTO ext
  2347. END IF
  2348. END IF
  2349. END IF
  2350. IF arg_fprice * arg_rebate < 0 THEN //检查进仓价
  2351. rslt = 0
  2352. arg_msg = "物料或产品:" + String(arg_mtrlcode)+",进仓成本价错误"
  2353. GOTO ext
  2354. END IF
  2355. String ls_relbillcode
  2356. ls_relbillcode = ''
  2357. IF arg_relbillid > 0 THEN
  2358. SELECT billcode
  2359. INTO :ls_relbillcode
  2360. FROM u_sptcheck
  2361. Where billid = :arg_relbillid;
  2362. IF commit_transaction.SQLCode <> 0 THEN
  2363. rslt = 0
  2364. arg_msg = '查询质检单号失败'+commit_transaction.SQLErrText
  2365. GOTO ext
  2366. END IF
  2367. END IF
  2368. //写入内容
  2369. it_mxbt++
  2370. inwaremx[it_mxbt].noauditqty = ld_noauditqty
  2371. inwaremx[it_mxbt].printid = arg_printid
  2372. inwaremx[it_mxbt].mtrlid = arg_mtrlid
  2373. inwaremx[it_mxbt].mtrlcode = arg_mtrlcode
  2374. inwaremx[it_mxbt].storageid = arg_storageid
  2375. inwaremx[it_mxbt].jgdscrp = arg_jgdscrp
  2376. inwaremx[it_mxbt].plancode = arg_plancode
  2377. inwaremx[it_mxbt].bootqty = ld_bootqty
  2378. inwaremx[it_mxbt].status = arg_status
  2379. inwaremx[it_mxbt].planprice = ld_planprice
  2380. inwaremx[it_mxbt].mxdscrp = arg_mxdscrp
  2381. inwaremx[it_mxbt].dxflag = dxflag
  2382. inwaremx[it_mxbt].relid = arg_relid
  2383. inwaremx[it_mxbt].ifrel = arg_ifrel
  2384. inwaremx[it_mxbt].woodcode = arg_woodcode
  2385. inwaremx[it_mxbt].pcode = arg_pcode
  2386. inwaremx[it_mxbt].mtrlcuscode = arg_mtrlcuscode
  2387. inwaremx[it_mxbt].Location = arg_location
  2388. inwaremx[it_mxbt].relcode = ls_relcode
  2389. inwaremx[it_mxbt].relprintid = arg_relprintid
  2390. inwaremx[it_mxbt].checkqty = arg_checkqty
  2391. inwaremx[it_mxbt].result = arg_result
  2392. inwaremx[it_mxbt].relbillid = arg_relbillid
  2393. inwaremx[it_mxbt].relbillprintid = arg_relbillprintid
  2394. inwaremx[it_mxbt].relbillcode = ls_relbillcode
  2395. IF dxflag = 0 THEN
  2396. inwaremx[it_mxbt].sptid = arg_cusid_sptid
  2397. ELSE
  2398. inwaremx[it_mxbt].sptid = sptid
  2399. END IF
  2400. inwaremx[it_mxbt].unit = arg_unit
  2401. IF uo_option_2unit = 0 THEN
  2402. arg_uqty = arg_qty
  2403. END IF
  2404. inwaremx[it_mxbt].uqty = arg_uqty
  2405. inwaremx[it_mxbt].jgprice = arg_jgprice
  2406. inwaremx[it_mxbt].rebate = arg_rebate
  2407. IF arg_qty <> 0 THEN
  2408. inwaremx[it_mxbt].uprice = Round(arg_jgprice * arg_uqty/arg_qty,5)
  2409. ELSE
  2410. inwaremx[it_mxbt].uprice = 0
  2411. END IF
  2412. IF arg_uqty <> 0 THEN
  2413. inwaremx[it_mxbt].rate = arg_qty/arg_uqty
  2414. ELSE
  2415. inwaremx[it_mxbt].rate = 0
  2416. END IF
  2417. inwaremx[it_mxbt].qty = arg_qty
  2418. inwaremx[it_mxbt].fprice = arg_fprice
  2419. inwaremx[it_mxbt].price = inwaremx[it_mxbt].uprice * arg_rebate + arg_fprice
  2420. inwaremx[it_mxbt].mxtype = arg_mxtype
  2421. inwaremx[it_mxbt].taxrate = arg_taxrate
  2422. IF billtype = 1 THEN
  2423. String ls_sptmtrlname
  2424. uo_spt_price uo_price
  2425. uo_price = Create uo_spt_price
  2426. IF uo_price.uof_getmtrlname(sptid,arg_mtrlid,ls_sptmtrlname,arg_msg) = 0 THEN
  2427. rslt = 0
  2428. GOTO ext
  2429. END IF
  2430. Destroy uo_price
  2431. inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname
  2432. END IF
  2433. IF thflag = 1 THEN
  2434. SELECT cost
  2435. INTO :ld_cost
  2436. FROM u_mtrlware
  2437. WHERE scid = :scid
  2438. AND mtrlid = :arg_mtrlid
  2439. AND status = :arg_status
  2440. AND plancode = :arg_plancode
  2441. AND woodcode = :arg_woodcode
  2442. AND pcode = :arg_pcode
  2443. AND mtrlcuscode = :arg_mtrlcuscode
  2444. AND location = :arg_location
  2445. AND storageid = :arg_storageid
  2446. AND dxflag = :dxflag
  2447. And sptid = 0;
  2448. IF sqlca.SQLCode <> 0 Or IsNull(ld_cost) THEN ld_cost = 0
  2449. inwaremx[it_mxbt].cost = ld_cost
  2450. ELSE
  2451. inwaremx[it_mxbt].cost = (inwaremx[it_mxbt].uprice * arg_rebate) + inwaremx[it_mxbt].fprice
  2452. END IF
  2453. ext:
  2454. Destroy uo_sptprice
  2455. IF rslt = 0 THEN p_clearmx()
  2456. Return(rslt)
  2457. */
  2458. end function
  2459. 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
  2460. s_mx.mtrlwareid = arg_mtrlwareid
  2461. s_mx.qty = arg_qty
  2462. s_mx.mxdscrp = arg_mxdscrp
  2463. s_mx.printid = arg_printid
  2464. s_mx.unit = arg_unit
  2465. s_mx.uqty = arg_uqty
  2466. s_mx.rate = arg_rate
  2467. s_mx.relprintid = arg_relprintid
  2468. return acceptmx_bef(s_mx, arg_msg)
  2469. /*
  2470. Long rslt = 1,cnt = 0,LS_i
  2471. Long i_mtrlid,i_sptid
  2472. String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
  2473. Double i_cost,i_newprice
  2474. Decimal i_allouseqty
  2475. String ls_relcode
  2476. Decimal ld_rate = 1
  2477. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  2478. rslt = 0
  2479. arg_msg = "非编辑状态不可以使用,操作取消"
  2480. GOTO ext
  2481. END IF
  2482. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  2483. IF IsNull(arg_printid) THEN arg_printid = 0
  2484. IF IsNull(arg_qty) THEN arg_qty = 0
  2485. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  2486. IF IsNull(arg_unit) THEN arg_unit = ''
  2487. IF IsNull(arg_uqty) THEN arg_uqty = 0
  2488. IF IsNull(arg_rate) THEN arg_rate = 0
  2489. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  2490. IF arg_mtrlwareid = 0 OR arg_qty = 0 THEN
  2491. rslt = 1
  2492. GOTO ext
  2493. END IF
  2494. SELECT ow_wfjgware.mtrlid,
  2495. ow_wfjgware.sptid,
  2496. ow_wfjgware.plancode,
  2497. ow_wfjgware.status,
  2498. ow_wfjgware.cost,
  2499. u_mtrldef.mtrlcode,
  2500. ow_wfjgware.woodcode,
  2501. ow_wfjgware.pcode,
  2502. ow_wfjgware.noallocqty
  2503. INTO :i_mtrlid,
  2504. :i_sptid,
  2505. :i_plancode,
  2506. :i_status,
  2507. :i_cost,
  2508. :i_mtrlcode,
  2509. :i_woodcode,
  2510. :i_pcode,
  2511. :i_allouseqty
  2512. FROM ow_wfjgware ,u_mtrldef
  2513. WHERE ( ow_wfjgware.mtrlwareid = :arg_mtrlwareid )
  2514. AND ( ow_wfjgware.mtrlid = u_mtrldef.mtrlid )
  2515. USING commit_transaction;
  2516. IF commit_transaction.SQLCode <> 0 THEN
  2517. rslt = 0
  2518. arg_msg = "查询操作失败,库存编号错误"
  2519. GOTO ext
  2520. END IF
  2521. IF IsNull(i_cost) THEN i_cost = 0
  2522. IF IsNull(i_plancode) THEN i_plancode = ''
  2523. IF IsNull(i_status) THEN i_status = ''
  2524. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  2525. IF IsNull(i_sptid) THEN i_sptid = 0
  2526. IF IsNull(i_woodcode) THEN i_woodcode = ''
  2527. IF IsNull(i_pcode) THEN i_pcode = ''
  2528. IF sptid <> i_sptid THEN
  2529. arg_msg = "物料:" + String(i_mtrlcode) + '所属加工商资料不对应'
  2530. rslt = 0
  2531. GOTO ext
  2532. END IF
  2533. IF i_cost < 0 THEN //检查进仓价
  2534. rslt = 0
  2535. arg_msg = "物料:" + String(i_mtrlcode)+" 单价错误"
  2536. GOTO ext
  2537. END IF
  2538. //写入内容
  2539. it_mxbt_bef++
  2540. inwaremx_bef[it_mxbt_bef].mtrlwareid = arg_mtrlwareid
  2541. inwaremx_bef[it_mxbt_bef].mtrlid = i_mtrlid
  2542. inwaremx_bef[it_mxbt_bef].status = i_status
  2543. inwaremx_bef[it_mxbt_bef].qty = arg_qty
  2544. inwaremx_bef[it_mxbt_bef].sptid = i_sptid
  2545. inwaremx_bef[it_mxbt_bef].plancode = i_plancode
  2546. inwaremx_bef[it_mxbt_bef].mtrlcode = i_mtrlcode
  2547. inwaremx_bef[it_mxbt_bef].mxdscrp = arg_mxdscrp
  2548. inwaremx_bef[it_mxbt_bef].printid = arg_printid
  2549. inwaremx_bef[it_mxbt_bef].fprice = i_cost
  2550. inwaremx_bef[it_mxbt_bef].woodcode = i_woodcode
  2551. inwaremx_bef[it_mxbt_bef].pcode = i_pcode
  2552. inwaremx_bef[it_mxbt_bef].unit = arg_unit
  2553. inwaremx_bef[it_mxbt_bef].uqty = arg_uqty
  2554. inwaremx_bef[it_mxbt_bef].relprintid = arg_relprintid
  2555. IF arg_uqty <> 0 THEN
  2556. inwaremx_bef[it_mxbt_bef].rate = arg_qty / arg_uqty
  2557. ELSE
  2558. inwaremx_bef[it_mxbt_bef].rate = 0
  2559. END IF
  2560. ext:
  2561. IF rslt = 0 THEN p_clearmx()
  2562. RETURN rslt
  2563. */
  2564. end function
  2565. public function integer acceptmx (s_wfjgmx_in_aft s_mx, ref string arg_msg);
  2566. Long rslt = 1,cnt = 0,ls_i
  2567. Decimal ld_planprice,ld_cost
  2568. Decimal ld_noauditqty,ld_bootqty
  2569. String ls_relcode
  2570. Decimal lde_mx_qty
  2571. Decimal lde_orderqty
  2572. Long ll_moneyid_native
  2573. String ls_unit
  2574. IF uo_option_wfjg_zero = -1000 THEN
  2575. rslt = 0
  2576. arg_msg = '选项:[184]外协收货单允许保存零数量,读取初始默认值失败,操作取消!'
  2577. GOTO ext
  2578. END IF
  2579. IF uo_option_2unit = -1000 THEN
  2580. rslt = 0
  2581. arg_msg = '选项:[067]外协双单位核算,读取初始默认值失败,操作取消!'
  2582. GOTO ext
  2583. END IF
  2584. IF uo_option_change_status = '-1000' THEN
  2585. rslt = 0
  2586. arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
  2587. GOTO ext
  2588. END IF
  2589. IF uo_option_change_woodcode = '-1000' THEN
  2590. rslt = 0
  2591. arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
  2592. GOTO ext
  2593. END IF
  2594. IF uo_option_change_pcode = '-1000' THEN
  2595. rslt = 0
  2596. arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
  2597. GOTO ext
  2598. END IF
  2599. IF uo_option_ifovertask = -1000 THEN
  2600. rslt = 0
  2601. arg_msg = '选项:[010]超采购,外协订单收货,读取初始默认值失败,操作取消!'
  2602. GOTO ext
  2603. END IF
  2604. uo_spt_price uo_sptprice
  2605. uo_sptprice = Create uo_spt_price
  2606. IF it_newbegin = False And it_updatebegin = False THEN
  2607. rslt = 0
  2608. arg_msg = "非编辑状态不可以使用,操作取消"
  2609. GOTO ext
  2610. END IF
  2611. //清除空值
  2612. IF IsNull(s_mx.printid) THEN s_mx.printid = 0
  2613. IF IsNull(s_mx.mtrlid) THEN s_mx.mtrlid = 0
  2614. IF IsNull(s_mx.mtrlcode) THEN s_mx.mtrlcode = ''
  2615. IF IsNull(s_mx.plancode) THEN s_mx.plancode = ''
  2616. IF IsNull(s_mx.status) THEN s_mx.status = ''
  2617. IF IsNull(s_mx.mxdscrp) THEN s_mx.mxdscrp = ''
  2618. IF IsNull(s_mx.relid) THEN s_mx.relid = 0
  2619. IF IsNull(s_mx.ifrel) THEN s_mx.ifrel = 0
  2620. IF IsNull(s_mx.mxdscrp) THEN s_mx.woodcode = ''
  2621. IF IsNull(s_mx.pcode) THEN s_mx.pcode = ''
  2622. IF IsNull(s_mx.sptid) THEN s_mx.sptid = 0
  2623. IF IsNull(s_mx.storageid) THEN s_mx.storageid = 0
  2624. IF IsNull(s_mx.relprintid) THEN s_mx.relprintid = 0
  2625. IF IsNull(s_mx.jgdscrp) THEN s_mx.jgdscrp = ''
  2626. IF IsNull(s_mx.unit) THEN s_mx.unit = ''
  2627. IF IsNull(s_mx.jgprice) THEN s_mx.jgprice = 0
  2628. IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
  2629. IF IsNull(s_mx.qty) THEN s_mx.qty = 0
  2630. IF IsNull(s_mx.rebate) THEN s_mx.rebate = 1
  2631. IF IsNull(s_mx.fprice) THEN s_mx.fprice = 0
  2632. IF IsNull(s_mx.mxtype) THEN s_mx.mxtype = 0
  2633. IF IsNull(s_mx.checkqty) THEN s_mx.checkqty = 0
  2634. IF IsNull(s_mx.result) THEN s_mx.result = ''
  2635. IF IsNull(s_mx.rate) THEN s_mx.rate = 1
  2636. IF s_mx.rate = 0 THEN s_mx.rate = 1
  2637. IF IsNull(s_mx.mtrlcuscode) THEN s_mx.mtrlcuscode = ''
  2638. IF IsNull(s_mx.Location) THEN s_mx.Location = ''
  2639. IF IsNull(s_mx.relbillid) THEN s_mx.relbillid = 0
  2640. IF IsNull(s_mx.relbillprintid) THEN s_mx.relbillprintid = 0
  2641. IF IsNull(s_mx.taxrate) THEN s_mx.taxrate = 0
  2642. IF s_mx.mtrlid = 0 THEN
  2643. rslt = 1
  2644. GOTO ext
  2645. END IF
  2646. IF uo_option_wfjg_zero = 0 THEN
  2647. If ( s_mx.uqty = 0 And s_mx.qty = 0 ) THEN
  2648. rslt = 1
  2649. GOTO ext
  2650. END IF
  2651. IF s_mx.checkqty = 0 THEN s_mx.checkqty = s_mx.uqty
  2652. IF s_mx.qty = 0 THEN
  2653. arg_msg = '行:'+String(s_mx.printid)+ ',请输入数量'
  2654. rslt = 0
  2655. GOTO ext
  2656. END IF
  2657. IF uo_option_2unit = 1 THEN
  2658. IF s_mx.uqty = 0 THEN
  2659. arg_msg = '行:'+String(s_mx.printid)+ ',请输入计价数量'
  2660. rslt = 0
  2661. GOTO ext
  2662. END IF
  2663. IF Trim(s_mx.unit) = '' THEN
  2664. arg_msg = '行:'+String(s_mx.printid)+ ',请输入计价单位'
  2665. rslt = 0
  2666. GOTO ext
  2667. END IF
  2668. END IF
  2669. END IF
  2670. IF s_mx.rebate <= 0 Or s_mx.rebate > 1 THEN
  2671. arg_msg = '行:'+String(s_mx.printid)+',折扣错误,只能取范围(0, 1]'
  2672. rslt = 0
  2673. GOTO ext
  2674. END IF
  2675. IF s_mx.taxrate < 0 THEN
  2676. arg_msg = '税率错误,请检查'
  2677. rslt = 0
  2678. GOTO ext
  2679. END IF
  2680. IF billtype = 4 THEN
  2681. // cnt = 0
  2682. // //检查仓库
  2683. // SELECT count(*)
  2684. // INTO :cnt
  2685. // FROM u_storage
  2686. // WHERE u_storage.storageid = :s_mx.storageid
  2687. // Using commit_transaction ;
  2688. // IF commit_transaction.SQLCode <> 0 THEN
  2689. // rslt = 0
  2690. // arg_msg = "查询操作失败,仓库"
  2691. // GOTO ext
  2692. // END IF
  2693. // IF cnt = 0 THEN
  2694. // rslt = 0
  2695. // arg_msg = "错误的仓库编号: "+String(s_mx.storageid)
  2696. // GOTO ext
  2697. // END IF
  2698. String ls_storagename
  2699. Int li_if_cus_mtrlware
  2700. SELECT storagename,noallocflag
  2701. INTO :ls_storagename,:li_if_cus_mtrlware
  2702. FROM u_storage
  2703. Where storageid = :s_mx.storageid Using commit_transaction ;
  2704. IF commit_transaction.SQLCode <> 0 THEN
  2705. rslt = 0
  2706. arg_msg = "查询操作失败,仓库编号: "+String(s_mx.storageid)
  2707. GOTO ext
  2708. END IF
  2709. //检查是否有该仓库的建立权限
  2710. IF sys_user_storagestr_new <> '0' THEN
  2711. IF Pos(sys_user_storagestr_new,','+String(s_mx.storageid)+',') <= 0 THEN
  2712. rslt = 0
  2713. arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
  2714. GOTO ext
  2715. END IF
  2716. END IF //
  2717. //检查库存数是否足够
  2718. Decimal lde_noallocqty
  2719. IF li_if_cus_mtrlware = 1 THEN
  2720. If thflag = 1 THEN
  2721. SELECT sum(noallocqty)
  2722. INTO :lde_noallocqty
  2723. FROM u_mtrlware
  2724. WHERE scid = :scid
  2725. AND mtrlid = :s_mx.mtrlid
  2726. AND storageid = :s_mx.storageid
  2727. AND plancode = :s_mx.plancode
  2728. AND status = :s_mx.status
  2729. AND woodcode = :s_mx.woodcode
  2730. AND pcode = :s_mx.pcode
  2731. AND dxflag = 0
  2732. AND sptid = :s_mx.sptid
  2733. AND mtrlcuscode = :s_mx.mtrlcuscode
  2734. And Location = :s_mx.Location Using commit_transaction;
  2735. IF commit_transaction.SQLCode <> 0 THEN
  2736. rslt = 0
  2737. arg_msg = "查询操作失败,仓库"
  2738. GOTO ext
  2739. END IF
  2740. If (Abs(s_mx.qty) > lde_noallocqty ) THEN
  2741. rslt = 0
  2742. arg_msg = '行:'+String(s_mx.printid)+"物料:" + s_mx.mtrlcode+' 库存数量:'+String(lde_noallocqty,'#,##0.##########')+'少于本次返工数量:'+String(Abs(s_mx.qty),'#,##0.##########')
  2743. GOTO ext
  2744. END IF
  2745. END IF
  2746. END IF
  2747. END IF
  2748. IF f_check_status(1,s_mx.status) = 0 THEN
  2749. rslt = 0
  2750. arg_msg = "查询操作失败,可能"+uo_option_change_status+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.status
  2751. GOTO ext
  2752. END IF
  2753. IF f_check_status(2,s_mx.woodcode) = 0 THEN
  2754. rslt = 0
  2755. arg_msg = "查询操作失败,可能"+uo_option_change_woodcode+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.woodcode
  2756. GOTO ext
  2757. END IF
  2758. IF f_check_status(3,s_mx.pcode) = 0 THEN
  2759. rslt = 0
  2760. arg_msg = "查询操作失败,可能"+uo_option_change_pcode+"未定义,物料:"+s_mx.mtrlcode+",内容:"+s_mx.pcode
  2761. GOTO ext
  2762. END IF
  2763. //检查物料id
  2764. SELECT planprice
  2765. INTO :ld_planprice
  2766. FROM u_mtrldef
  2767. Where u_mtrldef.mtrlid = :s_mx.mtrlid Using commit_transaction ;
  2768. IF commit_transaction.SQLCode <> 0 THEN
  2769. rslt = 0
  2770. arg_msg = "查询操作失败,物料或产品编号:"+s_mx.mtrlcode
  2771. GOTO ext
  2772. END IF
  2773. Int li_iflimitprice
  2774. SELECT iflimitprice,unit INTO :li_iflimitprice,:ls_unit
  2775. FROM u_mtrldef
  2776. Where mtrlid = :s_mx.mtrlid;
  2777. IF sqlca.SQLCode <> 0 THEN
  2778. arg_msg = '查询物料:'+s_mx.mtrlcode+'限价属性失败 '+commit_transaction.SQLErrText
  2779. rslt = 0
  2780. GOTO ext
  2781. END IF
  2782. ls_unit = Trim(ls_unit)
  2783. SELECT moneyid INTO :ll_moneyid_native
  2784. FROM cw_currency
  2785. Where native = 1;
  2786. IF commit_transaction.SQLCode <> 0 THEN
  2787. arg_msg = '查询本位币资料失败'
  2788. rslt = 0
  2789. GOTO ext
  2790. END IF
  2791. //查询采购限价并检查进仓价
  2792. IF billtype = 5 Or billtype = 4 THEN
  2793. IF li_iflimitprice = 1 THEN
  2794. 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
  2795. rslt = 0
  2796. GOTO ext
  2797. END IF
  2798. END IF
  2799. END IF
  2800. IF s_mx.ifrel > 0 THEN
  2801. IF s_mx.relid = 0 THEN
  2802. arg_msg = '行:'+String(s_mx.printid)+ ',请先择相应的外协订单'
  2803. rslt = 0
  2804. GOTO ext
  2805. END IF
  2806. SELECT u_order_wfjg.taskcode ,sum(u_order_wfjgmx.qty - u_order_wfjgmx.consignedqty),sum(u_order_wfjgmx.qty)
  2807. INTO :ls_relcode,:ld_bootqty,:lde_orderqty
  2808. FROM u_order_wfjgmx,u_order_wfjg
  2809. WHERE u_order_wfjgmx.wfjgid = :s_mx.relid
  2810. AND u_order_wfjgmx.scid = :scid
  2811. AND u_order_wfjgmx.printid = :s_mx.relprintid
  2812. AND u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid
  2813. AND u_order_wfjgmx.scid = u_order_wfjg.scid
  2814. GROUP BY u_order_wfjg.taskcode
  2815. Using commit_transaction;
  2816. IF commit_transaction.SQLCode <> 0 THEN
  2817. arg_msg = '查询外协订单是否有加工产品:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText
  2818. rslt = 0
  2819. GOTO ext
  2820. END IF
  2821. lde_mx_qty = 0
  2822. FOR ls_i = 1 To it_mxbt
  2823. IF s_mx.mtrlid = inwaremx[ls_i].mtrlid And &
  2824. s_mx.relid = inwaremx[ls_i].relid And &
  2825. s_mx.relprintid = inwaremx[ls_i].relprintid THEN
  2826. lde_mx_qty = lde_mx_qty + inwaremx[ls_i].qty
  2827. END IF
  2828. NEXT
  2829. lde_mx_qty = lde_mx_qty + s_mx.qty
  2830. SELECT isnull(sum(ow_wfjgmx_in_aft.qty),0) INTO :ld_noauditqty
  2831. FROM ow_wfjgmx_in_aft,ow_wfjg_in
  2832. WHERE ow_wfjgmx_in_aft.relid = :s_mx.relid
  2833. AND ow_wfjgmx_in_aft.scid = :scid
  2834. AND ow_wfjgmx_in_aft.relprintid = :s_mx.relprintid
  2835. AND ow_wfjgmx_in_aft.inwareid = ow_wfjg_in.inwareid
  2836. AND ow_wfjgmx_in_aft.scid = ow_wfjg_in.scid
  2837. AND ow_wfjg_in.inwareid <> :inwareid
  2838. AND ow_wfjg_in.flag = 0
  2839. Using commit_transaction;
  2840. IF commit_transaction.SQLCode <> 0 THEN
  2841. arg_msg = '查询物料:'+s_mx.mtrlcode+'相关外协订单已开单数失败,'+commit_transaction.SQLErrText
  2842. rslt = 0
  2843. GOTO ext
  2844. END IF
  2845. Decimal ld_uprate,ld_upqty
  2846. IF uo_option_ifovertask = 1 THEN //不允许超收
  2847. IF lde_mx_qty + ld_noauditqty > ld_bootqty THEN
  2848. 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
  2849. rslt = 0
  2850. GOTO ext
  2851. END IF
  2852. ELSEIF uo_option_ifovertask = 3 THEN //允许超收但按比例限制
  2853. SELECT uprate , upqty
  2854. INTO :ld_uprate,:ld_upqty
  2855. FROM u_mtrldef
  2856. Where mtrlid = :s_mx.mtrlid;
  2857. IF sqlca.SQLCode <> 0 THEN
  2858. arg_msg = '查询物料:'+Trim(s_mx.mtrlcode)+'超收货比例失败,'+sqlca.SQLErrText
  2859. rslt = 0
  2860. GOTO ext
  2861. END IF
  2862. IF lde_mx_qty + ld_noauditqty > ld_bootqty + lde_orderqty * ld_uprate + ld_upqty THEN
  2863. 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
  2864. rslt = 0
  2865. GOTO ext
  2866. END IF
  2867. END IF
  2868. END IF
  2869. IF s_mx.fprice * s_mx.rebate < 0 THEN //检查进仓价
  2870. rslt = 0
  2871. arg_msg = "物料或产品:" + String(s_mx.mtrlcode)+",进仓成本价错误"
  2872. GOTO ext
  2873. END IF
  2874. String ls_relbillcode
  2875. ls_relbillcode = ''
  2876. IF s_mx.relbillid > 0 THEN
  2877. SELECT billcode
  2878. INTO :ls_relbillcode
  2879. FROM u_sptcheck
  2880. Where billid = :s_mx.relbillid;
  2881. IF commit_transaction.SQLCode <> 0 THEN
  2882. rslt = 0
  2883. arg_msg = '查询质检单号失败'+commit_transaction.SQLErrText
  2884. GOTO ext
  2885. END IF
  2886. END IF
  2887. //写入内容
  2888. it_mxbt++
  2889. inwaremx[it_mxbt].printid = s_mx.printid
  2890. inwaremx[it_mxbt].noauditqty = ld_noauditqty
  2891. inwaremx[it_mxbt].mtrlid = s_mx.mtrlid
  2892. inwaremx[it_mxbt].mtrlcode = s_mx.mtrlcode
  2893. inwaremx[it_mxbt].jgdscrp = s_mx.jgdscrp
  2894. inwaremx[it_mxbt].status = s_mx.status
  2895. inwaremx[it_mxbt].woodcode = s_mx.woodcode
  2896. inwaremx[it_mxbt].pcode = s_mx.pcode
  2897. inwaremx[it_mxbt].storageid = s_mx.storageid
  2898. inwaremx[it_mxbt].dxflag = dxflag
  2899. inwaremx[it_mxbt].mtrlcuscode = s_mx.mtrlcuscode
  2900. inwaremx[it_mxbt].Location = s_mx.Location
  2901. inwaremx[it_mxbt].plancode = s_mx.plancode
  2902. IF dxflag = 0 THEN
  2903. inwaremx[it_mxbt].sptid = s_mx.sptid
  2904. ELSE
  2905. inwaremx[it_mxbt].sptid = sptid
  2906. END IF
  2907. inwaremx[it_mxbt].bootqty = ld_bootqty
  2908. inwaremx[it_mxbt].planprice = ld_planprice
  2909. inwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
  2910. inwaremx[it_mxbt].ifrel = s_mx.ifrel
  2911. inwaremx[it_mxbt].relid = s_mx.relid
  2912. inwaremx[it_mxbt].relprintid = s_mx.relprintid
  2913. inwaremx[it_mxbt].relcode = ls_relcode
  2914. inwaremx[it_mxbt].checkqty = s_mx.checkqty
  2915. inwaremx[it_mxbt].result = s_mx.result
  2916. inwaremx[it_mxbt].relbillid = s_mx.relbillid
  2917. inwaremx[it_mxbt].relbillprintid = s_mx.relbillprintid
  2918. inwaremx[it_mxbt].relbillcode = ls_relbillcode
  2919. inwaremx[it_mxbt].unit = s_mx.unit
  2920. IF uo_option_2unit = 0 THEN
  2921. s_mx.uqty = s_mx.qty
  2922. END IF
  2923. inwaremx[it_mxbt].uqty = s_mx.uqty
  2924. IF s_mx.uqty <> 0 THEN
  2925. inwaremx[it_mxbt].rate = s_mx.qty/s_mx.uqty
  2926. ELSE
  2927. inwaremx[it_mxbt].rate = 0
  2928. END IF
  2929. inwaremx[it_mxbt].qty = s_mx.qty
  2930. inwaremx[it_mxbt].jgprice = s_mx.jgprice //加工价, 本位币, 外协单位
  2931. inwaremx[it_mxbt].rebate = s_mx.rebate
  2932. inwaremx[it_mxbt].taxrate = s_mx.taxrate
  2933. IF s_mx.qty <> 0 THEN
  2934. inwaremx[it_mxbt].uprice = Round(s_mx.jgprice * s_mx.uqty/s_mx.qty,5) //加工价, 本位币, 库存单位
  2935. ELSE
  2936. inwaremx[it_mxbt].uprice = 0
  2937. END IF
  2938. inwaremx[it_mxbt].fprice = s_mx.fprice //材料成本价, 本位币, 库存单位
  2939. inwaremx[it_mxbt].price = inwaremx[it_mxbt].uprice * s_mx.rebate + s_mx.fprice //材料实价,本位币,库存单位(进仓成本价)
  2940. inwaremx[it_mxbt].mxtype = s_mx.mxtype
  2941. IF billtype = 1 THEN
  2942. String ls_sptmtrlname
  2943. uo_spt_price uo_price
  2944. uo_price = Create uo_spt_price
  2945. IF uo_price.uof_getmtrlname(sptid,s_mx.mtrlid,ls_sptmtrlname,arg_msg) = 0 THEN
  2946. rslt = 0
  2947. GOTO ext
  2948. END IF
  2949. Destroy uo_price
  2950. inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname
  2951. END IF
  2952. IF thflag = 1 THEN
  2953. SELECT cost
  2954. INTO :ld_cost
  2955. FROM u_mtrlware
  2956. WHERE scid = :scid
  2957. AND mtrlid = :s_mx.mtrlid
  2958. AND status = :s_mx.status
  2959. AND plancode = :s_mx.plancode
  2960. AND woodcode = :s_mx.woodcode
  2961. AND pcode = :s_mx.pcode
  2962. AND mtrlcuscode = :s_mx.mtrlcuscode
  2963. AND location = :s_mx.location
  2964. AND storageid = :s_mx.storageid
  2965. AND dxflag = :dxflag
  2966. And sptid = 0;
  2967. IF sqlca.SQLCode <> 0 Or IsNull(ld_cost) THEN ld_cost = 0
  2968. inwaremx[it_mxbt].cost = ld_cost
  2969. ELSE
  2970. inwaremx[it_mxbt].cost = (inwaremx[it_mxbt].uprice * s_mx.rebate) + inwaremx[it_mxbt].fprice //进仓成本价,本位币,库存单位
  2971. END IF
  2972. ext:
  2973. Destroy uo_sptprice
  2974. IF rslt = 0 THEN p_clearmx()
  2975. Return(rslt)
  2976. end function
  2977. public function integer acceptmx_bef (s_wfjgmx_in_bef s_mx, ref string arg_msg);
  2978. Long rslt = 1,cnt = 0,LS_i
  2979. Long i_mtrlid,i_sptid
  2980. String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
  2981. Double i_cost,i_newprice
  2982. Decimal i_allouseqty
  2983. String ls_relcode
  2984. Decimal ld_rate = 1
  2985. IF it_newbegin = False And it_updatebegin = False THEN
  2986. rslt = 0
  2987. arg_msg = "非编辑状态不可以使用,操作取消"
  2988. GOTO ext
  2989. END IF
  2990. IF IsNull(s_mx.mtrlwareid) THEN s_mx.mtrlwareid = 0
  2991. IF IsNull(s_mx.printid) THEN s_mx.printid = 0
  2992. IF IsNull(s_mx.qty) THEN s_mx.qty = 0
  2993. IF IsNull(s_mx.mxdscrp) THEN s_mx.mxdscrp = ''
  2994. IF IsNull(s_mx.unit) THEN s_mx.unit = ''
  2995. IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
  2996. IF IsNull(s_mx.rate) THEN s_mx.rate = 0
  2997. IF IsNull(s_mx.relprintid) THEN s_mx.relprintid = 0
  2998. IF s_mx.mtrlwareid = 0 Or s_mx.qty = 0 THEN
  2999. rslt = 1
  3000. GOTO ext
  3001. END IF
  3002. SELECT ow_wfjgware.mtrlid,
  3003. ow_wfjgware.sptid,
  3004. ow_wfjgware.plancode,
  3005. ow_wfjgware.status,
  3006. ow_wfjgware.cost,
  3007. u_mtrldef.mtrlcode,
  3008. ow_wfjgware.woodcode,
  3009. ow_wfjgware.pcode,
  3010. ow_wfjgware.noallocqty
  3011. INTO :i_mtrlid,
  3012. :i_sptid,
  3013. :i_plancode,
  3014. :i_status,
  3015. :i_cost,
  3016. :i_mtrlcode,
  3017. :i_woodcode,
  3018. :i_pcode,
  3019. :i_allouseqty
  3020. FROM ow_wfjgware ,u_mtrldef
  3021. WHERE ( ow_wfjgware.mtrlwareid = :s_mx.mtrlwareid )
  3022. AND ( ow_wfjgware.mtrlid = u_mtrldef.mtrlid )
  3023. Using commit_transaction;
  3024. IF commit_transaction.SQLCode <> 0 THEN
  3025. rslt = 0
  3026. arg_msg = "查询操作失败,库存编号错误"
  3027. GOTO ext
  3028. END IF
  3029. IF IsNull(i_cost) THEN i_cost = 0
  3030. IF IsNull(i_plancode) THEN i_plancode = ''
  3031. IF IsNull(i_status) THEN i_status = ''
  3032. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  3033. IF IsNull(i_sptid) THEN i_sptid = 0
  3034. IF IsNull(i_woodcode) THEN i_woodcode = ''
  3035. IF IsNull(i_pcode) THEN i_pcode = ''
  3036. IF sptid <> i_sptid THEN
  3037. arg_msg = "物料:" + String(i_mtrlcode) + '所属加工商资料不对应'
  3038. rslt = 0
  3039. GOTO ext
  3040. END IF
  3041. IF i_cost < 0 THEN //检查进仓价
  3042. rslt = 0
  3043. arg_msg = "物料:" + String(i_mtrlcode)+" 单价错误"
  3044. GOTO ext
  3045. END IF
  3046. //外协收货,检查供应商库存是否足够;
  3047. //外协返工,检查仓库是否足够;
  3048. IF sys_option_wfjg_in_chksptware = 1 THEN
  3049. IF s_mx.qty > 0 THEN //
  3050. IF i_allouseqty < s_mx.qty THEN //检查库存数
  3051. rslt = 0
  3052. arg_msg = "物料:" + String(i_mtrlcode)+' 外协商库存数量:'+String(i_allouseqty,'#,##0.##########')+'少于本次扣减数量:'+String(s_mx.qty,'#,##0.##########')
  3053. GOTO ext
  3054. END IF
  3055. END IF
  3056. END IF
  3057. //写入内容
  3058. it_mxbt_bef++
  3059. inwaremx_bef[it_mxbt_bef].mtrlwareid = s_mx.mtrlwareid
  3060. inwaremx_bef[it_mxbt_bef].mtrlid = i_mtrlid
  3061. inwaremx_bef[it_mxbt_bef].status = i_status
  3062. inwaremx_bef[it_mxbt_bef].qty = s_mx.qty
  3063. inwaremx_bef[it_mxbt_bef].sptid = i_sptid
  3064. inwaremx_bef[it_mxbt_bef].plancode = i_plancode
  3065. inwaremx_bef[it_mxbt_bef].mtrlcode = i_mtrlcode
  3066. inwaremx_bef[it_mxbt_bef].mxdscrp = s_mx.mxdscrp
  3067. inwaremx_bef[it_mxbt_bef].printid = s_mx.printid
  3068. inwaremx_bef[it_mxbt_bef].fprice = i_cost
  3069. inwaremx_bef[it_mxbt_bef].woodcode = i_woodcode
  3070. inwaremx_bef[it_mxbt_bef].pcode = i_pcode
  3071. inwaremx_bef[it_mxbt_bef].unit = s_mx.unit
  3072. inwaremx_bef[it_mxbt_bef].uqty = s_mx.uqty
  3073. inwaremx_bef[it_mxbt_bef].relprintid = s_mx.relprintid
  3074. IF s_mx.uqty <> 0 THEN
  3075. inwaremx_bef[it_mxbt_bef].rate = s_mx.qty / s_mx.uqty
  3076. ELSE
  3077. inwaremx_bef[it_mxbt_bef].rate = 0
  3078. END IF
  3079. ext:
  3080. IF rslt = 0 THEN p_clearmx()
  3081. RETURN rslt
  3082. end function
  3083. public function integer p_create_wfjgorder (string arg_opemp, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1,i
  3084. Long rst_wfjgid
  3085. uo_order_wfjg uo_wforder
  3086. uo_wforder = Create uo_order_wfjg
  3087. uo_wforder.commit_transaction = commit_transaction
  3088. IF uo_wforder.newbegin(scid,arg_msg) = 0 THEN //
  3089. rslt = 0
  3090. GOTO ext
  3091. END IF
  3092. uo_wforder.Requiredate = indate
  3093. uo_wforder.Assign_emp = inrep
  3094. uo_wforder.sptID = sptID
  3095. uo_wforder.dscrp = '返工单审核自动生成的外协订单'
  3096. uo_wforder.billtype = 4
  3097. uo_wforder.reason = ''
  3098. uo_wforder.relcode = inwarecode
  3099. FOR i = 1 To it_mxbt
  3100. IF uo_wforder.acceptmx(0,&
  3101. 0,&
  3102. '',&
  3103. inwaremx[i].mtrlid,&
  3104. abs(inwaremx[i].qty),&
  3105. inwaremx[i].jgprice,&
  3106. inwaremx[i].mxdscrp,&
  3107. inwaremx[i].mtrlcode,&
  3108. arg_msg,&
  3109. i,&
  3110. indate,&
  3111. 0,&
  3112. inwaremx[i].jgdscrp,&
  3113. inwaremx[i].status,&
  3114. inwaremx[i].woodcode,&
  3115. inwaremx[i].pcode,&
  3116. 0,&
  3117. 0,&
  3118. 0,&
  3119. '[常规]',&
  3120. inwaremx[i].unit,&
  3121. abs(inwaremx[i].uqty),&
  3122. inwaremx[i].rate,&
  3123. 0,&
  3124. inwaremx[i].plancode,&
  3125. 0,0) = 0 THEN
  3126. rslt = 0
  3127. GOTO ext
  3128. END IF
  3129. NEXT
  3130. FOR i = 1 To it_mxbt
  3131. IF uo_wforder.acceptmx_out(0,&
  3132. 0,&
  3133. '',&
  3134. inwaremx_bef[i].mtrlid,&
  3135. abs(inwaremx_bef[i].qty),&
  3136. inwaremx_bef[i].fprice,&
  3137. inwaremx_bef[i].mxdscrp,&
  3138. inwaremx_bef[i].mtrlcode,&
  3139. arg_msg,&
  3140. i,&
  3141. 0,&
  3142. inwaremx_bef[i].status,&
  3143. inwaremx_bef[i].woodcode,&
  3144. inwaremx_bef[i].pcode,&
  3145. inwaremx_bef[i].unit,&
  3146. abs(inwaremx_bef[i].uqty),&
  3147. inwaremx_bef[i].rate,&
  3148. i,&
  3149. 0) = 0 THEN
  3150. rslt = 0
  3151. GOTO ext
  3152. END IF
  3153. NEXT
  3154. IF uo_wforder.savesubmit(arg_opemp,arg_msg,False) = 0 THEN
  3155. rslt = 0
  3156. GOTO ext
  3157. END IF
  3158. rst_wfjgid = uo_wforder.wfjgid
  3159. IF uo_wforder.firstpermit(scid,rst_wfjgid,arg_opemp,arg_msg,False) = 0 THEN
  3160. rslt = 0
  3161. GOTO ext
  3162. END IF
  3163. UPDATE ow_wfjg_in
  3164. SET relint_3 = :rst_wfjgid
  3165. WHERE scid = :scid
  3166. And inwareid = :inwareid Using commit_transaction;
  3167. IF commit_transaction.SQLCode <> 0 THEN
  3168. arg_msg = '记录相关返工外协订单id失败,'+commit_transaction.SQLErrText
  3169. rslt = 0
  3170. GOTO ext
  3171. END IF
  3172. ext:
  3173. IF rslt = 0 THEN
  3174. ROLLBACK Using commit_transaction;
  3175. ELSEIF arg_ifcommit And rslt = 1 THEN
  3176. COMMIT Using commit_transaction;
  3177. END IF
  3178. Destroy uo_wforder
  3179. RETURN rslt
  3180. end function
  3181. public function integer p_destroy_wfjgorder (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  3182. uo_order_wfjg uo_wforder
  3183. uo_wforder = Create uo_order_wfjg
  3184. uo_wforder.commit_transaction = commit_transaction
  3185. uo_wforder.caudit_checkauto = 1
  3186. IF inwareid = 0 THEN
  3187. rslt = 0
  3188. arg_msg = "没有审核对象"
  3189. GOTO ext
  3190. END IF
  3191. IF relint_3 = 0 THEN
  3192. rslt = 1
  3193. GOTO ext
  3194. END IF
  3195. IF uo_wforder.cancelpermit(scid,relint_3,arg_msg,False) = 0 THEN
  3196. rslt = 0
  3197. GOTO ext
  3198. END IF
  3199. IF uo_wforder.Cancel(scid,relint_3,arg_msg,False) = 0 THEN
  3200. rslt = 0
  3201. GOTO ext
  3202. END IF
  3203. UPDATE ow_wfjg_in
  3204. SET relint_3 = 0
  3205. WHERE scid = :scid
  3206. And inwareid = :inwareid Using commit_transaction;
  3207. IF commit_transaction.SQLCode <> 0 THEN
  3208. arg_msg = '清除相关返工外协订单id失败,'+commit_transaction.SQLErrText
  3209. rslt = 0
  3210. GOTO ext
  3211. END IF
  3212. ext:
  3213. IF rslt = 0 THEN
  3214. ROLLBACK Using commit_transaction;
  3215. ELSEIF arg_ifcommit And rslt = 1 THEN
  3216. COMMIT Using commit_transaction;
  3217. END IF
  3218. Destroy uo_wforder
  3219. RETURN rslt
  3220. end function
  3221. public function integer uof_check_sptpdb_audit (long arg_sptid, ref string arg_msg);Int rslt = 1
  3222. Long cnt
  3223. if billtype = 9 then goto ext //盘点单不算
  3224. SELECT count(*)
  3225. INTO :cnt
  3226. FROM ow_wfjg_sptpdb
  3227. WHERE sptid = :arg_sptid
  3228. And flag = 0 Using commit_transaction;
  3229. IF commit_transaction.SQLCode <> 0 THEN
  3230. rslt = 0
  3231. arg_msg = '查询外协商库存是否有盘点表未审核失败,'+commit_transaction.SQLErrText
  3232. GOTO ext
  3233. END IF
  3234. IF cnt > 0 THEN
  3235. rslt = 0
  3236. arg_msg = '外协商库存有盘点表未审核,不能仓审或仓撤单据,请检查'
  3237. GOTO ext
  3238. END IF
  3239. ext:
  3240. RETURN rslt
  3241. end function
  3242. 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
  3243. uo_inware uo_in
  3244. uo_in = Create uo_inware
  3245. uo_in.commit_transaction = sqlca
  3246. IF p_getinfo(arg_scid,arg_inwareid,arg_msg) = 0 THEN
  3247. rslt = 0
  3248. GOTO ext
  3249. END IF
  3250. IF flag = 0 THEN
  3251. rslt = 0
  3252. arg_msg = '进仓单待审核状态下不能执行修改单价功能'
  3253. GOTO ext
  3254. END IF
  3255. Decimal ld_jgprice,ld_fprice,ld_uqty,ld_rate,ld_qty,ld_rebate,ld_taxrate
  3256. Long ll_mtrlid
  3257. String ls_status,ls_woodcode,ls_pcode
  3258. Long ll_storageid
  3259. SELECT jgprice,
  3260. fprice,
  3261. uqty,
  3262. qty,
  3263. rebate,
  3264. mtrlid,
  3265. status,
  3266. woodcode,
  3267. pcode,
  3268. storageid,
  3269. rate,
  3270. taxrate
  3271. INTO :ld_jgprice,
  3272. :ld_fprice,
  3273. :ld_uqty,
  3274. :ld_qty,
  3275. :ld_rebate,
  3276. :ll_mtrlid,
  3277. :ls_status,
  3278. :ls_woodcode,
  3279. :ls_pcode,
  3280. :ll_storageid,
  3281. :ld_rate,
  3282. :ld_taxrate
  3283. FROM ow_wfjgmx_in_aft
  3284. WHERE scid = :arg_scid
  3285. AND inwareid = :arg_inwareid
  3286. AND printid = :arg_printid
  3287. Using commit_transaction;
  3288. IF commit_transaction.SQLCode <> 0 THEN
  3289. rslt = 0
  3290. arg_msg = '查询单据明细内容失败'+commit_transaction.SQLErrText
  3291. GOTO ext
  3292. END IF
  3293. IF arg_taxrate = -1 THEN arg_taxrate = ld_taxrate
  3294. IF arg_rebate = -1 THEN arg_rebate = ld_rebate
  3295. IF secflag = 1 THEN
  3296. IF arg_jgprice <> ld_jgprice Or arg_taxrate <> ld_taxrate or arg_rebate = ld_rebate THEN //可以修改材料成本价
  3297. rslt = 0
  3298. arg_msg = '进仓单已财审,不能执行修改加工价、折扣、税率'
  3299. GOTO ext
  3300. END IF
  3301. END IF
  3302. IF arg_jgprice = ld_jgprice And arg_fprice = ld_fprice And arg_taxrate = ld_taxrate and arg_rebate = ld_rebate THEN //没有修改,成功返回
  3303. rslt = 1
  3304. //arg_msg = '单价或税率没有任何修改,不能保存'
  3305. GOTO ext
  3306. END IF
  3307. Long ll_inwareid, ll_balcdateint, ll_cnt
  3308. Int li_balcflag
  3309. Int li_StoreBalcType
  3310. Int li_storagetype
  3311. IF billtype = 4 THEN //仓库外协需更新仓库进仓单, 车间外协不需要
  3312. SELECT storagetype, StoreBalcType
  3313. INTO :li_storagetype, :li_StoreBalcType
  3314. FROM u_storage
  3315. Where storageid = :ll_storageid Using commit_transaction ;
  3316. IF commit_transaction.SQLCode <> 0 THEN
  3317. rslt = 0
  3318. arg_msg = "查询操作失败,仓库属性"
  3319. GOTO ext
  3320. END IF
  3321. SELECT inwareid,balcflag,balcdateint
  3322. INTO :ll_inwareid,:li_balcflag,:ll_balcdateint
  3323. FROM u_inware
  3324. WHERE scid = :arg_scid
  3325. AND relid = :arg_inwareid
  3326. AND storageid = :ll_storageid
  3327. And billtype = 4 Using commit_transaction;
  3328. IF commit_transaction.SQLCode <> 0 THEN
  3329. rslt = 0
  3330. arg_msg = '查询相关进仓单失败'+commit_transaction.SQLErrText
  3331. GOTO ext
  3332. END IF
  3333. IF li_StoreBalcType = 0 THEN
  3334. IF li_balcflag = 1 THEN
  3335. rslt = 0
  3336. arg_msg = '外协收货单相关进仓单已结存,期间['+string(ll_balcdateint)+'],不能修改'
  3337. GOTO ext
  3338. END IF
  3339. ELSE
  3340. SELECT count(*)
  3341. INTO :ll_cnt
  3342. FROM u_warebalc
  3343. WHERE storageid = :ll_storageid
  3344. AND balcdateint = :ll_balcdateint
  3345. AND AmtAuditFlag = 1
  3346. Using commit_transaction;
  3347. IF commit_transaction.SQLCode <> 0 THEN
  3348. rslt = 0
  3349. arg_msg = "查询操作失败,仓库属性"
  3350. GOTO ext
  3351. END IF
  3352. IF ll_cnt > 0 THEN
  3353. rslt = 0
  3354. arg_msg = '外协收货单相关进仓仓库已金额结存,期间['+string(ll_balcdateint)+'],不能修改'
  3355. GOTO ext
  3356. END IF
  3357. END IF
  3358. END IF
  3359. Decimal ld_uprice_new,ld_price_new,ld_cost_new
  3360. IF ld_qty <> 0 THEN
  3361. ld_uprice_new = Round(arg_jgprice * ld_uqty/ld_qty,5)
  3362. ELSE
  3363. ld_uprice_new = 0
  3364. END IF
  3365. ld_cost_new = ld_uprice_new * arg_rebate + arg_fprice
  3366. ld_price_new = ld_uprice_new * arg_rebate + arg_fprice
  3367. UPDATE ow_wfjgmx_in_aft
  3368. SET jgprice = :arg_jgprice,
  3369. fprice = :arg_fprice,
  3370. uprice = :ld_uprice_new,
  3371. price = :ld_price_new,
  3372. cost = :ld_cost_new,
  3373. taxrate = :arg_taxrate,
  3374. rebate = :arg_rebate
  3375. WHERE scid = :arg_scid
  3376. AND inwareid = :arg_inwareid
  3377. And printid = :arg_printid Using commit_transaction;
  3378. IF commit_transaction.SQLCode <> 0 THEN
  3379. rslt = 0
  3380. arg_msg = '更新单据明细失败'+commit_transaction.SQLErrText
  3381. GOTO ext
  3382. END IF
  3383. IF billtype = 4 THEN
  3384. 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
  3385. rslt = 0
  3386. GOTO ext
  3387. END IF
  3388. END IF
  3389. ext:
  3390. Destroy uo_in
  3391. IF rslt = 0 THEN
  3392. ROLLBACK Using commit_transaction;
  3393. ELSEIF rslt = 1 And arg_ifcommit THEN
  3394. COMMIT Using commit_transaction;
  3395. END IF
  3396. RETURN rslt
  3397. end function
  3398. on uo_inware_wfjg.create
  3399. call super::create
  3400. TriggerEvent( this, "constructor" )
  3401. end on
  3402. on uo_inware_wfjg.destroy
  3403. TriggerEvent( this, "destructor" )
  3404. call super::destroy
  3405. end on
  3406. event constructor;String str_optionvalue,arg_msg
  3407. f_get_sys_option_value('086',str_optionvalue,arg_msg)
  3408. uo_option_wfjg_outmx = Long(str_optionvalue)
  3409. f_get_sys_option_value('169',str_optionvalue,arg_msg)
  3410. uo_option_wfjg_sptprice_sec = Long(str_optionvalue)
  3411. f_get_sys_option_value('131',str_optionvalue,arg_msg)
  3412. uo_option_check_wfjgin = Long(str_optionvalue)
  3413. f_get_sys_option_value('184',str_optionvalue,arg_msg)
  3414. uo_option_wfjg_zero = Long(str_optionvalue)
  3415. f_get_sys_option_value('067',str_optionvalue,arg_msg)
  3416. uo_option_2unit = Long(str_optionvalue)
  3417. f_get_sys_option_value('029',str_optionvalue,arg_msg)
  3418. uo_option_change_status = str_optionvalue
  3419. f_get_sys_option_value('027',str_optionvalue,arg_msg)
  3420. uo_option_change_woodcode = str_optionvalue
  3421. f_get_sys_option_value('028',str_optionvalue,arg_msg)
  3422. uo_option_change_pcode = str_optionvalue
  3423. f_get_sys_option_value('010',str_optionvalue,arg_msg)
  3424. uo_option_ifovertask = Long(str_optionvalue)
  3425. f_get_sys_option_value('322',str_optionvalue,arg_msg)
  3426. uo_option_wfjg_th_ifnotorder = Long(str_optionvalue)
  3427. f_get_sys_option_value('362',str_optionvalue,arg_msg)
  3428. uo_option_cost_notax = long(str_optionvalue)
  3429. end event