12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205 |
- $PBExportHeader$uo_outware.sru
- forward
- global type uo_outware from nonvisualobject
- end type
- end forward
- global type uo_outware from nonvisualobject
- end type
- global uo_outware uo_outware
- type variables
- Public ProtectedWrite Long scid = 0 //分部id
- Public ProtectedWrite Long outwareid //进仓单表自动增量id
- Public ProtectedWrite String outwarecode //单据的唯一编号
- Public ProtectedWrite Int billtype = 0 //业务类型
- Public ProtectedWrite DateTime opdate //建立时间,自动
- Public ProtectedWrite String opemp //建立操作员
- Public ProtectedWrite DateTime moddate //修改时间,自动
- Public ProtectedWrite String modemp //修改操作员
- Public ProtectedWrite Int balcflag = 0 //仓库日结标志
- Public ProtectedWrite Int flag = 0 //仓库审核标志
- Public ProtectedWrite DateTime auditingdate //审核时间
- Public ProtectedWrite String auditingrep //审核操作员
- Public ProtectedWrite Int secflag = 0 //财务审核标志
- Public ProtectedWrite DateTime secauditingdate //二审核时间
- Public ProtectedWrite String secauditingrep //二审核操作员
- Public ProtectedWrite Decimal sum_amt = 0 //单据总金额
- Public ProtectedWrite Decimal sum_amt_en = 0 //单据总金额(其它单价)
- Public ProtectedWrite long balcdateint = 0
- Public ProtectedWrite Decimal sum_taxamt = 0 //单据税额
- Public ProtectedWrite Decimal sum_taxamt_en = 0 //单据税额(其它单价)
- Public ProtectedWrite Int priceflag = 0 //确认标志
- Public ProtectedWrite DateTime pricedate //确认时间
- Public ProtectedWrite String priceemp //确认操作员
- Public ProtectedWrite Long ctmint
- Long relid = 0 //关联id
- Long storageid = 0 //进仓仓库
- DateTime outdate //进仓发生时间
- String outrep = '' //经手人
- String part = '' //相关号码
- String dscrp = '' //备注
- Long cusid = 0 //客户id
- String cusname = '' //客户名称(不记帐模式使用)
- Int thflag = 0 //退货标记
- Int ifauto = 0
- String relstr_1
- String relstr_2
- String relstr_3
- Long relint_1
- Long relint_2
- Long relint_3
- long relint_4
- Decimal otheramt
- Decimal damt
- Decimal mrate
- String rel_address
- String rel_tele
- String rel_fax
- String rel_rep
- String upname
- DateTime viewdate
- Long storagescid = 0 //仓库分部ID
- Long deptid = 0
- long typeid = 0
- String carcode
- String transcode
- Decimal totalamt
- Decimal getamt
- Int lsflag
- Int pda_flag
- DateTime pda_date
- long exchangeid
- string station_address
- Boolean if_getid_ture = True
- Transaction commit_transaction //数据commit事务
- s_outwaremx outwaremx[], ins_ref_outwaremx[],ins_empty_outwaremx[] //明细结构数组
- long ins_ref_mxbt = 0
- s_outwaremx_mx outwaremx_mx[]
- s_outwaremx_barcode s_mx_barcode[]
- s_outware_itemmx outware_itemmx[]
- Long it_mxbt = 0 //明细结构数组末指针
- Long it_mxbt_mx = 0
- Long it_mxbt_barcode = 0
- Long it_mxbt_item = 0
- Boolean it_newbegin = False //新建标志
- Boolean it_updatebegin = False //修改标志
- Boolean if_pd_py_check_barcode = False
- Int uo_option_autowaste,uo_option_inout_type
- Int uo_option_barcode_outwareother_paudit
- Int uo_option_confirmaudit_sale,uo_option_sale_use_planqty
- Int uo_option_confirmaudit_scll,uo_option_cost_dec
- String uo_option_change_status,uo_option_change_woodcode,uo_option_change_pcode
- Int uo_option_mtrlware_autocmp,uo_option_mtrlware_limit
- Int uo_option_scll_limit,uo_option_if_pricetype
- Int uo_option_checkprice_native
- Int uo_option_if_saleout
- Int uo_option_disuse_outware_sale
- Int uo_option_sale_ifuse_negativeprice
- Int uo_option_pda_sale_lock
- Int uo_option_price_rmb
- int uo_option_outware_sale_checkprice
- int uo_option_scll_use_planqty
- int uo_option_barcodelocation_use_inwaremx_location
- int uo_option_djqty_check
- int uo_option_outware_saleout
- int uo_option_scllplan_outware_auto
- int uo_option_noauditingqty_mode
- int uo_option_outware_pack_save_cmp
- int uo_option_pk_notauditqty_check
- int uo_option_canpack_ifzanyong
- end variables
- forward prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer p_reset ()
- public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit)
- public function integer del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg)
- public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg)
- public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit)
- public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_check_qty_to_bqty (ref string arg_msg)
- public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
- public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg)
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula)
- public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg)
- public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit)
- public function integer uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg)
- protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg)
- public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg)
- public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg)
- public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg)
- end prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF Not (arg_billtype = 1 OR &
- arg_billtype = 2 OR &
- arg_billtype = 3 OR &
- arg_billtype = 4 OR &
- arg_billtype = 5 OR &
- arg_billtype = 6 OR &
- arg_billtype = 7 OR &
- arg_billtype = 8 OR &
- arg_billtype = 9 OR &
- arg_billtype = 10 OR &
- arg_billtype = 12 OR &
- arg_billtype = 15 OR &
- arg_billtype = 16 OR &
- arg_billtype = 17 or &
- arg_billtype = 18 or &
- arg_billtype = 19 or &
- arg_billtype = 20 or &
- arg_billtype = 21 or &
- arg_billtype = 22 or &
- arg_billtype = 23 or &
- arg_billtype = 24 or &
- arg_billtype = 25) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'1-销售出仓单[记帐模式],'
- arg_msg = arg_msg+'2-销售出仓单[不记帐模式],'
- arg_msg = arg_msg+'3-领料出仓单,'
- arg_msg = arg_msg+'4-外协出仓单,'
- arg_msg = arg_msg+'5-来料加工发货,'
- arg_msg = arg_msg+'6-售后服务出仓单,'
- arg_msg = arg_msg+'7-外协销售出仓单,'
- arg_msg = arg_msg+'8-其它出仓单,'
- arg_msg = arg_msg+'9-盘亏出仓单,'
- arg_msg = arg_msg+'10-工具出仓单,'
- arg_msg = arg_msg+'12-调拨出仓单'
- arg_msg = arg_msg+'15-拆装出仓单'
- arg_msg = arg_msg+'16-生产进仓车间自动出仓单(未分配)'
- arg_msg = arg_msg+'17-还货出仓单'
- arg_msg = arg_msg+'18-自动组装出仓单'
- arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)'
- arg_msg = arg_msg+'20-车间库存转换自动出仓单'
- arg_msg = arg_msg+'21-送货单包件明细自动出仓单'
- arg_msg = arg_msg+'22-欠货终止单自动出仓单'
- arg_msg = arg_msg+'23-收货单收货明细自动出仓单'
- arg_msg = arg_msg+'24-员工物品领用单'
- arg_msg = arg_msg+'25-发料损耗自动出仓单'
- GOTO ext
- END IF
- p_reset()
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = TRUE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1
- Long cnt = 0,i,j
- DateTime server_dt
- Long ls_newid
- Int li_outtype
- String ls_storagename
- String ls_sccode
- Decimal ld_trueoverqty
- Int li_ifmrp
- Long ll_mtrlid_arr[]
- Decimal ld_qty_arr[]
- String ls_mtrlcode_arr[]
- Long ll_mxcnt = 0
- Decimal ld_djqty,ld_noallocqty
- Int li_priceflag
- Long ll_cnt_billtype21
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- IF uo_option_disuse_outware_sale = -1000 THEN
- rslt = 0
- arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_price_rmb = -1000 THEN
- arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!'
- rslt = 0
- GOTO ext
- END IF
- IF uo_option_djqty_check = -1000 THEN
- rslt = 0
- arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF IsNull(relid) THEN relid = 0
- IF IsNull(storageid) THEN storageid = 0
- IF IsNull(outrep) THEN outrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(cusid) THEN cusid = 0
- IF IsNull(cusname) THEN cusname = ''
- IF IsNull(thflag) THEN thflag = 0
- IF IsNull(otheramt) THEN otheramt = 0
- IF IsNull(damt) THEN damt = 0
- IF IsNull(relstr_1) THEN relstr_1 = ''
- IF IsNull(relstr_2) THEN relstr_2 = ''
- IF IsNull(relstr_3) THEN relstr_3 = ''
- IF IsNull(relint_1) THEN relint_1 = 0
- IF IsNull(relint_2) THEN relint_2 = 0
- IF IsNull(relint_3) THEN relint_3 = 0
- IF IsNull(relint_4) THEN relint_4 = 0
- IF IsNull(mrate) THEN mrate = 0
- IF IsNull(ifauto) THEN ifauto = 0
- IF IsNull(rel_address) THEN rel_address = ''
- IF IsNull(rel_tele) THEN rel_tele = ''
- IF IsNull(rel_fax) THEN rel_fax = ''
- IF IsNull(rel_rep) THEN rel_rep = ''
- IF IsNull(upname) THEN upname = ''
- IF IsNull(deptid) THEN deptid = 0
- IF IsNull(totalamt) THEN totalamt = 0
- IF IsNull(getamt) THEN getamt = 0
- IF IsNull(lsflag) THEN lsflag = 0
- IF IsNull(carcode) THEN carcode = ''
- IF IsNull(transcode) THEN transcode = ''
- IF IsNull(typeid) THEN typeid = 0
- IF IsNull(exchangeid) THEN exchangeid = 0
- IF IsNull(station_address) THEN station_address = ''
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确出仓内容"
- GOTO ext
- END IF
- //yyx20150529发货单使用先确认后仓审模式在修改保存操作增加检查单据状态
- IF uo_option_confirmaudit_sale = 1 THEN
- IF billtype = 1 And outwareid > 0 And priceflag = 0 THEN
- SELECT priceflag INTO :li_priceflag
- FROM u_outware
- WHERE u_outware.outwareid = :outwareid
- And u_outware.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询单据确认状态操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF li_priceflag = 1 THEN
- arg_msg = '单据已经确认,不能保存,操作取消'
- rslt = 0
- GOTO ext
- ELSE
- SELECT count(*) INTO :ll_cnt_billtype21
- FROM u_outware
- WHERE u_outware.relid = :outwareid
- AND u_outware.scid = :scid
- And billtype = 21 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询单据是否已确认操作生成销售出仓单失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF ll_cnt_billtype21 > 0 THEN
- arg_msg = '单据已确认操作生成销售出仓单,不能保存,操作取消'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- //
- Int li_mustloca,li_nocheck_bjmx
- SELECT storagename,outtype,mustloca,nocheck_bjmx,ifmrp
- INTO :ls_storagename,:li_outtype,:li_mustloca,:li_nocheck_bjmx,:li_ifmrp
- FROM u_storage
- Where storageid = :storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF li_nocheck_bjmx = 0 THEN
- IF li_outtype <> 0 And billtype = 1 And flag = 0 THEN
- IF it_mxbt_mx = 0 THEN
- rslt = 0
- arg_msg = "没有正确包件明细"
- GOTO ext
- END IF
- END IF
- END IF
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_new <> '0' THEN
- IF Pos(sys_user_storagestr_new,','+String(storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许建立该仓库的单据'
- GOTO ext
- END IF
- END IF
- //
- IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
- rslt = 0
- arg_msg = "缺少出仓发生时间或不合理"
- GOTO ext
- END IF
- IF flag = 0 THEN
- Boolean lb_chk_balc = True
- IF sys_option_warebalc_checksale = 0 And billtype = 21 THEN //临时的,详见系统选项152
- lb_chk_balc = False
- END IF
- IF f_check_inoutdate(storageid,outdate,lb_chk_balc,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- IF billtype = 1 Or billtype = 5 THEN
- SELECT name INTO :cusname
- FROM u_cust
- Where cusid = :cusid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,客户资料"
- GOTO ext
- END IF
-
- IF billtype = 1 THEN
- IF relint_1 = 0 THEN
- arg_msg = '请选择结算方式'
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM cw_currency
- Where moneyid = :relint_2;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询币种失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- arg_msg = '币种资料不存在'
- rslt = 0
- GOTO ext
- END IF
-
- IF mrate = 0 THEN
- arg_msg = '币种汇率错误'
- rslt = 0
- GOTO ext
- END IF
-
-
- IF f_moneyid_rate_check(relint_2,mrate,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSEIF billtype = 4 Or billtype = 7 THEN
- SELECT name INTO :cusname
- FROM u_spt
- Where sptid = :cusid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,加工商资料"
- GOTO ext
- END IF
- ELSEIF billtype = 3 THEN
- IF relid = 0 THEN
- arg_msg = '请选择领料工组'
- rslt = 0
- GOTO ext
- END IF
-
- IF relint_1 = 1 Or relint_1 = 2 THEN
- IF cusname = '' THEN
- arg_msg = '请输入原因'
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSEIF billtype = 8 THEN
- IF Trim(cusname) = '' Or IsNull(cusname) THEN
- rslt = 0
- arg_msg = "请输入出仓原因!"
- GOTO ext
- END IF
- END IF
- If (thflag = 1 Or (billtype = 3 And relint_1 = 2 )) And li_mustloca = 1 THEN
- //
- String ls_msg_loca
- Long ll_cnt_loca
- ll_cnt_loca = 0
- FOR i = 1 To it_mxbt
- IF Trim(outwaremx[i].Location) = '' THEN
- ll_cnt_loca++
- IF ll_cnt_loca <= 10 THEN
- IF Trim(ls_msg_loca) = '' THEN
- ls_msg_loca = ls_msg_loca + String(i)
- ELSE
- ls_msg_loca = ls_msg_loca + ','+String(i)
- END IF
- END IF
- END IF
- NEXT
-
- IF ll_cnt_loca > 0 THEN
- rslt = 0
- IF ll_cnt_loca <= 10 THEN
- arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'明细中第'+ls_msg_loca+'行没有填仓位,请检查'
- ELSE
- arg_msg = '仓库属性已设为仓位必填'+'~r~n'+'其中第'+ls_msg_loca+'等'+String(ll_cnt_loca)+'行明细没有填仓位,请详细检查'
- END IF
-
- GOTO ext
- END IF
- END IF
- IF billtype = 1 And thflag = 0 And outwareid > 0 And uo_option_disuse_outware_sale = 1 THEN
- IF uof_disuse(scid,outwareid,0,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- //检查冻结数
- IF uo_option_djqty_check = 1 And li_ifmrp = 1 And Not ( billtype = 3 And relint_1 = 4) THEN
- FOR i = 1 To it_mxbt
- FOR j = 1 To ll_mxcnt
- IF outwaremx[i].mtrlid = ll_mtrlid_arr[j] THEN
- ld_qty_arr[j] = ld_qty_arr[j] + outwaremx[i].qty
- GOTO _next_mx
- END IF
- NEXT
-
- ll_mxcnt++
- ll_mtrlid_arr[ll_mxcnt] = outwaremx[i].mtrlid
- ld_qty_arr[ll_mxcnt] = outwaremx[i].qty
- ls_mtrlcode_arr[ll_mxcnt] = outwaremx[i].mtrlcode
- _next_mx:
- NEXT
-
- FOR i = 1 To ll_mxcnt
- SELECT SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) )
- INTO :ld_djqty
- FROM u_OrderRqMtrl_scll INNER JOIN
- u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN
- uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND
- u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND
- u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND
- u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND
- u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND
- u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode
- WHERE (u_OrderRqMtrl_scll.wareqty <> 0) AND (u_Order_ml.Status NOT IN (3,5,6))
- AND u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0
- AND u_OrderRqMtrl_scll.MtrlID = :ll_mtrlid_arr[i]
- And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- ld_djqty = 0
- END IF
-
- IF IsNull(ld_djqty) THEN ld_djqty = 0
-
- SELECT SUM(u_mtrlware.noallocqty)
- INTO :ld_noallocqty
- FROM u_mtrlware INNER JOIN
- u_storage ON u_mtrlware.storageid = u_storage.storageid
- WHERE (u_storage.inuse = 1)
- AND u_storage.ifmrp = 1
- AND u_mtrlware.mtrlid = :ll_mtrlid_arr[i]
- And u_mtrlware.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- ld_noallocqty = 0
- END IF
-
- IF IsNull(ld_noallocqty) THEN ld_noallocqty = 0
-
- IF ld_djqty > ld_noallocqty - ld_qty_arr[i] THEN
- rslt = 0
- arg_msg = '物料['+ls_mtrlcode_arr[i]+']冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########')+',本次出仓数:'+String(ld_qty_arr[i],'#,##0.##########')
- GOTO ext
- END IF
- NEXT
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF outwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_outware","outwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- CHOOSE CASE billtype
- CASE 1,2
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'XS',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- IF relid = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'XT',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relid = 1 THEN
- outwarecode = getid(scid,ls_sccode + 'QS',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- END IF
- CASE 3
- IF relint_1 = 0 THEN //生产领料
- outwarecode = getid(scid,ls_sccode + 'LL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relint_1 = 1 THEN //超额发料单
- outwarecode = getid(scid,ls_sccode + 'BL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relint_1 = 2 THEN //生产还料单
- outwarecode = getid(scid,ls_sccode + 'HL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relint_1 = 3 THEN //其他领料
- outwarecode = getid(scid,ls_sccode + 'OL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relint_1 = 4 THEN //发料单
- outwarecode = getid(scid,ls_sccode + 'FO',Date(server_dt),if_getid_ture,commit_transaction)
- ELSEIF relint_1 = 5 THEN //生产补料单
- outwarecode = getid(scid,ls_sccode + 'BU',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 4
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'KL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid(scid,ls_sccode + 'TL',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 5 //来料加工
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'XL',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid(scid,ls_sccode + 'LT',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 6
- outwarecode = getid(scid,ls_sccode + 'SU',Date(server_dt),if_getid_ture,commit_transaction)
-
- CASE 7
- IF thflag = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'KW',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid(scid,ls_sccode + 'TW',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
-
- CASE 8
- outwarecode = getid(scid,ls_sccode + 'CC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 9
- outwarecode = getid(scid,ls_sccode + 'PQ',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 10
- outwarecode = getid(scid,ls_sccode + 'KF',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 12
- outwarecode = getid(scid,ls_sccode + 'OC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 15
- outwarecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 16
- outwarecode = getid(scid,ls_sccode + 'LC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 17
- outwarecode = getid(scid,ls_sccode + 'RO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 18
- outwarecode = getid(scid,ls_sccode + 'OA',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 19
- outwarecode = getid(scid,ls_sccode + 'CO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 20
- outwarecode = getid(scid,ls_sccode + 'WO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 21
- outwarecode = getid(scid,ls_sccode + 'BO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 22
- outwarecode = getid(scid,ls_sccode + 'QO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 23
- outwarecode = getid(scid,ls_sccode + 'HO',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 24
- outwarecode = getid(scid,ls_sccode + 'LY',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 25
- outwarecode = getid(scid,ls_sccode + 'FW',Date(server_dt),if_getid_ture,commit_transaction)
-
- END CHOOSE
-
- IF outwarecode = "err" Or outwarecode = '' THEN
- outwarecode = ''
- rslt = 0
- arg_msg = "无法获取进仓单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
-
- INSERT INTO u_outware (
- scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- storageid,
- outdate,
- outrep,
- part,
- dscrp,
- cusid,
- cusname,
- thflag,
- opdate,
- opemp,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- relint_4,
- otheramt,
- damt,
- rel_address,
- rel_tele,
- rel_fax,
- rel_rep,
- mrate,
- upname,
- ifauto,
- viewdate,
- deptid,
- totalamt,
- getamt,
- lsflag,
- carcode,
- transcode,
- typeid,
- exchangeid,
- station_address)
- VALUES (
- :scid,
- :ls_newid,
- :outwarecode,
- :billtype,
- :relid,
- :storageid,
- :outdate,
- :outrep,
- :part,
- :dscrp,
- :cusid,
- :cusname,
- :thflag,
- :server_dt,
- :publ_operator,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :relint_1,
- :relint_2,
- :relint_3,
- :relint_4,
- :otheramt,
- :damt,
- :rel_address,
- :rel_tele,
- :rel_fax,
- :rel_rep,
- :mrate,
- :upname,
- :ifauto,
- :viewdate,
- :deptid,
- :totalamt,
- :getamt,
- :lsflag,
- :carcode,
- :transcode,
- :typeid,
- :exchangeid,
- :station_address) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新outwareid
- outwareid = ls_newid
-
- FOR i = 1 To it_mxbt
-
- //如果是发料单,计算实际超发数量
- IF billtype = 3 And relint_1 = 4 THEN
- IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN
- ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty
- ELSE
- ld_trueoverqty = 0
- END IF
- END IF
-
- INSERT INTO u_outwaremx
- (scid,
- outwareid,
- mtrlwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- sptid,
- dxflag,
- costamt,
- ifrel,
- relid,
- packqty,
- olmtrlid,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- outtypestr,
- dftsaleprice,
- cost,
- planqty,
- relprintid,
- unit,
- rate,
- uqty,
- storageid,
- scidprice,
- mtrlcuscode,
- location,
- pricetype,
- formula,
- capacity,
- saleqty,
- saleoutid,
- saleoutprintid,
- mxdscrp2,
- net_weight,
- gross_weight,
- cubage,
- taxrate,
- priceformula,
- qtyformula,
- enacprice,
- ifvqty,
- trueoverqty,
- backtype,
- ifnotinout)
- VALUES (
- :scid,
- :ls_newid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].printid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].plancode,
- :outwaremx[i].status,
- :outwaremx[i].qty,
- :outwaremx[i].fprice,
- :outwaremx[i].rebate,
- :outwaremx[i].price,
- :outwaremx[i].planprice,
- :outwaremx[i].mxdscrp,
- :outwaremx[i].sptid,
- :outwaremx[i].dxflag,
- :outwaremx[i].costamt,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].packqty,
- :outwaremx[i].olmtrlid,
- :outwaremx[i].woodcode,
- :outwaremx[i].relcode,
- :outwaremx[i].pcode,
- :outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,
- :outwaremx[i].outtype,
- :outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,
- :outwaremx[i].planqty,
- :outwaremx[i].relprintid,
- :outwaremx[i].unit,
- :outwaremx[i].rate,
- :outwaremx[i].uqty,
- :outwaremx[i].storageid,
- :outwaremx[i].scidprice,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].Location,
- :outwaremx[i].pricetype,
- :outwaremx[i].formula,
- :outwaremx[i].capacity,
- :outwaremx[i].qty,
- :outwaremx[i].saleoutid,
- :outwaremx[i].saleoutprintid,
- :outwaremx[i].mxdscrp2,
- :outwaremx[i].net_weight,
- :outwaremx[i].gross_weight,
- :outwaremx[i].cubage,
- :outwaremx[i].taxrate,
- :outwaremx[i].priceformula,
- :outwaremx[i].qtyformula,
- :outwaremx[i].enacprice,
- :outwaremx[i].ifvqty,
- :ld_trueoverqty,
- :outwaremx[i].backtype,
- :outwaremx[i].ifnotinout) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原outwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt_mx
- INSERT INTO u_outwaremx_mx
- (scid,
- outwareid,
- mtrlwareid,
- printid,
- mxprintid,
- mtrlid,
- plancode,
- status,
- qty,
- mxdscrp,
- sptid,
- dxflag,
- woodcode,
- pcode,
- planqty,
- storageid,
- mtrlcuscode,
- location,
- ifnotinout)
- VALUES (
- :scid,
- :ls_newid,
- :outwaremx_mx[i].mtrlwareid,
- :outwaremx_mx[i].printid,
- :outwaremx_mx[i].mxprintid,
- :outwaremx_mx[i].mtrlid,
- :outwaremx_mx[i].plancode,
- :outwaremx_mx[i].status,
- :outwaremx_mx[i].qty,
- :outwaremx_mx[i].mxdscrp,
- :outwaremx_mx[i].sptid,
- :outwaremx_mx[i].dxflag,
- :outwaremx_mx[i].woodcode,
- :outwaremx_mx[i].pcode,
- :outwaremx_mx[i].planqty,
- :outwaremx_mx[i].storageid,
- :outwaremx_mx[i].mtrlcuscode,
- :outwaremx_mx[i].Location,
- :outwaremx_mx[i].ifnotinout) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原outwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt_item
- INSERT INTO u_outware_itemmx
- (scid,
- outwareid,
- printid,
- itemid,
- amt,
- mxdscrp)
- VALUES (:scid,
- :ls_newid,
- :outware_itemmx[i].printid,
- :outware_itemmx[i].itemid,
- :outware_itemmx[i].amt,
- :outware_itemmx[i].mxdscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原taskid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //增加已开单数
- IF billtype <> 21 And billtype <> 12 THEN
- IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
-
- IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN
- FOR i = 1 To it_mxbt
- If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- END IF
- NEXT
- END IF
-
- ELSE //////////////////////////////////////////////// //更新
- // IF (billtype = 1 OR billtype = 5) AND sys_option_autowaste = 1 THEN
- // uo_outware_waste uo_waste
- // uo_waste = CREATE uo_outware_waste
- // uo_waste.commit_transaction = commit_transaction
- // IF uo_waste.insertwaste(1,scid,outwareid,arg_msg,FALSE) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- // DESTROY uo_waste
- // END IF
-
- IF uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 THEN
-
- ins_ref_mxbt = 1
- DECLARE cur_outwaremx_ori CURSOR FOR
- SELECT u_outwaremx.mtrlid,
- u_outwaremx.plancode,
- u_outwaremx.mtrlcuscode,
- u_outwaremx.storageid
- FROM u_outwaremx,u_mtrldef
- WHERE u_outwaremx.outwareid = :outwareid
- AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
- AND u_outwaremx.scid = :scid
- AND ( u_mtrldef.ifpack = 1 OR u_mtrldef.ifpack = 2 OR u_mtrldef.ifpackpro = 3 OR u_mtrldef.ifpackpro = 4 )
- Order By u_outwaremx.printid Using commit_transaction;
-
- OPEN cur_outwaremx_ori;
- FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid;
- DO WHILE sqlca.SQLCode = 0
- ins_ref_mxbt++
- FETCH cur_outwaremx_ori Into :ins_ref_outwaremx[ins_ref_mxbt].mtrlid,:ins_ref_outwaremx[ins_ref_mxbt].plancode,:ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode,:ins_ref_outwaremx[ins_ref_mxbt].storageid;
- LOOP
- CLOSE cur_outwaremx_ori;
-
- ins_ref_mxbt = ins_ref_mxbt - 1
-
- FOR i = 1 To it_mxbt
- If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) THEN
-
- FOR j = 1 To ins_ref_mxbt
- IF ins_ref_outwaremx[j].mtrlid = outwaremx[i].mtrlid And ins_ref_outwaremx[j].plancode = outwaremx[i].plancode And ins_ref_outwaremx[j].mtrlcuscode = outwaremx[i].mtrlcuscode And ins_ref_outwaremx[j].storageid = storageid THEN
- GOTO _next_mtrl
- END IF
- NEXT
-
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- END IF
-
- _next_mtrl:
- NEXT
- END IF
-
- If (billtype > 1 And billtype <> 5 ) Or ((billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 0) THEN
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- cusid = :cusid,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- relint_3 = :relint_3,
- relint_4 = :relint_4,
- otheramt = :otheramt,
- damt = :damt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- upname = :upname,
- viewdate = :viewdate,
- deptid = :deptid,
- totalamt = :totalamt,
- getamt = :getamt,
- lsflag = :lsflag,
- carcode = :carcode,
- transcode = :transcode,
- typeid = :typeid,
- exchangeid = :exchangeid,
- station_address = :station_address
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败(1)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //更新库存已开单数(减)
- IF billtype <> 21 And billtype <> 12 THEN
- IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- //删除原有明细
- DELETE FROM u_outwaremx
- WHERE u_outwaremx.outwareid = :outwareid
- And u_outwaremx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
-
- //如果是发料单,计算实际超发数量
- IF billtype = 3 And relint_1 = 4 THEN
- IF outwaremx[i].qty - outwaremx[i].planqty > 0 THEN
- ld_trueoverqty = outwaremx[i].qty - outwaremx[i].planqty
- ELSE
- ld_trueoverqty = 0
- END IF
- END IF
-
- INSERT INTO u_outwaremx
- (scid,
- outwareid,
- mtrlwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- sptid,
- dxflag,
- costamt,
- ifrel,
- relid,
- packqty,
- olmtrlid,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- outtypestr,
- dftsaleprice,
- cost,
- planqty,
- relprintid,
- unit,
- rate,
- uqty,
- storageid,
- scidprice,
- mtrlcuscode,
- location,
- pricetype,
- formula,
- capacity,
- saleqty,
- saleoutid,
- saleoutprintid,
- mxdscrp2,
- net_weight,
- gross_weight,
- cubage,
- taxrate,
- priceformula,
- qtyformula,
- enacprice,
- ifvqty,
- trueoverqty,
- backtype,
- ifnotinout)
- VALUES (
- :scid,
- :outwareid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].printid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].plancode,
- :outwaremx[i].status,
- :outwaremx[i].qty,
- :outwaremx[i].fprice,
- :outwaremx[i].rebate,
- :outwaremx[i].price,
- :outwaremx[i].planprice,
- :outwaremx[i].mxdscrp,
- :outwaremx[i].sptid,
- :outwaremx[i].dxflag,
- :outwaremx[i].costamt,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].packqty,
- :outwaremx[i].olmtrlid,
- :outwaremx[i].woodcode,
- :outwaremx[i].relcode,
- :outwaremx[i].pcode,
- :outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,
- :outwaremx[i].outtype,
- :outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,
- :outwaremx[i].planqty,
- :outwaremx[i].relprintid,
- :outwaremx[i].unit,
- :outwaremx[i].rate,
- :outwaremx[i].uqty,
- :outwaremx[i].storageid,
- :outwaremx[i].scidprice,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].Location,
- :outwaremx[i].pricetype,
- :outwaremx[i].formula,
- :outwaremx[i].capacity,
- :outwaremx[i].qty,
- :outwaremx[i].saleoutid,
- :outwaremx[i].saleoutprintid,
- :outwaremx[i].mxdscrp2,
- :outwaremx[i].net_weight,
- :outwaremx[i].gross_weight,
- :outwaremx[i].cubage,
- :outwaremx[i].taxrate,
- :outwaremx[i].priceformula,
- :outwaremx[i].qtyformula,
- :outwaremx[i].enacprice,
- :outwaremx[i].ifvqty,
- :ld_trueoverqty,
- :outwaremx[i].backtype,
- :outwaremx[i].ifnotinout) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- //删除原有明细
- DELETE FROM u_outwaremx_mx
- WHERE u_outwaremx_mx.outwareid = :outwareid
- And u_outwaremx_mx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt_mx
- INSERT INTO u_outwaremx_mx
- (scid,
- outwareid,
- mtrlwareid,
- printid,
- mxprintid,
- mtrlid,
- plancode,
- status,
- qty,
- mxdscrp,
- sptid,
- dxflag,
- woodcode,
- pcode,
- planqty,
- storageid,
- mtrlcuscode,
- location,
- ifnotinout)
- VALUES (
- :scid,
- :outwareid,
- :outwaremx_mx[i].mtrlwareid,
- :outwaremx_mx[i].printid,
- :outwaremx_mx[i].mxprintid,
- :outwaremx_mx[i].mtrlid,
- :outwaremx_mx[i].plancode,
- :outwaremx_mx[i].status,
- :outwaremx_mx[i].qty,
- :outwaremx_mx[i].mxdscrp,
- :outwaremx_mx[i].sptid,
- :outwaremx_mx[i].dxflag,
- :outwaremx_mx[i].woodcode,
- :outwaremx_mx[i].pcode,
- :outwaremx_mx[i].planqty,
- :outwaremx_mx[i].storageid,
- :outwaremx_mx[i].mtrlcuscode,
- :outwaremx_mx[i].Location,
- :outwaremx_mx[i].ifnotinout) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原outwareid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- DELETE FROM u_outware_itemmx
- WHERE u_outware_itemmx.outwareid = :outwareid
- And u_outware_itemmx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt_item
- INSERT INTO u_outware_itemmx
- (scid,
- outwareid,
- printid,
- itemid,
- amt,
- mxdscrp)
- VALUES (:scid,
- :outwareid,
- :outware_itemmx[i].printid,
- :outware_itemmx[i].itemid,
- :outware_itemmx[i].amt,
- :outware_itemmx[i].mxdscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原taskid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //增加已开单数
- IF billtype <> 21 And billtype <> 12 THEN
- IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- ElseIf (billtype = 1 Or billtype = 5) And flag = 0 And priceflag = 1 THEN
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- cusid = :cusid,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- otheramt = :otheramt,
- damt = :damt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- upname = :upname,
- viewdate = :viewdate,
- deptid = :deptid,
- carcode = :carcode,
- transcode = :transcode,
- typeid = :typeid,
- exchangeid = :exchangeid,
- station_address = :station_address
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- AND flag = 0
- AND secflag = 0
- And priceflag = 1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败(3)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //更新库存已开单数(减)
- IF billtype <> 21 And billtype <> 12 THEN
- IF uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- FOR i = 1 To it_mxbt
- UPDATE u_outWAREmx
- SET qty = :outWAREmx[i].qty,
- saleqty = :outwaremx[i].qty,
- mxdscrp = :outwaremx[I].mxdscrp,
- fprice = :outwaremx[I].fprice,
- rebate = :outwaremx[I].rebate,
- enprice = :outwaremx[I].enprice,
- enacprice = :outwaremx[I].enacprice,
- packqty = :outwaremx[I].packqty,
- outtype = :outwaremx[I].outtype,
- formula = :outwaremx[i].formula,
- capacity = :outwaremx[i].capacity,
- mxdscrp2 = :outwaremx[i].mxdscrp2,
- net_weight = :outwaremx[i].net_weight,
- gross_weight = :outwaremx[i].gross_weight,
- cubage = :outwaremx[i].cubage,
- taxrate = :outwaremx[i].taxrate,
- priceformula = :outwaremx[i].priceformula,
- qtyformula = :outwaremx[i].qtyformula
- WHERE ( scid = :scid AND
- outWAREid = :outwareid AND
- printid = :outwaremx[i].printid);
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新明细实发数操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- FOR i = 1 To it_mxbt_mx
- UPDATE u_outwaremx_mx
- SET qty = :outwaremx_mx[i].qty,
- mxdscrp = :outwaremx_mx[I].mxdscrp
- WHERE ( scid = :scid AND
- outWAREid = :outwareid AND
- printid = :outwaremx_mx[i].printid AND
- mxprintid = :outwaremx_mx[i].mxprintid);
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新应发明细实发数操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
-
- DELETE FROM u_outware_itemmx
- WHERE u_outware_itemmx.outwareid = :outwareid
- And u_outware_itemmx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt_item
- INSERT INTO u_outware_itemmx
- (scid,
- outwareid,
- printid,
- itemid,
- amt,
- mxdscrp)
- VALUES (:scid,
- :outwareid,
- :outware_itemmx[i].printid,
- :outware_itemmx[i].itemid,
- :outware_itemmx[i].amt,
- :outware_itemmx[i].mxdscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- //增加已开单数
- IF billtype <> 21 And billtype <> 12 THEN
- IF uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ELSE
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- cusid = :cusid,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- otheramt = :otheramt,
- damt = :damt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- upname = :upname,
- viewdate = :viewdate,
- deptid = :deptid,
- carcode = :carcode,
- transcode = :transcode,
- typeid = :typeid,
- exchangeid = :exchangeid,
- station_address = :station_address
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- AND flag = 1
- And secflag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败(2)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
- UPDATE u_outWAREmx
- SET price = :outWAREmx[i].price,
- mxdscrp = :outwaremx[I].mxdscrp,
- fprice = :outwaremx[I].fprice,
- rebate = :outwaremx[I].rebate,
- enprice = :outwaremx[I].enprice,
- enacprice = :outwaremx[I].enacprice,
- taxrate = :outwaremx[i].taxrate,
- priceformula = :outwaremx[i].priceformula,
- qtyformula = :outwaremx[i].qtyformula
- WHERE ( scid = :scid AND
- outWAREid = :outwareid AND
- printid = :outwaremx[i].printid);
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新明细价格操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
-
- DELETE FROM u_outware_itemmx
- WHERE u_outware_itemmx.outwareid = :outwareid
- And u_outware_itemmx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt_item
- INSERT INTO u_outware_itemmx
- (scid,
- outwareid,
- printid,
- itemid,
- amt,
- mxdscrp)
- VALUES (:scid,
- :outwareid,
- :outware_itemmx[i].printid,
- :outware_itemmx[i].itemid,
- :outware_itemmx[i].amt,
- :outware_itemmx[i].mxdscrp) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- outwareid = 0 //还原taskid
- rslt = 0
- arg_msg = "因网络或其它原因导致插入费用明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- END IF
- it_newbegin = False
- it_updatebegin = False
- //
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- p_clearmx()
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,j,mx_barcode_cnt
- String ls_storagename
- Int li_outtype,li_storagetype,li_if_pd_usebarcode
- Decimal ld_sumnotoutqty,ld_sumnotoutqty_bill
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- Long ll_taskid,ll_taskprintid
- Decimal ld_assign_outqty,ld_outmx_qty
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_cmpl_packpro uo_cmpl_p
- uo_cmpl_p = Create uo_cmpl_packpro
- uo_cmpl_p.commit_transaction = commit_transaction
- If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- If uo_option_inout_type = -1000 Then
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_barcode_outwareother_paudit = -1000 Then
- rslt = 0
- arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- If thflag = 0 Then
- ds_out_assign.DataObject = 'ds_outwaremx_assign'
- Else
- ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
- End If
- ds_out_assign.SetTransObject(commit_transaction)
- If outwareid = 0 Then
- rslt = 0
- arg_msg = "没有出仓审核对象"
- Goto ext
- End If
- If storageid = 0 Then
- rslt = 0
- arg_msg = '没有正确的仓库'
- Goto ext
- End If
- If billtype <> 9 Then
- If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- Select storagename,outtype,storagetype,if_pd_usebarcode
- Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode
- From u_storage
- Where storageid = :storageid Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- Goto ext
- End If
- //检查是否有该仓库的建立权限
- If sys_user_storagestr_audit <> '0' Then
- If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据'
- Goto ext
- End If
- End If
- //
- If uo_option_inout_type = 2 And li_outtype = 2 And &
- ( uo_option_barcode_outwareother_paudit = 1 And billtype = 8 ) Then
- If priceflag = 0 Then
- arg_msg = '单据未确认,不能审核'
- rslt = 0
- Goto ext
- End If
- End If
- If flag = 1 Then
- rslt = 0
- arg_msg = "单据已经审核"
- Goto ext
- End If
- If li_outtype = 2 Then
- For i = 1 To it_mxbt
- If outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
- Next
-
- If mx_barcode_cnt > 0 And ( billtype = 8 Or billtype = 9 And &
- ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
- If uof_check_qty_to_bqty(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
- Update u_outware
- Set Auditingrep = :publ_operator,
- Auditingdate = getdate(),
- flag = 1
- Where u_outware.outwareid = :outwareid
- And flag = 0
- And scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- For i = 1 To it_mxbt
-
- Decimal ld_ref_costamt
-
- // ld_ref_costamt = 0
- If p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,&
- outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If billtype <> 19 Then
- //先取消分配再扣库存
- //更新库存分配(销售出仓单包件出仓)
-
- If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then
- ll_taskid = 0
- ll_taskprintid = 0
- ld_assign_outqty = 0
-
- Select u_outwaremx.relid,
- u_outwaremx.relprintid
- Into :ll_taskid,
- :ll_taskprintid
- From u_outwaremx
- Where u_outwaremx.scid = :scid
- And u_outwaremx.outwareid = :relid //发货单id
- And u_outwaremx.printid = :outwaremx[i].olmtrlid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If ll_taskid > 0 Then
- ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
-
- If ds_out_assign.RowCount() > 0 Then
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- Else
- ld_sumnotoutqty = 0
- End If
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = outwaremx[i].qty
-
- ds_out_assign.AcceptText()
- If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then
- ld_assign_outqty = ld_sumnotoutqty_bill
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- End If
-
- If sys_option_inout_procedure = 0 Then
- If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Else
- If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- //更新库存分配销售退货单
- If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then
- ll_taskid = 0
- ll_taskprintid = 0
- ld_assign_outqty = 0
-
- Select u_outwaremx.relid,
- u_outwaremx.relprintid
- Into :ll_taskid,
- :ll_taskprintid
- From u_outwaremx
- Where u_outwaremx.scid = :scid
- And u_outwaremx.outwareid = :relid
- And u_outwaremx.printid = :outwaremx[i].olmtrlid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If ll_taskid > 0 Then
- ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
-
- If ds_out_assign.RowCount() > 0 Then
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- Else
- ld_sumnotoutqty = 0
- End If
-
- ds_out_assign.AcceptText()
-
- ld_outmx_qty = Abs(outwaremx[i].qty)
- If ld_outmx_qty > ld_sumnotoutqty And ll_taskid > 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then
- ld_assign_outqty = ld_outmx_qty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- End If
- Else
- If sys_option_inout_procedure = 0 Then
- If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Else
- If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- //yyx2012-9-29返回计算可装数库存id数组
-
- If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- End If
- End If
-
- //
- Next
- //更新条码
- If li_outtype = 2 And &
- mx_barcode_cnt > 0 And &
- ( billtype <> 9 Or billtype = 9 And &
- ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
- If uof_p_barcode(1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //更新库存已开单数(减)
- If billtype <> 21 And billtype <> 12 Then
- If uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //yyx2012-9-29返回计算可装数库存id数组计算可装数
- If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
- //
- flag = 1
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_ma
- Destroy ds_out_assign
- Destroy uo_pro
- Destroy uo_cmpl_p
- Return rslt
- end function
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);Long rslt = 1
- IF uo_option_inout_type = -1000 THEN
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_barcode_outwareother_paudit= -1000 THEN
- rslt = 0
- arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_confirmaudit_sale = -1000 THEN
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_sale_use_planqty = -1000 THEN
- rslt = 0
- arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_outwareid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF Not (arg_billtype = 1 OR &
- arg_billtype = 2 OR &
- arg_billtype = 3 OR &
- arg_billtype = 4 OR &
- arg_billtype = 5 OR &
- arg_billtype = 6 OR &
- arg_billtype = 7 OR &
- arg_billtype = 8 OR &
- arg_billtype = 9 OR &
- arg_billtype = 10 OR &
- arg_billtype = 12 OR &
- arg_billtype = 15 OR &
- arg_billtype = 16 OR &
- arg_billtype = 17 or &
- arg_billtype = 18 or &
- arg_billtype = 19 or &
- arg_billtype = 20 or &
- arg_billtype = 21 or &
- arg_billtype = 22 or &
- arg_billtype = 23 or &
- arg_billtype = 24 or &
- arg_billtype = 25) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'1-销售单[记帐模式],'
- arg_msg = arg_msg+'2-销售单[不记帐模式],'
- arg_msg = arg_msg+'3-领料出仓单,'
- arg_msg = arg_msg+'4-外加工出仓单,'
- arg_msg = arg_msg+'5-来料加工发货,'
- arg_msg = arg_msg+'6-售后服务出仓单,'
- arg_msg = arg_msg+'7-外协销售出仓单,'
- arg_msg = arg_msg+'8-其他出仓单,'
- arg_msg = arg_msg+'9-盘亏出仓单,'
- arg_msg = arg_msg+'10-工具出仓单,'
- arg_msg = arg_msg+'12-调拨出仓单,'
- arg_msg = arg_msg+'15-拆装出仓单,'
- arg_msg = arg_msg+'16-生产进仓车间自动出仓(未分配),'
- arg_msg = arg_msg+'17-还货出仓单,'
- arg_msg = arg_msg+'18-自动组装出仓单,'
- arg_msg = arg_msg+'19-生产进仓车间自动出仓单(已分配)'
- arg_msg = arg_msg+'20-车间库存转换自动出仓单'
- arg_msg = arg_msg+'21-销售发货单包件明细自动出仓单'
- arg_msg = arg_msg+'22-欠货终止单自动出仓单'
- arg_msg = arg_msg+'23-采购收货单收货明细自动出仓单'
- arg_msg = arg_msg+'24-员工物品领用单'
- arg_msg = arg_msg+'25-发料损耗自动出仓单'
- GOTO ext
- END IF
- IF arg_billtype = 12 THEN
- rslt = 0
- arg_msg = '单据类型:12-调拨出仓>>不能修改'
- GOTO ext
- END IF
- IF arg_billtype = 17 THEN
- rslt = 0
- arg_msg = '单据类型:17-还货出仓单>>不能修改'
- GOTO ext
- END IF
- IF arg_billtype = 18 THEN
- rslt = 0
- arg_msg = '单据类型:18-自动组装出仓单>>不能修改'
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF uo_option_inout_type = 2 AND &
- ( uo_option_barcode_outwareother_paudit = 1 AND arg_billtype = 8 ) THEN
- IF priceflag = 1 THEN
- arg_msg = '单据已确认,不能修改'
- rslt = 0
- GOTO ext
- END IF
- END IF
- String ls_storagename
- SELECT storagename
- INTO :ls_storagename
- FROM u_storage
- Where storageid = :storageid USING commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
- //检查是否有该仓库的建立权限
- IF sys_user_storagestr_new <> '0' THEN
- IF Pos(sys_user_storagestr_new,','+String(storageid)+',') <= 0 THEN
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的建立权限,不允许修改该仓库的单据'
- GOTO ext
- END IF
- END IF
- //
- IF arg_billtype = 1 THEN
- IF uo_option_confirmaudit_sale = 1 AND uo_option_sale_use_planqty = 1 THEN
- IF priceflag = 1 AND flag = 1 AND secflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经过仓库及财务审核,不可以修改'
- GOTO ext
- ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
- rslt = 0
- arg_msg = '单据已经确认,仓审前不可以修改'
- GOTO ext
- END IF
- ELSE
- IF flag = 1 AND secflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经过仓库及财务审核,不可以修改'
- GOTO ext
- ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
- rslt = 0
- arg_msg = '单据已经确认,仓审前不可以修改'
- GOTO ext
- END IF
- END IF
- ELSEIF arg_billtype = 5 THEN
- IF flag = 1 AND secflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经过仓库及财务审核,不可以修改'
- GOTO ext
- ELSEIF priceflag = 1 AND flag = 0 AND secflag = 0 THEN
- rslt = 0
- arg_msg = '单据已经确认,仓审前不可以修改,不可以修改'
- GOTO ext
- END IF
- ELSE
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- END IF
- outwareid = arg_outwareid
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = FALSE
- it_updatebegin = TRUE
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1
- Long i = 1,no_mxcheck = 0,j = 1,no_mxcheck_barcode = 0,k = 1,l = 1,ll_i
- Int li_outtype
- Decimal ld_planprice
- sum_amt = 0
- sum_amt_en = 0
- sum_taxamt = 0
- sum_taxamt_en = 0
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arg_msg = "非法出仓单唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- SELECT outtype
- INTO :li_outtype
- FROM u_storage
- Where storageid = :storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库出仓类型,"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- //用游标读取明细
- DECLARE cur_outwaremx CURSOR FOR
- SELECT u_outwaremx.printid,
- u_outwaremx.mtrlid,
- u_outwaremx.plancode,
- u_outwaremx.status,
- u_outwaremx.qty,
- u_outwaremx.fprice,
- u_outwaremx.rebate,
- u_outwaremx.price,
- u_outwaremx.mxdscrp,
- u_mtrldef.mtrlcode,
- u_outwaremx.sptid,
- u_outwaremx.dxflag,
- u_outwaremx.mtrlwareid,
- u_outwaremx.storageid,
- u_outwaremx.costamt,
- u_outwaremx.ifrel,
- u_outwaremx.relid,
- u_outwaremx.olmtrlid,
- u_outwaremx.packqty,
- u_outwaremx.woodcode,
- u_outwaremx.pcode,
- u_outwaremx.enprice,
- u_outwaremx.newpriceamt,
- u_outwaremx.outtypestr,
- u_outwaremx.dftsaleprice,
- u_outwaremx.cost,
- u_outwaremx.planqty,
- u_outwaremx.relprintid,
- u_outwaremx.relcode,
- u_outwaremx.unit,
- u_outwaremx.rate,
- u_outwaremx.uqty,
- u_outwaremx.overqty,
- u_outwaremx.mtrlcuscode,
- u_outwaremx.location,
- u_outwaremx.pricetype,
- u_outwaremx.formula,
- u_outwaremx.capacity,
- u_mtrldef.ifpackpro,
- u_mtrldef.ifpack,
- u_mtrldef.outtype,
- u_outwaremx.saleqty,
- u_outwaremx.saleoutid,
- u_outwaremx.saleoutprintid,
- u_outwaremx.mxdscrp2,
- u_outwaremx.net_weight,
- u_outwaremx.gross_weight,
- u_outwaremx.cubage,
- u_outwaremx.taxrate,
- u_outwaremx.priceformula,
- u_outwaremx.qtyformula,
- u_mtrldef.iffp,
- u_outwaremx.enacprice,
- u_outwaremx.ifvqty,
- u_outwaremx.backtype,
- u_outwaremx.ifnotinout
- FROM u_outwaremx,u_mtrldef,u_outware
- WHERE u_outware.outwareid = :arg_outwareid AND
- u_outwaremx.mtrlid = u_mtrldef.mtrlid AND
- u_outware.scid = :arg_scid AND
- u_outware.outwareid = u_outwaremx.outwareid AND
- u_outware.scid = u_outwaremx.scid
- Order By u_outwaremx.printid Using commit_transaction;
-
- OPEN cur_outwaremx;
- FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].sptid,:outwaremx[i].dxflag,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode,
- :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty,
- :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula,
- :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl,
- :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid,
- :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage,
- :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp,
- :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout;
- DO WHILE commit_transaction.SQLCode = 0
-
- sum_amt = sum_amt + Round( (outwaremx[i].saleqty * outwaremx[i].price) / ( 1 + outwaremx[i].taxrate) ,2) //计算单据总金额
- sum_amt_en = sum_amt_en + Round((outwaremx[i].saleqty * outwaremx[i].enacprice) / ( 1 + outwaremx[i].taxrate),2) //计算单据总金额
-
- sum_taxamt = sum_taxamt + Round( ( outwaremx[i].saleqty * outwaremx[i].price * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate) ,2)
- sum_taxamt_en = sum_taxamt_en + Round( (outwaremx[i].saleqty * outwaremx[i].enacprice * outwaremx[i].taxrate) / ( 1 + outwaremx[i].taxrate),2)
-
- i++
- FETCH cur_outwaremx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].sptid,:outwaremx[i].dxflag,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,:outwaremx[i].planqty,:outwaremx[i].relprintid,:outwaremx[i].relcode,
- :outwaremx[i].unit,:outwaremx[i].rate,:outwaremx[i].uqty,:outwaremx[i].overqty,
- :outwaremx[i].mtrlcuscode,:outwaremx[i].Location,:outwaremx[i].pricetype,:outwaremx[i].formula,
- :outwaremx[i].capacity,:outwaremx[i].ifpackpro,:outwaremx[i].ifpack,:outwaremx[i].outtype_mtrl,
- :outwaremx[i].saleqty,:outwaremx[i].saleoutid,:outwaremx[i].saleoutprintid,
- :outwaremx[i].mxdscrp2,:outwaremx[i].net_weight,:outwaremx[i].gross_weight,:outwaremx[i].cubage,
- :outwaremx[i].taxrate,:outwaremx[i].priceformula,:outwaremx[i].qtyformula,:outwaremx[i].iffp,
- :outwaremx[i].enacprice,:outwaremx[i].ifvqty,:outwaremx[i].backtype,:outwaremx[i].ifnotinout;
- LOOP
- CLOSE cur_outwaremx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_outwaremx
- WHERE u_outwaremx.outwareid = :arg_outwareid
- And scid = :arg_scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细"
- GOTO ext
- END IF
- //取计划价
- FOR ll_i = 1 To i - 1
- ld_planprice = 0
- f_get_planprice_mtrl(outwaremx[ll_i].mtrlid,outwaremx[ll_i].status,outwaremx[ll_i].woodcode,outwaremx[ll_i].pcode,ld_planprice)
- IF IsNull(ld_planprice) THEN ld_planprice = 0
- outwaremx[ll_i].planprice = ld_planprice
- NEXT
- DECLARE cur_outwaremx_mx CURSOR FOR
- SELECT u_outwaremx_mx.printid, u_outwaremx_mx.mxprintid,
- u_outwaremx_mx.mtrlwareid, u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid,
- u_outwaremx_mx.plancode, u_outwaremx_mx.status, u_outwaremx_mx.woodcode,
- u_outwaremx_mx.pcode, u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location,
- u_outwaremx_mx.sptid, u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty,
- u_outwaremx_mx.qty, u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ifnotinout,
- u_mtrldef.ifpackpro, u_mtrldef.ifpack,u_mtrldef.mtrlcode
- FROM u_outwaremx_mx INNER JOIN
- u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
- WHERE u_outwaremx_mx.scid = :arg_scid
- AND u_outwaremx_mx.outwareid = :arg_outwareid
- Order By u_outwaremx_mx.mxprintid Using commit_transaction;
-
- OPEN cur_outwaremx_mx;
- FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid,
- :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid,
- :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode,
- :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location,
- :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty,
- :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout,
- :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode;
-
- DO WHILE commit_transaction.SQLCode = 0
- j++
- FETCH cur_outwaremx_mx INTO :outwaremx_mx[j].printid,:outwaremx_mx[j].mxprintid,
- :outwaremx_mx[j].mtrlwareid,:outwaremx_mx[j].storageid,:outwaremx_mx[j].mtrlid,
- :outwaremx_mx[j].plancode,:outwaremx_mx[j].status,:outwaremx_mx[j].woodcode,
- :outwaremx_mx[j].pcode,:outwaremx_mx[j].mtrlcuscode,:outwaremx_mx[j].location,
- :outwaremx_mx[j].sptid,:outwaremx_mx[j].dxflag,:outwaremx_mx[j].planqty,
- :outwaremx_mx[j].qty,:outwaremx_mx[j].mxdscrp,:outwaremx_mx[j].ifnotinout,
- :outwaremx_mx[j].ifpackpro, :outwaremx_mx[j].ifpack, :outwaremx_mx[j].mtrlcode;
- LOOP
- CLOSE cur_outwaremx_mx;
- SELECT count(*) INTO :no_mxcheck
- FROM u_outwaremx_mx
- WHERE u_outwaremx_mx.outwareid = :arg_outwareid
- And scid = :arg_scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单应发明细数量"
- GOTO ext
- END IF
- IF j <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单应发明细"
- GOTO ext
- END IF
- //用游标读取条码明细
- IF li_outtype = 2 THEN
- DECLARE cur_outwaremx_barcode CURSOR FOR
- SELECT u_outwaremx_mx_barcode.barcode,
- u_outwaremx_mx_barcode.qty,
- u_mtrlware_mx.packqty,
- u_mtrlware_mx.mtrlwareid,
- u_outwaremx_mx_barcode.qty * u_mtrlware_mx.packqty
- FROM u_outwaremx_mx_barcode,u_mtrlware_mx
- WHERE u_outwaremx_mx_barcode.barcode = u_mtrlware_mx.barcode AND
- u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
- u_outwaremx_mx_barcode.scid = :arg_scid AND
- u_outwaremx_mx_barcode.billtype = :billtype
- Order By u_outwaremx_mx_barcode.barcode Using commit_transaction;
-
- OPEN cur_outwaremx_barcode;
- FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,
- :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty;
-
- DO WHILE commit_transaction.SQLCode = 0
- k++
- FETCH cur_outwaremx_barcode INTO :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty,
- :s_mx_barcode[k].packqty,:s_mx_barcode[k].mtrlwareid,:s_mx_barcode[k].outqty;
- LOOP
- CLOSE cur_outwaremx_barcode;
-
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck_barcode
- FROM u_outwaremx_mx_barcode
- WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- AND u_outwaremx_mx_barcode.scid = :arg_scid
- And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细数量"
- GOTO ext
- END IF
-
- IF k <> (no_mxcheck_barcode+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单条码明细"
- GOTO ext
- END IF
-
- it_mxbt_barcode = k - 1
- END IF
- //读取来料加工订单费用明细
- DECLARE cur_outware_itemmx CURSOR FOR
- SELECT scid, outwareid, printid, itemid, amt, mxdscrp,IsCusAmt
- FROM u_outware_itemmx
- WHERE outwareid = :arg_outwareid
- AND scid = :arg_scid
- Using commit_transaction;
-
- OPEN cur_outware_itemmx;
- FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid,
- :outware_itemmx[l].printid,:outware_itemmx[l].itemid,
- :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp,
- :outware_itemmx[l].IsCusAmt;
- DO WHILE commit_transaction.SQLCode = 0
- l++
- FETCH cur_outware_itemmx INTO :outware_itemmx[l].scid,:outware_itemmx[l].outwareid,
- :outware_itemmx[l].printid,:outware_itemmx[l].itemid,
- :outware_itemmx[l].amt,:outware_itemmx[l].mxdscrp,
- :outware_itemmx[l].IsCusAmt;
- LOOP
- CLOSE cur_outware_itemmx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_outware_itemmx
- Where outwareid = :arg_outwareid And scid = :arg_scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,费用明细数量"
- GOTO ext
- END IF
- IF l <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,费用明细"
- GOTO ext
- END IF
- it_mxbt_item = l - 1
- outwareid = arg_outwareid
- scid = arg_scid
- it_mxbt = i - 1
- it_mxbt_mx = j - 1
- it_mxbt_barcode = k - 1
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);Int rslt = 1
- IF uo_option_confirmaudit_sale = -1000 THEN
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arg_msg = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF billtype = 1 and uo_option_confirmaudit_sale = 1 THEN
- IF priceflag = 0 THEN
- rslt = 0
- arg_msg = "单据未确认,不能增备注"
- GOTO ext
- END IF
- ELSE
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "非审核状态下不可用"
- GOTO ext
- END IF
- END IF
- UPDATE u_outware
- SET dscrp = dscrp+' '+:arg_newdescppart
- WHERE outwareid = :outwareid
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- ROLLBACK ;
- rslt = 0
- arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- COMMIT USING commit_transaction;
- dscrp = dscrp+' '+arg_newdescppart
- ext: Return (rslt)
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
- Long cnt = 0,i,j,mx_barcode_cnt
- String ls_storagename
- Int li_outtype,li_storagetype,li_if_pd_usebarcode
- Decimal ld_sumnotoutqty
- Decimal ld_assign_outqty,ld_outmx_qty,ld_sumnotoutqty_bill
- Long ll_taskid,ll_taskprintid
- DateTime null_dt
- SetNull(null_dt)
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_cmpl_packpro uo_cmpl_p
- uo_cmpl_p = Create uo_cmpl_packpro
- uo_cmpl_p.commit_transaction = commit_transaction
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- If f_aps_mrp_cklock(scid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- If thflag = 0 Then
- ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
- Else
- ds_out_assign.DataObject = 'ds_outwaremx_assign'
- End If
- ds_out_assign.SetTransObject(commit_transaction)
- If storageid = 0 Then
- rslt = 0
- arg_msg = '没有正确的仓库'
- Goto ext
- End If
- If billtype <> 9 And Not (billtype = 3 And Pos(dscrp,'电脑生成的') > 0 And Pos(dscrp,'的领料单') > 0) Then
- If uof_check_warepdb_audit(storageid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- Select storagename,outtype,storagetype,if_pd_usebarcode
- Into :ls_storagename,:li_outtype,:li_storagetype,:li_if_pd_usebarcode
- From u_storage
- Where storageid = :storageid Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- Goto ext
- End If
- //检查是否有该仓库的建立权限
- If sys_user_storagestr_audit <> '0' Then
- If Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 Then
- rslt = 0
- arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据'
- Goto ext
- End If
- End If
- //
- If outwareid = 0 Then
- rslt = 0
- arg_msg = "没有出仓撤审对象"
- Goto ext
- End If
- If ctmint > 0 Then
- arg_msg = '单据已截数,不能操作'
- rslt = 0
- Goto ext
- End If
- If flag = 0 Then
- rslt = 0
- arg_msg = "单据还未审核"
- Goto ext
- End If
- If balcflag = 1 Then
- rslt = 0
- arg_msg = "单据已经日结,不能撤审"
- Goto ext
- End If
- Update u_outware
- Set Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0
- Where u_outware.outwareid = :outwareid
- And flag = 1
- And secflag = 0
- And scid = :scid Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- For i = 1 To it_mxbt
- If billtype <> 19 Then
- //销售退货单更新分配明细
- If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 1 Then
- ll_taskid = 0
- ll_taskprintid = 0
- ld_assign_outqty = 0
-
- Select u_outwaremx.relid,
- u_outwaremx.relprintid
- Into :ll_taskid,
- :ll_taskprintid
- From u_outwaremx
- Where u_outwaremx.scid = :scid
- And u_outwaremx.outwareid = :relid //发货单id
- And u_outwaremx.printid = :outwaremx[i].olmtrlid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If ll_taskid > 0 Then
- ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
-
- If ds_out_assign.RowCount() > 0 Then
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- Else
- ld_sumnotoutqty = 0
- End If
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = Abs(outwaremx[i].qty)
-
- ds_out_assign.AcceptText()
- If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+'订单库存分配数不足,请检查库存分配未出仓明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_sumnotoutqty_bill Then
- ld_assign_outqty = ld_sumnotoutqty_bill
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售退货单(包件明细)行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_sumnotoutqty_bill = ld_sumnotoutqty_bill - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- End If
-
-
- If sys_option_inout_procedure = 0 Then
- If p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Else
- If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- //发货单更新库存分配
-
- If billtype = 21 And li_storagetype = 1 And li_outtype > 0 And thflag = 0 Then
- ll_taskid = 0
- ll_taskprintid = 0
- ld_assign_outqty = 0
-
- Select u_outwaremx.relid,
- u_outwaremx.relprintid
- Into :ll_taskid,
- :ll_taskprintid
- From u_outwaremx
- Where u_outwaremx.scid = :scid
- And u_outwaremx.outwareid = :relid
- And u_outwaremx.printid = :outwaremx[i].olmtrlid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售出仓单明细行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If ll_taskid > 0 Then
- ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
-
- If ds_out_assign.RowCount() > 0 Then
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- Else
- ld_sumnotoutqty = 0
- End If
-
- ds_out_assign.AcceptText()
-
- ld_outmx_qty = outwaremx[i].qty
- If ld_outmx_qty > ld_sumnotoutqty Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配已出仓明细'
- rslt = 0
- Goto ext
- Else
- ld_assign_outqty = 0
- For j = 1 To ds_out_assign.RowCount()
- If ds_out_assign.Object.notoutqty[j] >= ld_outmx_qty Then
- ld_assign_outqty = ld_outmx_qty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Exit
- Else
- ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmx_qty = ld_outmx_qty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- End If
- Else
- If sys_option_inout_procedure = 0 Then
- If p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
- outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
- outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Else
- If uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
- 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- If li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
-
- //yyx2012-9-29返回计算可装数库存id数组
- If billtype <> 23 And ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_ref_mtrlwarid_array(outwaremx[i].mtrlid,outwaremx[i].plancode,outwaremx[i].mtrlcuscode,storageid,s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- End If
- End If
- //
- Next
- //更新条码
- If li_outtype = 2 And &
- mx_barcode_cnt > 0 And &
- ( billtype <> 9 Or billtype = 9 And &
- ( li_if_pd_usebarcode = 1 Or li_if_pd_usebarcode = 0 And if_pd_py_check_barcode )) Then
- If uof_p_barcode(0,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //增加已开单数
- If billtype <> 21 And billtype <> 12 Then
- If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //yyx2012-9-29返回计算可装数库存id数组计算可装数
- If billtype <> 23 And UpperBound(s_mtrlwareid_array_rst.mtrlwareid) > 0 And uo_option_mtrlware_autocmp = 1 Then
- If uo_option_noauditingqty_mode = 0 Then
- If uo_cmpl_p.uof_cmpl_diqty(s_mtrlwareid_array_rst,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
- //
- flag = 0
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_ma
- Destroy ds_out_assign
- Destroy uo_pro
- Destroy uo_cmpl_p
- Return rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt = 0
- it_mxbt_mx = 0
- it_mxbt_barcode = 0
- it_mxbt_item = 0
- RETURN 1
- end function
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arG_MSG = "非法出仓单唯一码"
- GOTO ext
- END IF
- SELECT u_outware.outwarecode,
- u_outware.billtype,
- u_outware.relid,
- u_outware.storageid,
- u_outware.outdate,
- u_outware.outrep,
- u_outware.part,
- u_outware.cusid,
- u_outware.cusname,
- u_outware.dscrp,
- u_outware.thflag,
- u_outware.flag,
- u_outware.secflag,
- u_outware.balcflag,
- u_outware.relstr_1,
- u_outware.relstr_2,
- u_outware.relstr_3,
- u_outware.relint_1,
- u_outware.relint_2,
- u_outware.relint_3,
- u_outware.priceflag,
- u_outware.otheramt,
- u_outware.damt,
- u_outware.rel_address,
- u_outware.rel_tele,
- u_outware.rel_fax,
- u_outware.rel_rep,
- u_outware.mrate,
- u_outware.upname,
- u_outware.ctmint,
- u_outware.ifauto,
- u_outware.viewdate,
- u_outware.deptid,
- u_outware.carcode,
- u_outware.transcode,
- u_outware.pda_flag,
- u_outware.pda_date,
- u_outware.typeid,
- u_outware.exchangeid,
- u_outware.balcdateint,
- u_outware.relint_4,
- u_outware.station_address
- INTO :outwarecode,
- :billtype,
- :relid,
- :storageid,
- :outdate,
- :outrep,
- :part,
- :cusid,
- :cusname,
- :dscrp,
- :thflag,
- :flag,
- :secflag,
- :balcflag,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :relint_1,
- :relint_2,
- :relint_3,
- :priceflag,
- :otheramt,
- :damt,
- :rel_address,
- :rel_tele,
- :rel_fax,
- :rel_rep,
- :mrate,
- :upname,
- :ctmint,
- :ifauto,
- :viewdate,
- :deptid,
- :carcode,
- :transcode,
- :pda_flag,
- :pda_date,
- :typeid,
- :exchangeid,
- :balcdateint,
- :relint_4,
- :station_address
- FROM u_outware
- WHERE u_outware.outwareid = :arg_outwareid
- AND scid = :arg_scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败(错误出仓单唯一码),出仓单,"+string(arg_outwareid)+','+string(commit_transaction.SQLCode)+'~n'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- outwareid = arg_outwareid
- scid = arg_scid
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid = 0
- outwareid = 0
- outwarecode = ''
- billtype = 0
- opemp = ''
- modemp = ''
- auditingrep = ''
- secauditingrep = ''
- flag = 0
- secflag = 0
- relid = 0
- storageid = 0
- outrep = ''
- part = ''
- dscrp = ''
- cusid = 0
- cusname = ''
- thflag = 0
- otheramt = 0
- damt = 0
- rel_address = ''
- rel_tele = ''
- rel_fax = ''
- rel_rep= ''
- deptid = 0
- station_address = ''
- exchangeid = 0
- balcdateint = 0
- relint_4 = 0
- carcode = ''
- transcode = ''
- typeid = 0
- it_newbegin = FALSE
- it_updatebegin = FALSE
- //清除明细
- p_clearmx()
- RETURN 1
- end function
- public function integer p_update_cost (long arg_mtrlwareid, string arg_mtrlcode, decimal arg_qty, long arg_printid, ref decimal arg_ref_costamt, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_cost,ld_cost_cmpl,ld_noallocqty,ld_wareamt
- Long ll_storagescid
- SELECT scid INTO :ll_storagescid
- FROM u_storage
- Where storageid = :storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库分部失败'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- //yyx2012-9-21 storageid = :storageid 这个无用
- //SELECT cost INTO :ld_cost
- // FROM u_mtrlware
- // WHERE storageid = :storageid
- // AND mtrlwareid = :arg_mtrlwareid
- // AND scid = :ll_storagescid USING commit_transaction;
- //IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
- // rslt = 0
- // GOTO ext
- //END IF
- SELECT u_mtrlware.cost,u_mtrlware.noallocqty,u_mtrlware.wareamt
- INTO :ld_cost,:ld_noallocqty,:ld_wareamt
- FROM u_mtrlware
- WHERE u_mtrlware.mtrlwareid = :arg_mtrlwareid
- And u_mtrlware.scid = :ll_storagescid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- //yyx2013-8-31
- IF ld_noallocqty = 0 THEN
- ld_cost = ld_cost
- ELSE
- ld_cost_cmpl = Round(ld_wareamt/ld_noallocqty,uo_option_cost_dec)
-
- IF ld_cost <> ld_cost_cmpl THEN
- ld_cost = ld_cost_cmpl
- END IF
- END IF
- //yyx2013-8-31_end
- arg_ref_costamt = Round(ld_cost * arg_qty ,2)
- UPDATE u_outwaremx
- SET costamt = :arg_ref_costamt,
- cost = :ld_cost
- WHERE scid = :scid
- AND outwareid = :outwareid
- And printid = :arg_printid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新'+arg_mtrlcode+'出仓成本价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 3 Or &
- billtype = 4 Or &
- billtype = 8 Or &
- billtype = 9 Or &
- billtype = 12 Or &
- billtype = 24 THEN
- UPDATE u_outwaremx
- SET u_outwaremx.fprice = :ld_cost,
- u_outwaremx.price = :ld_cost
- WHERE scid = :scid
- AND outwareid = :outwareid
- And printid = :arg_printid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新'+arg_mtrlcode+'出仓面价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_outwareid, integer arg_ifcheck_auto, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
- //0 FAIL, 1 SUCCESS
- Int rslt = 1
- Long i
- s_cmplpackpro_ref_mtrlwareid_array s_mtrlwareid_array_rst
- ins_ref_outwaremx = ins_empty_outwaremx
- ins_ref_mxbt = 0
- If uo_option_disuse_outware_sale = -1000 Then
- rslt = 0
- arg_msg = '选项:[292]启用销售发货单废弃单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_confirmaudit_sale = -1000 Then
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_confirmaudit_scll = -1000 Then
- rslt = 0
- arg_msg = '选项:[006]生产领料单先确认后审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If arg_outwareid <= 0 Then
- rslt = 0
- arg_msg = "没有删除对象,操作取消"
- Goto ext
- End If
- If getinfo(arg_scid,arg_outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- //IF ( billtype = 1 or billtype = 5 ) AND uo_option_autowaste = 1 THEN
- // uo_outware_waste uo_waste
- // uo_waste = CREATE uo_outware_waste
- // uo_waste.commit_transaction = commit_transaction
- // IF uo_waste.insertwaste(0,arg_scid,arg_outwareid,arG_MSG,FALSE) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // DESTROY uo_waste
- //END IF
- If ( billtype = 1 Or billtype = 5 ) And uo_option_confirmaudit_sale = 1 Then
- If priceflag = 1 Then
- arg_msg = '单据已确认,不能删除'
- rslt = 0
- Goto ext
- End If
- End If
- If billtype = 3 And relint_1 = 0 And uo_option_confirmaudit_scll = 1 Then
- If priceflag = 1 Then
- arg_msg = '单据已确认,不能删除'
- rslt = 0
- Goto ext
- End If
- End If
- If flag = 1 Then
- rslt = 0
- arg_msg = "单据已经审核,不可以删除"
- Goto ext
- End If
- If arg_ifcheck_auto = 1 Then
- If ifauto = 1 Then
- rslt = 0
- arg_msg = '单据为动建立的单据,不可以删除'
- Goto ext
- End If
- End If
- If billtype = 1 And thflag = 0 And uo_option_disuse_outware_sale = 1 Then
- If uof_disuse(arg_scid,arg_outwareid,1,arg_msg,False) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- If uo_option_outware_pack_save_cmp = 1 And billtype <> 23 And uo_option_mtrlware_autocmp = 1 Then
- For i = 1 To it_mxbt
- If ( outwaremx[i].ifpack = 1 Or outwaremx[i].ifpack = 2 Or outwaremx[i].ifpackpro = 3 Or outwaremx[i].ifpackpro = 4 ) Then
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = outwaremx[i].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = outwaremx[i].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = outwaremx[i].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = storageid
- End If
- Next
- End If
- //更新库存已开单数(减)
- If billtype <> 21 And billtype <> 12 Then
- If uof_noauditingqty_del(arg_scid,arg_outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- Delete From u_outware
- Where u_outware.outwareid = :arg_outwareid
- And u_outware.scid = :arg_scid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除出仓单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- Delete From u_outwaremx
- Where u_outwaremx.outwareid = :arg_outwareid
- And u_outwaremx.scid = :arg_scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除出仓单明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- Delete From u_outwaremx_mx
- Where u_outwaremx_mx.outwareid = :arg_outwareid
- And u_outwaremx_mx.scid = :arg_scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除出仓单应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- Delete From u_outwaremx_mx_barcode
- Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
- And u_outwaremx_mx_barcode.scid = :arg_scid
- And u_outwaremx_mx_barcode.billtype = :billtype Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除出仓单条码明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- Delete From u_outware_itemmx
- Where u_outware_itemmx.outwareid = :arg_outwareid
- And u_outware_itemmx.scid = :arg_scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除出仓单费用明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- it_newbegin = False
- it_updatebegin = False
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- p_reset()
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return (rslt)
- end function
- public function integer p_update_mtrlware_ws (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, ref string arg_msg);Int rslt = 1
- Long ls_newid
- Decimal ld_cost
- Int li_storMtrlprp
- Long ll_storagescid
- Int li_ifunit
- Int li_statusflag
- Decimal ld_capacity,ld_capacity_zj
- s_mtrlcfg_expr s_pz[]
- String ls_status_zj
- Long ll_i
- Int li_ifpack
- Int if_recmp_balc
- Int li_ifcost
- IF sys_if_recmp_balc < 0 THEN
- SELECT if_recmp_balc
- INTO :if_recmp_balc
- From sys_msg Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF if_recmp_balc = 0 THEN
- rslt = 0
- arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
- GOTO ext
- END IF
- ELSE
- IF sys_if_recmp_balc = 0 THEN
- rslt = 0
- arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
- GOTO ext
- END IF
- END IF
- IF uo_option_change_status = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_woodcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_pcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_cost_dec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- SELECT Mtrlprp,scid,ifcost INTO :li_storMtrlprp,:ll_storagescid,:li_ifcost
- FROM u_storage
- Where storageid = :arg_storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询仓库信息失败'
- rslt = 0
- GOTO ext
- END IF
- SELECT ifunit,ifpack,capacity,statusflag
- INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询物料信息失败'
- rslt = 0
- GOTO ext
- END IF
- IF li_statusflag = 2 THEN
- ld_capacity = 0
- f_checkpz(arg_status,s_pz[])
- FOR ll_i = 1 To UpperBound(s_pz)
- ls_status_zj = s_pz[ll_i].cfgname
-
- SELECT capacity
- INTO :ld_capacity_zj
- FROM u_mtrl_configure
- WHERE mtrlid = :arg_mtrlid
- And Name = :ls_status_zj;
- IF commit_transaction.SQLCode <> 0 THEN
- ld_capacity_zj = 0
- END IF
-
- ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
-
- NEXT
- END IF
- Int li_ifupdate_date
- String ls_str
- String or_err_part
- IF billtype = 1 Or &
- billtype = 2 Or &
- billtype = 3 Or &
- billtype = 4 Or &
- billtype = 5 Or &
- billtype = 7 Or &
- billtype = 8 Or &
- billtype = 10 THEN
- li_ifupdate_date = 1
- ELSE
- li_ifupdate_date = 0
- END IF
- IF li_ifunit = 0 THEN arg_uqty = 0
- IF li_ifcost = 1 THEN
-
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- wsallocqty = wsallocqty - :arg_qty,
- unoallocqty = unoallocqty - :arg_uqty,
- capacity = capacity + :ld_capacity * :arg_qty,
- wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END ,
- cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END ,
- saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :ll_storagescid ) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
-
- ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec)
- INSERT INTO u_mtrlware
- ( scid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- noallocqty,
- unoallocqty,
- wareamt,
- planprice,
- sptid,
- dxflag,
- woodcode,
- pcode,
- cost,
- storMtrlprp,
- mtrlcuscode,
- location,
- capacity,
- wsallocqty)
- VALUES (
- :ll_storagescid,
- :ls_newid,
- :arg_mtrlid,
- :arg_storageid,
- :arg_plancode,
- :arg_status,
- :arg_qty,
- :arg_uqty,
- :arg_costamt,
- :arg_planprice,
- :arg_sptid,
- :arg_dxflag,
- :arg_woodcode,
- :arg_pcode,
- :ld_cost,
- :li_storMtrlprp,
- :arg_mtrlcuscode,
- :arg_location,
- :ld_capacity * :arg_qty,
- :arg_qty) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
- ELSE
- arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减"
- ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
-
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
- ELSE
- arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- ELSE
-
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- wsallocqty = wsallocqty - :arg_qty,
- unoallocqty = unoallocqty - :arg_uqty,
- capacity = capacity + :ld_capacity * :arg_qty,
- wareamt = 0 ,
- cost = 0 ,
- saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :ll_storagescid ) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_mtrlware
- ( scid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- noallocqty,
- unoallocqty,
- wareamt,
- planprice,
- sptid,
- dxflag,
- woodcode,
- pcode,
- cost,
- storMtrlprp,
- mtrlcuscode,
- location,
- capacity,
- wsallocqty)
- VALUES (
- :ll_storagescid,
- :ls_newid,
- :arg_mtrlid,
- :arg_storageid,
- :arg_plancode,
- :arg_status,
- :arg_qty,
- :arg_uqty,
- 0,
- 0,
- :arg_sptid,
- :arg_dxflag,
- :arg_woodcode,
- :arg_pcode,
- 0,
- :li_storMtrlprp,
- :arg_mtrlcuscode,
- :arg_location,
- :ld_capacity * :arg_qty,
- :arg_qty) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
- ELSE
- arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = "物料:"+arg_mtrlcode+"同仓库内同批号没有足够的库存支持冲减"
- ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
-
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- arg_msg = "物料:"+arg_mtrlcode+ls_str+" 同仓库内同批号没有足够的库存支持冲减"
- ELSE
- arg_msg = "因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction ;
- END IF
- RETURN rslt
- end function
- public function integer uof_p_barcode (integer arg_audittype, ref string arg_msg);Int rslt = 1
- Long i
- Long ll_scid,ll_mtrlwareid
- Int li_storagetype_storage
- String ls_location_top1
- IF billtype <> 1 And billtype <> 8 And billtype <> 9 And billtype <> 12 And billtype <> 17 THEN
- rslt = 1
- GOTO ext
- END IF
- uo_getbar uo_gb
- uo_gb = Create uo_getbar
- IF it_mxbt_barcode = 0 THEN
- arg_msg = '没有条码明细,请检查'
- rslt = 0
- GOTO ext
- END IF
- IF f_rst_storage_storagetype(storageid,li_storagetype_storage) = 0 THEN
- arg_msg = '查询仓库库存策略失败,请检查'
- rslt = 0
- GOTO ext
- END IF
- FOR i = 1 To it_mxbt_barcode
- IF thflag = 0 THEN
- IF uo_gb.uof_barcode_out(s_mx_barcode[i].barcode,arg_audittype,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF arg_audittype = 1 THEN
-
- IF uo_option_barcodelocation_use_inwaremx_location = 0 THEN
- ls_location_top1 = ''
- ELSE
- SELECT top 1 u_outwaremx.location
- INTO :ls_location_top1
- FROM u_outwaremx
- WHERE u_outwaremx.scid = :scid
- AND u_outwaremx.outwareid = :outwareid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询出仓单明细仓位信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- SELECT u_mtrlware.scid,u_mtrlware.mtrlwareid
- INTO :ll_scid,:ll_mtrlwareid
- FROM u_mtrlware,u_mtrlware_mx,u_mtrldef
- WHERE u_mtrlware.storageid = :storageid
- AND u_mtrlware_mx.barcode = :s_mx_barcode[i].barcode
- AND u_mtrlware.mtrlid = u_mtrlware_mx.mtrlid
- AND u_mtrlware.mtrlid = u_mtrldef.mtrlid
- AND ( u_mtrlware.sptid = u_mtrlware_mx.sptid AND :li_storagetype_storage = 0 OR
- u_mtrlware.sptid = 0 AND :li_storagetype_storage = 1 )
- AND u_mtrlware.status = u_mtrlware_mx.status
- AND u_mtrlware.woodcode = u_mtrlware_mx.woodcode
- AND u_mtrlware.pcode = u_mtrlware_mx.pcode
- AND u_mtrlware.plancode = u_mtrlware_mx.plancode
- AND ( u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND :li_storagetype_storage = 0 OR
- :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = u_mtrlware_mx.mtrlcuscode AND (u_mtrldef.ifpackpro = 4 OR u_mtrldef.ifpack = 2) OR
- :li_storagetype_storage = 1 AND u_mtrlware.mtrlcuscode = '' AND u_mtrldef.ifpackpro <> 4 AND u_mtrldef.ifpack <> 2 )
- AND (u_mtrlware.Location = u_mtrlware_mx.Location AND :uo_option_barcodelocation_use_inwaremx_location = 0 OR
- u_mtrlware.Location = :ls_location_top1 And :uo_option_barcodelocation_use_inwaremx_location = 1 ) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '条码:'+s_mx_barcode[i].barcode+',查询库存资料失败,请检查对应条码单与库存资料,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- ll_scid = 0
- ll_mtrlwareid = 0
- END IF
-
- IF uo_gb.uof_barcode_in(s_mx_barcode[i].barcode,&
- ll_scid,ll_mtrlwareid,'',0,0,arg_audittype,0,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- END IF
- Destroy uo_getbar
- RETURN rslt
- end function
- public function integer uof_outbarcode_add (integer arg_billtype, long arg_scid, long arg_outwareid, string arg_barcode, decimal arg_qty, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- INSERT INTO u_outwaremx_mx_barcode
- (billtype,scid,outwareid,barcode,qty)
- VALUES
- (:arg_billtype,
- :arg_scid,:arg_outwareid,:arg_barcode,:arg_qty);
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '出仓明细保存条码失败,条码:'+arg_barcode+','+sqlca.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT;
- END IF
- RETURN rslt
- end function
- public function integer priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- IF priceflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经确认"
- GOTO ext
- END IF
- UPDATE u_outware
- SET priceemp = :publ_operator,
- pricedate = getdate(),
- priceflag = 1
- WHERE u_outware.outwareid = :outwareid
- AND priceflag = 0
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- priceflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer c_priceaudit (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- DateTime null_dt
- SetNull(null_dt)
- IF priceflag = 0 THEN
- rslt = 0
- arg_msg = "单据还未确认,不能反确认"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已仓审,不能反确认"
- GOTO ext
- END IF
- IF it_mxbt_barcode > 0 THEN
- arg_msg = '单据已扫描条码,不能反确认,如果要反确认,请先清除条码'
- rslt = 0
- GOTO ext
- END IF
- UPDATE u_outware
- SET priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- WHERE u_outware.outwareid = :outwareid
- AND priceflag = 1
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致反确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在反确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- priceflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer uof_set_qty_equal_bqty (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Int li_ref_outtype
- Long ll_i,ll_j,ll_k
- Long ll_f,ll_arr
- Long ll_mtrlware_arr[]
- Decimal ld_outqty_arr[],ld_updateqty
- IF arg_outwareid <= 0 THEN
- arg_msg = '错误的单据id'
- rslt = 0
- GOTO ext
- END IF
- IF getinfo(arg_scid,arg_outwareid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF f_rst_storage_outtype(storageid,li_ref_outtype) = 0 THEN
- arg_msg = '查询仓库出仓策略失败,请检查仓库资料'
- rslt = 0
- GOTO ext
- END IF
- IF li_ref_outtype <> 2 THEN
- arg_msg = '仓库出仓策略不是使用条码出仓,操作取消,请检查仓库资料'
- rslt = 0
- GOTO ext
- END IF
- IF priceflag = 0 THEN
- arg_msg = '单据未确认,操作取消'
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- arg_msg = '单据已仓审,操作取消'
- rslt = 0
- GOTO ext
- END IF
- //计算条码出仓数
- FOR ll_j = 1 TO it_mxbt_barcode
- ll_f = 0
- ll_arr = UpperBound(ll_mtrlware_arr)
- FOR ll_k = 1 TO ll_arr
- IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN
- ll_f = ll_k
- EXIT
- END IF
- NEXT
-
- IF ll_f > 0 THEN
- ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty
- ELSE
- ll_arr++
- ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid
- ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty
- END IF
- NEXT
- UPDATE u_outwaremx
- SET u_outwaremx.uqty = 0,
- u_outwaremx.qty = 0
- FROM u_outwaremx,u_mtrldef
- WHERE u_outwaremx.scid = :arg_scid
- AND u_outwaremx.outwareid = :arg_outwareid
- AND u_outwaremx.mtrlid = u_mtrldef.mtrlid
- AND u_mtrldef.outtype = 2 USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '清除出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- FOR ll_i = 1 TO it_mxbt
- ld_updateqty = 0
- IF outwaremx[ll_i].outtype_mtrl <> 2 THEN CONTINUE
-
- FOR ll_k = 1 TO UpperBound(ll_mtrlware_arr)
- IF ld_outqty_arr[ll_k] = 0 THEN CONTINUE
- IF outwaremx[ll_i].mtrlwareid = ll_mtrlware_arr[ll_k] THEN
- IF outwaremx[ll_i].qty >= ld_outqty_arr[ll_k] THEN
- ld_updateqty = ld_outqty_arr[ll_k]
- ld_outqty_arr[ll_k] = 0
- ELSE
- ld_updateqty = outwaremx[ll_i].qty
- ld_outqty_arr[ll_k] = ld_outqty_arr[ll_k] - outwaremx[ll_i].qty
- END IF
- EXIT
- END IF
- NEXT
-
- IF ld_updateqty > 0 THEN
- UPDATE u_outwaremx
- SET u_outwaremx.uqty = :ld_updateqty,
- u_outwaremx.qty = :ld_updateqty
- WHERE u_outwaremx.scid = :arg_scid
- AND u_outwaremx.outwareid = :arg_outwareid
- AND u_outwaremx.printid = :outwaremx[ll_i].printid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '行:'+String(ll_i)+',更新出仓明细按条码出仓物料出仓数失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer uof_check_qty_to_bqty (ref string arg_msg);Int rslt = 1
- Long ll_j,ll_k
- Long ll_f,ll_arr,ll_find
- String ls_mtrlcode_array[],ls_mtrlcode
- Long ll_mtrlware_arr[]
- Decimal ld_outqty_arr[]
- Long ll_mtrlware_arr_bill[]
- Decimal ld_outqty_arr_bill[]
- Boolean lb_equal = False
- //计算条码出仓数
- FOR ll_j = 1 To it_mxbt_barcode
- ll_f = 0
- ll_arr = UpperBound(ll_mtrlware_arr)
- FOR ll_k = 1 To ll_arr
- IF ll_mtrlware_arr[ll_k] = s_mx_barcode[ll_j].mtrlwareid THEN
- ll_f = ll_k
- EXIT
- END IF
- NEXT
-
- IF ll_f > 0 THEN
- ld_outqty_arr[ll_f] += s_mx_barcode[ll_j].outqty
- ELSE
- ll_arr++
- ll_mtrlware_arr[ll_arr] = s_mx_barcode[ll_j].mtrlwareid
- ld_outqty_arr[ll_arr] = s_mx_barcode[ll_j].outqty
- END IF
- NEXT
- //计算出仓明细出仓数
- IF billtype = 1 THEN
- FOR ll_j = 1 To it_mxbt_mx
- ll_f = 0
- ll_arr = UpperBound(ll_mtrlware_arr_bill)
- FOR ll_k = 1 To ll_arr
- IF ll_mtrlware_arr_bill[ll_k] = outwaremx_mx[ll_j].mtrlwareid THEN
- ll_f = ll_k
- EXIT
- END IF
- NEXT
-
- IF ll_f > 0 THEN
- ld_outqty_arr_bill[ll_f] += outwaremx_mx[ll_j].qty
- ELSE
- ll_arr++
- ls_mtrlcode_array[ll_arr] = outwaremx_mx[ll_j].mtrlcode
- ll_mtrlware_arr_bill[ll_arr] = outwaremx_mx[ll_j].mtrlwareid
- ld_outqty_arr_bill[ll_arr] = outwaremx_mx[ll_j].qty
- END IF
- NEXT
- ELSE
- FOR ll_j = 1 To it_mxbt
- IF outwaremx[ll_j].outtype_mtrl <> 2 THEN CONTINUE
- ll_f = 0
- ll_arr = UpperBound(ll_mtrlware_arr_bill)
- FOR ll_k = 1 To ll_arr
- IF ll_mtrlware_arr_bill[ll_k] = outwaremx[ll_j].mtrlwareid THEN
- ll_f = ll_k
- EXIT
- END IF
- NEXT
-
- IF ll_f > 0 THEN
- ld_outqty_arr_bill[ll_f] += outwaremx[ll_j].qty
- ELSE
- ll_arr++
- ls_mtrlcode_array[ll_arr] = outwaremx[ll_j].mtrlcode
- ll_mtrlware_arr_bill[ll_arr] = outwaremx[ll_j].mtrlwareid
- ld_outqty_arr_bill[ll_arr] = outwaremx[ll_j].qty
- END IF
- NEXT
- END IF
- //检查1
- FOR ll_j = 1 To UpperBound(ll_mtrlware_arr_bill)
- lb_equal = False
- IF ld_outqty_arr_bill[ll_j] = 0 THEN CONTINUE
-
- ll_find = 0
- FOR ll_k = 1 To UpperBound(ll_mtrlware_arr)
- IF ll_mtrlware_arr_bill[ll_j] = ll_mtrlware_arr[ll_k] THEN
- ll_find = ll_k
- IF ld_outqty_arr_bill[ll_j] = ld_outqty_arr[ll_k] THEN
- lb_equal = True
- EXIT
- END IF
- END IF
- NEXT
-
- IF Not lb_equal THEN
- IF ll_find = 0 THEN
- arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:0,不相等请检查'
- ELSE
- arg_msg = '出仓明细:'+ls_mtrlcode_array[ll_j]+',按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_j],'#0.##########')+',与条码扫描明细数量:'+String( ld_outqty_arr[ll_find],'#0.##########')+',不相等请检查'
- END IF
- rslt = 0
- GOTO ext
- END IF
- NEXT
- //检查2
- FOR ll_j = 1 To UpperBound(ll_mtrlware_arr)
- lb_equal = False
- IF ld_outqty_arr[ll_j] = 0 THEN CONTINUE
-
- ll_find = 0
- FOR ll_k = 1 To UpperBound(ll_mtrlware_arr_bill)
- IF ll_mtrlware_arr[ll_j] = ll_mtrlware_arr_bill[ll_k] THEN
- ll_find = ll_k
- IF ld_outqty_arr[ll_j] = ld_outqty_arr_bill[ll_k] THEN
- lb_equal = True
- EXIT
- END IF
- END IF
- NEXT
-
- IF Not lb_equal THEN
- ls_mtrlcode = ''
- SELECT u_mtrldef.mtrlcode INTO :ls_mtrlcode
- FROM u_mtrlware,u_mtrldef
- WHERE u_mtrlware.mtrlid = u_mtrldef.mtrlid
- AND u_mtrlware.scid = :scid
- And u_mtrlware.mtrlwareid = :ll_mtrlware_arr[ll_j] Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询条码库存id:'+String(ll_mtrlware_arr[ll_j])+',查询物料编码失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF ll_find = 0 THEN
- arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:0,不相等,请检查'
- ELSE
- arg_msg = '条码扫描明细物料:'+ls_mtrlcode+',数量:'+String( ld_outqty_arr[ll_j],'#0.##########')+',与出仓明细按条码出仓物料的出仓数:'+String( ld_outqty_arr_bill[ll_find],'#0.##########')+',不相等,请检查'
- END IF
- rslt = 0
- GOTO ext
- END IF
- NEXT
- ext:
- RETURN rslt
- end function
- public function integer uof_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经财审,不能再财审"
- GOTO ext
- END IF
- UPDATE u_outware
- SET secauditingrep = :publ_operator,
- secauditingdate = getdate(),
- secflag = 1
- WHERE outwareid = :outwareid
- AND secflag = 0
- AND scid = :scid USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- secflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer uof_c_secaudit (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,i
- DateTime null_dt
- SetNull(null_dt)
- Int li_StoreBalcType,li_AmtAuditFlag
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 0 THEN
- rslt = 0
- arg_msg = "单据不在财审状态,不能执行财撤"
- GOTO ext
- END IF
- //检查仓库是否分开结存
- IF balcdateint <> 0 THEN
- SELECT StoreBalcType
- INTO :li_StoreBalcType
- FROM u_storage
- Where storageid = :storageid;
- IF sqlca.SQLCode <> 0 THEN
- li_StoreBalcType = 0
- END IF
-
- //如果分开结存,检查结存表是否已金额结存
- IF li_StoreBalcType = 1 THEN
- SELECT top 1 AmtAuditFlag
- INTO :li_AmtAuditFlag
- FROM u_warebalc
- WHERE storageid = :storageid
- And balcdateint = :balcdateint;
- IF sqlca.SQLCode <> 0 THEN
- li_AmtAuditFlag = 0
- END IF
-
- IF li_AmtAuditFlag = 1 THEN
- rslt = 0
- arg_msg = '仓库结存日期段已执行过金额结存,不能财撤单据'
- GOTO ext
- END IF
- END IF
- END IF
- UPDATE u_outware
- SET secauditingrep = '',
- secauditingdate = :null_dt,
- secflag = 0
- WHERE outwareid = :outwareid
- AND secflag = 1
- And scid = :scid Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- secflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer acceptmx_item (long arg_printid, long arg_itemid, decimal arg_amt, string arg_mxdscrp, ref string arg_msg);Int rslt = 1
- Long cnt
- cnt = 0
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_itemid) THEN arg_itemid = 0
- IF IsNull(arg_amt) THEN arg_amt = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF arg_itemid = 0 Or arg_amt = 0 THEN
- rslt = 1
- GOTO ext
- END IF
- SELECT count(*)
- INTO :cnt
- FROM u_itemdef
- Where itemid = :arg_itemid;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询收支项目是否存在失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = '第'+String(arg_printid)+'行,收支项目不存在,请检查'
- GOTO ext
- END IF
- it_mxbt_item++
- outware_itemmx[it_mxbt_item].printid = arg_printid
- outware_itemmx[it_mxbt_item].itemid = arg_itemid
- outware_itemmx[it_mxbt_item].amt = arg_amt
- outware_itemmx[it_mxbt_item].mxdscrp = arg_mxdscrp
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- end function
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_olmtrlid, long arg_packqty, string arg_outtype, decimal arg_planqty, long arg_relprintid, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_pricetype, string arg_formula, long arg_saleoutid, long arg_saleoutprintid, string arg_mxdscrp2, decimal arg_net_weight, decimal arg_gross_weight, decimal arg_cubage, decimal arg_taxrate, string arg_priceformula, string arg_qtyformula);
- s_outwaremx s_mx
- s_mx.mtrlwareid = arg_mtrlwareid
- s_mx.qty = arg_qty
- s_mx.fprice = arg_fprice
- s_mx.rebate = arg_rebate
- s_mx.mxdscrp = arg_mxdscrp
- s_mx.printid = arg_printid
- s_mx.ifrel = arg_ifrel
- s_mx.relid = arg_relid
- s_mx.olmtrlid = arg_olmtrlid
- s_mx.packqty = arg_packqty
- s_mx.outtype = arg_outtype
- s_mx.planqty = arg_planqty
- s_mx.relprintid = arg_relprintid
- s_mx.unit = arg_unit
- s_mx.uqty = arg_uqty
- s_mx.rate = arg_rate
- s_mx.pricetype = arg_pricetype
- s_mx.formula = arg_formula
- s_mx.saleoutid = arg_saleoutid
- s_mx.saleoutprintid = arg_saleoutprintid
- s_mx.mxdscrp2 = arg_mxdscrp2
- s_mx.net_weight = arg_net_weight
- s_mx.gross_weight = arg_gross_weight
- s_mx.cubage = arg_cubage
- s_mx.taxrate = arg_taxrate
- s_mx.priceformula = arg_priceformula
- s_mx.qtyformula = arg_qtyformula
- return acceptmx(s_mx, arg_msg)
- end function
- public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg);Int rslt = 1
- Long cnt
- SELECT count(*)
- INTO :cnt
- FROM u_warepdb
- WHERE storageid = :arg_storageid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库是否有盘点表未审核失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = '仓库有盘点表未审核,不能仓审或仓撤单据,请检查'
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
- public function integer uof_disuse (long arg_scid, long arg_outwareid, integer arg_disusetype, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Long ll_disuseid
- //arg_disusetype 0 - 修改, 1-删除
- Select max(disuseid) Into :ll_disuseid
- From u_outware_disuse
- Where scid = :arg_scid
- And outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode = -1 Then
- rslt = 0
- arg_msg = '获取销售发货单废弃单序号失败,'+ commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLCode = 100 Then
- ll_disuseid = 0
- End If
- if isnull(ll_disuseid) then ll_disuseid = 0
- ll_disuseid++
- Insert Into u_outware_disuse
- (scid, outwareid, outwarecode, billtype, relid, StorageID, opdate, opemp, Modemp,
- moddate, flag, auditingdate, auditingrep, outdate, outrep, part, dscrp, cusid, cusname,
- balcflag, balcdateint, thflag, secflag, secauditingdate, secauditingrep, ctmint,
- printnum, wagemth, otheramt, relstr_1, relstr_2, relstr_3, relint_1, relint_2, relint_3,
- priceflag, pricedate, priceemp, rel_address, rel_tele, rel_fax, rel_rep, mrate, damt,
- upname, ifauto, viewdate, deptid, senduser, sendcnt, sendtime, pda_flag, pda_date,
- carcode, transcode, lsflag, totalamt, getamt, moneyname, banktypename,
- storagename, disuseemp, disusedate, disusetype, disuseid)
- Select u_outware.scid, u_outware.outwareid, u_outware.outwarecode, u_outware.billtype,
- u_outware.relid, u_outware.StorageID, u_outware.opdate, u_outware.opemp,
- u_outware.Modemp, u_outware.moddate, u_outware.flag, u_outware.auditingdate,
- u_outware.auditingrep, u_outware.outdate, u_outware.outrep, u_outware.part,
- u_outware.dscrp, u_outware.cusid, u_outware.cusname, u_outware.balcflag,
- u_outware.balcdateint, u_outware.thflag, u_outware.secflag,
- u_outware.secauditingdate, u_outware.secauditingrep, u_outware.ctmint,
- u_outware.printnum, u_outware.wagemth, u_outware.otheramt, u_outware.relstr_1,
- u_outware.relstr_2, u_outware.relstr_3, u_outware.relint_1, u_outware.relint_2,
- u_outware.relint_3, u_outware.priceflag, u_outware.pricedate, u_outware.priceemp,
- u_outware.rel_address, u_outware.rel_tele, u_outware.rel_fax, u_outware.rel_rep,
- u_outware.mrate, u_outware.damt, u_outware.upname, u_outware.ifauto,
- u_outware.viewdate, u_outware.deptid, u_outware.senduser, u_outware.sendcnt,
- u_outware.sendtime, u_outware.pda_flag, u_outware.pda_date, u_outware.carcode,
- u_outware.transcode, u_outware.lsflag, u_outware.totalamt, u_outware.getamt,
- cw_currency.name, cw_banktype.banktypename, u_storage.storagename,
- :publ_operator,getdate(),:arg_disusetype,:ll_disuseid
- From u_outware LEFT Outer JOIN
- u_storage ON u_outware.StorageID = u_storage.storageid LEFT Outer JOIN
- cw_banktype ON u_outware.relint_1 = cw_banktype.banktypeid LEFT Outer JOIN
- cw_currency ON u_outware.relint_2 = cw_currency.moneyid
- Where u_outware.scid = :arg_scid
- And u_outware.outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '插入销售发货单废弃单失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Insert Into u_outwaremx_disuse
- (scid, outwareid, printid, mtrlwareid, mtrlid, storageid, plancode, status, qty, fprice,
- rebate, price, costamt, planprice, mxdscrp, Sptid, Dxflag, ifrel, olmtrlid, relid, packqty,
- woodcode, relcode, pcode, enprice, newpriceamt, ctmint, outtype, dftsaleprice, cost,
- planqty, relprintid, uqty, rate, unit, scidprice, outtypestr, overqty, mtrlcuscode,
- location, pricetype, formula, capacity, saleqty, saleoutid, saleoutprintid, net_weight,
- gross_weight, cubage, mxdscrp2, taxrate, priceformula, qtyformula, mtrlwareprintid,
- mtrlcode, mtrlname,disuseid)
- Select u_outwaremx.scid, u_outwaremx.outwareid, u_outwaremx.printid,
- u_outwaremx.mtrlwareid, u_outwaremx.mtrlid, u_outwaremx.storageid,
- u_outwaremx.plancode, u_outwaremx.status, u_outwaremx.qty, u_outwaremx.fprice,
- u_outwaremx.rebate, u_outwaremx.price, u_outwaremx.costamt,
- u_outwaremx.planprice, u_outwaremx.mxdscrp, u_outwaremx.Sptid,
- u_outwaremx.Dxflag, u_outwaremx.ifrel, u_outwaremx.olmtrlid, u_outwaremx.relid,
- u_outwaremx.packqty, u_outwaremx.woodcode, u_outwaremx.relcode,
- u_outwaremx.pcode, u_outwaremx.enprice, u_outwaremx.newpriceamt,
- u_outwaremx.ctmint, u_outwaremx.outtype, u_outwaremx.dftsaleprice,
- u_outwaremx.cost, u_outwaremx.planqty, u_outwaremx.relprintid, u_outwaremx.uqty,
- u_outwaremx.rate, u_outwaremx.unit, u_outwaremx.scidprice,
- u_outwaremx.outtypestr, u_outwaremx.overqty, u_outwaremx.mtrlcuscode,
- u_outwaremx.location, u_outwaremx.pricetype, u_outwaremx.formula,
- u_outwaremx.capacity, u_outwaremx.saleqty, u_outwaremx.saleoutid,
- u_outwaremx.saleoutprintid, u_outwaremx.net_weight, u_outwaremx.gross_weight,
- u_outwaremx.cubage, u_outwaremx.mxdscrp2, u_outwaremx.taxrate,
- u_outwaremx.priceformula, u_outwaremx.qtyformula, u_outwaremx.mtrlwareprintid,
- u_mtrldef.mtrlcode, u_mtrldef.mtrlname,:ll_disuseid
- From u_outwaremx LEFT Outer JOIN
- u_mtrldef ON u_outwaremx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx.scid = :arg_scid
- And u_outwaremx.outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '插入销售发货单废弃单明细失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Insert Into u_outwaremx_mx_disuse
- (scid, outwareid, printid, mxprintid, mtrlwareid, storageid, mtrlid, plancode, status,
- woodcode, pcode, mtrlcuscode, location, sptid, dxflag, planqty, qty, mxdscrp, ctmint,
- mtrlcode, mtrlname, disuseid)
- Select u_outwaremx_mx.scid, u_outwaremx_mx.outwareid, u_outwaremx_mx.printid,
- u_outwaremx_mx.mxprintid, u_outwaremx_mx.mtrlwareid,
- u_outwaremx_mx.storageid, u_outwaremx_mx.mtrlid, u_outwaremx_mx.plancode,
- u_outwaremx_mx.status, u_outwaremx_mx.woodcode, u_outwaremx_mx.pcode,
- u_outwaremx_mx.mtrlcuscode, u_outwaremx_mx.location, u_outwaremx_mx.sptid,
- u_outwaremx_mx.dxflag, u_outwaremx_mx.planqty, u_outwaremx_mx.qty,
- u_outwaremx_mx.mxdscrp, u_outwaremx_mx.ctmint, u_mtrldef.mtrlcode,
- u_mtrldef.mtrlname,:ll_disuseid
- From u_outwaremx_mx LEFT Outer JOIN
- u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx_mx.scid = :arg_scid
- And u_outwaremx_mx.outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '插入销售发货单废弃单包件明细失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Insert Into u_outwaremx_mx_barcode_disuse
- (billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, disuseid)
- Select billtype, scid, outwareid, barcode, qty, ctmint, printid, opemp, opdate, :ll_disuseid
- From u_outwaremx_mx_barcode
- Where u_outwaremx_mx_barcode.scid = :arg_scid
- And u_outwaremx_mx_barcode.outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '插入销售发货单废弃单条码明细失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Insert Into u_outware_itemmx_disuse
- (scid, outwareid, printid, itemid, amt, mxdscrp, itemcode, itemname, itemtype,
- disuseid)
- Select u_outware_itemmx.scid, u_outware_itemmx.outwareid, u_outware_itemmx.printid,
- u_outware_itemmx.itemid, u_outware_itemmx.amt, u_outware_itemmx.mxdscrp,
- u_itemdef.itemcode, u_itemdef.itemname, u_itemdef.itemtype,:ll_disuseid
- From u_outware_itemmx LEFT Outer JOIN
- u_itemdef ON u_outware_itemmx.itemid = u_itemdef.itemid
- Where u_outware_itemmx.scid = :arg_scid
- And u_outware_itemmx.outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '插入销售发货单废弃单费用明细失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Return rslt
- end function
- public function integer uof_updatesaleoutcodestr (long arg_scid, long arg_outwareid, ref string arg_msg);if sys_option_if_saleout = 0 then return 1
- Int rslt = 1
- Long i
- Long ll_scid, ll_taskid, ll_printid
- uo_bgtr_timer uo_tr
- uo_tr = Create uo_bgtr_timer
- IF getinfo(arg_scid, arg_outwareid, arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- FOR i = 1 To it_mxbt
- ll_taskid = outwaremx[i].relid
- ll_printid = outwaremx[i].relprintid
- IF ll_taskid > 0 And ll_printid > 0 THEN
- IF uo_tr.uf_update_saleoutcodestr(arg_scid, ll_taskid, ll_printid, arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- ext:
- Destroy uo_tr
- RETURN rslt
- end function
- public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i
- Long i_mtrlid,i_storageid,i_sptid
- Int i_dxflag,li_mtrlkind
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- Decimal i_planprice,ld_dftsaleprice
- Double i_cost,i_newprice
- Decimal i_notauditqty,i_allouseqty
- String ls_relcode,ls_relcode_saleout
- Decimal lde_noconqty,lde_notauditqty,lde_mx_qty
- Decimal ld_saletqty_task,ld_fpqty_task,ld_consignedqty_task
- Decimal lde_notauditqty_plan
- Long ll_storagescid
- String ls_unit
- Int li_ifunit
- Decimal ld_scllrate
- String i_mtrlcuscode,i_location
- Decimal ld_viewqty
- Int li_if_cus_mtrlware
- Int ls_noallocflag
- Long ll_storagetype,ll_storagetype_storage,ll_outtype_storage
- Int li_statusflag
- Decimal ld_capacity,ld_capacity_zj
- s_mtrlcfg_expr s_pz[]
- String ls_status_zj
- Long ll_i
- Long li_storagetype
- Decimal ld_upsalerate,ld_upsaleqty
- String ls_status_task,ls_woodcode_task,ls_pcode_task
- Long ll_mtrlid_task
- Decimal ld_scllqty
- Int li_status_ck,li_woodcode_ck,li_pcode_ck
- Decimal ld_noaudit_planqty
- Int i_ifpackpro,li_outtype,i_ifpack
- Decimal i_packqty_fp,ld_pack_noauditqty
- //uo_option_confirmaudit_sale
- //uo_option_sale_use_planqty
- //uo_option_mtrlware_limit
- //uo_option_inout_type
- //uo_option_if_pricetype
- //uo_option_checkprice_native
- uo_cusprice uo_price
- uo_price = Create uo_cusprice
- If uo_option_confirmaudit_sale = -1000 Then
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_sale_use_planqty = -1000 Then
- rslt = 0
- arg_msg = '选项:[115]销售发货单使用计划发货数,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_mtrlware_limit = -1000 Then
- rslt = 0
- arg_msg = '选项:[037]客户库存选择限制,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_inout_type = -1000 Then
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_if_pricetype = -1000 Then
- rslt = 0
- arg_msg = '选项:[154]启用价格分类,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_checkprice_native = -1000 Then
- rslt = 0
- arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_if_saleout = -1000 Then
- rslt = 0
- arg_msg = '选项:[200]使用发货通知单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_outware_sale_checkprice = -1000 Then
- rslt = 0
- arg_msg = '选项:[320]销售发货单保存时检查实价是否与销售订单一致,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_scll_use_planqty = -1000 Then
- rslt = 0
- arg_msg = '选项:[123]领料单使用计划领料数,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_price_rmb = -1000 Then
- rslt = 0
- arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_pk_notauditqty_check = -1000 Then
- rslt = 0
- arg_msg = '选项:[397]盘亏单保存时检查库存未开单数,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If it_newbegin = False And it_updatebegin = False Then
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- Goto ext
- End If
- If uo_option_canpack_ifzanyong = -1000 Then
- rslt = 0
- arg_msg = '选项:[417]通用包件产品可装数选项,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- Select scid,
- storagetype,
- outtype,
- balctype,
- noallocflag
- Into :ll_storagescid,
- :ll_storagetype_storage,
- :ll_outtype_storage,
- :li_if_cus_mtrlware,
- :ls_noallocflag
- From u_storage
- Where storageid = :storageid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText
- Goto ext
- End If
- //清除空值
- If IsNull(s_mx.mtrlwareid) Then s_mx.mtrlwareid = 0
- If IsNull(s_mx.printid) Then s_mx.printid = 0
- If IsNull(s_mx.qty) Then s_mx.qty = 0
- If IsNull(s_mx.fprice) Then s_mx.fprice = 0
- If IsNull(s_mx.rebate) Then s_mx.rebate = 0
- If IsNull(s_mx.mxdscrp) Then s_mx.mxdscrp = ''
- If IsNull(s_mx.ifrel) Then s_mx.ifrel = 0
- If IsNull(s_mx.relid) Then s_mx.relid = 0
- If IsNull(s_mx.olmtrlid) Then s_mx.olmtrlid = 0
- If IsNull(s_mx.packqty) Then s_mx.packqty = 0
- If IsNull(s_mx.outtype) Then s_mx.outtype = ''
- If IsNull(s_mx.planqty) Then s_mx.planqty = 0
- If IsNull(s_mx.relprintid) Then s_mx.relprintid = 0
- If IsNull(s_mx.unit) Then s_mx.unit = ''
- If IsNull(s_mx.uqty) Then s_mx.uqty = 0
- If IsNull(s_mx.rate) Then s_mx.rate = 1
- If IsNull(s_mx.pricetype) Then s_mx.pricetype = ''
- If IsNull(s_mx.formula) Then s_mx.formula = ''
- If IsNull(s_mx.saleoutid) Then s_mx.saleoutid = 0
- If IsNull(s_mx.saleoutprintid) Then s_mx.saleoutprintid = 0
- If IsNull(s_mx.mxdscrp2) Then s_mx.mxdscrp2 = ''
- If IsNull(s_mx.net_weight) Then s_mx.net_weight = 0
- If IsNull(s_mx.gross_weight) Then s_mx.gross_weight = 0
- If IsNull(s_mx.cubage) Then s_mx.cubage = 0
- If IsNull(s_mx.taxrate) Then s_mx.taxrate = 0
- If IsNull(s_mx.priceformula) Then s_mx.priceformula = ''
- If IsNull(s_mx.qtyformula) Then s_mx.qtyformula = ''
- If IsNull(s_mx.ifvqty) Then s_mx.ifvqty = 0
- If IsNull(s_mx.backtype) Then s_mx.backtype = 0
- If IsNull(s_mx.ifnotinout) Then s_mx.ifnotinout = 0
- If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then
- rslt = 1
- Goto ext
- End If
- If billtype <> 9 Then
- If s_mx.uqty = 0 And s_mx.rate = 0 Then
- rslt = 1
- Goto ext
- End If
- End If
- If s_mx.uqty = 0 Then
- s_mx.rate = 1
- Else
- If billtype = 1 Then
- s_mx.rate = s_mx.planqty / s_mx.uqty
- Else
- s_mx.rate = s_mx.qty / s_mx.uqty
- End If
- End If
- If s_mx.rebate < 0 Then
- arg_msg = '折扣错误,请检查'
- rslt = 0
- Goto ext
- End If
- //检查物料库存ID
- Select u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.cost,
- u_mtrldef.mtrlcode,
- u_mtrlware.sptid,
- u_mtrlware.dxflag,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- u_mtrlware.noauditingqty,
- u_mtrlware.noallocqty,
- u_mtrldef.unit,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location,
- u_mtrldef.storagetype,
- u_mtrldef.statusflag,
- u_mtrldef.capacity * u_mtrldef.capaparm,
- u_mtrldef.storagetype,
- u_mtrldef.upsalerate,
- u_mtrldef.upsaleqty,
- u_mtrldef.ifunit,
- u_mtrldef.outtype,
- u_mtrldef.ifpackpro,
- u_mtrldef.ifpack,
- u_mtrlware.packqty_fp
- Into :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_mtrlcode,
- :i_sptid,
- :i_dxflag,
- :i_woodcode,
- :i_pcode,
- :i_notauditqty,
- :i_allouseqty,
- :ls_unit,
- :i_mtrlcuscode,
- :i_location,
- :ll_storagetype,
- :li_statusflag,
- :ld_capacity,
- :li_storagetype,
- :ld_upsalerate,
- :ld_upsaleqty,
- :li_ifunit,
- :li_outtype,
- :i_ifpackpro,
- :i_ifpack,
- :i_packqty_fp
- From u_mtrlware Inner JOIN
- u_mtrldef ON u_mtrlware.mtrlid = u_mtrldef.mtrlid
- Where ( u_mtrlware.mtrlwareid = :s_mx.mtrlwareid )
- And ( u_mtrlware.scid = :ll_storagescid ) Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText
- Goto ext
- End If
- If IsNull(ld_dftsaleprice) Then ld_dftsaleprice = 0
- If IsNull(i_cost) Then i_cost = 0
- If IsNull(i_plancode) Then i_plancode = ''
- If IsNull(i_status) Then i_status = ''
- If IsNull(i_mtrlid) Then i_mtrlid = 0
- If IsNull(i_storageid) Then i_storageid = 0
- If IsNull(i_sptid) Then i_sptid = 0
- If IsNull(i_dxflag) Then i_dxflag = 0
- If IsNull(i_woodcode) Then i_woodcode = ''
- If IsNull(i_pcode) Then i_pcode = ''
- If IsNull(i_mtrlcuscode) Then i_mtrlcuscode = ''
- If IsNull(i_location) Then i_location = ''
- If IsNull(ll_storagetype) Then ll_storagetype = 0
- If IsNull(li_statusflag) Then li_statusflag = 0
- If IsNull(ld_capacity) Then ld_capacity = 0
- If IsNull(ld_upsalerate) Then ld_upsalerate = 0
- If IsNull(ld_upsaleqty) Then ld_upsaleqty = 0
- If IsNull(i_packqty_fp) Then i_packqty_fp = 0
- If billtype = 1 And thflag = 0 Then
- If uo_option_confirmaudit_sale = 0 Or uo_option_sale_use_planqty = 0 Then
- If ll_outtype_storage = 0 Then //And ll_storagetype_storage = 0 THEN // // dyy edit 2012-02-23
- s_mx.qty = s_mx.planqty
- End If
-
- If li_ifunit = 0 And s_mx.rate <> 0 Then
- s_mx.uqty = s_mx.qty / s_mx.rate
- End If
-
- End If
- End If
- //销售发货单检查高级进出仓属性
- If billtype = 1 Then
- If uo_option_inout_type <> 0 And ll_outtype_storage <> 0 And i_ifpackpro <> 0 And li_outtype = 0 Then
- rslt = 0
- arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",仓库使用包件出仓或条码出仓,发货明细物料资料是包件产品,但产品资料没设为包件出仓或条码出仓,不能保存"
- Goto ext
- End If
- End If
- If s_mx.mtrlwareid = 0 Or ( s_mx.qty = 0 And s_mx.planqty = 0 And s_mx.uqty = 0 ) Then
- rslt = 1
- Goto ext
- End If
- //IF billtype <> 9 THEN
- // IF li_ifunit = 1 THEN
- // IF s_mx.uqty = s_mx.qty And s_mx.uqty > 0 And s_mx.qty > 0 And s_mx.unit <> ls_unit THEN
- // rslt = 0
- // arg_msg = "第"+String(s_mx.printid)+"行,物料使用库存双数量核算,但录入的计量单位数量与库存单位数量相同,操作取消"
- // GOTO ext
- // END IF
- // END IF
- //END IF
- //
- f_get_planprice_mtrl(i_mtrlid,i_status,i_woodcode,i_pcode,i_planprice)
- If IsNull(i_planprice) Then i_planprice = 0
- If li_statusflag = 2 Then
- ld_capacity = 0
- f_checkpz(i_status,s_pz[])
- For ll_i = 1 To UpperBound(s_pz)
- ls_status_zj = s_pz[ll_i].cfgname
-
- Select capacity * capaparm
- Into :ld_capacity_zj
- From u_mtrl_configure
- Where mtrlid = :i_mtrlid
- And Name = :ls_status_zj Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "第"+String(s_mx.printid)+"行,物料编码:"+i_mtrlcode+",查询子件 "+ls_status_zj+" 折算套数参数操作失败"
- Goto ext
- End If
-
- ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
- Next
- End If
- Select sum(qty) Into :ld_viewqty
- From u_mtrlware_view
- Where scid = :ll_storagescid
- And mtrlwareid = :s_mx.mtrlwareid
- And inuse = 1
- And cusid = :cusid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "第"+String(s_mx.printid)+"行,查询操作失败,库存虚拟数量,分部:"+String(ll_storagescid)+'库存:'+String(s_mx.mtrlwareid)+',~n'+commit_transaction.SQLErrText
- Goto ext
- End If
- If IsNull(ld_viewqty) Then ld_viewqty = 0
- If billtype = 1 Or billtype = 5 Then
- If ll_storagetype = 0 Then
- If li_if_cus_mtrlware = 1 And uo_option_mtrlware_limit = 0 And flag = 0 Then
- If cusid <> i_sptid Then
- rslt = 0
- arg_msg = "查询操作失败,明细纪录对应的库存不是该客户的库存!"
- Goto ext
- End If
- End If
- End If
- End If
- If billtype = 1 Then
- f_get_defsaleprice(cusid,i_mtrlid,i_status,i_pcode,i_woodcode,relint_2,ld_dftsaleprice)
- Else
- ld_dftsaleprice = 0
- mrate = 1
- End If
- If billtype <> 9 Then
- // IF Trim(ls_unit) <> Trim(s_mx.unit) And s_mx.rate = 1 THEN
- // arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'不同,但转换率为1,请检查'
- // rslt = 0
- // GOTO ext
- // END IF
-
- If Trim(ls_unit) = Trim(s_mx.unit) And s_mx.rate <> 1 Then
- arg_msg = '出仓单,行:'+String(s_mx.printid)+' '+i_mtrlcode+',物料库存单位:'+Trim(ls_unit)+'与采购单位:'+Trim(s_mx.unit)+'相同,但转换率不为1,请检查'
- rslt = 0
- Goto ext
- End If
- End If
- //*****检查大于未开数不可以开单
- If (flag = 0 And billtype <> 12 And billtype <> 21 And billtype <> 23 And billtype <> 17 And billtype <> 4 And billtype <> 7 ) And thflag = 0 Then
-
- If uo_option_pk_notauditqty_check = 0 And billtype = 9 Then
- Goto _end_check_qty
- End If
-
- If Not (billtype = 3 And relint_1 = 4 And it_newbegin) Then
- Decimal ol_mtrl_qty = 0,ld_mx_qty = 0,ld_ref_qty = 0
- Decimal ol_mtrl_qty_plan = 0,ol_mtrl_qty_sf = 0
-
-
- String ls_msg
- Boolean lb_ifplan = False
-
- If billtype = 1 And uo_option_confirmaudit_sale = 1 And uo_option_sale_use_planqty = 1 Then lb_ifplan = True
- If billtype = 1 And ll_outtype_storage = 2 Then lb_ifplan = True
- If billtype = 3 And relint_1 <> 4 And relint_1 <> 5 And uo_option_scll_use_planqty = 1 Then lb_ifplan = True
-
-
- If ls_noallocflag = 1 Then
- If it_updatebegin Then
- Select sum(u_outwaremx.qty),sum(u_outwaremx.planqty)
- Into :ol_mtrl_qty_sf,:ol_mtrl_qty_plan
- From u_outwaremx
- Where u_outwaremx.outwareid = :outwareid
- And u_outwaremx.mtrlwareid = :s_mx.mtrlwareid
- And scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode = -1 Then
- rslt = 0
- arg_msg = "物料编码:"+i_mtrlcode+',查询原开单数量失败'
- Goto ext
- End If
- End If
-
- For LS_i = 1 To it_mxbt
- If s_mx.mtrlwareid = outwaremx[LS_i].mtrlwareid Then
- If lb_ifplan Then
- ld_mx_qty = ld_mx_qty + outwaremx[LS_i].planqty
- Else
- ld_mx_qty = ld_mx_qty + outwaremx[LS_i].qty
- End If
- End If
- Next
-
- If lb_ifplan Then
- ld_mx_qty = ld_mx_qty + s_mx.planqty
- Else
- ld_mx_qty = ld_mx_qty + s_mx.qty
- End If
-
- If IsNull(i_allouseqty) Then i_allouseqty = 0
- If IsNull(i_notauditqty) Then i_notauditqty = 0
- If IsNull(ol_mtrl_qty_sf) Then ol_mtrl_qty_sf = 0
- If IsNull(ol_mtrl_qty_plan) Then ol_mtrl_qty_plan = 0
- If IsNull(ld_mx_qty) Then ld_mx_qty = 0
-
- Select ifpackpro Into :i_ifpackpro
- From u_mtrldef
- Where mtrlid = :i_mtrlid Using commit_transaction ;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = "物料编码:"+i_mtrlcode+',查询物料是否包件产品失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- ld_ref_qty = 0
- If i_ifpackpro > 0 Then
- If f_cmp_di_qty_outware(scid,outwareid,i_mtrlid,storageid,i_status,i_woodcode,i_pcode,i_plancode,i_mtrlcuscode,cusid,ld_ref_qty,ls_msg,arg_msg) = 0 Then
- ld_ref_qty = 0
- // arg_msg = '第'+String(s_mx.printid)+'行,计算可装数失败,'+arg_msg
- // rslt = 0
- // GOTO ext
- End If
-
- If uo_option_inout_type = 0 Then
- If lb_ifplan Then
- ol_mtrl_qty = ol_mtrl_qty_plan
- Else
- ol_mtrl_qty = ol_mtrl_qty_sf
- End If
- Else
- ol_mtrl_qty = 0
- End If
- Else
- If lb_ifplan Then
- ol_mtrl_qty = ol_mtrl_qty_plan
- Else
- ol_mtrl_qty = ol_mtrl_qty_sf
- End If
- End If
-
- If ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty + ld_ref_qty + ld_viewqty ) Then
- rslt = 0
- arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00#######')+"}" + "可组装数{"+String(ld_ref_qty,'#####,0.00#######')+"}"+ "库存虚拟数量{"+String(ld_viewqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######')
- Goto ext
- End If
-
- //如果包件产品使用占用数流程, 直接开单发包件,要检查数量不能超出未分配占用数(盘亏单除外)
- If i_ifpack = 1 And uo_option_canpack_ifzanyong = 1 And billtype <> 9 Then
- Select SUM(Case u_outwaremx.qty WHEN 0 Then u_outwaremx.planqty Else u_outwaremx.qty End)
- Into :ld_pack_noauditqty
- From u_outwaremx Inner JOIN
- u_outware On u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid
- Where (u_outware.flag = 0)
- And (u_outware.thflag = 0)
- And ( u_outwaremx.mtrlwareid = :s_mx.mtrlwareid )
- And ( u_outwaremx.scid = :scid )
- and (u_outware.outwareid <> :outwareid) Using commit_transaction;
- If commit_transaction.SQLCode = -1 Then
- rslt = 0
- arg_msg = "物料编码:"+i_mtrlcode+',查询包件直接开单数量失败'
- Goto ext
- End If
-
- If IsNull(ld_pack_noauditqty) Then ld_pack_noauditqty = 0
-
- If ld_mx_qty - ol_mtrl_qty + ld_pack_noauditqty > i_allouseqty - i_packqty_fp Then
- rslt = 0
- arg_msg = String(i_mtrlcode)+"库存未分配数不够,不能开单.未分配占用数{"+String(i_allouseqty - i_packqty_fp + ol_mtrl_qty,'#####,0.00#######')+"}" + "包件已直接开单数{"+string(ld_pack_noauditqty,'#####,0.00#######')+"},不能开单:"+String(ld_mx_qty,'#####,0.00#######')
- Goto ext
- End If
-
- End If
-
-
- End If
- End If
- _end_check_qty:
- End If
- //***********************************************
- If uo_option_sale_ifuse_negativeprice = 0 Then
- If s_mx.fprice * s_mx.rebate < 0 Then //检查单价
- rslt = 0
- arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 单价错误"
- Goto ext
- End If
- End If
- If s_mx.rebate < 0 Then
- rslt = 0
- arg_msg = '明细行:'+String(s_mx.printid)+",物料或产品:" + String(i_mtrlcode)+" 折扣错误"
- Goto ext
- End If
- Choose Case billtype
- Case 1
- If s_mx.ifrel > 0 Then
- If flag = 0 Then
- //检查订单
- If s_mx.relid = 0 Then
- arg_msg = '请先择相应的订单'
- rslt = 0
- Goto ext
- End If
-
- Select u_saletask.taskcode,
- u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty - u_saletaskmx.consignedqty ,
- u_saletaskmx.mtrlid,
- u_saletaskmx.status,
- u_saletaskmx.woodcode,
- u_saletaskmx.pcode,
- u_saletaskmx.fpqty,
- u_saletaskmx.saleqty * (1 + :ld_upsalerate) + :ld_upsaleqty,
- u_saletaskmx.consignedqty
- Into :ls_relcode,
- :lde_noconqty,
- :ll_mtrlid_task,
- :ls_status_task,
- :ls_woodcode_task,
- :ls_pcode_task,
- :ld_fpqty_task,
- :ld_saletqty_task,
- :ld_consignedqty_task
- From u_saletaskmx,u_saletask
- Where u_saletaskmx.taskid = :s_mx.relid
- And u_saletaskmx.scid = :scid
- And u_saletaskmx.scid = u_saletask.scid
- And u_saletaskmx.printid = :s_mx.relprintid
- And u_saletaskmx.taskid = u_saletask.taskid
- Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询销售订单是否有订购产品:'+i_mtrlcode+'失败'
- rslt = 0
- Goto ext
- End If
-
- If ll_mtrlid_task <> i_mtrlid Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息(物料id)不匹配,不允许保存,请检查相关订单信息与库存信息'
- rslt = 0
- Goto ext
- End If
-
- Select Top 1 Case WHEN ltrim(rtrim(:i_status)) = ltrim(rtrim(:ls_status_task)) Then 0 Else 1 End,
- Case WHEN ltrim(rtrim(:i_woodcode)) = ltrim(rtrim(:ls_woodcode_task)) Then 0 Else 1 End,
- Case WHEN ltrim(rtrim(:i_pcode)) = ltrim(rtrim(:ls_pcode_task)) Then 0 Else 1 End
- Into :li_status_ck,:li_woodcode_ck,:li_pcode_ck
- From u_user Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询订单:'+ls_relcode+' 产品:'+i_mtrlcode+',3个配置信息与库存3个配置信息是否相同失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If li_status_ck + li_woodcode_ck + li_pcode_ck > 0 Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+' 与发货单明细的库存信息不匹配,不允许保存,请检查相关订单信息与库存信息'
- rslt = 0
- Goto ext
- End If
-
- lde_mx_qty = 0
- For LS_i = 1 To it_mxbt
- If i_mtrlid = outwaremx[LS_i].mtrlid And &
- s_mx.relid = outwaremx[LS_i].relid And &
- i_status = outwaremx[LS_i].status And &
- i_woodcode = outwaremx[LS_i].woodcode And &
- i_pcode = outwaremx[LS_i].pcode And &
- (i_plancode = outwaremx[LS_i].plancode Or li_storagetype = 1) And &
- s_mx.relprintid = outwaremx[LS_i].relprintid Then
- If lb_ifplan Then
- lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty
- Else
- lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty
- End If
- End If
- Next
-
- If lb_ifplan Then
- lde_mx_qty = lde_mx_qty + s_mx.planqty
- Else
- lde_mx_qty = lde_mx_qty + s_mx.qty
- End If
-
- //查询相关订单已开发货单未审核数量
- Select isnull(sum(qty),0),isnull(sum(planqty),0)
- Into :lde_notauditqty,:lde_notauditqty_plan
- From u_outwaremx,u_outware
- Where u_outwaremx.relid = :s_mx.relid
- And u_outwaremx.relprintid = :s_mx.relprintid
- And u_outware.flag = 0
- And u_outware.billtype = 1
- And u_outwaremx.outwareid = u_outware.outwareid
- And u_outwaremx.scid = u_outware.scid
- And u_outware.outwareid <> :outwareid
- And u_outware.scid = :scid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询销售订单:'+ls_relcode+'产品:'+i_mtrlcode+'已开发货单未审核数量失败'
- rslt = 0
- Goto ext
- End If
-
- If lb_ifplan Then
- If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
-
- If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then
- If lde_notauditqty_plan + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
- End If
-
- Else
- If lde_notauditqty + lde_mx_qty > lde_noconqty Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数上限:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
- If ll_storagetype_storage = 1 And ls_noallocflag = 1 Then
- If lde_notauditqty + lde_mx_qty > ld_fpqty_task - ld_consignedqty_task Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'分配未发货数上限:'+String(ld_fpqty_task - ld_consignedqty_task,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- //检查发货通知单
- If uo_option_if_saleout = 1 And thflag = 0 Then
- If s_mx.saleoutid = 0 Then
- arg_msg = '请先择相应的发货通知单'
- rslt = 0
- Goto ext
- End If
-
- Select u_saleoutmx.saleqty - u_saleoutmx.consignedqty - u_saleoutmx.stopqty,
- u_saleout.taskcode
- Into :lde_noconqty,:ls_relcode_saleout
- From u_saleoutmx,u_saleout
- Where u_saleoutmx.taskid = :s_mx.saleoutid
- And u_saleoutmx.printid = :s_mx.saleoutprintid
- And u_saleoutmx.taskid = u_saleout.taskid
- And u_saleout.scid = :scid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询发货通知单是否有产品:'+i_mtrlcode+'失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- lde_mx_qty = 0
- For LS_i = 1 To it_mxbt
- If s_mx.saleoutid = outwaremx[LS_i].saleoutid And &
- s_mx.saleoutprintid = outwaremx[LS_i].saleoutprintid Then
- If lb_ifplan Then
- lde_mx_qty = lde_mx_qty + outwaremx[LS_i].planqty
- Else
- lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty
- End If
- End If
- Next
-
- If lb_ifplan Then
- lde_mx_qty = lde_mx_qty + s_mx.planqty
- Else
- lde_mx_qty = lde_mx_qty + s_mx.qty
- End If
-
- //查询相关订单已开发货单未审核数量
- Select isnull(sum(qty),0),isnull(sum(planqty),0)
- Into :lde_notauditqty,:lde_notauditqty_plan
- From u_outwaremx,u_outware
- Where u_outwaremx.saleoutid = :s_mx.saleoutid
- And u_outwaremx.saleoutprintid = :s_mx.saleoutprintid
- And u_outware.flag = 0
- And u_outware.billtype = 1
- And u_outwaremx.outwareid = u_outware.outwareid
- And u_outwaremx.scid = u_outware.scid
- And u_outware.outwareid <> :outwareid
- And u_outware.scid = :scid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'已开发货单未审核数量失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If lb_ifplan Then
- If lde_notauditqty_plan + lde_mx_qty > lde_noconqty Then
- arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty_plan,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
- Else
- If lde_notauditqty + lde_mx_qty > lde_noconqty Then
- arg_msg = '发货通知单:'+ls_relcode_saleout+',明细id:'+String(s_mx.saleoutprintid)+',产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
- End If
- End If
- End If
- End If
-
- Case 3
-
- // IF uo_option_scll_limit = 0 AND NOT relint_1 = 3 THEN
- If Not (relint_1 = 3 Or relint_1 = 4 ) Then
-
- Select u_mtrldef.mtrlkind,
- u_mtrldef.scllrate,
- u_mtrldef.scllqty
- Into :li_mtrlkind,
- :ld_scllrate,
- :ld_scllqty
- From u_mtrldef,u_mtrlware
- Where u_mtrldef.mtrlid = u_mtrlware.mtrlid And
- u_mtrlware.mtrlwareid = :s_mx.mtrlwareid And
- u_mtrlware.scid = :ll_storagescid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询物料:'+i_mtrlcode+'分摊属性失败'
- rslt = 0
- Goto ext
- End If
-
- // If li_mtrlkind = 0 And Not f_power_ind(119,sys_msg_pow) And ( s_mx.ifrel = 0 Or s_mx.relid = 0 ) Then
- // arg_msg = '请先选择计划,第'+String(s_mx.printid)+'行'
- // rslt = 0
- // Goto ext
- // End If
- //
- // If li_mtrlkind = 1 And ( s_mx.ifrel = 1 Or s_mx.relid > 0 ) Then
- // arg_msg = '不能选择计划,第'+String(s_mx.printid)+'行'
- // rslt = 0
- // Goto ext
- // End If
-
- If (li_mtrlkind = 0 Or (li_mtrlkind = 2 And ld_scllrate > 0)) And (relint_1 = 0 Or relint_1 = 5) And s_mx.relid > 0 Then
- Decimal ld_RqQty,ld_DstrQty,ld_noaudit_DstrQty
- Decimal ld_allowqty
- Long ll_wrkGrpid
- Decimal ld_backqty,ld_backbuqty
-
- Select u_OrderRqMtrl_scll.trueRqQty,
- u_OrderRqMtrl_scll.DstrQty,
- u_OrderRqMtrl_scll.wrkGrpid,
- isnull(uv_outware_scll_back.qty,0)
- Into :ld_RqQty,
- :ld_DstrQty,
- :ll_wrkGrpid,
- :ld_backqty
- From u_OrderRqMtrl_scll Inner JOIN
- u_workgroup ON
- u_OrderRqMtrl_scll.wrkGrpid = u_workgroup.wrkGrpid LEFT Outer JOIN
- uv_outware_scll_back ON
- u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid And
- u_OrderRqMtrl_scll.status = uv_outware_scll_back.status And
- u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode And
- u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode And
- u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid And
- u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid
- Where u_OrderRqMtrl_scll.scid = :scid
- And u_OrderRqMtrl_scll.orderid = :s_mx.relid
- And u_OrderRqMtrl_scll.MtrlID = :i_mtrlid
- And u_OrderRqMtrl_scll.status = :i_status
- And u_OrderRqMtrl_scll.woodcode = :i_woodcode
- And u_OrderRqMtrl_scll.pcode = :i_pcode
- And u_workgroup.workgroupid = :relid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询物料'+i_mtrlcode+'计划领料数和已领料数失败,'+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If relint_1 = 5 Then
- Select sum(u_Outwaremx.qty) Into :ld_backbuqty
- From u_outware,u_Outwaremx,u_workgroup
- Where u_outware.scid = u_Outwaremx.scid
- And u_outware.outwareid = u_Outwaremx.outwareid
- And u_outware.billtype = 3
- And u_outware.relint_1 = 5
- And u_outware.outwareid <> :outwareid
- And u_Outwaremx.scid = :scid
- And u_Outwaremx.mtrlid = :i_mtrlid
- And u_outware.relid = u_workgroup.workgroupid
- And u_workgroup.wrkGrpid = :ll_wrkGrpid
- And u_Outwaremx.relid = :s_mx.relid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询物料'+i_mtrlcode+'已补料单数失败,'+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If IsNull(ld_backbuqty) Then ld_backbuqty = 0
-
- If 0 - ld_backqty < s_mx.qty + ld_backbuqty Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可补料总数:'+String(0 - ld_backqty,'#,#0.0#########')+',已补料数:'+String(ld_backbuqty,'#,#0.0#########')+',不可再补料:'+String(s_mx.qty,'#,#0.0#########')
- rslt = 0
- Goto ext
- End If
-
-
- End If
-
- Select sum(u_Outwaremx.qty),sum(u_Outwaremx.planqty) Into :ld_noaudit_DstrQty,:ld_noaudit_planqty
- From u_outware,u_Outwaremx,u_workgroup
- Where u_outware.scid = u_Outwaremx.scid
- And u_outware.outwareid = u_Outwaremx.outwareid
- And u_outware.billtype = 3
- And u_outware.flag = 0
- And u_outware.outwareid <> :outwareid
- And u_Outwaremx.scid = :scid
- And u_Outwaremx.mtrlid = :i_mtrlid
- And u_outware.relid = u_workgroup.workgroupid
- And u_workgroup.wrkGrpid = :ll_wrkGrpid
- And u_Outwaremx.relid = :s_mx.relid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询物料'+i_mtrlcode+'已开单领料数失败,'+sqlca.SQLErrText
- rslt = 0
- Goto ext
- End If
-
- If IsNull(ld_RqQty) Then ld_RqQty = 0
- If IsNull(ld_DstrQty) Then ld_DstrQty = 0
- If IsNull(ld_noaudit_DstrQty) Then ld_noaudit_DstrQty = 0
-
- // IF li_mtrlkind = 0 THEN
- // ld_scllrate = 0
- // ld_scllqty
-
- ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_DstrQty
-
- If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_DstrQty + s_mx.qty Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单数:'+String(ld_noaudit_DstrQty,'#,#0.0####')
- rslt = 0
- Goto ext
- End If
-
- If uo_option_scll_use_planqty = 1 And Not f_power_ind(3863,sys_msg_pow) Then
- ld_allowqty = ld_RqQty * (1 + ld_scllrate) + ld_scllqty - ld_DstrQty - ld_noaudit_planqty
-
- If ld_RqQty * (1 + ld_scllrate) + ld_scllqty < ld_DstrQty + ld_noaudit_planqty + s_mx.planqty Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料超领料:'+i_mtrlcode+',可领料:'+String(ld_allowqty,'#,#0.0####')+',需求数:'+String(ld_RqQty,'#,#0.0####')+',已领数:'+String(ld_DstrQty,'#,#0.0####')+',已开单计划数:'+String(ld_noaudit_planqty,'#,#0.0####')
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- End If
-
-
- If s_mx.ifrel > 0 And relint_1 <> 4 Then
- If s_mx.relid = 0 Then
- arg_msg = '请先择相应的计划'
- rslt = 0
- Goto ext
- End If
-
- Select ordercode Into :ls_relcode
- From u_order_ml
- Where u_order_ml.orderid = :s_mx.relid
- And u_order_ml.scid = :scid
- Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询生产计划是否有生产产品失败'
- rslt = 0
- Goto ext
- End If
- End If
-
- If relint_1 = 4 Then
- Select outwarecode
- Into :ls_relcode
- From u_outware_scllplan
- Where outwareid = :s_mx.relid
- And scid = :scid
- Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询相关发料通知单失败'
- rslt = 0
- Goto ext
- End If
- End If
-
- End Choose
- //销售发货单要取分部结算价
- Decimal ld_scidprice,ld_price_task
- If flag = 0 Then
- If billtype = 1 Or billtype = 5 Then
- If s_mx.ifrel = 1 Then
- Select scidprice,price
- Into :ld_scidprice,:ld_price_task
- From u_saletaskmx
- Where scid = :scid
- And u_saletaskmx.printid = :s_mx.relprintid
- And u_saletaskmx.taskid = :s_mx.relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询相关销售订单分部结算价失败'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
- Else
- Select scidprice
- Into :ld_scidprice
- From u_mtrldef
- Where mtrlid = :i_mtrlid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询物料分部结算价失败'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
- End If
- End If
- End If
- //**取最新价
- Select price
- Into :i_newprice
- From v_maxprice_sptprice
- Where mtrlid = :i_mtrlid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Or IsNull(i_newprice) Then i_newprice = 0
- If billtype = 1 Then
- // IF uo_option_if_pricetype = 1 And s_mx.pricetype <> '' THEN
- Int li_ifcheckprice
-
- If s_mx.pricetype <> '' Then
- Select ifcheckprice
- Into :li_ifcheckprice
- From u_pricetype
- Where pricetype = :s_mx.pricetype Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+'查询价格分类是否属于赠送类型失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
- Else
- li_ifcheckprice = 1
- End If
-
- If li_ifcheckprice = 2 Then s_mx.rebate = 0
-
- If li_ifcheckprice = 1 And s_mx.ifrel = 0 Then
- If uo_option_checkprice_native = 1 Then
- If uo_price.uof_check_price (cusid,i_mtrlid,&
- i_mtrlcode,i_status,i_pcode,&
- i_woodcode,relint_2,s_mx.fprice * mrate * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- If uo_price.uof_check_price (cusid,i_mtrlid,&
- i_mtrlcode,i_status,i_pcode,&
- i_woodcode,relint_2,s_mx.fprice * s_mx.rebate,s_mx.qty,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- // END IF
- End If
- //写入内容
- it_mxbt++
- outwaremx[it_mxbt].dftsaleprice = ld_dftsaleprice
- outwaremx[it_mxbt].mtrlwareid = s_mx.mtrlwareid
- outwaremx[it_mxbt].mtrlid = i_mtrlid
- outwaremx[it_mxbt].status = i_status
- outwaremx[it_mxbt].qty = s_mx.qty
- outwaremx[it_mxbt].planqty = s_mx.planqty
- outwaremx[it_mxbt].storageid = i_storageid
- outwaremx[it_mxbt].cost = i_cost
- outwaremx[it_mxbt].costamt = Round(i_cost * s_mx.qty,2)
- outwaremx[it_mxbt].newpriceamt = Round(i_newprice * s_mx.qty,2)
- outwaremx[it_mxbt].plancode = i_plancode
- outwaremx[it_mxbt].planprice = i_planprice
- outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- outwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
- outwaremx[it_mxbt].printid = s_mx.printid
- outwaremx[it_mxbt].outtype = s_mx.outtype
- outwaremx[it_mxbt].enprice = s_mx.fprice
- outwaremx[it_mxbt].rebate = s_mx.rebate
- If uo_option_price_rmb = 1 And billtype = 1 Then
- outwaremx[it_mxbt].fprice = Round(s_mx.fprice * mrate,2)
- outwaremx[it_mxbt].price = Round(outwaremx[it_mxbt].fprice * s_mx.rebate,2)
- Else
- outwaremx[it_mxbt].fprice = s_mx.fprice * mrate
- outwaremx[it_mxbt].price = outwaremx[it_mxbt].fprice * s_mx.rebate
- End If
- If billtype = 1 And s_mx.ifrel = 1 And uo_option_outware_sale_checkprice = 1 Then
- If Abs(outwaremx[it_mxbt].price - ld_price_task) > 0.02 Then
- arg_msg = '第'+String(s_mx.printid)+'行,物料编码:'+i_mtrlcode+',销售发货单实价:'+String(outwaremx[it_mxbt].price,'#,##0.00')+' 与对应销售订单实价:'+String(ld_price_task,'#,##0.00')+' 不一致,请检查'
- rslt = 0
- Goto ext
- End If
- End If
- If billtype = 1 Then
- If uo_option_price_rmb = 1 Then
- outwaremx[it_mxbt].enacprice = Round(outwaremx[it_mxbt].fprice * s_mx.rebate/mrate,2)
- Else
- outwaremx[it_mxbt].enacprice = outwaremx[it_mxbt].fprice * s_mx.rebate/mrate
- End If
- Else
- outwaremx[it_mxbt].enacprice = 0
- End If
- outwaremx[it_mxbt].sptid = i_sptid
- outwaremx[it_mxbt].dxflag = i_dxflag
- outwaremx[it_mxbt].ifrel = s_mx.ifrel
- outwaremx[it_mxbt].relid = s_mx.relid
- outwaremx[it_mxbt].olmtrlid = s_mx.olmtrlid
- outwaremx[it_mxbt].packqty = s_mx.packqty
- outwaremx[it_mxbt].woodcode = i_woodcode
- outwaremx[it_mxbt].pcode = i_pcode
- outwaremx[it_mxbt].relcode = ls_relcode
- outwaremx[it_mxbt].relprintid = s_mx.relprintid
- outwaremx[it_mxbt].unit = s_mx.unit
- outwaremx[it_mxbt].rate = s_mx.rate
- outwaremx[it_mxbt].uqty = s_mx.uqty
- outwaremx[it_mxbt].mtrlcuscode = i_mtrlcuscode
- outwaremx[it_mxbt].Location = i_location
- outwaremx[it_mxbt].scidprice = ld_scidprice
- outwaremx[it_mxbt].pricetype = s_mx.pricetype
- outwaremx[it_mxbt].formula = s_mx.formula
- outwaremx[it_mxbt].capacity = ld_capacity * s_mx.qty
- outwaremx[it_mxbt].saleoutid = s_mx.saleoutid
- outwaremx[it_mxbt].saleoutprintid = s_mx.saleoutprintid
- outwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2
- outwaremx[it_mxbt].net_weight = s_mx.net_weight
- outwaremx[it_mxbt].gross_weight = s_mx.gross_weight
- outwaremx[it_mxbt].cubage = s_mx.cubage
- outwaremx[it_mxbt].taxrate = s_mx.taxrate
- outwaremx[it_mxbt].priceformula = s_mx.priceformula
- outwaremx[it_mxbt].qtyformula = s_mx.qtyformula
- outwaremx[it_mxbt].ifvqty = s_mx.ifvqty
- outwaremx[it_mxbt].backtype = s_mx.backtype
- outwaremx[it_mxbt].ifnotinout = s_mx.ifnotinout
- outwaremx[it_mxbt].ifpackpro = i_ifpackpro
- outwaremx[it_mxbt].ifpack = i_ifpack
- ext:
- If rslt = 0 Then p_clearmx()
- Destroy uo_price
- Return rslt
- end function
- protected function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_uqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, string arg_mtrlcuscode, string arg_location, integer arg_ifvqty, ref string arg_msg);Int rslt = 1
- Long ls_newid
- Decimal ld_cost
- Int li_storMtrlprp,li_storagetype,li_outtype_storage
- Long ll_storagescid
- Int li_ifunit,li_ifpack,li_ifpackpro
- Int li_statusflag
- Decimal ld_capacity,ld_capacity_zj
- s_mtrlcfg_expr s_pz[]
- String ls_status_zj
- Long ll_i
- Decimal ld_noallocqty,ld_allocqty
- String ls_storagename
- Int li_ifcost
- Int if_recmp_balc
- String or_err_part
- Decimal ld_pypkqty,ld_pypkamt
- Decimal ld_saleoutqty,ld_saleoutamt
- Decimal ld_saleoutqty_pack,ld_saleoutamt_pack
- Decimal ld_buyoutqty_packpro,ld_buyoutamt_packpro
- Decimal ld_cpoutqty,ld_cpoutamt
- Decimal ld_jgoutqty,ld_jgoutamt
- Decimal ld_dioutqty,ld_dioutamt
- Decimal ld_mvoutqty,ld_mvoutamt
- Decimal ld_otoutqty,ld_otoutamt
- Decimal ld_pkoutqty,ld_pkoutamt
- int li_ifmrp
- IF sys_if_recmp_balc < 0 THEN
- SELECT if_recmp_balc
- INTO :if_recmp_balc
- From sys_msg Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询是否执行结存表重算失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF if_recmp_balc = 0 THEN
- rslt = 0
- arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
- GOTO ext
- END IF
- ELSE
- IF sys_if_recmp_balc = 0 THEN
- rslt = 0
- arg_msg = '由于系统升级,结存表结构与原来不同,请先通知管理员执行危险功能中的[按新结构重算现结存表]功能,才能审核和撤审进出仓单据'
- GOTO ext
- END IF
- END IF
- IF uo_option_change_status = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[029]配置标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_woodcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[027]配置1标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_pcode = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[028]配置2标题文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_cost_dec = -1000 THEN
- rslt = 0
- arg_msg = '选项:[022]库存成本价转换小数点,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_mtrlware_autocmp = -1000 THEN
- rslt = 0
- arg_msg = '选项:[158]自动计算库存包件可装数,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- If uo_option_djqty_check = -1000 Then
- rslt = 0
- arg_msg = '选项:[378]进出仓检查冻结数不能大于库存数,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- uo_cmpl_packpro uo_cmpl_p
- uo_cmpl_p = Create uo_cmpl_packpro
- uo_cmpl_p.commit_transaction = commit_transaction
- SELECT Mtrlprp,scid,storagetype,outtype,storagename,ifcost,ifmrp
- INTO :li_storMtrlprp,:ll_storagescid,:li_storagetype,:li_outtype_storage,:ls_storagename,:li_ifcost,:li_ifmrp
- FROM u_storage
- Where storageid = :arg_storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询仓库信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF li_storagetype = 1 THEN
- IF billtype <> 1 And billtype <> 23 Or billtype = 1 And li_outtype_storage = 0 THEN
- SELECT noallocqty,allocqty INTO :ld_noallocqty,:ld_allocqty
- FROM u_mtrlware
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :ll_storagescid ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '仓库:'+ls_storagename+',查询库存信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF ld_noallocqty - arg_qty < ld_allocqty THEN
- arg_msg = '仓库:'+ls_storagename+',库存数小于已分配数,请检查库存,库存id:'+string(arg_mtrlwareid)+',库存数:'+String(ld_noallocqty - arg_qty,'#0.##########')+',已分配数:'+String(ld_allocqty,'#0.##########')
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- SELECT ifunit,ifpack,capacity,statusflag,ifpackpro
- INTO :li_ifunit,:li_ifpack,:ld_capacity,:li_statusflag,:li_ifpackpro
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询物料信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- IF li_statusflag = 2 THEN
- ld_capacity = 0
- f_checkpz(arg_status,s_pz[])
- FOR ll_i = 1 To UpperBound(s_pz)
- ls_status_zj = s_pz[ll_i].cfgname
-
- SELECT capacity
- INTO :ld_capacity_zj
- FROM u_mtrl_configure
- WHERE mtrlid = :arg_mtrlid
- And Name = :ls_status_zj;
- IF commit_transaction.SQLCode <> 0 THEN
- ld_capacity_zj = 0
- END IF
-
- ld_capacity = ld_capacity + ld_capacity_zj * Dec(s_pz[ll_i].qty)
-
- NEXT
- END IF
- Int li_ifupdate_date
- String ls_str
- IF billtype = 1 Or &
- billtype = 2 Or &
- billtype = 3 Or &
- billtype = 4 Or &
- billtype = 5 Or &
- billtype = 7 Or &
- billtype = 8 Or &
- billtype = 10 Or &
- billtype = 12 Or &
- billtype = 17 Or &
- billtype = 21 Or &
- billtype = 24 THEN
- li_ifupdate_date = 1
- ELSE
- li_ifupdate_date = 0
- END IF
- IF li_ifunit = 0 THEN arg_uqty = 0
- IF li_ifcost = 1 THEN
-
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- unoallocqty = unoallocqty - :arg_uqty,
- capacity = capacity + :ld_capacity * :arg_qty ,
- wareamt = case noallocqty - :arg_qty when 0 then 0 else wareamt - :arg_costamt END ,
- cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:uo_option_cost_dec) END ,
- saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :ll_storagescid ) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ld_cost = Round(arg_costamt/arg_qty,uo_option_cost_dec)
- INSERT INTO u_mtrlware
- ( scid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- noallocqty,
- unoallocqty,
- allocqty,
- wareamt,
- planprice,
- sptid,
- dxflag,
- woodcode,
- pcode,
- cost,
- storMtrlprp,
- mtrlcuscode,
- location,
- capacity)
- VALUES (
- :ll_storagescid,
- :ls_newid,
- :arg_mtrlid,
- :arg_storageid,
- :arg_plancode,
- :arg_status,
- :arg_qty,
- :arg_uqty,
- 0,
- :arg_costamt,
- :arg_planprice,
- :arg_sptid,
- :arg_dxflag,
- :arg_woodcode,
- :arg_pcode,
- :ld_cost,
- :li_storMtrlprp,
- :arg_mtrlcuscode,
- :arg_location,
- :ld_capacity * :arg_qty) Using commit_transaction ;
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText
- ELSE
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
-
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
-
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减"
- ELSE
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- //-----------------------------------更新结存
-
-
- CHOOSE CASE billtype
- CASE 1,2,5,6
- ld_saleoutqty = arg_qty
- ld_saleoutamt = arg_costamt
- CASE 3
- ld_cpoutqty = arg_qty
- ld_cpoutamt = arg_costamt
- CASE 4,7
- ld_jgoutqty = arg_qty
- ld_jgoutamt = arg_costamt
- CASE 8
- ld_otoutqty = arg_qty
- ld_otoutamt = arg_costamt
- CASE 9
- ld_pkoutqty = arg_qty
- ld_pkoutamt = arg_costamt
- ld_pypkqty = arg_qty
- ld_pypkamt = arg_costamt
- CASE 12
- ld_mvoutqty = arg_qty
- ld_mvoutamt = arg_costamt
- CASE 15
- ld_dioutqty = arg_qty
- ld_dioutamt = arg_costamt
- CASE 21
- ld_saleoutqty_pack = arg_qty
- ld_saleoutamt_pack = arg_costamt
- CASE 23
- ld_buyoutqty_packpro = arg_qty
- ld_buyoutamt_packpro = arg_costamt
- CASE ELSE
- ld_otoutqty = arg_qty
- ld_otoutamt = arg_costamt
- END CHOOSE
-
-
- UPDATE u_warebalc
- SET desqty = desqty + :arg_qty ,
- udesqty = udesqty + :arg_uqty,
- desamt = desamt + :arg_costamt,
-
- vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END ,
- uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END ,
- vdesamt = case :arg_ifvqty when 0 then vdesamt else vdesamt + :arg_costamt END ,
-
- balcqty = balcqty - :arg_qty,
- ubalcqty = ubalcqty - :arg_uqty,
- balcamt = case balcqty - :arg_qty when 0 then 0 else balcamt - :arg_costamt END,
- pypk = pypk - :ld_pypkqty,
- pypkamt = pypkamt - :ld_pypkamt,
-
- saleoutqty = saleoutqty + :ld_saleoutqty,
- saleoutamt = saleoutamt + :ld_saleoutamt,
-
- saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack,
- saleoutamt_pack = saleoutamt_pack + :ld_saleoutamt_pack,
-
- buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro,
- buyoutamt_packpro = buyoutamt_packpro + :ld_buyoutamt_packpro,
-
- cpoutqty = cpoutqty + :ld_cpoutqty,
- cpoutamt = cpoutamt + :ld_cpoutamt,
-
- jgoutqty = jgoutqty + :ld_jgoutqty,
- jgoutamt = jgoutamt + :ld_jgoutamt,
-
- otoutqty = otoutqty + :ld_otoutqty,
- otoutamt = otoutamt + :ld_otoutamt,
-
- mvoutqty = mvoutqty + :ld_mvoutqty,
- mvoutamt = mvoutamt + :ld_mvoutamt,
-
- dioutqty = dioutqty + :ld_dioutqty,
- dioutamt = dioutamt + :ld_dioutamt,
-
- pkoutqty = pkoutqty + :ld_pkoutqty,
- pkoutamt = pkoutamt + :ld_pkoutamt
- WHERE ( balcdateint = 0 ) AND
- ( scid = :ll_storagescid) AND
- ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- INSERT INTO u_warebalc
- ( balcdateint,
- mtrlid,
- storageid,
- bgqty,
- bgamt,
- incqty,
- incamt,
- desqty,
- desamt,
- balcqty,
- balcamt,
- pypk,
- pypkamt,
- status,
- scid ,
- saleoutqty,
- saleoutamt,
- saleoutqty_pack,
- saleoutamt_pack,
- buyoutqty_packpro,
- buyoutamt_packpro,
- cpoutqty,
- cpoutamt,
- jgoutqty,
- jgoutamt,
- dioutqty,
- dioutamt,
- mvoutqty,
- mvoutamt,
- otoutqty,
- otoutamt,
- pkoutqty,
- pkoutamt,
- woodcode,
- pcode,
- ubgqty,
- uincqty,
- udesqty,
- ubalcqty,
- plancode,
- sptid,
- dxflag,
- mtrlcuscode,
- location,
- mtrlwareid)
- VALUES (
- 0,
- :arg_mtrlid,
- :arg_storageid,
- 0,
- 0,
- 0,
- 0,
- :arg_qty,
- :arg_costamt,
- 0 - :arg_qty,
- 0 - :arg_costamt,
- 0 - :ld_pypkqty,
- 0 - :ld_pypkamt,
- :arg_status,
- :ll_storagescid,
- :ld_saleoutqty,
- :ld_saleoutamt,
- :ld_saleoutqty_pack,
- :ld_saleoutamt_pack,
- :ld_buyoutqty_packpro,
- :ld_buyoutamt_packpro,
- :ld_cpoutqty,
- :ld_cpoutamt,
- :ld_jgoutqty,
- :ld_jgoutamt,
- :ld_dioutqty,
- :ld_dioutamt,
- :ld_mvoutqty,
- :ld_mvoutamt,
- :ld_otoutqty,
- :ld_otoutamt,
- :ld_pkoutqty,
- :ld_pkoutamt,
- :arg_woodcode,
- :arg_pcode,
- 0,
- 0,
- :arg_uqty,
- 0 - :arg_uqty,
- :arg_plancode,
- :arg_sptid,
- :arg_dxflag,
- :arg_mtrlcuscode,
- :arg_location,
- :arg_mtrlwareid) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减"
- ELSE
- arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- ELSE
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- unoallocqty = unoallocqty - :arg_uqty,
- capacity = capacity + :ld_capacity * :arg_qty ,
- wareamt = 0 ,
- cost = 0 ,
- saledate = case :li_ifupdate_date when 1 then getdate() else saledate END
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :ll_storagescid ) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- ls_newid = f_sys_scidentity(ll_storagescid,"u_mtrlware","mtrlwareid",arg_msg,True,id_sqlca)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- INSERT INTO u_mtrlware
- ( scid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- noallocqty,
- unoallocqty,
- allocqty,
- wareamt,
- planprice,
- sptid,
- dxflag,
- woodcode,
- pcode,
- cost,
- storMtrlprp,
- mtrlcuscode,
- location,
- capacity)
- VALUES (
- :ll_storagescid,
- :ls_newid,
- :arg_mtrlid,
- :arg_storageid,
- :arg_plancode,
- :arg_status,
- :arg_qty,
- :arg_uqty,
- 0,
- 0,
- 0,
- :arg_sptid,
- :arg_dxflag,
- :arg_woodcode,
- :arg_pcode,
- 0,
- :li_storMtrlprp,
- :arg_mtrlcuscode,
- :arg_location,
- :ld_capacity * :arg_qty) Using commit_transaction ;
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- IF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存数量支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减,"+commit_transaction.SQLErrText
- ELSE
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
-
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
-
- IF arg_status <> '' THEN
- ls_str = ' '+uo_option_change_status+':'+arg_status
- END IF
- IF arg_pcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_pcode+':'+arg_pcode
- END IF
- IF arg_woodcode <> '' THEN
- ls_str = ls_str + ' '+uo_option_change_woodcode+':'+arg_woodcode
- END IF
-
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CK_u_mtrlware') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号没有足够的库存支持冲减,"+commit_transaction.SQLErrText
- ELSEIF Pos(commit_transaction.SQLErrText,'CREATE RULE') > 0 And Pos(commit_transaction.SQLErrText,'cost') > 0 THEN
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",物料:"+arg_mtrlcode+ls_str+",同仓库内同批号的库存金额不够冲减"
- ELSE
- arg_msg = '仓库:'+ls_storagename+',库存id:'+String(arg_mtrlwareid)+",因网络或其它原因导致物料:"+arg_mtrlcode+' '+uo_option_change_status+':'+arg_status+' '+uo_option_change_pcode+':'+arg_pcode+' '+uo_option_change_woodcode+':'+arg_woodcode+"库存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- //-----------------------------------更新结存
-
-
- CHOOSE CASE billtype
- CASE 1,2,5,6
- ld_saleoutqty = arg_qty
- CASE 3
- ld_cpoutqty = arg_qty
- CASE 4,7
- ld_jgoutqty = arg_qty
- CASE 8
- ld_otoutqty = arg_qty
- CASE 9
- ld_pkoutqty = arg_qty
- ld_pypkqty = arg_qty
- CASE 12
- ld_mvoutqty = arg_qty
- CASE 15
- ld_dioutqty = arg_qty
- CASE 21
- ld_saleoutqty_pack = arg_qty
- CASE 23
- ld_buyoutqty_packpro = arg_qty
- CASE ELSE
- ld_otoutqty = arg_qty
- END CHOOSE
-
-
- UPDATE u_warebalc
- SET desqty = desqty + :arg_qty ,
- udesqty = udesqty + :arg_uqty,
- desamt = 0,
-
- vdesqty = case :arg_ifvqty when 0 then vdesqty else vdesqty + :arg_qty END ,
- uvdesqty = case :arg_ifvqty when 0 then uvdesqty else uvdesqty + :arg_uqty END ,
- vdesamt = 0 ,
-
- balcqty = balcqty - :arg_qty,
- ubalcqty = ubalcqty - :arg_uqty,
- balcamt = 0,
- pypk = pypk - :ld_pypkqty,
- pypkamt = 0,
-
- saleoutqty = saleoutqty + :ld_saleoutqty,
- saleoutamt = 0,
-
- saleoutqty_pack = saleoutqty_pack + :ld_saleoutqty_pack,
- saleoutamt_pack = 0,
-
- buyoutqty_packpro = buyoutqty_packpro + :ld_buyoutqty_packpro,
- buyoutamt_packpro = 0,
-
- cpoutqty = cpoutqty + :ld_cpoutqty,
- cpoutamt = 0,
-
- jgoutqty = jgoutqty + :ld_jgoutqty,
- jgoutamt = 0,
-
- otoutqty = otoutqty + :ld_otoutqty,
- otoutamt = 0,
-
- mvoutqty = mvoutqty + :ld_mvoutqty,
- mvoutamt = 0,
-
- dioutqty = dioutqty + :ld_dioutqty,
- dioutamt = 0,
-
- pkoutqty = pkoutqty + :ld_pkoutqty,
- pkoutamt = 0
- WHERE ( balcdateint = 0 ) AND
- ( scid = :ll_storagescid) AND
- ( mtrlwareid = :arg_mtrlwareid) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- INSERT INTO u_warebalc
- ( balcdateint,
- mtrlid,
- storageid,
- bgqty,
- bgamt,
- incqty,
- incamt,
- desqty,
- desamt,
- balcqty,
- balcamt,
- pypk,
- pypkamt,
- status,
- scid ,
- saleoutqty,
- saleoutamt,
- saleoutqty_pack,
- saleoutamt_pack,
- buyoutqty_packpro,
- buyoutamt_packpro,
- cpoutqty,
- cpoutamt,
- jgoutqty,
- jgoutamt,
- dioutqty,
- dioutamt,
- mvoutqty,
- mvoutamt,
- otoutqty,
- otoutamt,
- pkoutqty,
- pkoutamt,
- woodcode,
- pcode,
- ubgqty,
- uincqty,
- udesqty,
- ubalcqty,
- plancode,
- sptid,
- dxflag,
- mtrlcuscode,
- location,
- mtrlwareid)
- VALUES (
- 0,
- :arg_mtrlid,
- :arg_storageid,
- 0,
- 0,
- 0,
- 0,
- :arg_qty,
- 0,
- 0 - :arg_qty,
- 0,
- 0 - :ld_pypkqty,
- 0,
- :arg_status,
- :ll_storagescid,
- :ld_saleoutqty,
- 0,
- :ld_saleoutqty_pack,
- 0,
- :ld_buyoutqty_packpro,
- 0,
- :ld_cpoutqty,
- 0,
- :ld_jgoutqty,
- 0,
- :ld_dioutqty,
- 0,
- :ld_mvoutqty,
- 0,
- :ld_otoutqty,
- 0,
- :ld_pkoutqty,
- 0,
- :arg_woodcode,
- :arg_pcode,
- 0,
- 0,
- :arg_uqty,
- 0 - :arg_uqty,
- :arg_plancode,
- :arg_sptid,
- :arg_dxflag,
- :arg_mtrlcuscode,
- :arg_location,
- :arg_mtrlwareid) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = '仓库:'+ls_storagename+",物料"+arg_mtrlcode+"同仓库内同批号没有足够的结存支持冲减"
- ELSE
- arg_msg = '仓库:'+ls_storagename+",因网络或其它原因导致物料:"+arg_mtrlcode+'颜色:'+arg_status+'面料:'+arg_pcode+'材质:'+arg_woodcode+"结存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
-
- END IF
- //自动计算包件产品可装数yyx20100414
- //yyx2012-9-28取消
- //IF ( li_ifpack = 1 or li_ifpack = 2 Or li_ifpackpro = 3 Or li_ifpackpro = 4 ) AND uo_option_mtrlware_autocmp = 1 THEN
- // IF uo_cmpl_p.uof_cmpl(arg_mtrlid,arg_plancode,arg_mtrlcuscode,arg_storageid,arg_msg) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- //END IF
- If uo_option_djqty_check = 1 and not (billtype = 3 And relint_1 = 2 ) and li_ifmrp = 1 and not ( billtype = 3 And relint_1 = 4) Then
- Decimal ld_djqty
-
- Select SUM(u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0))
- Into :ld_djqty
- FROM u_OrderRqMtrl_scll INNER JOIN
- u_Order_ml ON u_OrderRqMtrl_scll.OrderID = u_Order_ml.OrderID LEFT OUTER JOIN
- uv_outware_scll_back ON u_OrderRqMtrl_scll.scid = uv_outware_scll_back.scid AND
- u_OrderRqMtrl_scll.OrderID = uv_outware_scll_back.relid AND
- u_OrderRqMtrl_scll.MtrlID = uv_outware_scll_back.mtrlid AND
- u_OrderRqMtrl_scll.status = uv_outware_scll_back.status AND
- u_OrderRqMtrl_scll.woodcode = uv_outware_scll_back.woodcode AND
- u_OrderRqMtrl_scll.pcode = uv_outware_scll_back.pcode
- Where (u_OrderRqMtrl_scll.wareqty <> 0) And (u_Order_ml.Status Not In (3,5,6))
- And u_OrderRqMtrl_scll.wareqty - u_OrderRqMtrl_scll.DstrQty + isnull(uv_outware_scll_back.qty,0) > 0
- And u_OrderRqMtrl_scll.MtrlID = :arg_mtrlid
- And u_OrderRqMtrl_scll.scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- ld_djqty = 0
- End If
-
- If IsNull(ld_djqty) Then ld_djqty = 0
-
- Select SUM(u_mtrlware.noallocqty)
- Into :ld_noallocqty
- From u_mtrlware Inner JOIN
- u_storage ON u_mtrlware.storageid = u_storage.storageid
- Where (u_storage.inuse = 1)
- And u_storage.ifmrp = 1
- And u_mtrlware.mtrlid = :arg_mtrlid
- And u_mtrlware.scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- ld_noallocqty = 0
- End If
-
- If IsNull(ld_noallocqty) Then ld_noallocqty = 0
-
- If ld_djqty > ld_noallocqty Then
- rslt = 0
- arg_msg = '冻结数不能大于库存数,冻结数:'+String(ld_djqty,'#,##0.##########')+',库存数:'+String(ld_noallocqty,'#,##0.##########')
- Goto ext
- End If
-
- End If
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction ;
- END IF
- Destroy uo_cmpl_p
- RETURN rslt
- end function
- public function integer acceptmx_mx (long arg_printid, long arg_mtrlwareid, decimal arg_planqty, decimal arg_qty, string arg_mxdscrp, long arg_mxprintid, integer arg_ifnotinout, ref string arg_msg);Long rslt = 1,cnt = 0,LS_i
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode
- Long ll_storagescid
- Long i_mtrlid,i_storageid,i_sptid
- Int i_dxflag
- string i_mtrlcuscode,i_location
- int i_ifpackpro,i_ifpack
- IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- SELECT scid INTO :ll_storagescid
- FROM u_storage
- Where storageid = :storageid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库分部失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- //清除空值
- IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
- IF IsNull(arg_printid) THEN arg_printid = 0
- IF IsNull(arg_qty) THEN arg_qty = 0
- IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- IF IsNull(arg_planqty) THEN arg_planqty = 0
- IF IsNull(arg_mxprintid) THEN arg_mxprintid = 0
- IF arg_mtrlwareid = 0 Or ( arg_qty = 0 AND arg_planqty = 0 ) THEN
- rslt = 1
- GOTO ext
- END IF
- //检查物料库存ID
- SELECT u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrldef.mtrlcode,
- u_mtrlware.sptid,
- u_mtrlware.dxflag,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- u_mtrlware.mtrlcuscode,
- u_mtrlware.location,
- u_mtrldef.ifpackpro,
- u_mtrldef.ifpack
- INTO :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_mtrlcode,
- :i_sptid,
- :i_dxflag,
- :i_woodcode,
- :i_pcode,
- :i_mtrlcuscode,
- :i_location,
- :i_ifpackpro,
- :i_ifpack
- FROM u_mtrlware ,u_mtrldef
- WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- And ( u_mtrlware.scid = :ll_storagescid ) USING commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "第"+String(arg_printid)+"行,查询操作失败,库存编号(出仓单)错误,分部:"+String(ll_storagescid)+'库存:'+String(arg_mtrlwareid)+',~n'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF IsNull(i_plancode) THEN i_plancode = ''
- IF IsNull(i_status) THEN i_status = ''
- IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- IF IsNull(i_storageid) THEN i_storageid = 0
- IF IsNull(i_sptid) THEN i_sptid = 0
- IF IsNull(i_dxflag) THEN i_dxflag = 0
- IF IsNull(i_woodcode) THEN i_woodcode = ''
- IF IsNull(i_pcode) THEN i_pcode = ''
- IF IsNull(i_mtrlcuscode) THEN i_mtrlcuscode = ''
- IF IsNull(i_location) THEN i_location = ''
- IF IsNull(i_ifpackpro) THEN i_ifpackpro = 0
- IF IsNull(i_ifpack) THEN i_ifpack = 0
- //写入内容
- it_mxbt_mx++
- outwaremx_mx[it_mxbt_mx].mtrlwareid = arg_mtrlwareid
- outwaremx_mx[it_mxbt_mx].mtrlid = i_mtrlid
- outwaremx_mx[it_mxbt_mx].status = i_status
- outwaremx_mx[it_mxbt_mx].qty = arg_qty
- outwaremx_mx[it_mxbt_mx].planqty = arg_planqty
- outwaremx_mx[it_mxbt_mx].storageid = i_storageid
- outwaremx_mx[it_mxbt_mx].plancode = i_plancode
- outwaremx_mx[it_mxbt_mx].mtrlcode = i_mtrlcode
- outwaremx_mx[it_mxbt_mx].mxdscrp = arg_mxdscrp
- outwaremx_mx[it_mxbt_mx].printid = arg_printid
- outwaremx_mx[it_mxbt_mx].mxprintid = arg_mxprintid
- outwaremx_mx[it_mxbt_mx].sptid = i_sptid
- outwaremx_mx[it_mxbt_mx].dxflag = i_dxflag
- outwaremx_mx[it_mxbt_mx].woodcode = i_woodcode
- outwaremx_mx[it_mxbt_mx].pcode = i_pcode
- outwaremx_mx[it_mxbt_mx].mtrlcuscode = i_mtrlcuscode
- outwaremx_mx[it_mxbt_mx].location = i_location
- outwaremx_mx[it_mxbt_mx].ifnotinout = arg_ifnotinout
- outwaremx_mx[it_mxbt_mx].ifpackpro = i_ifpackpro
- outwaremx_mx[it_mxbt_mx].ifpack = i_ifpack
- ext:
- IF rslt = 0 THEN p_clearmx()
- RETURN rslt
- end function
- public function integer uof_noauditingqty_add (long arg_scid, long arg_billtype, integer arg_relint_1, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i
- Decimal ld_qty,ld_uqty
- If thflag = 1 Then
- rslt = 1
- Goto ext
- End If
- For i = 1 To it_mxbt
- ld_qty = 0
- ld_uqty = 0
- If arg_billtype <> 1 And arg_billtype <> 3 Then
- ld_qty = outwaremx[i].qty
- ld_uqty = outwaremx[i].uqty
- ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then
- ld_qty = outwaremx[i].qty
- ld_uqty = outwaremx[i].uqty
- ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then
- ld_qty = outwaremx[i].qty
- ld_uqty = outwaremx[i].uqty
- ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then
- If outwaremx[i].qty = 0 Then
- ld_qty = outwaremx[i].planqty
- Else
- ld_qty = outwaremx[i].qty
- End If
-
- ld_uqty = outwaremx[i].uqty
- ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And outwaremx[i].ifpack = 0 And outwaremx[i].ifpackpro = 0 Then
- If outwaremx[i].qty = 0 Then
- ld_qty = outwaremx[i].planqty
- Else
- ld_qty = outwaremx[i].qty
- End If
-
- ld_uqty = outwaremx[i].uqty
- End If
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty + :ld_qty,
- noauditinguqty = noauditingqty + :ld_uqty
- Where scid = :arg_scid
- And mtrlwareid = :outwaremx[i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- For i = 1 To it_mxbt_mx
-
- ld_qty = 0
- ld_uqty = 0
- If uo_option_inout_type > 0 Then
- If outwaremx_mx[i].ifpack = 1 Or outwaremx_mx[i].ifpackpro = 4 Or outwaremx_mx[i].ifpackpro = 3 Then
- If outwaremx_mx[i].qty = 0 Then
- ld_qty = outwaremx_mx[i].planqty
- Else
- ld_qty = outwaremx_mx[i].qty
- End If
-
- ld_uqty = ld_qty
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty + :ld_qty,
- noauditinguqty = noauditingqty + :ld_uqty
- Where scid = :arg_scid
- And mtrlwareid = :outwaremx_mx[i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(outwaremx_mx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
- End If
- End If
-
- Next
- ext:
- Return rslt
- end function
- public function integer uof_noauditingqty_del (long arg_scid, long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
- Int rslt = 1
- Long i,ll_i,j
- Decimal ld_qty,ld_uqty
- Int arg_billtype,arg_relint_1
- If thflag = 1 Then
- rslt = 1
- Goto ext
- End If
- i = 1
- j = 1
- s_outwaremx arg_s_mx[]
- s_outwaremx_mx arg_s_mxmx[]
- Select billtype,relint_1
- Into :arg_billtype,:arg_relint_1
- From u_outware
- Where scid = :arg_scid
- And outwareid = :arg_outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询单据信息失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Declare cur_outwaremx Cursor For
- Select u_outwaremx.mtrlwareid,
- u_outwaremx.planqty,
- u_outwaremx.qty,
- u_outwaremx.uqty,
- u_mtrldef.mtrlcode,
- u_mtrldef.ifpackpro,
- u_mtrldef.ifpack
- From u_outwaremx,u_mtrldef
- Where u_outwaremx.outwareid = :arg_outwareid And
- u_outwaremx.mtrlid = u_mtrldef.mtrlid And
- u_outwaremx.scid = :arg_scid
- Order By u_outwaremx.printid Using commit_transaction;
-
- Open cur_outwaremx;
- Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,
- :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack;
- Do While sqlca.SQLCode = 0
- i++
- Fetch cur_outwaremx Into :arg_s_mx[i].mtrlwareid,:arg_s_mx[i].planqty,:arg_s_mx[i].qty,:arg_s_mx[i].uqty,
- :arg_s_mx[i].mtrlcode,:arg_s_mx[i].ifpackpro,:arg_s_mx[i].ifpack;
- Loop
- Close cur_outwaremx;
- Declare cur_outwaremx_mx Cursor For
- Select u_outwaremx_mx.mtrlwareid,
- u_outwaremx_mx.planqty,
- u_outwaremx_mx.qty,
- u_mtrldef.ifpackpro,
- u_mtrldef.ifpack,
- u_mtrldef.mtrlcode
- From u_outwaremx_mx Inner JOIN
- u_mtrldef ON u_outwaremx_mx.mtrlid = u_mtrldef.mtrlid
- Where u_outwaremx_mx.scid = :arg_scid
- And u_outwaremx_mx.outwareid = :arg_outwareid
- Order By u_outwaremx_mx.mxprintid Using commit_transaction;
-
- Open cur_outwaremx_mx;
- Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty,
- :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode;
- Do While sqlca.SQLCode = 0
- j++
- Fetch cur_outwaremx_mx Into :arg_s_mxmx[j].mtrlwareid,:arg_s_mxmx[j].planqty,:arg_s_mxmx[j].qty,
- :arg_s_mxmx[j].ifpackpro, :arg_s_mxmx[j].ifpack, :arg_s_mxmx[j].mtrlcode;
- Loop
- Close cur_outwaremx_mx;
- For ll_i = 1 To i - 1
- ld_qty = 0
- ld_uqty = 0
- If arg_billtype <> 1 And arg_billtype <> 3 Then
- ld_qty = arg_s_mx[ll_i].qty
- ld_uqty = arg_s_mx[ll_i].uqty
- ElseIf arg_billtype = 3 And arg_relint_1 <> 4 And arg_relint_1 <> 2 Then
- ld_qty = arg_s_mx[ll_i].qty
- ld_uqty = arg_s_mx[ll_i].uqty
- ElseIf arg_billtype = 3 And arg_relint_1 = 4 And uo_option_scllplan_outware_auto = 1 Then
- ld_qty = arg_s_mx[ll_i].qty
- ld_uqty = arg_s_mx[ll_i].uqty
- ElseIf arg_billtype = 1 And uo_option_inout_type = 0 Then
- If arg_s_mx[ll_i].qty = 0 Then
- ld_qty = arg_s_mx[ll_i].planqty
- Else
- ld_qty = arg_s_mx[ll_i].qty
- End If
-
- ld_uqty = arg_s_mx[ll_i].uqty
- ElseIf arg_billtype = 1 And uo_option_inout_type > 0 And arg_s_mx[ll_i].ifpack = 0 And arg_s_mx[ll_i].ifpackpro = 0 Then
- If arg_s_mx[ll_i].qty = 0 Then
- ld_qty = arg_s_mx[ll_i].planqty
- Else
- ld_qty = arg_s_mx[ll_i].qty
- End If
-
- ld_uqty = arg_s_mx[ll_i].uqty
- End If
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty - :ld_qty,
- noauditinguqty = noauditingqty - :ld_uqty
- Where scid = :arg_scid
- And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(arg_s_mx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
-
- Next
- For ll_i = 1 To j - 1
- ld_qty = 0
- ld_uqty = 0
- If uo_option_inout_type > 0 Then
- If arg_s_mxmx[ll_i].ifpack = 1 Or arg_s_mxmx[ll_i].ifpackpro = 4 Or arg_s_mxmx[ll_i].ifpackpro = 3 Then
- If arg_s_mxmx[ll_i].qty = 0 Then
- ld_qty = arg_s_mxmx[ll_i].planqty
- Else
- ld_qty = arg_s_mxmx[ll_i].qty
- End If
-
- ld_uqty = ld_qty
-
-
-
- Update u_mtrlware
- Set noauditingqty = noauditingqty - :ld_qty,
- noauditinguqty = noauditingqty - :ld_uqty
- Where scid = :arg_scid
- And mtrlwareid = :arg_s_mxmx[ll_i].mtrlwareid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '物料:'+String(arg_s_mxmx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
- Goto ext
- End If
- End If
- End If
-
- Next
- ext:
- Return rslt
- end function
- on uo_outware.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_outware.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event constructor;String str_optionvalue,arg_msg
- //f_get_sys_option_value('030',str_optionvalue,arg_msg)
- //uo_option_autowaste = Long(str_optionvalue)
- //
- f_get_sys_option_value('142',str_optionvalue,arg_msg)
- uo_option_inout_type = Long(str_optionvalue)
- f_get_sys_option_value('205',str_optionvalue,arg_msg)
- uo_option_barcode_outwareother_paudit = Long(str_optionvalue)
- f_get_sys_option_value('025',str_optionvalue,arg_msg)
- uo_option_confirmaudit_sale = Long(str_optionvalue)
- f_get_sys_option_value('115',str_optionvalue,arg_msg)
- uo_option_sale_use_planqty = Long(str_optionvalue)
- f_get_sys_option_value('006',str_optionvalue,arg_msg)
- uo_option_confirmaudit_scll = Long(str_optionvalue)
- f_get_sys_option_value('022',str_optionvalue,arg_msg)
- uo_option_cost_dec = Long(str_optionvalue)
- f_get_sys_option_value('029',str_optionvalue,arg_msg)
- uo_option_change_status = str_optionvalue
- f_get_sys_option_value('027',str_optionvalue,arg_msg)
- uo_option_change_woodcode = str_optionvalue
- f_get_sys_option_value('028',str_optionvalue,arg_msg)
- uo_option_change_pcode = str_optionvalue
- f_get_sys_option_value('158',str_optionvalue,arg_msg)
- uo_option_mtrlware_autocmp = Long(str_optionvalue)
- f_get_sys_option_value('037',str_optionvalue,arg_msg)
- uo_option_mtrlware_limit = Long(str_optionvalue)
- f_get_sys_option_value('200',str_optionvalue,arg_msg)
- uo_option_if_saleout = Long(str_optionvalue)
- f_get_sys_option_value('154',str_optionvalue,arg_msg)
- uo_option_if_pricetype = Long(str_optionvalue)
- f_get_sys_option_value('056',str_optionvalue,arg_msg)
- uo_option_checkprice_native = Long(str_optionvalue)
- f_get_sys_option_value('292',str_optionvalue,arg_msg)
- uo_option_disuse_outware_sale = Long(str_optionvalue)
- f_get_sys_option_value('300',str_optionvalue,arg_msg)
- uo_option_sale_ifuse_negativeprice = Long(str_optionvalue)
- f_get_sys_option_value('310',str_optionvalue,arg_msg)
- uo_option_pda_sale_lock = Long(str_optionvalue)
- f_get_sys_option_value('238',str_optionvalue,arg_msg)
- uo_option_price_rmb = Long(str_optionvalue)
- f_get_sys_option_value('320',str_optionvalue,arg_msg)
- uo_option_outware_sale_checkprice = Long(str_optionvalue)
- f_get_sys_option_value('123',str_optionvalue,arg_msg)
- uo_option_scll_use_planqty = Long(str_optionvalue)
- f_get_sys_option_value('287',str_optionvalue,arg_msg)
- uo_option_barcodelocation_use_inwaremx_location = Long(str_optionvalue)
- f_get_sys_option_value('378',str_optionvalue,arg_msg)
- uo_option_djqty_check = long(str_optionvalue)
- f_get_sys_option_value('147',str_optionvalue,arg_msg)
- uo_option_outware_saleout = Long(str_optionvalue)
- f_get_sys_option_value('248',str_optionvalue,arg_msg)
- uo_option_scllplan_outware_auto = Long(str_optionvalue)
- f_get_sys_option_value('390',str_optionvalue,arg_msg)
- uo_option_noauditingqty_mode = Long(str_optionvalue)
- f_get_sys_option_value('395',str_optionvalue,arg_msg)
- uo_option_outware_pack_save_cmp = Long(str_optionvalue)
- f_get_sys_option_value('397',str_optionvalue,arg_msg)
- uo_option_pk_notauditqty_check = Long(str_optionvalue)
- f_get_sys_option_value('417',str_optionvalue,arg_msg)
- uo_option_canpack_ifzanyong = Long(str_optionvalue)
- end event
|