1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822 |
- $PBExportHeader$uo_outware_sale.sru
- forward
- global type uo_outware_sale from uo_outware
- end type
- end forward
- global type uo_outware_sale from uo_outware
- end type
- global uo_outware_sale uo_outware_sale
- type variables
- Int uo_option_m_msttake
- Int uo_option_otheramt_msttake
- String uo_option_change_otheramt
- Int uo_option_outware_sale_ifmating
- Int uo_option_secaudit_notupdate_hisprice
- end variables
- forward prototypes
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_create_owe (ref string arg_msg)
- public function integer auditing_th (boolean arg_ifcommit, ref string arg_msg)
- public function integer c_auditing_th (boolean arg_ifcommit, ref string arg_msg)
- public function integer uof_check_pt (ref string arg_msg)
- public function integer priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg, string arg_emp)
- end prototypes
- public function integer secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j
- IF uo_option_m_msttake = -1000 THEN
- rslt = 0
- arg_msg = '选项:[045]系统使用多币种应收帐,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_otheramt_msttake = -1000 THEN
- rslt = 0
- arg_msg = '选项:[052]优惠金额多币种,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_change_otheramt = '-1000' THEN
- rslt = 0
- arg_msg = '选项:[050]销售发货单优惠金额文本,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_price_rmb = -1000 THEN
- rslt = 0
- arg_msg = '选项:[238]销售单价按人民币单价折算,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_secaudit_notupdate_hisprice = -1000 THEN
- rslt = 0
- arg_msg = '选项:[332]销售发货单财审时不更新客户价格历史,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_cusprice uo_update_cusprice
- uo_update_cusprice = Create uo_cusprice
- uo_musttake uo_take
- uo_take = Create uo_musttake
- String ls_mtrlname
- String ls_about
- Decimal ld_takeamt = 0,ld_msttakeamt = 0,ld_taxamt = 0
- Long ll_moneyid,ll_moneyid_yh,ll_moneyid_native
- Long ll_dft_itemid_take,ll_dft_itemid_yh,ll_dft_itemid_tax
- Decimal ld_mrate_amt
- Decimal ld_itemamt = 0
- String ls_taskdscrp
- Decimal ld_taskamt
- String ls_taskcode[]
- Decimal ld_saletaskamt[]
- Long ll_i,k
- String ls_itemname
- Decimal ld_mrate,ld_mrate_yh
- s_bmsttakemx s_takemx_item
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还没有经过仓库审核"
- GOTO ext
- END IF
- IF secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经过财务审核"
- GOTO ext
- END IF
- Int li_btype
- Long ll_accountsid
- SELECT btype,accountsid INTO :li_btype,:ll_accountsid
- FROM cw_banktype
- Where banktypeid = :relint_1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,操作员"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = "操作员姓名未登记或已取消"
- GOTO ext
- END IF
- UPDATE u_outware
- SET secauditingrep = :publ_operator,
- secauditingdate = getdate(),
- secflag = 1
- 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
- IF uo_option_secaudit_notupdate_hisprice = 0 THEN
- FOR i = 1 To it_mxbt
- IF outwaremx[i].outtype <> '' THEN CONTINUE
-
- IF uo_update_cusprice.uof_update_custprice(thflag,0,cusid,&
- outwaremx[i].mtrlid,outwaremx[i].mtrlcode,outwaremx[i].status,&
- outwaremx[i].woodcode,outwaremx[i].pcode,&
- outwareid,outwarecode,outdate,outwaremx[i].enprice,&
- outwaremx[i].rebate,outwaremx[i].costamt,0,'',&
- outwaremx[i].printid,0,relint_2,0,0,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- FOR j = 1 To it_mxbt_item
- IF outware_itemmx[j].IsCusAmt = 1 THEN
- ld_itemamt = ld_itemamt + outware_itemmx[j].amt
- END IF
- NEXT
- IF sum_amt <> 0 Or ld_itemamt <> 0 THEN
-
- IF thflag = 1 THEN
- ls_about = outwarecode + "退货款,相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid_take
- FROM u_itemdef
- Where dfttype = 4 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认销售退货项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- ls_about = outwarecode + "应收款,相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid_take
- FROM u_itemdef
- Where dfttype = 1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认应收项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
-
-
-
- SELECT moneyid INTO :ll_moneyid_native
- FROM cw_currency
- Where native = 1;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询本位币资料失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_option_m_msttake = 0 THEN
- ld_msttakeamt = sum_amt
- ll_moneyid = ll_moneyid_native
- ld_taxamt = sum_taxamt
- ld_mrate = 1
- ELSE
- ld_msttakeamt = sum_amt_en
- ll_moneyid = relint_2
- ld_taxamt = sum_taxamt_en
- IF uo_option_price_rmb = 0 THEN
- ld_mrate = mrate
- ELSE
- ld_mrate = Round(sum_amt/sum_amt_en,10)
- END IF
- END IF
-
-
- IF otheramt <> 0 THEN
- IF uo_option_otheramt_msttake = 1 THEN
- ld_mrate_amt = otheramt * mrate
- ll_moneyid_yh = ll_moneyid_native
- ld_mrate_yh = mrate
- ELSE
- ld_mrate_amt = otheramt
- ll_moneyid_yh = relint_2
- ld_mrate_yh = 1
- END IF
- END IF
-
- IF li_btype = 1 THEN
- ld_takeamt = ld_msttakeamt - ld_mrate_amt + ld_itemamt
- ELSE
- ld_takeamt = 0
- END IF
-
-
- ll_i = 0
- FOR i = 1 To it_mxbt
- IF outwaremx[i].ifrel = 1 THEN
-
- IF uo_option_m_msttake = 0 THEN
- ld_taskamt = outwaremx[i].saleqty * outwaremx[i].price / (1 + outwaremx[i].taxrate) //计算单据总金额
- ELSE
- ld_taskamt = outwaremx[i].saleqty * outwaremx[i].rebate * outwaremx[i].enprice / (1 + outwaremx[i].taxrate) //计算单据总金额
- END IF
-
- FOR j = 1 To ll_i
- IF ls_taskcode[j] = outwaremx[i].relcode THEN
- ld_saletaskamt[j] = ld_saletaskamt[j] + ld_taskamt
- GOTO exit_for
- END IF
- NEXT
-
- ll_i++
- ls_taskcode[ll_i] = outwaremx[i].relcode
- ld_saletaskamt[ll_i] = ld_taskamt
-
- END IF
- exit_for:
- NEXT
-
- FOR k = 1 To ll_i
- ls_taskdscrp = ls_taskdscrp + '订单'+ls_taskcode[k]+'金额:'+String(ld_saletaskamt[k],'#,##0.00')+','
- NEXT
-
- IF sum_amt <> 0 THEN
- s_bmsttake s_take
-
- s_take.scid = scid
- s_take.cusid = cusid
- s_take.takedate = outdate
- s_take.inrep = outrep
- s_take.oriamt = ld_msttakeamt
- s_take.msttakeamt = ld_msttakeamt
- s_take.takeamt = ld_takeamt
- s_take.takeamt_cn = ld_takeamt
- s_take.dscrp = ls_about
- s_take.billcode = outwarecode
- s_take.relcode = part
- s_take.banktypeid = relint_1
- s_take.opemp = publ_operator
- s_take.buildtype = 1
- s_take.outwareid = outwareid
- s_take.accountsid = ll_accountsid
- s_take.itemid = ll_dft_itemid_take
- s_take.moneyid = ll_moneyid
- s_take.moneyid_cn = ll_moneyid
- s_take.viewdate = viewdate
- s_take.taskdscrp = ls_taskdscrp
- s_take.mrate = ld_mrate
- s_take.exchangeid = exchangeid
-
- IF uo_take.add_takerec(s_take,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF otheramt <> 0 THEN
- ls_about = outwarecode + uo_option_change_otheramt +",相关号:"+part
-
- SELECT itemid INTO :ll_dft_itemid_yh
- FROM u_itemdef
- Where dfttype = 3 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认优惠项目资料失败'
- rslt = 0
- GOTO ext
- END IF
-
- s_bmsttakemx s_takemx
-
- s_takemx.scid = scid
- s_takemx.takeid = uo_take.ref_takeid
- s_takemx.cusid = cusid
- s_takemx.takedate = outdate
- s_takemx.inrep = outrep
- s_takemx.msttakeamt = 0 - ld_mrate_amt
- s_takemx.takeamt = 0
- s_takemx.dscrp = ls_about
- s_takemx.billcode = outwarecode
- s_takemx.relcode = part
- s_takemx.banktypeid = relint_1
- s_takemx.opemp = publ_operator
- s_takemx.buildtype = 3
- s_takemx.outwareid = outwareid
- s_takemx.salebillid = 0
- s_takemx.itemid = ll_dft_itemid_yh
- s_takemx.moneyid = ll_moneyid_yh
- s_takemx.mrate = ld_mrate_yh
-
- IF uo_take.add_takerecmx(s_takemx,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- IF ld_taxamt <> 0 THEN
- ls_about = outwarecode + "销售税金,相关号:"+part
-
-
- SELECT itemid INTO :ll_dft_itemid_tax
- FROM u_itemdef
- Where dfttype = 12 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询默认销售税金项目资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- s_bmsttakemx s_takemx_tax
-
- s_takemx_tax.scid = scid
- s_takemx_tax.takeid = uo_take.ref_takeid
- s_takemx_tax.cusid = cusid
- s_takemx_tax.takedate = outdate
- s_takemx_tax.inrep = outrep
- s_takemx_tax.msttakeamt = ld_taxamt
- s_takemx_tax.takeamt = 0
- s_takemx_tax.dscrp = ls_about
- s_takemx_tax.billcode = outwarecode
- s_takemx_tax.relcode = part
- s_takemx_tax.banktypeid = relint_1
- s_takemx_tax.opemp = publ_operator
- s_takemx_tax.buildtype = 3
- s_takemx_tax.outwareid = outwareid
- s_takemx_tax.salebillid = 0
- s_takemx_tax.itemid = ll_dft_itemid_tax
- s_takemx_tax.moneyid = ll_moneyid
- s_takemx_tax.mrate = ld_mrate
-
-
- IF uo_take.add_takerecmx(s_takemx_tax,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
-
- FOR i = 1 To it_mxbt_item
- IF outware_itemmx[i].amt <> 0 THEN
- SELECT itemname
- INTO :ls_itemname
- FROM u_itemdef
- Where itemid = :outware_itemmx[i].itemid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询第'+String(i)+'行费用项目信息失败,'+ commit_transaction.SQLErrText
- GOTO ext
- END IF
-
-
-
- IF sum_amt = 0 And i = 1 THEN
- ls_about = outwarecode + '费用项目金额,相关号:'+part
-
- s_bmsttake s_take_it
-
- s_take_it.scid = scid
- s_take_it.cusid = cusid
- s_take_it.takedate = outdate
- s_take_it.inrep = outrep
- s_take_it.oriamt = outware_itemmx[i].amt
- s_take_it.msttakeamt = outware_itemmx[i].amt
- s_take_it.takeamt = 0
- s_take_it.takeamt_cn = 0
- s_take_it.dscrp = ls_about
- s_take_it.billcode = outwarecode
- s_take_it.relcode = part
- s_take_it.banktypeid = relint_1
- s_take_it.opemp = publ_operator
- s_take_it.buildtype = 1
- s_take_it.outwareid = outwareid
- s_take_it.accountsid = ll_accountsid
- s_take_it.itemid = ll_dft_itemid_take
- s_take_it.moneyid = ll_moneyid
- s_take_it.moneyid_cn = ll_moneyid
- s_take_it.viewdate = viewdate
- s_take_it.taskdscrp = ls_taskdscrp
- s_take_it.mrate = ld_mrate
-
- IF uo_take.add_takerec(s_take_it,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
-
- ls_about = outwarecode + '费用项目:'+ls_itemname +",相关号:"+part
-
- s_takemx_item.scid = scid
- s_takemx_item.takeid = uo_take.ref_takeid
- s_takemx_item.cusid = cusid
- s_takemx_item.takedate = outdate
- s_takemx_item.inrep = outrep
- s_takemx_item.msttakeamt = outware_itemmx[i].amt
- s_takemx_item.takeamt = 0
- s_takemx_item.dscrp = ls_about
- s_takemx_item.billcode = outwarecode
- s_takemx_item.relcode = part
- s_takemx_item.banktypeid = relint_1
- s_takemx_item.opemp = publ_operator
- s_takemx_item.buildtype = 3
- s_takemx_item.outwareid = outwareid
- s_takemx_item.salebillid = 0
- s_takemx_item.itemid = outware_itemmx[i].itemid
- s_takemx_item.moneyid = ll_moneyid
- s_takemx_item.mrate = ld_mrate
-
- IF uo_take.add_takerecmx(s_takemx_item,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- NEXT
-
- UPDATE u_outware
- SET relint_3 = :uo_take.ref_takeid
- WHERE u_outware.outwareid = :outwareid
- AND scid = :scid
- AND flag = 1
- And secflag = 1 Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新相关应收帐id失败'
- rslt = 0
- GOTO ext
- END IF
-
- END IF
- secflag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_update_cusprice
- Destroy uo_take
- RETURN rslt
- end function
- public function integer c_secauditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j
- uo_musttake uo_take
- uo_take = Create uo_musttake
- uo_cusprice uo_update_cusprice
- uo_update_cusprice = Create uo_cusprice
- IF uo_option_secaudit_notupdate_hisprice = -1000 THEN
- rslt = 0
- arg_msg = '选项:[332]销售发货单财审时不更新客户价格历史,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- String ls_mtrlname
- String ls_cusname
- DateTime null_datetime
- Long ll_takeid
- Decimal ld_itemamt
- int li_StoreBalcType,li_AmtAuditFlag
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有撤审对象"
- GOTO ext
- END IF
- IF ctmint > 0 THEN
- arg_msg = '单据已截数,不能操作'
- rslt = 0
- GOTO ext
- END IF
- IF secflag = 0 THEN
- rslt = 0
- arg_msg = "该单据财务未审,不能进行财务撤审"
- GOTO ext
- END IF
- //检查仓库是否分开结存
- 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
- SELECT count(*) INTO :cnt
- FROM u_user
- Where username = :publ_operator Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,操作员"
- GOTO ext
- END IF
- IF cnt = 0 THEN
- rslt = 0
- arg_msg = "操作员姓名未登记或已取消"
- GOTO ext
- END IF
- SetNull(null_datetime)
- UPDATE u_outware
- SET secAuditingrep = '',
- secAuditingdate = :null_datetime,
- secflag = 0,
- relint_3 = 0
- WHERE u_outware.outwareid = :outwareid
- And scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致财务审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在财务撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF uo_option_secaudit_notupdate_hisprice = 0 THEN
- FOR i = 1 To it_mxbt
- IF outwaremx[i].outtype <> '' THEN CONTINUE
-
- IF uo_update_cusprice.uof_del_cusprice_auto(cusid,outwareid,&
- outwaremx[i].printid,outwaremx[i].mtrlid,outwaremx[i].status,&
- outwaremx[i].woodcode,outwaremx[i].pcode,&
- 0,relint_2,0,0,False,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- FOR j = 1 To it_mxbt_item
- IF outware_itemmx[j].IsCusAmt = 1 THEN
- ld_itemamt = ld_itemamt + outware_itemmx[j].amt
- END IF
- NEXT
- If (sum_amt <> 0 Or ld_itemamt <> 0) And relint_3 <> 0 THEN
- IF uo_take.del_takerec(scid,1,relint_3,cusid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- secflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_take
- Destroy uo_update_cusprice
- 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,k
- Long chc
- Long rst_outwareid //
- Long rst_inwareid //
- Long ll_i,ll_j,ll_k,ll_l
- Int li_ifpack,li_ifunit,li_ifpackpro
- Int li_ifpackcnt,li_ifpackprocnt
- Decimal ld_rate,ld_uqty,ld_rate_buy
- Decimal ld_fprice,ld_uprice,ld_planprice
- String ls_uunit,ls_unit_buy,ls_unit
- Long ll_storageid_arr[]
- //
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_sumnotoutqty_bill
- Long ll_row
- Long ll_pda_hh
- Int li_ifvqty
- uo_cmpl_packpro uo_pack
- uo_pack = Create uo_cmpl_packpro
- uo_pack.commit_transaction = commit_transaction
- s_inwaremx s_mx
- s_outwaremx s_mx_out
- 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
- If uo_option_confirmaudit_sale = -1000 Then
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_outware_saleout = -1000 Then
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_outware_sale_ifmating = -1000 Then
- rslt = 0
- arg_msg = '选项:[188]销售发货单仓审时是否检查配套出仓,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_pda_sale_lock = -1000 Then
- rslt = 0
- arg_msg = '选项:[310]PDA销售发货加锁,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_canpack_ifzanyong = -1000 Then
- rslt = 0
- arg_msg = '选项:[417]通用包件产品可装数选项,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = commit_transaction
- uo_saleout uo_sout
- uo_sout = Create uo_saleout
- uo_sout.commit_transaction = commit_transaction
- 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
- ds_out_assign.DataObject = 'ds_outwaremx_assign'
- 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
- String ls_storagename
- Int li_outtype_storage,li_storagetype
- Select storagename,outtype,storagetype
- Into :ls_storagename,:li_outtype_storage,:li_storagetype
- 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 flag = 1 Then
- rslt = 0
- arg_msg = "单据已经审核"
- Goto ext
- End If
- //yyx2013-4-3
- If f_power_ind(3715,sys_msg_pow) And Not sys_power_issuper Then
- For i = 1 To it_mxbt
- If outwaremx[i].qty <> outwaremx[i].planqty Then
- arg_msg = '有实发数与计划发货数不相等的发货明细,你没有权限操作'
- rslt = 0
- Goto ext
- End If
- Next
- End If
- //
- If uo_option_pda_sale_lock = 1 And uo_option_inout_type = 2 And li_outtype_storage = 2 Then
- If pda_flag = 1 Then
- Select Top 1 DATEDIFF(hh, :pda_date, getdate()) Into :ll_pda_hh From u_user Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "查询单据条码扫描开始时间与当前时间的小时间隔失败,"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If ll_pda_hh < 4 Then
- rslt = 0
- arg_msg = "单据正在扫描条码,不能仓审单据,操作取消"
- Goto ext
- End If
- End If
- End If
- If uo_option_confirmaudit_sale = 1 Then
- If priceflag = 0 Then
- rslt = 0
- arg_msg = "销售单要确认后才能审核"
- Goto ext
- End If
- End If
- //检查配套
- If uo_option_outware_sale_ifmating = 1 And li_outtype_storage > 0 Then
- If uof_check_pt(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- Update u_outware
- Set Auditingrep = :publ_operator,
- Auditingdate = getdate(),
- flag = 1,
- carflag = 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
- uo_inware uo_in
- uo_outware uo_out
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then
-
- //yyx20120906包件产品先更新分配出仓数
- For i = 1 To it_mxbt
- //yyx20120825
- //仓库是用库存分配,(包件出仓或条码出仓),包件产品扣分配,包件在销售出仓单做
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = outwaremx[i].qty
-
-
- If ld_sumnotoutqty > 0 And ld_sumnotoutqty_bill > 0 Then
- 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_20120825
- Next
- //yyx20120906
-
- cnt = 1
- For ll_i = 1 To it_mxbt_mx
- If ll_i = 1 Then
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- Goto _next
- End If
-
- For ll_j = 1 To cnt
- If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then
- Goto _next
- End If
- Next
-
- cnt++
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- _next:
- Next
-
- For ll_i = 1 To cnt
- If uo_out.newbegin(scid,21,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_out.relid = outwareid
- uo_out.outdate = outdate
- uo_out.outrep = outrep
- uo_out.part = outwarecode
- uo_out.dscrp = dscrp
- uo_out.cusname = '销售发货单包件明细自动出仓'
- uo_out.storageid = ll_storageid_arr[ll_i]
-
- chc = 0
-
- For i = 1 To it_mxbt_mx
- If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue
- Select ifpack,ifunit,unit,rate_buy,unit_buy
- Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy
- From u_mtrldef
- Where mtrlid = :outwaremx_mx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(包件明细)'+String(i)+",查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- f_get_planprice_mtrl(outwaremx_mx[i].mtrlid,outwaremx_mx[i].status,outwaremx_mx[i].woodcode,outwaremx_mx[i].pcode,ld_fprice)
-
-
- chc++
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx_mx[i].qty
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '销售发货单(包件明细)'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx_mx[i].qty /ld_rate_buy
- End If
-
- li_ifvqty = 0
- For k = 1 To it_mxbt
- If outwaremx[k].printid = outwaremx_mx[i].printid Then
-
- If outwaremx[k].mtrlid = outwaremx_mx[i].mtrlid And &
- outwaremx[k].status = outwaremx_mx[i].status And &
- outwaremx[k].woodcode = outwaremx_mx[i].woodcode And &
- outwaremx[k].pcode = outwaremx_mx[i].pcode Then
-
- li_ifvqty = 1
- Else
- li_ifvqty = 0
- End If
-
- Exit
- End If
- Next
-
- s_mx_out.mtrlwareid = outwaremx_mx[i].mtrlwareid
- s_mx_out.qty = outwaremx_mx[i].qty
- s_mx_out.fprice = ld_fprice
- s_mx_out.rebate = 1
- s_mx_out.mxdscrp = outwaremx_mx[i].mxdscrp
- s_mx_out.printid = chc
- s_mx_out.ifrel = 0
- s_mx_out.relid = 0
- s_mx_out.olmtrlid = outwaremx_mx[i].printid
- s_mx_out.packqty = 0
- s_mx_out.outtype = ''
- s_mx_out.planqty = 0
- s_mx_out.relprintid = outwaremx_mx[i].mxprintid
- s_mx_out.unit = ls_uunit
- s_mx_out.uqty = ld_uqty
- s_mx_out.rate = ld_rate
- s_mx_out.pricetype = ''
- s_mx_out.formula = ''
- s_mx_out.saleoutid = 0
- s_mx_out.saleoutprintid = 0
- s_mx_out.mxdscrp2 = ''
- s_mx_out.net_weight = 0
- s_mx_out.gross_weight = 0
- s_mx_out.cubage = 0
- s_mx_out.taxrate = 0
- s_mx_out.priceformula = ''
- s_mx_out.qtyformula = ''
- s_mx_out.ifvqty = li_ifvqty
- s_mx_out.ifnotinout = outwaremx_mx[i].ifnotinout
-
- If uo_out.acceptmx(s_mx_out,arg_msg) = 0 Then
- arg_msg = '销售发货单(包件明细)'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- // IF uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,&
- // outwaremx_mx[i].qty,ld_fprice,1,&
- // outwaremx_mx[i].mxdscrp,chc,arg_msg,0,0,outwaremx_mx[i].printid,0,'',0,outwaremx_mx[i].mxprintid,&
- // ls_uunit,ld_uqty,ld_rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN
- // arg_msg = '销售发货单(包件明细)'+String(i)+','+arg_msg
- // rslt = 0
- // GOTO ext
- // END IF
- Next
-
- If uo_out.Save(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(包件明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- rst_outwareid = uo_out.outwareid
-
- //2.原事务审核出仓单
- If uo_out.getinfo(scid,rst_outwareid,arg_msg) = 0 Then
- arg_msg = '销售发货单(包件明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_out.auditing(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(包件明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_option_noauditingqty_mode = 1 Then
- If UpperBound(uo_out.ins_ref_outwaremx) > 0 Then
- For ll_l = 1 To UpperBound(uo_out.ins_ref_outwaremx)
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = uo_out.ins_ref_outwaremx[ll_l].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = uo_out.ins_ref_outwaremx[ll_l].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = uo_out.ins_ref_outwaremx[ll_l].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = uo_out.storageid
- Next
- End If
- End If
- Next
-
- If uo_in.newbegin(scid,23,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_in.relid = outwareid
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.sptname = '销售发货单发货明细包件产品自动进仓'
- uo_in.storageid = storageid
-
- chc = 0
-
- For i = 1 To it_mxbt
- Select ifpackpro,ifunit,unit,rate_buy,unit_buy
- Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy
- From u_mtrldef
- Where mtrlid = :outwaremx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(发货明细)行:'+String(i)+','+"查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- chc++
-
- f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_planprice)
-
-
- If li_ifpackpro = 0 Then
- Select cost Into :ld_fprice
- From u_mtrlware
- Where mtrlwareid = :outwaremx[i].mtrlwareid
- And scid = :scid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(发货明细)行:'+String(i)+','+"查询库存成本价操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If ld_fprice = 0 Then ld_fprice = ld_planprice
- Else
-
- If ld_planprice <> 0 Then
- ld_fprice = ld_planprice
- Else
- For j = 1 To it_mxbt_mx
- If outwaremx_mx[j].printid = outwaremx[i].printid Then
- f_get_planprice_mtrl(outwaremx_mx[j].mtrlid,outwaremx_mx[j].status,outwaremx_mx[j].woodcode,outwaremx_mx[j].pcode,ld_planprice)
-
- If outwaremx[i].planqty <> 0 Then
- ld_fprice = ld_fprice + outwaremx_mx[j].planqty / outwaremx[i].planqty * ld_planprice
- End If
- End If
- Next
- End If
- End If
-
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx[i].qty
- ld_uprice = ld_fprice
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '物料:'+outwaremx[i].mtrlcode+',销售发货单(发货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx[i].qty /ld_rate_buy
- ld_uprice = ld_fprice * ld_rate
- End If
-
- s_mx.printid = chc
- s_mx.mtrlid = outwaremx[i].mtrlid
- s_mx.mtrlcode = outwaremx[i].mtrlcode
- s_mx.plancode = outwaremx[i].plancode
- s_mx.status = outwaremx[i].status
- s_mx.uqty = ld_uqty
- s_mx.enprice = ld_uprice
- s_mx.rebate = 1
- s_mx.mxdscrp = outwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = outwaremx[i].woodcode
- s_mx.pcode = outwaremx[i].pcode
- s_mx.sptid = outwaremx[i].sptid
- s_mx.unit = ls_uunit
- s_mx.rate = ld_rate
- s_mx.qty = outwaremx[i].qty
- s_mx.relprintid = 0
- s_mx.checkqty = 0
- s_mx.result = ''
- s_mx.waredscrp = ''
- s_mx.relbillid = 0
- s_mx.relbillprintid = 0
- s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode
- s_mx.Location = outwaremx[i].Location
- s_mx.deliqty = ld_uqty
- s_mx.tax = 0
-
-
- If outwaremx[i].ifpackpro = 0 Then
- s_mx.ifvqty = 1
- s_mx.ifnotinout = 1
- Else
- s_mx.ifvqty = 0
- s_mx.ifnotinout = 0
- End If
-
- If uo_in.acceptmx(s_mx, arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- // IF uo_in.acceptmx(chc,&
- // outwaremx[i].mtrlid,&
- // outwaremx[i].mtrlcode,&
- // outwaremx[i].plancode,&
- // outwaremx[i].status,&
- // ld_uqty,&
- // ld_uprice,&
- // 1,&
- // outwaremx[i].mxdscrp,&
- // arg_msg,&
- // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,&
- // outwaremx[i].qty,0,0,'','',0,0,&
- // outwaremx[i].mtrlcuscode,outwaremx[i].Location,&
- // ld_uqty,&
- // 0) = 0 THEN
- // arg_msg = '销售发货单(发货明细),'+arg_msg
- // rslt = 0
- // GOTO ext
- // END IF
- Next
-
- If uo_in.Save(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
-
- rslt = 0
- Goto ext
- End If
-
- rst_inwareid = uo_in.inwareid
-
- //4.原事务审核进仓单
- If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
- // END IF
- End If
- Long ll_printid_arr[],ll_mtrlwareid_arr[],ll_mtrlid_arr[]
- String ls_status_arr[],ls_woodcode_arr[],ls_pcode_arr[]
- Decimal ld_qty_arr[]
- Long ll_cnt = 1
- Long ll_printid
- Decimal ld_maxqty
- Long ll_mtrlid
- Int li_outtype
- String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[]
- Int li_ifover[],li_dipztype[]
- Decimal ld_Sonscale[]
- Long ll_SonMtrlid[]
- Long it_mxt = 1
- String ls_status_find,ls_woodcode_find,ls_pcode_find
- String ls_status,ls_woodcode,ls_pcode
- Decimal ld_pfqty
- If uo_option_outware_saleout = 1 Then
- Declare cur_mx Cursor For
- Select u_outwaremx.relid, u_outwaremx.mtrlwareid, u_outwaremx.mtrlid,
- u_outwaremx.status, u_outwaremx.woodcode, u_outwaremx.pcode,
- u_outwaremx.qty
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid
- Where u_outware.relid = :outwareid And
- u_outware.scid = :scid And
- u_outware.billtype = 21 Using commit_transaction;
-
- Open cur_mx;
- Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt],
- :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt];
- Do While commit_transaction.SQLCode = 0
- ll_cnt++
- Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt],
- :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt];
- Loop
- Close cur_mx;
- ll_cnt = ll_cnt - 1
-
- For ll_i = 1 To it_mxbt
- ld_maxqty = 0
- it_mxt = 1
- ll_printid = outwaremx[ll_i].printid
- ll_mtrlid = outwaremx[ll_i].mtrlid
- ls_status = outwaremx[ll_i].status
- ls_woodcode = outwaremx[ll_i].woodcode
- ls_pcode = outwaremx[ll_i].pcode
-
- Select outtype,ifpackpro Into :li_outtype,:li_ifpackpro
- From u_mtrldef
- Where mtrlid = :ll_mtrlid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',查询产品出仓类型失败,'+commit_transaction.SQLErrText
- rslt = 0
- Goto ext
- End If
- // IF li_outtype = 0 or li_ifpackpro = 0 THEN
- If Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro = 1) Then
- For ll_j = 1 To ll_cnt
- If ll_mtrlwareid_arr[ll_j] = 0 Then Continue
-
- If ll_printid_arr[ll_j] = ll_printid Then
- ld_maxqty = ld_qty_arr[ll_j]
- Exit
- End If
- Next
-
- Update u_outwaremx
- Set qty = :ld_maxqty,
- saleqty = :ld_maxqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :ll_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',更新实发数失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- Else
- Declare cur_pf Cursor For
- Select u_PrdPF.SonMtrlid,
- u_PrdPF.status,
- u_PrdPF.woodcode,
- u_PrdPF.pcode,
- u_PrdPF.ifover,
- u_prdpf.dipztype,
- u_prdpf.Sonscale
- From u_PrdPF,u_mtrl_pf
- Where ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid )
- And ( u_PrdPF.pfcode = u_mtrl_pf.pfcode )
- And ( u_PrdPF.mtrlid = :ll_mtrlid )
- And ( u_mtrl_pf.ifdi = 1 And :li_ifpackpro = 0
- Or u_mtrl_pf.ifdft = 1 And :li_ifpackpro = 1 );
-
- Open cur_pf;
-
- Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- Do While sqlca.SQLCode = 0
- it_mxt++
- Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- Loop
-
- it_mxt = it_mxt - 1
- Close cur_pf;
-
- For ll_k = 1 To it_mxt
- If li_ifover[ll_k] = 1 Then
- Choose Case li_dipztype[ll_k]
- Case 0
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ''
- Case 1
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- Case 2
- ls_status_find = ''
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- Case 3
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- Case 4
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- Case 5
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- Case 6
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- End Choose
- Else
- ls_status_find = ls_pf_status[ll_k]
- ls_woodcode_find = ls_pf_woodcode[ll_k]
- ls_pcode_find = ls_pf_pcode[ll_k]
- End If
-
- ls_status_find = Trim(ls_status_find)
- ls_woodcode_find = Trim(ls_woodcode_find)
- ls_pcode_find = Trim(ls_pcode_find)
-
- ld_pfqty = 0
- For ll_j = 1 To ll_cnt
- If ll_mtrlwareid_arr[ll_j] = 0 Then Continue
-
- If ll_printid_arr[ll_j] = ll_printid And &
- ll_mtrlid_arr[ll_j] = ll_SonMtrlid[ll_k] And &
- ls_status_arr[ll_j] = ls_status_find And &
- ls_woodcode_arr[ll_j] = ls_woodcode_find And &
- ls_pcode_arr[ll_j] = ls_pcode_find Then
- ld_pfqty = ld_pfqty + ld_qty_arr[ll_j] / ld_Sonscale[ll_k]
-
- End If
- Next
-
-
- If thflag = 0 Then
- If ld_pfqty > ld_maxqty Then ld_maxqty = ld_pfqty
- Else
- If ld_pfqty < ld_maxqty Then ld_maxqty = ld_pfqty
- End If
- Next
-
- Update u_outwaremx
- Set qty = :ld_maxqty,
- saleqty = :ld_maxqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :ll_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+',更新实发数失败,'+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
- outwaremx[ll_i].qty = ld_maxqty
- Next
-
- If uo_in.newbegin(scid,23,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_in.relid = outwareid
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.sptname = '销售发货单发货明细包件产品自动进仓'
- uo_in.storageid = storageid
-
- chc = 0
-
- For i = 1 To it_mxbt
- Select ifpackpro,ifunit,unit,rate_buy,unit_buy,planprice
- Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy,:ld_fprice
- From u_mtrldef
- Where mtrlid = :outwaremx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '销售发货单(发货明细)行:'+String(ll_i)+",查询物料资料失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- chc++
-
- f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice)
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx[i].qty
- ld_uprice = ld_fprice
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '销售发货单(发货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx[i].qty /ld_rate_buy
- ld_uprice = ld_fprice * ld_rate
- End If
-
- If ld_uqty <> 0 Or outwaremx[i].qty <> 0 Then
-
- s_mx.printid = chc
- s_mx.mtrlid = outwaremx[i].mtrlid
- s_mx.mtrlcode = outwaremx[i].mtrlcode
- s_mx.plancode = outwaremx[i].plancode
- s_mx.status = outwaremx[i].status
- s_mx.uqty = ld_uqty
- s_mx.enprice = ld_uprice
- s_mx.rebate = 1
- s_mx.mxdscrp = outwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = outwaremx[i].woodcode
- s_mx.pcode = outwaremx[i].pcode
- s_mx.sptid = outwaremx[i].sptid
- s_mx.unit = ls_uunit
- s_mx.rate = ld_rate
- s_mx.qty = outwaremx[i].qty
- s_mx.relprintid = 0
- s_mx.checkqty = 0
- s_mx.result = ''
- s_mx.waredscrp = ''
- s_mx.relbillid = 0
- s_mx.relbillprintid = 0
- s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode
- s_mx.Location = outwaremx[i].Location
- s_mx.deliqty = ld_uqty
- s_mx.tax = 0
-
-
- If outwaremx[i].ifpackpro = 0 Then
- s_mx.ifvqty = 1
- s_mx.ifnotinout = 1
- Else
- s_mx.ifvqty = 0
- s_mx.ifnotinout = 0
- End If
-
- If uo_in.acceptmx(s_mx, arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
-
- // IF uo_in.acceptmx(chc,&
- // outwaremx[i].mtrlid,&
- // outwaremx[i].mtrlcode,&
- // outwaremx[i].plancode,&
- // outwaremx[i].status,&
- // ld_uqty,&
- // ld_uprice,&
- // 1,&
- // outwaremx[i].mxdscrp,&
- // arg_msg,&
- // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,&
- // outwaremx[i].qty,0,0,'','',0,0,&
- // outwaremx[i].mtrlcuscode,outwaremx[i].Location,&
- // ld_uqty,&
- // 0) = 0 THEN
- // arg_msg = '销售发货单(发货明细)行:'+String(i)+','+arg_msg
- // rslt = 0
- // GOTO ext
- // END IF
- End If
- Next
-
- If uo_in.Save(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- rst_inwareid = uo_in.inwareid
- //4.原事务审核进仓单
- If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- arg_msg = '销售发货单(发货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
- //审核原发货单明细出仓
- For i = 1 To it_mxbt
- //先扣库存分配,再扣库存
- //仓库是用库存分配,不是(包件出仓和条码出仓),包件的在销售出仓单做
-
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = outwaremx[i].qty
-
- If ld_sumnotoutqty_bill > ld_sumnotoutqty Then
- arg_msg = '发货明细行:'+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 = '发货明细行:'+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 = '发货明细行:'+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
-
- //扣库存
- Decimal ld_ref_costamt
- 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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- 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 = '发货明细行:'+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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If billtype = 1 And outwaremx[i].saleoutid > 0 Then
- If uo_sout.addmxcmpl(outwaremx[i].saleoutid,outwaremx[i].saleoutprintid,outwaremx[i].saleqty,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If billtype = 1 And outwaremx[i].saleoutid > 0 Then
- If uo_sout.trycmpsaleout(outwaremx[i].saleoutid,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- If uo_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].saleqty,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- If uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
- Next
- If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then
- If uof_p_barcode(1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- If uof_create_owe(arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- //更新库存已开单数(减)
- If uo_option_inout_type = 0 Or (uo_option_inout_type <> 0 And uo_option_outware_saleout = 0) Then
- If uof_noauditingqty_del(scid,outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //更新通用包件明细已占用数(outqty)
- Long ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp
- If uo_option_canpack_ifzanyong = 1 Then
- For ll_i = 1 To it_mxbt_mx
-
- ll_mtrlwareid_fp = 0
- ll_mtrlid_fp = 0
- ll_cpmtrlwareid_fp = 0
- ll_cpmtrlid_fp = 0
-
- If outwaremx_mx[ll_i].ifpack = 1 Then
-
- ll_mtrlwareid_fp = outwaremx_mx[ll_i].mtrlwareid
- ll_mtrlid_fp = outwaremx_mx[ll_i].mtrlid
-
- //查找包件明细对应的发货明细
- For ll_j = 1 To it_mxbt
- If outwaremx_mx[ll_i].printid = outwaremx[ll_j].printid Then
- If outwaremx[ll_j].ifpackpro = 1 Then
- ll_cpmtrlwareid_fp = outwaremx[ll_j].mtrlwareid
- ll_cpmtrlid_fp = outwaremx[ll_j].mtrlid
- Else
- Goto _next_mx
- End If
- End If
- Next
-
- If ll_cpmtrlwareid_fp = 0 Then Goto _next_mx
-
- If uo_pack.uof_add_fpqty_out(scid,ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp,outwaremx_mx[ll_i].qty,arg_msg,False) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- End If
- _next_mx:
- Next
- End If
- flag = 1
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_task
- Destroy uo_in
- Destroy uo_out
- Destroy uo_ma
- Destroy uo_sout
- Destroy uo_pro
- Destroy ds_out_assign
- Destroy uo_pack
- 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
- Long ls_newid
- DateTime null_dt
- SetNull(null_dt)
- Long ll_inwareid_rel,ll_outwareid_rel
- String ls_inwarecode_rel,ls_outwarecode_rel
- String ls_outwarecode_arr[]
- Long ll_outwareid[]
- Long ll_itmx = 1,ll_i,ll_l,ll_j
- 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_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- If uo_option_outware_saleout = -1000 Then
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = commit_transaction
- uo_saleout uo_sout
- uo_sout = Create uo_saleout
- uo_sout.commit_transaction = commit_transaction
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- uo_cmpl_packpro uo_pack
- uo_pack = Create uo_cmpl_packpro
- uo_pack.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
- ds_out_assign.SetTransObject(commit_transaction)
- uo_inware uo_in
- uo_outware uo_out
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- 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
- String ls_storagename
- Int li_outtype_storage,li_storagetype
- Select storagename,outtype,storagetype
- Into :ls_storagename,:li_outtype_storage,:li_storagetype
- 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 secflag = 1 Then
- rslt = 0
- arg_msg = "单据已经过财务审核"
- Goto ext
- End If
- If balcflag = 1 Then
- rslt = 0
- arg_msg = "单据已经日结,不能撤审"
- Goto ext
- End If
- String ls_owecode
- Int li_oweflag
- Long ll_owebillid
- cnt = 0
- Select count(*) Into :cnt
- From u_owegood
- Where scid = :scid
- And relid = :outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其它原因导致查询是否存在相关欠货单操作失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- If cnt > 1 Then
- rslt = 0
- arg_msg = '不合理的欠货单数量(存在多张相关欠货单),请检查'
- Goto ext
- ElseIf cnt = 1 Then
- Select billid,billcode ,flag
- Into :ll_owebillid,:ls_owecode,:li_oweflag
- From u_owegood
- Where scid = :scid
- And relid = :outwareid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '因网络或其它原因导致查询\相关欠货单信息操作失败'+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If li_oweflag <> 0 Then
- rslt = 0
- arg_msg = '相关欠货单:'+ls_owecode+' 已在进行或完成,不能撤审销售发货单,请检查'
- Goto ext
- End If
-
- Delete From u_owegoodmx
- Where billid = :ll_owebillid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除相关欠货单明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- Delete From u_owegood
- Where billid = :ll_owebillid
- And flag = 0;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "删除相关欠货单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- End If
- Update u_outware
- Set Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0,
- carflag = 0
- Where u_outware.outwareid = :outwareid
- And flag = 1
- And scid = :scid Using commit_transaction;
-
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- //原发货单明细
- For i = 1 To it_mxbt
- 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 = '发货明细行:'+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,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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If billtype = 1 And outwaremx[i].saleoutid > 0 Then
- If uo_sout.addmxcmpl(outwaremx[i].saleoutid,outwaremx[i].saleoutprintid,0 - outwaremx[i].saleqty,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If billtype = 1 And outwaremx[i].saleoutid > 0 Then
- If uo_sout.trycmpsaleout(outwaremx[i].saleoutid,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- If uo_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid, 0 - outwaremx[i].saleqty,arg_msg,False) <> 1 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- If uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then
- arg_msg = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- //更新库存分配
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_outmxqty
- Long ll_row
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_outmxqty = outwaremx[i].qty
-
- If ld_sumnotoutqty > 0 And ld_outmxqty > 0 Then
-
- // IF ld_outmxqty > ld_sumnotoutqty THEN
- // arg_msg = '发货明细行:'+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_outmxqty Then
- ld_assign_outqty = ld_outmxqty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '发货明细行:'+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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- // END IF
- End If
- End If
-
- If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
- Next
- If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then
-
- Select count(*)
- Into :cnt
- From u_inware
- Where scid = :scid
- And relid = :outwareid
- And billtype = 23 Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If cnt > 0 Then
- Select inwareid,inwarecode
- Into :ll_inwareid_rel,:ls_inwarecode_rel
- From u_inware
- Where scid = :scid
- And relid = :outwareid
- And billtype = 23 Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.c_auditing(False,arg_msg) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- Declare cur_mx Cursor For
- Select outwareid,outwarecode
- From u_outware
- Where billtype = 21
- And relid = :outwareid
- And scid = :scid Using commit_transaction;
-
- Open cur_mx;
- Fetch cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx];
- Do While commit_transaction.SQLCode = 0
- ll_itmx++
- Fetch cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx];
- Loop
- ll_itmx = ll_itmx - 1
- Close cur_mx;
-
- For ll_i = 1 To ll_itmx
- If uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 Then
- rslt = 0
- arg_msg = '查询相关出仓单失败,' + arg_msg
- Goto ext
- End If
-
- If uo_out.c_auditing(False,arg_msg) = 0 Then
- rslt = 0
- arg_msg = '撤审相关出仓单失败,' + arg_msg
- Goto ext
- End If
-
- If uo_out.del(scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 Then
- arg_msg = '相关出仓单:'+ls_outwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
- Next
-
- //原发货单明细取消分配出仓
- For i = 1 To it_mxbt
- //yyx20120825
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_outmxqty = outwaremx[i].qty
-
- If ld_sumnotoutqty > 0 And ld_outmxqty > 0 Then
-
- // IF ld_outmxqty > ld_sumnotoutqty THEN
- // arg_msg = '发货明细行:'+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_outmxqty Then
- ld_assign_outqty = ld_outmxqty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '发货明细行:'+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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- // END IF
- End If
- //
- Next
-
- End If
- If uo_option_outware_saleout = 1 Then
- Select count(*)
- Into :cnt
- From u_inware
- Where scid = :scid
- And relid = :outwareid
- And billtype = 23 Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If cnt > 0 Then
- Select inwareid,inwarecode
- Into :ll_inwareid_rel,:ls_inwarecode_rel
- From u_inware
- Where scid = :scid
- And relid = :outwareid
- And billtype = 23;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- If uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.c_auditing(False,arg_msg) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 Then
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- Declare cur_mx_rel Cursor For
- Select outwareid
- From u_outware
- Where billtype = 21
- And relid = :outwareid
- And scid = :scid Using commit_transaction;
-
- Open cur_mx_rel;
- Fetch cur_mx_rel Into :ll_outwareid[ll_itmx];
- Do While commit_transaction.SQLCode = 0
- ll_itmx++
- Fetch cur_mx_rel Into :ll_outwareid[ll_itmx];
- Loop
- ll_itmx = ll_itmx - 1
- Close cur_mx_rel;
-
- For ll_i = 1 To ll_itmx
- If uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 Then
- rslt = 0
- arg_msg = '查询相关出仓单失败,' + arg_msg
- Goto ext
- End If
-
- If uo_out.c_auditing(False,arg_msg) = 0 Then
- rslt = 0
- arg_msg = '撤审相关出仓单失败,' + arg_msg
- Goto ext
- End If
-
- If uo_option_noauditingqty_mode = 1 Then
- If UpperBound(uo_out.ins_ref_outwaremx) > 0 Then
- For ll_l = 1 To UpperBound(uo_out.ins_ref_outwaremx)
- ins_ref_mxbt++
- ins_ref_outwaremx[ins_ref_mxbt].mtrlid = uo_out.ins_ref_outwaremx[ll_l].mtrlid
- ins_ref_outwaremx[ins_ref_mxbt].plancode = uo_out.ins_ref_outwaremx[ll_l].plancode
- ins_ref_outwaremx[ins_ref_mxbt].mtrlcuscode = uo_out.ins_ref_outwaremx[ll_l].mtrlcuscode
- ins_ref_outwaremx[ins_ref_mxbt].storageid = uo_out.storageid
- Next
- End If
- End If
- Next
- End If
- If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then
- If uof_p_barcode(0,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //增加已开单数
- If uo_option_inout_type = 0 Or (uo_option_inout_type <> 0 And uo_option_outware_saleout = 0) Then
- If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- //更新通用包件明细已占用数(outqty)
- Long ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp
- If uo_option_canpack_ifzanyong = 1 Then
- For ll_i = 1 To it_mxbt_mx
-
- ll_mtrlwareid_fp = 0
- ll_mtrlid_fp = 0
- ll_cpmtrlwareid_fp = 0
- ll_cpmtrlid_fp = 0
-
- If outwaremx_mx[ll_i].ifpack = 1 Then
-
- ll_mtrlwareid_fp = outwaremx_mx[ll_i].mtrlwareid
- ll_mtrlid_fp = outwaremx_mx[ll_i].mtrlid
-
- //查找包件明细对应的发货明细
- For ll_j = 1 To it_mxbt
- If outwaremx_mx[ll_i].printid = outwaremx[ll_j].printid Then
- If outwaremx[ll_j].ifpackpro = 1 Then
- ll_cpmtrlwareid_fp = outwaremx[ll_j].mtrlwareid
- ll_cpmtrlid_fp = outwaremx[ll_j].mtrlid
- Else
- Goto _next_mx
- End If
- End If
- Next
-
- If ll_cpmtrlwareid_fp = 0 Then Goto _next_mx
-
- If uo_pack.uof_add_fpqty_out(scid,ll_mtrlwareid_fp,ll_mtrlid_fp,ll_cpmtrlwareid_fp,ll_cpmtrlid_fp,0 - outwaremx_mx[ll_i].qty,arg_msg,False) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- End If
- _next_mx:
- Next
- End If
- flag = 0
- ext:
- If rslt = 0 Then
- Rollback Using commit_transaction;
- ElseIf rslt = 1 And arg_ifcommit Then
- Commit Using commit_transaction;
- End If
- Destroy uo_task
- Destroy uo_in
- Destroy uo_out
- Destroy uo_ma
- Destroy uo_sout
- Destroy uo_pro
- Destroy ds_out_assign
- destroy uo_pack
- Return rslt
- end function
- public function integer c_priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
- DateTime null_dt
- Long cnt
- Long ll_pda_hh
- IF uo_option_outware_saleout = -1000 THEN
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_checkprice_native = -1000 THEN
- rslt = 0
- arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_inout_type = -1000 THEN
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_confirmaudit_sale = -1000 THEN
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_pda_sale_lock = -1000 THEN
- rslt = 0
- arg_msg = '选项:[310]PDA销售发货加锁,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- uo_cusprice uo_price
- uo_outware uo_out
- SetNull(null_dt)
- IF arg_scid < 0 THEN
- rslt = 0
- arg_msg = "错误的分部ID"
- 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 priceflag = 0 THEN
- rslt = 0
- arg_msg = "单据还未确认,不能反确认"
- GOTO ext
- END IF
- IF uo_option_confirmaudit_sale = 1 THEN
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "销售单已仓审,不能反确认"
- GOTO ext
- END IF
- END IF
- Int li_outtype_storage
- Long mx_barcode_cnt
- SELECT outtype
- INTO :li_outtype_storage
- FROM u_storage
- Where storageid = :storageid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,仓库"
- GOTO ext
- END IF
- IF li_outtype_storage = 2 THEN
- FOR i = 1 To it_mxbt
- IF li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
- NEXT
- END IF
- IF uo_option_pda_sale_lock = 1 And uo_option_inout_type = 2 And li_outtype_storage = 2 THEN
- IF pda_flag = 1 THEN
- SELECT Top 1 DATEDIFF(hh, :pda_date, getdate()) Into :ll_pda_hh From u_user Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询单据条码扫描开始时间与当前时间的小时间隔失败,"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF ll_pda_hh < 4 THEN
- rslt = 0
- arg_msg = "单据正在扫描条码,不能反确认,操作取消"
- GOTO ext
- END IF
- END IF
- END IF
- IF uo_option_inout_type = 2 And li_outtype_storage = 2 And mx_barcode_cnt > 0 THEN
- SELECT count(*) INTO :cnt
- FROM u_outwaremx_mx_barcode
- WHERE scid = :arg_scid
- AND outwareid = :arg_outwareid
- And billtype = 1 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
- END IF
- uo_price = Create uo_cusprice
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- FOR i = 1 To it_mxbt
- IF outwaremx[i].outtype <> '' THEN CONTINUE
-
- IF uo_option_checkprice_native = 1 THEN
- IF uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,&
- outwaremx[i].woodcode,relint_2,outwaremx[i].price,outwaremx[i].uqty,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,&
- outwaremx[i].woodcode,relint_2,outwaremx[i].enprice * outwaremx[i].enprice,outwaremx[i].uqty,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- NEXT
- IF uo_option_outware_saleout = 1 THEN
- cnt = 0
- Long ll_outwareid[]
- Long ll_itmx = 1,ll_i
- SELECT count(*) INTO :cnt
- FROM u_outware
- WHERE billtype = 21
- AND relid = :arg_outwareid
- AND scid = :arg_scid
- And flag = 1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询相关出仓单失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = '相关出仓单已仓审,不能反确认,请检查'
- GOTO ext
- END IF
-
- DECLARE cur_mx CURSOR FOR
- SELECT outwareid
- FROM u_outware
- WHERE billtype = 21
- AND relid = :arg_outwareid
- And scid = :arg_scid Using commit_transaction;
-
- OPEN cur_mx;
- FETCH cur_mx Into :ll_outwareid[ll_itmx];
- DO WHILE commit_transaction.SQLCode = 0
- ll_itmx++
- FETCH cur_mx Into :ll_outwareid[ll_itmx];
- LOOP
- ll_itmx = ll_itmx - 1
-
- FOR ll_i = 1 To ll_itmx
- IF uo_out.del(arg_scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 THEN
- rslt = 0
- arg_msg = '删除相关出仓单失败,' + arg_msg
- GOTO ext
- END IF
- NEXT
- END IF
- If uo_option_outware_saleout > 0 Then
- //增加库存已开单数
- If uof_noauditingqty_add(arg_scid,billtype,relint_1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- UPDATE u_outware
- SET priceemp = '',
- pricedate = :null_dt,
- priceflag = 0
- WHERE u_outware.outwareid = :arg_outwareid
- AND priceflag = 1
- And scid = :arg_scid Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致反确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在反确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- priceflag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- Destroy uo_price
- Destroy uo_out
- RETURN rslt
- end function
- public function integer uof_create_owe (ref string arg_msg);Int rslt = 1
- Long ll_i,ll_j,ll_k
- Long ll_printid,ll_mtrlid
- Int li_ifpackpro,li_outtype
- String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[]
- Int li_ifover[],li_dipztype[]
- Decimal ld_Sonscale[]
- Long ll_SonMtrlid[]
- Long it_mxt = 1
- String ls_status_find,ls_woodcode_find,ls_pcode_find
- String ls_status,ls_woodcode,ls_pcode
- Decimal ld_qty,ld_pfqty
- Long count
- Long ll_taskid
- String ls_taskcode,ls_taskrelcode
- uo_owegood uo_owe
- uo_owe = CREATE uo_owegood
- s_owegood arg_s_owe
- FOR ll_i = 1 TO it_mxbt
- ll_mtrlid = outwaremx[ll_i].mtrlid
- ls_status = outwaremx[ll_i].status
- ls_woodcode = outwaremx[ll_i].woodcode
- ls_pcode = outwaremx[ll_i].pcode
- ll_printid = outwaremx[ll_i].printid
- ld_qty = outwaremx[ll_i].qty
- ll_taskid = outwaremx[ll_i].relid
-
- IF ll_taskid > 0 THEN
- SELECT taskcode,relcode
- INTO :ls_taskcode,:ls_taskrelcode
- FROM u_saletask
- WHERE taskid = :ll_taskid
- AND scid = :scid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询明细相关订单失败'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
-
- SELECT outtype,ifpackpro INTO :li_outtype,:li_ifpackpro
- FROM u_mtrldef
- Where mtrlid = :ll_mtrlid using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询产品出仓类型失败'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- it_mxt = 1 //yyx20100424
-
- IF li_outtype <> 0 THEN
-
- DECLARE cur_pf CURSOR FOR
- SELECT u_PrdPF.SonMtrlid,
- u_PrdPF.status,
- u_PrdPF.woodcode,
- u_PrdPF.pcode,
- u_PrdPF.ifover,
- u_prdpf.dipztype,
- u_prdpf.Sonscale
- FROM u_PrdPF,u_mtrl_pf
- WHERE ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid )
- AND ( u_PrdPF.pfcode = u_mtrl_pf.pfcode )
- AND ( u_PrdPF.mtrlid = :ll_mtrlid )
- AND ( u_mtrl_pf.ifdi = 1 AND :li_ifpackpro = 0
- OR u_mtrl_pf.ifdft = 1 AND :li_ifpackpro = 1 ) using commit_transaction;
-
- OPEN cur_pf;
-
- FETCH cur_pf INTO :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- DO WHILE sqlca.SQLCode = 0
- it_mxt++
- FETCH cur_pf INTO :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- LOOP
-
- it_mxt = it_mxt - 1
- CLOSE cur_pf;
-
-
-
- FOR ll_k = 1 TO it_mxt
- IF li_ifover[ll_k] = 1 THEN
- CHOOSE CASE li_dipztype[ll_k]
- CASE 0
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ''
- CASE 1
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- CASE 2
- ls_status_find = ''
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- CASE 3
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- CASE 4
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- CASE 5
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- CASE 6
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- END CHOOSE
- ELSE
- ls_status_find = ls_pf_status[ll_k]
- ls_woodcode_find = ls_pf_woodcode[ll_k]
- ls_pcode_find = ls_pf_pcode[ll_k]
- END IF
-
- ls_status_find = Trim(ls_status_find)
- ls_woodcode_find = Trim(ls_woodcode_find)
- ls_pcode_find = Trim(ls_pcode_find)
-
-
- ld_pfqty = 0
-
- FOR ll_j = 1 TO it_mxbt_mx
- IF outwaremx_mx[ll_j].printid = ll_printid AND &
- outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] AND &
- outwaremx_mx[ll_j].status = ls_status_find AND &
- outwaremx_mx[ll_j].woodcode = ls_woodcode_find AND &
- outwaremx_mx[ll_j].pcode = ls_pcode_find THEN
- ld_pfqty = ld_pfqty + outwaremx_mx[ll_j].qty
- END IF
- NEXT
-
- IF ld_qty * ld_Sonscale[ll_k] > ld_pfqty THEN
- count++
-
- arg_s_owe.arg_s_mx[count].printid = count
- arg_s_owe.arg_s_mx[count].taskid = ll_taskid
- arg_s_owe.arg_s_mx[count].taskprintid = ll_printid
- arg_s_owe.arg_s_mx[count].taskcode = ls_taskcode
- arg_s_owe.arg_s_mx[count].taskrelcode = ls_taskrelcode
- arg_s_owe.arg_s_mx[count].taskmtrlid = ll_mtrlid
- arg_s_owe.arg_s_mx[count].mtrlid = ll_SonMtrlid[ll_k]
- arg_s_owe.arg_s_mx[count].status = ls_status_find
- arg_s_owe.arg_s_mx[count].woodcode = ls_woodcode_find
- arg_s_owe.arg_s_mx[count].pcode = ls_pcode_find
- arg_s_owe.arg_s_mx[count].plancode = outwaremx[ll_i].plancode
- arg_s_owe.arg_s_mx[count].qty = ld_qty * ld_Sonscale[ll_k] - ld_pfqty
- arg_s_owe.arg_s_mx[count].mxdscrp = ''
- IF ll_taskid > 0 THEN
- arg_s_owe.arg_s_mx[count].ifrel = 1
- ELSE
- arg_s_owe.arg_s_mx[count].ifrel = 0
- END IF
-
- END IF
- NEXT
- END IF
-
- NEXT
- IF count > 0 THEN
- arg_s_owe.scid = scid
- arg_s_owe.billid = 0
- arg_s_owe.cusid = cusid
- arg_s_owe.loandate = outdate
- arg_s_owe.relcode = outwarecode
- arg_s_owe.dscrp = '销售发货单仓审自动生成'
- arg_s_owe.assignemp = outrep
- arg_s_owe.storageid = storageid
- arg_s_owe.ifaddware = 0
- arg_s_owe.relid = outwareid
- IF uo_owe.Save(arg_s_owe,publ_operator,arg_msg,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- END IF
- DESTROY uo_owe
- RETURN rslt
- end function
- public function integer auditing_th (boolean arg_ifcommit, ref string arg_msg);
- Long rslt = 1,cnt = 0,i,j,k
- Long chc
- Long rst_outwareid //
- Long rst_inwareid //
- Long ll_i,ll_j,ll_k
- Int li_ifpack,li_ifunit,li_ifpackpro
- Int li_ifpackcnt,li_ifpackprocnt
- Decimal ld_rate,ld_uqty,ld_rate_buy
- Decimal ld_fprice,ld_uprice
- String ls_uunit,ls_unit_buy,ls_unit
- Long ll_storageid_arr[]
- Long mx_barcode_cnt
- Decimal ld_ref_costamt
- Int li_flag
- Int li_ifvqty
- s_inwaremx s_mx
- s_outwaremx s_mx_out
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- //库存分配ds
- datastore ds_out_assign
- ds_out_assign = Create datastore
- ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
- ds_out_assign.SetTransObject(commit_transaction)
- uo_mtrlware_assign uo_ma
- uo_ma = Create uo_mtrlware_assign
- uo_ma.commit_transaction = commit_transaction
- If uo_option_outware_saleout = -1000 Then
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_inout_type = -1000 Then
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_confirmaudit_sale = -1000 Then
- rslt = 0
- arg_msg = '选项:[025]销售单先确认后审核,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = commit_transaction
- 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
- String ls_storagename
- Int li_outtype_storage,li_storagetype
- Select storagename,outtype,storagetype
- Into :ls_storagename,:li_outtype_storage,:li_storagetype
- 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 flag = 1 Then
- rslt = 0
- arg_msg = "单据已经审核"
- Goto ext
- End If
- If uo_option_confirmaudit_sale = 1 Then
- If priceflag = 0 Then
- rslt = 0
- arg_msg = "销售单要确认后才能审核"
- Goto ext
- 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
- uo_inware uo_in
- uo_outware uo_out
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- For i = 1 To it_mxbt
- 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 = '退货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If ld_ref_costamt = 0 Then
- ld_ref_costamt = Round(outwaremx[i].qty * outwaremx[i].planprice,2)
- 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 = '退货明细行:'+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 = '退货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- If uo_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].qty,arg_msg,False) <> 1 Then
- arg_msg = '退货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 Then
- Select status Into :li_flag
- From u_saletask
- Where scid = :scid
- And taskid = :outwaremx[i].relid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询相关订单状态失败,'+sqlca.SQLErrText
- arg_msg = '退货明细行:'+String(i)+','+arg_msg
- Goto ext
- End If
-
- If li_flag = 1 Or li_flag = 5 Then
- If uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 Then
- arg_msg = '退货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- //更新库存分配yyx20130130
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_outmxqty
- Long ll_row
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_outmxqty = Abs(outwaremx[i].qty)
-
- If ld_outmxqty > ld_sumnotoutqty Then
- arg_msg = '退货明细行:'+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_outmxqty Then
- ld_assign_outqty = ld_outmxqty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '退货明细行:'+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 = '退货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
-
- If li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 Then mx_barcode_cnt++
- Next
- If li_outtype_storage <> 0 And uo_option_outware_saleout = 0 Then
-
- cnt = 1
- For ll_i = 1 To it_mxbt_mx
- If ll_i = 1 Then
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- Goto _next
- End If
-
- For ll_j = 1 To cnt
- If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then
- Goto _next
- End If
- Next
-
- cnt++
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- _next:
- Next
-
- For ll_i = 1 To cnt
- If uo_out.newbegin(scid,21,arg_msg) = 0 Then
- arg_msg = '退货单(包件明细),' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- uo_out.relid = outwareid
- uo_out.outdate = outdate
- uo_out.outrep = outrep
- uo_out.part = outwarecode
- uo_out.dscrp = dscrp
- uo_out.cusname = '包件明细自动出仓'
- uo_out.storageid = ll_storageid_arr[ll_i]
- uo_out.thflag = 1
-
- chc = 0
-
- For i = 1 To it_mxbt_mx
- If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue
- Select ifpack,ifunit,unit,rate_buy,unit_buy
- Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy
- From u_mtrldef
- Where mtrlid = :outwaremx_mx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '退货单(包件明细)行:'+String(i)+",因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- chc++
- f_get_planprice_mtrl(outwaremx_mx[i].mtrlid,outwaremx_mx[i].status,outwaremx_mx[i].woodcode,outwaremx_mx[i].pcode,ld_fprice)
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx_mx[i].qty
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '退货单(包件明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx_mx[i].qty /ld_rate_buy
- End If
-
- li_ifvqty = 0
- For k = 1 To it_mxbt
- If outwaremx[k].printid = outwaremx_mx[i].printid Then
-
- If outwaremx[k].mtrlid = outwaremx_mx[i].mtrlid And &
- outwaremx[k].status = outwaremx_mx[i].status And &
- outwaremx[k].woodcode = outwaremx_mx[i].woodcode And &
- outwaremx[k].pcode = outwaremx_mx[i].pcode Then
-
- li_ifvqty = 1
- Else
- li_ifvqty = 0
- End If
-
- Exit
- End If
- Next
-
- s_mx_out.mtrlwareid = outwaremx_mx[i].mtrlwareid
- s_mx_out.qty = outwaremx_mx[i].qty
- s_mx_out.fprice = ld_fprice
- s_mx_out.rebate = 1
- s_mx_out.mxdscrp = outwaremx_mx[i].mxdscrp
- s_mx_out.printid = chc
- s_mx_out.ifrel = 0
- s_mx_out.relid = 0
- s_mx_out.olmtrlid = outwaremx_mx[i].printid
- s_mx_out.packqty = 0
- s_mx_out.outtype = ''
- s_mx_out.planqty = 0
- s_mx_out.relprintid = outwaremx_mx[i].mxprintid
- s_mx_out.unit = ls_uunit
- s_mx_out.uqty = ld_uqty
- s_mx_out.rate = ld_rate
- s_mx_out.pricetype = ''
- s_mx_out.formula = ''
- s_mx_out.saleoutid = 0
- s_mx_out.saleoutprintid = 0
- s_mx_out.mxdscrp2 = ''
- s_mx_out.net_weight = 0
- s_mx_out.gross_weight = 0
- s_mx_out.cubage = 0
- s_mx_out.taxrate = 0
- s_mx_out.priceformula = ''
- s_mx_out.qtyformula = ''
- s_mx_out.ifnotinout = outwaremx_mx[i].ifnotinout
-
- s_mx_out.ifvqty = li_ifvqty
-
- If uo_out.acceptmx(s_mx_out,arg_msg) = 0 Then
- arg_msg = '退货单(包件明细)'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- // IF uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,&
- // outwaremx_mx[i].qty,ld_fprice,1,&
- // outwaremx_mx[i].mxdscrp,chc,arg_msg,0,0,outwaremx_mx[i].printid,0,'',0,outwaremx_mx[i].mxprintid,&
- // ls_uunit,ld_uqty,ld_rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN
- // arg_msg = '退货单(包件明细)行:'+String(i)+arg_msg
- // rslt = 0
- // GOTO ext
- // END IF
- Next
-
- If uo_out.Save(False,arg_msg) = 0 Then
- arg_msg = '退货单(包件明细),' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- rst_outwareid = uo_out.outwareid
-
- //2.原事务审核出仓单
- If uo_out.getinfo(scid,rst_outwareid,arg_msg) = 0 Then
- arg_msg = '退货单(包件明细),' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_out.auditing(False,arg_msg) = 0 Then
- arg_msg = '退货单(包件明细),' + arg_msg
- rslt = 0
- Goto ext
- End If
- Next
-
- If uo_in.newbegin(scid,23,arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),' + arg_msg
- rslt = 0
- Goto ext
- End If
-
- uo_in.relid = outwareid
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.sptname = '银售退货单(退货明细)自动进仓'
- uo_in.storageid = storageid
-
- chc = 0
-
- For i = 1 To it_mxbt
- Select ifpackpro,ifunit,unit,rate_buy,unit_buy
- Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy
- From u_mtrldef
- Where mtrlid = :outwaremx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '退货单(退货明细)行'+String(i)+",查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- // IF li_ifpackpro = 1 THEN
- // f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice)
-
- 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 = '退货单(退货明细)行'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- // IF ld_ref_costamt > 0 THEN
- If outwaremx[i].qty <> 0 Then
- ld_fprice = Round(ld_ref_costamt/outwaremx[i].qty,uo_option_cost_dec)
- End If
- // END IF
-
- chc++
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx[i].qty
- ld_uprice = ld_fprice
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '退货单(退货明细)行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx[i].qty /ld_rate_buy
- ld_uprice = ld_fprice * ld_rate
- End If
-
- s_mx.printid = chc
- s_mx.mtrlid = outwaremx[i].mtrlid
- s_mx.mtrlcode = outwaremx[i].mtrlcode
- s_mx.plancode = outwaremx[i].plancode
- s_mx.status = outwaremx[i].status
- s_mx.uqty = ld_uqty
- s_mx.enprice = ld_uprice
- s_mx.rebate = 1
- s_mx.mxdscrp = outwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = outwaremx[i].woodcode
- s_mx.pcode = outwaremx[i].pcode
- s_mx.sptid = outwaremx[i].sptid
- s_mx.unit = ls_uunit
- s_mx.rate = ld_rate
- s_mx.qty = outwaremx[i].qty
- s_mx.relprintid = 0
- s_mx.checkqty = 0
- s_mx.result = ''
- s_mx.waredscrp = ''
- s_mx.relbillid = 0
- s_mx.relbillprintid = 0
- s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode
- s_mx.Location = outwaremx[i].Location
- s_mx.deliqty = ld_uqty
- s_mx.tax = 0
-
-
- If outwaremx[i].ifpackpro = 0 Then
- s_mx.ifvqty = 1
- s_mx.ifnotinout = 1
- Else
- s_mx.ifvqty = 0
- s_mx.ifnotinout = 0
- End If
-
- If uo_in.acceptmx(s_mx, arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
- // IF uo_in.acceptmx(chc,&
- // outwaremx[i].mtrlid,&
- // outwaremx[i].mtrlcode,&
- // outwaremx[i].plancode,&
- // outwaremx[i].status,&
- // ld_uqty,&
- // ld_uprice,&
- // 1,&
- // outwaremx[i].mxdscrp,&
- // arg_msg,&
- // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,&
- // outwaremx[i].qty,0,0,'','',0,0,&
- // outwaremx[i].mtrlcuscode,outwaremx[i].Location,&
- // ld_uqty,&
- // 0) = 0 THEN
- // arg_msg = '退货单(退货明细)行'+String(i)+','+arg_msg
- // rslt = 0
- // GOTO ext
- // END IF
- // END IF
- Next
-
- If uo_in.Save(False,arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- rst_inwareid = uo_in.inwareid
-
- //4.原事务审核进仓单
- If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),'+arg_msg
- rslt = 0
- Goto ext
- End If
- // END IF
-
- //原发货单明细取消分配出仓
- For i = 1 To it_mxbt
- //yyx20130130
- If billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 Then
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- If ll_row <= 0 Then
- ld_sumnotoutqty = 0
- Else
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- End If
-
- ld_outmxqty = Abs(outwaremx[i].qty)
-
- If ld_outmxqty > ld_sumnotoutqty Then
- arg_msg = '退货明细行:'+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_outmxqty Then
- ld_assign_outqty = ld_outmxqty
- If uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 Then
- arg_msg = '发货明细行:'+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 = '发货明细行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
- ld_outmxqty = ld_outmxqty - ds_out_assign.Object.notoutqty[j]
- End If
- Next
- End If
- End If
- //
- Next
- End If
- Long ll_printid_arr[],ll_mtrlwareid_arr[],ll_mtrlid_arr[]
- String ls_status_arr[],ls_woodcode_arr[],ls_pcode_arr[]
- Decimal ld_qty_arr[]
- Long ll_cnt = 1
- Long ll_printid
- Decimal ld_maxqty
- Long ll_mtrlid
- Int li_outtype
- String ls_pf_status[],ls_pf_woodcode[],ls_pf_pcode[]
- Int li_ifover[],li_dipztype[]
- Decimal ld_Sonscale[]
- Long ll_SonMtrlid[]
- Long it_mxt = 1
- String ls_status_find,ls_woodcode_find,ls_pcode_find
- String ls_status,ls_woodcode,ls_pcode
- Decimal ld_pfqty
- If uo_option_outware_saleout = 1 Then
- Declare cur_mx Cursor For
- Select u_outwaremx.relid, u_outwaremx.mtrlwareid, u_outwaremx.mtrlid,
- u_outwaremx.status, u_outwaremx.woodcode, u_outwaremx.pcode,
- u_outwaremx.qty
- From u_outwaremx Inner JOIN
- u_outware ON u_outwaremx.scid = u_outware.scid And
- u_outwaremx.outwareid = u_outware.outwareid
- Where u_outware.relid = :outwareid And
- u_outware.scid = :scid And
- u_outware.billtype = 21 Using commit_transaction;
-
- Open cur_mx;
- Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt],
- :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt];
- Do While commit_transaction.SQLCode = 0
- ll_cnt++
- Fetch cur_mx Into :ll_printid_arr[ll_cnt],:ll_mtrlwareid_arr[ll_cnt],:ll_mtrlid_arr[ll_cnt],
- :ls_status_arr[ll_cnt],:ls_woodcode_arr[ll_cnt],:ls_pcode_arr[ll_cnt],:ld_qty_arr[ll_cnt];
- Loop
- Close cur_mx;
- ll_cnt = ll_cnt - 1
-
- For ll_i = 1 To it_mxbt
- ld_maxqty = 0
- it_mxt = 1
- ll_printid = outwaremx[ll_i].printid
- ll_mtrlid = outwaremx[ll_i].mtrlid
- ls_status = outwaremx[ll_i].status
- ls_woodcode = outwaremx[ll_i].woodcode
- ls_pcode = outwaremx[ll_i].pcode
-
- Select outtype,ifpackpro Into :li_outtype,:li_ifpackpro
- From u_mtrldef
- Where mtrlid = :ll_mtrlid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询产品出仓类型失败'
- rslt = 0
- Goto ext
- End If
-
- // IF li_outtype = 0 or li_ifpackpro = 0 THEN
- If Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro = 1) Then
- For ll_j = 1 To ll_cnt
- If ll_mtrlwareid_arr[ll_j] = 0 Then Continue
-
- If ll_printid_arr[ll_j] = ll_printid Then
- ld_maxqty = ld_qty_arr[ll_j]
- Exit
- End If
- Next
-
- Update u_outwaremx
- Set qty = :ld_maxqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :ll_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新实发数失败'
- Goto ext
- End If
-
- Else
- Declare cur_pf Cursor For
- Select u_PrdPF.SonMtrlid,
- u_PrdPF.status,
- u_PrdPF.woodcode,
- u_PrdPF.pcode,
- u_PrdPF.ifover,
- u_prdpf.dipztype,
- u_prdpf.Sonscale
- From u_PrdPF,u_mtrl_pf
- Where ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid )
- And ( u_PrdPF.pfcode = u_mtrl_pf.pfcode )
- And ( u_PrdPF.mtrlid = :ll_mtrlid )
- And ( u_mtrl_pf.ifdi = 1 And :li_ifpackpro = 0
- Or u_mtrl_pf.ifdft = 1 And :li_ifpackpro = 1 );
-
- Open cur_pf;
-
- Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- Do While sqlca.SQLCode = 0
- it_mxt++
- Fetch cur_pf Into :ll_SonMtrlid[it_mxt],:ls_pf_status[it_mxt],
- :ls_pf_woodcode[it_mxt],:ls_pf_pcode[it_mxt],:li_ifover[it_mxt],
- :li_dipztype[it_mxt],:ld_Sonscale[it_mxt];
- Loop
-
- it_mxt = it_mxt - 1
- Close cur_pf;
-
- For ll_k = 1 To it_mxt
- If li_ifover[ll_k] = 1 Then
- Choose Case li_dipztype[ll_k]
- Case 0
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ''
- Case 1
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- Case 2
- ls_status_find = ''
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- Case 3
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ''
- Case 4
- ls_status_find = ''
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- Case 5
- ls_status_find = ls_status
- ls_woodcode_find = ''
- ls_pcode_find = ls_pcode
- Case 6
- ls_status_find = ls_status
- ls_woodcode_find = ls_woodcode
- ls_pcode_find = ls_pcode
- End Choose
- Else
- ls_status_find = ls_pf_status[ll_k]
- ls_woodcode_find = ls_pf_woodcode[ll_k]
- ls_pcode_find = ls_pf_pcode[ll_k]
- End If
-
- ls_status_find = Trim(ls_status_find)
- ls_woodcode_find = Trim(ls_woodcode_find)
- ls_pcode_find = Trim(ls_pcode_find)
-
- ld_pfqty = 0
- For ll_j = 1 To ll_cnt
- If ll_mtrlwareid_arr[ll_j] = 0 Then Continue
-
- If ll_printid_arr[ll_j] = ll_printid And &
- ll_mtrlid_arr[ll_j] = ll_SonMtrlid[ll_k] And &
- ls_status_arr[ll_j] = ls_status_find And &
- ls_woodcode_arr[ll_j] = ls_woodcode_find And &
- ls_pcode_arr[ll_j] = ls_pcode_find Then
- ld_pfqty = ld_pfqty + ld_qty_arr[ll_j] / ld_Sonscale[ll_k]
-
- End If
- Next
- If thflag = 0 Then
- If ld_pfqty > ld_maxqty Then ld_maxqty = ld_pfqty
- Else
- If ld_pfqty < ld_maxqty Then ld_maxqty = ld_pfqty
- End If
- Next
-
- Update u_outwaremx
- Set qty = :ld_maxqty
- Where outwareid = :outwareid
- And scid = :scid
- And printid = :ll_printid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新实发数失败'
- Goto ext
- End If
- End If
- outwaremx[ll_i].qty = ld_maxqty
- Next
-
- If uo_in.newbegin(scid,23,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_in.relid = outwareid
- uo_in.indate = outdate
- uo_in.inrep = outrep
- uo_in.part = outwarecode
- uo_in.dscrp = dscrp
- uo_in.sptname = '包件自动进仓'
- uo_in.storageid = storageid
-
- chc = 0
-
- For i = 1 To it_mxbt
- Select ifpackpro,ifunit,unit,rate_buy,unit_buy
- Into :li_ifpackpro,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy
- From u_mtrldef
- Where mtrlid = :outwaremx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- chc++
-
- f_get_planprice_mtrl(outwaremx[i].mtrlid,outwaremx[i].status,outwaremx[i].woodcode,outwaremx[i].pcode,ld_fprice)
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx[i].qty
- ld_uprice = ld_fprice
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx[i].qty /ld_rate_buy
- ld_uprice = ld_fprice * ld_rate
- End If
-
- If ld_uqty <> 0 Or outwaremx[i].qty <> 0 Then
- s_mx.printid = chc
- s_mx.mtrlid = outwaremx[i].mtrlid
- s_mx.mtrlcode = outwaremx[i].mtrlcode
- s_mx.plancode = outwaremx[i].plancode
- s_mx.status = outwaremx[i].status
- s_mx.uqty = ld_uqty
- s_mx.enprice = ld_uprice
- s_mx.rebate = 1
- s_mx.mxdscrp = outwaremx[i].mxdscrp
- s_mx.jgprice = 0
- s_mx.relid = 0
- s_mx.ifrel = 0
- s_mx.woodcode = outwaremx[i].woodcode
- s_mx.pcode = outwaremx[i].pcode
- s_mx.sptid = outwaremx[i].sptid
- s_mx.unit = ls_uunit
- s_mx.rate = ld_rate
- s_mx.qty = outwaremx[i].qty
- s_mx.relprintid = 0
- s_mx.checkqty = 0
- s_mx.result = ''
- s_mx.waredscrp = ''
- s_mx.relbillid = 0
- s_mx.relbillprintid = 0
- s_mx.mtrlcuscode = outwaremx[i].mtrlcuscode
- s_mx.Location = outwaremx[i].Location
- s_mx.deliqty = ld_uqty
- s_mx.tax = 0
-
-
- If outwaremx[i].ifpackpro = 0 Then
- s_mx.ifvqty = 1
- s_mx.ifnotinout = 1
- Else
- s_mx.ifvqty = 0
- s_mx.ifnotinout = 0
- End If
-
- If uo_in.acceptmx(s_mx, arg_msg) = 0 Then
- arg_msg = '退货单(退货明细),行:'+String(i)+','+arg_msg
- rslt = 0
- Goto ext
- End If
-
-
- // IF uo_in.acceptmx(chc,&
- // outwaremx[i].mtrlid,&
- // outwaremx[i].mtrlcode,&
- // outwaremx[i].plancode,&
- // outwaremx[i].status,&
- // ld_uqty,&
- // ld_uprice,&
- // 1,&
- // outwaremx[i].mxdscrp,&
- // arg_msg,&
- // 0,0,0,outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].sptid,ls_uunit,ld_rate,&
- // outwaremx[i].qty,0,0,'','',0,0,&
- // outwaremx[i].mtrlcuscode,outwaremx[i].Location,&
- // ld_uqty,&
- // 0) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- End If
- Next
-
- If uo_in.Save(False,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- rst_inwareid = uo_in.inwareid
-
- //4.原事务审核进仓单
- If uo_in.getinfo(scid,rst_inwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- If uo_in.auditing(False,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- If li_outtype_storage = 2 And mx_barcode_cnt > 0 Then
- If uof_p_barcode(1,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- 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_pro
- Destroy uo_task
- Destroy uo_in
- Destroy uo_out
- Destroy ds_out_assign
- Destroy uo_ma
- Return rslt
- end function
- public function integer c_auditing_th (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i,j
- Long ls_newid
- DateTime null_dt
- Long ll_inwareid_rel,ll_outwareid_rel
- String ls_inwarecode_rel,ls_outwarecode_rel
- String ls_outwarecode_arr[]
- Long mx_barcode_cnt
- Long ll_outwareid[]
- Long ll_itmx = 1,ll_i
- Int li_flag
- Decimal ld_assign_outqty,ld_sumnotoutqty,ld_sumnotoutqty_bill
- Long ll_row
- IF uo_option_outware_saleout = -1000 THEN
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- IF uo_option_inout_type = -1000 THEN
- rslt = 0
- arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
- GOTO ext
- END IF
- SetNull(null_dt)
- uo_saletask uo_task
- uo_task = Create uo_saletask
- uo_task.commit_transaction = commit_transaction
- uo_sqlpro uo_pro
- uo_pro = Create uo_sqlpro
- uo_pro.commit_transaction = commit_transaction
- uo_inware uo_in
- uo_outware uo_out
- uo_in = Create uo_inware
- uo_in.commit_transaction = sqlca
- uo_in.if_getid_ture = False
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
- 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
- ds_out_assign.DataObject = 'ds_outwaremx_assign'
- ds_out_assign.SetTransObject(commit_transaction)
- 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
- String ls_storagename
- Int li_outtype_storage,li_storagetype
- SELECT storagename,outtype,storagetype
- INTO :ls_storagename,:li_outtype_storage,:li_storagetype
- 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 secflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经过财务审核"
- GOTO ext
- END IF
- IF balcflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经日结,不能撤审"
- GOTO ext
- END IF
- String ls_owecode
- Int li_oweflag
- Long ll_owebillid
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM u_owegood
- WHERE scid = :scid
- And relid = :outwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其它原因导致查询是否存在相关欠货单操作失败'+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt > 1 THEN
- rslt = 0
- arg_msg = '不合理的欠货单数量(存在多张相关欠货单),请检查'
- GOTO ext
- ELSEIF cnt = 1 THEN
- SELECT billid,billcode ,flag
- INTO :ll_owebillid,:ls_owecode,:li_oweflag
- FROM u_owegood
- WHERE scid = :scid
- And relid = :outwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '因网络或其它原因导致查询\相关欠货单信息操作失败'+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF li_oweflag <> 0 THEN
- rslt = 0
- arg_msg = '相关欠货单:'+ls_owecode+' 已在进行或完成,不能撤审销售发货单,请检查'
- GOTO ext
- END IF
-
- DELETE FROM u_owegoodmx
- Where billid = :ll_owebillid;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除相关欠货单明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- DELETE FROM u_owegood
- WHERE billid = :ll_owebillid
- And flag = 0;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除相关欠货单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- UPDATE u_outware
- SET Auditingrep = '',
- Auditingdate = :null_dt,
- flag = 0
- WHERE u_outware.outwareid = :outwareid
- AND flag = 1
- And scid = :scid Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF li_outtype_storage <> 0 And uo_option_outware_saleout = 0 THEN
- //yyx20130130
- //仓库是用库存分配,(包件出仓或条码出仓),包件产品扣分配,包件在销售出仓单做
- FOR i = 1 To it_mxbt
- IF billtype = 1 And li_storagetype = 1 And li_outtype_storage > 0 And ( outwaremx[i].ifpackpro > 0 And outwaremx[i].ifpackpro <> 4 Or outwaremx[i].ifpackpro = 4 And (Pos(outwaremx[i].status,'+') > 0 Or Pos(outwaremx[i].status,'*') > 0)) And outwaremx[i].relid > 0 THEN
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- IF ll_row <= 0 THEN
- ld_sumnotoutqty = 0
- ELSE
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- END IF
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = Abs(outwaremx[i].qty)
-
-
- IF ld_sumnotoutqty > 0 And ld_sumnotoutqty_bill > 0 THEN
- 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
- NEXT
- //end_20130130
- SELECT count(*)
- INTO :cnt
- FROM u_inware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 23 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF cnt > 0 THEN
- SELECT inwareid,inwarecode
- INTO :ll_inwareid_rel,:ls_inwarecode_rel
- FROM u_inware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 23 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.c_auditing(False,arg_msg) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- DECLARE cur_mx CURSOR FOR
- SELECT outwareid,outwarecode
- FROM u_outware
- WHERE billtype = 21
- AND relid = :outwareid
- And scid = :scid Using commit_transaction;
-
- OPEN cur_mx;
- FETCH cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx];
- DO WHILE commit_transaction.SQLCode = 0
- ll_itmx++
- FETCH cur_mx Into :ll_outwareid[ll_itmx],:ls_outwarecode_arr[ll_itmx];
- LOOP
- ll_itmx = ll_itmx - 1
- CLOSE cur_mx;
-
- FOR ll_i = 1 To ll_itmx
- IF uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 THEN
- rslt = 0
- arg_msg = '查询相关出仓单失败,' + arg_msg
- GOTO ext
- END IF
-
- IF uo_out.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- arg_msg = '撤审相关出仓单失败,' + arg_msg
- GOTO ext
- END IF
-
- IF uo_out.del(scid,ll_outwareid[ll_i],0,arg_msg,False) = 0 THEN
- arg_msg = '相关出仓单:'+ls_outwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- IF uo_option_outware_saleout = 1 THEN
- SELECT count(*)
- INTO :cnt
- FROM u_inware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 23 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF cnt > 0 THEN
- SELECT inwareid,inwarecode
- INTO :ll_inwareid_rel,:ls_inwarecode_rel
- FROM u_inware
- WHERE scid = :scid
- AND relid = :outwareid
- And billtype = 23;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致查询相关包件进仓单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF uo_in.getinfo(scid,ll_inwareid_rel,arg_msg) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.c_auditing(False,arg_msg) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
- IF uo_in.del(scid,ll_inwareid_rel,arg_msg,False) = 0 THEN
- arg_msg = '相关进仓单:'+ls_inwarecode_rel+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- DECLARE cur_mx_rel CURSOR FOR
- SELECT outwareid
- FROM u_outware
- WHERE billtype = 21
- AND relid = :outwareid
- And scid = :scid Using commit_transaction;
-
- OPEN cur_mx_rel;
- FETCH cur_mx_rel Into :ll_outwareid[ll_itmx];
- DO WHILE commit_transaction.SQLCode = 0
- ll_itmx++
- FETCH cur_mx_rel Into :ll_outwareid[ll_itmx];
- LOOP
- ll_itmx = ll_itmx - 1
- CLOSE cur_mx_rel;
-
- FOR ll_i = 1 To ll_itmx
- IF uo_out.getinfo(scid,ll_outwareid[ll_i],arg_msg) = 0 THEN
- rslt = 0
- arg_msg = '查询相关出仓单失败,' + arg_msg
- GOTO ext
- END IF
-
- IF uo_out.c_auditing(False,arg_msg) = 0 THEN
- rslt = 0
- arg_msg = '撤审相关出仓单失败,' + arg_msg
- GOTO ext
- END IF
- NEXT
- END IF
- FOR i = 1 To it_mxbt
- //更新分配
- IF billtype = 1 And li_storagetype = 1 And li_outtype_storage = 0 And outwaremx[i].relid > 0 THEN
- ll_row = ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,outwaremx[i].relid,outwaremx[i].relprintid)
- ds_out_assign.AcceptText()
-
- IF ll_row <= 0 THEN
- ld_sumnotoutqty = 0
- ELSE
- ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
- END IF
-
- ld_sumnotoutqty_bill = 0
- ld_sumnotoutqty_bill = outwaremx[i].qty
-
- IF ld_sumnotoutqty_bill > ld_sumnotoutqty THEN
- arg_msg = '发货明细行:'+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 = '发货明细行:'+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 = '发货明细行:'+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
-
- 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
- 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,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 = '行:'+String(i)+','+arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- IF uo_task.addmxcmpl(scid,outwaremx[i].relid,outwaremx[i].relprintid, 0 - outwaremx[i].qty,arg_msg,False) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
-
- If (billtype = 1 Or billtype = 5) And outwaremx[i].relid > 0 THEN
- SELECT status INTO :li_flag
- FROM u_saletask
- WHERE scid = :scid
- And taskid = :outwaremx[i].relid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询相关订单状态失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
-
- IF li_flag = 1 Or li_flag = 5 THEN
-
- IF uo_task.trycmplsaletask(scid,outwaremx[i].relid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
-
- IF li_outtype_storage = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
- NEXT
- IF li_outtype_storage = 2 And mx_barcode_cnt > 0 THEN
- IF uof_p_barcode(0,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- 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_task
- Destroy uo_in
- Destroy uo_out
- Destroy uo_pro
- Destroy ds_out_assign
- Destroy uo_ma
- RETURN rslt
- end function
- public function integer uof_check_pt (ref string arg_msg);Int rslt = 1
- Long ll_ucrow,cnt
- Long ll_i,ll_j,ll_k,ll_l
- Boolean lb_f = False,lb_f2 = False
- Long ll_mtrlid_child
- Long ll_printid_child
- Decimal ld_planqty_child,ld_qty_child
- Long ll_taskid,ll_printid_task
- Int li_outtype,li_ifpackpro
- Decimal ld_planqty_mx_sum
- Decimal ld_Sonscale[],ld_Sonscale_fm[]
- Long ll_SonMtrlid[]
- Long it_mxt = 1
- Decimal ld_rqty_mx
- s_mtrlcfg_expr s_pz[]
- String ls_status_child,ls_woodcode_child,ls_pcode_child
- String ls_status[],ls_woodcode[],ls_pcode[]
- //检查包件明细to包货明细
- FOR ll_j = 1 To it_mxbt_mx
- lb_f2 = False
-
- FOR ll_i = 1 To it_mxbt
- IF outwaremx_mx[ll_j].printid = outwaremx[ll_i].printid THEN
- lb_f2 = True
- END IF
- NEXT
-
- IF Not lb_f2 THEN
- arg_msg = '包件明细行:'+String(outwaremx_mx[ll_j].mxprintid)+',相关发货明细行:'+String(outwaremx_mx[ll_j].printid)+',没有配套发货明细行,请检查'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- //检查发货明细to包件明细
- FOR ll_i = 1 To it_mxbt
- ll_mtrlid_child = outwaremx[ll_i].mtrlid
- ll_printid_child = outwaremx[ll_i].printid
- ld_planqty_child = outwaremx[ll_i].qty
- ls_status_child = outwaremx[ll_i].status
- ls_woodcode_child = outwaremx[ll_i].woodcode
- ls_pcode_child = outwaremx[ll_i].pcode
- ll_taskid = outwaremx[ll_i].relid
- ll_printid_task = outwaremx[ll_i].relprintid
-
- SELECT outtype,ifpackpro
- INTO :li_outtype,:li_ifpackpro
- FROM u_mtrldef
- WHERE mtrlid = :ll_mtrlid_child
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',查询产品出仓类型及包件产品属性失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF Not ((li_outtype = 1 Or li_outtype = 2) And li_ifpackpro > 0) THEN
- ld_planqty_mx_sum = 0
- lb_f = False
- FOR ll_j = 1 To it_mxbt_mx
- IF outwaremx_mx[ll_j].printid = ll_printid_child THEN
- ld_planqty_mx_sum += outwaremx_mx[ll_j].qty
- lb_f = True
- END IF
- NEXT
-
- IF Not lb_f THEN
- arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',没有配套包件明细行,请检查,可能包件库存不足'
- rslt = 0
- GOTO ext
- END IF
-
- IF ld_planqty_child <> ld_planqty_mx_sum THEN
- arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',与包件明细行配套数量不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF li_ifpackpro = 1 Or li_ifpackpro = 2 THEN
- it_mxt = 1
-
- cnt = 0
- //查是否有换清单
- IF li_ifpackpro = 2 And ll_taskid > 0 THEN
- SELECT count(*) INTO :cnt FROM u_saletaskmx_pf
- WHERE scid = :scid
- AND taskid = :ll_taskid
- And printid = :ll_printid_task;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = '查询发货明细:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',对应订单明细否有换包件失败,'+sqlca.SQLErrText
- RETURN 0
- END IF
- END IF
-
- IF cnt > 0 THEN
- DECLARE cur_pf_saletaskmx CURSOR FOR
- SELECT u_saletaskmx_pf.SonMtrlid,
- u_saletaskmx_pf.Sonscale,
- u_saletaskmx_pf.Sonscale_fm
- FROM u_saletaskmx_pf
- WHERE ( u_saletaskmx_pf.scid = :scid )
- AND ( u_saletaskmx_pf.taskid = :ll_taskid )
- And ( u_saletaskmx_pf.printid = :ll_printid_task );
- OPEN cur_pf_saletaskmx;
-
- FETCH cur_pf_saletaskmx Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- DO WHILE sqlca.SQLCode = 0
- it_mxt++
- FETCH cur_pf_saletaskmx Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- LOOP
- it_mxt = it_mxt - 1
- CLOSE cur_pf_saletaskmx;
- ELSE
- DECLARE cur_pf CURSOR FOR
- SELECT u_PrdPF.SonMtrlid,
- u_prdpf.Sonscale,
- 1
- FROM u_PrdPF,u_mtrl_pf,u_mtrldef
- WHERE ( u_PrdPF.mtrlid = u_mtrl_pf.mtrlid )
- AND ( u_PrdPF.pfcode = u_mtrl_pf.pfcode )
- AND ( u_PrdPF.SonMtrlid = u_mtrldef.mtrlid )
- AND ( u_PrdPF.mtrlid = :ll_mtrlid_child )
- AND ( u_mtrl_pf.ifdi = 1 AND :li_ifpackpro = 0
- OR u_mtrl_pf.ifdft = 1 AND (:li_ifpackpro = 1 OR :li_ifpackpro = 2) AND u_mtrldef.ifpack > 0)
- Order By u_PrdPF.printid;
-
- OPEN cur_pf;
-
- FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- DO WHILE sqlca.SQLCode = 0
- it_mxt++
- FETCH cur_pf Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- LOOP
- it_mxt = it_mxt - 1
- CLOSE cur_pf;
- END IF
- ELSEIF li_ifpackpro = 5 THEN
- DECLARE cur_pf5 CURSOR FOR
- SELECT u_PrdPF.SonMtrlid,
- u_prdpf.Sonscale,
- 1
- FROM u_PrdPF,u_mtrldef
- WHERE ( u_PrdPF.pfcode = :ls_status_child )
- AND ( u_PrdPF.SonMtrlid = u_mtrldef.mtrlid )
- AND ( u_PrdPF.mtrlid = :ll_mtrlid_child )
- AND ( u_mtrldef.ifpack > 0)
- Order By u_PrdPF.printid;
-
- OPEN cur_pf5;
-
- FETCH cur_pf5 Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- DO WHILE sqlca.SQLCode = 0
- it_mxt++
- FETCH cur_pf5 Into :ll_SonMtrlid[it_mxt],:ld_Sonscale[it_mxt],:ld_Sonscale_fm[it_mxt];
- LOOP
- it_mxt = it_mxt - 1
- CLOSE cur_pf5;
- ELSEIF li_ifpackpro = 3 Or li_ifpackpro = 4 THEN
- f_checkpz(ls_status_child,s_pz[])
- it_mxt = UpperBound(s_pz)
-
- FOR ll_l = 1 To it_mxt
- ll_SonMtrlid[ll_l] = ll_mtrlid_child
- ld_Sonscale[ll_l] = Dec(s_pz[ll_l].qty)
- ld_Sonscale_fm[ll_l] = 1
- ls_status[ll_l] = s_pz[ll_l].cfgname
- ls_woodcode[ll_l] = ls_woodcode_child
- ls_pcode[ll_l] = ls_pcode_child
- NEXT
- END IF
-
- FOR ll_k = 1 To it_mxt
- ld_planqty_mx_sum = 0
- lb_f = False
-
- ld_rqty_mx = ld_planqty_child * ld_Sonscale[ll_k]/ld_Sonscale_fm[ll_k]
-
- IF li_ifpackpro = 1 Or li_ifpackpro = 2 THEN
- FOR ll_j = 1 To it_mxbt_mx
- IF outwaremx_mx[ll_j].printid = ll_printid_child And &
- outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] THEN
- ld_planqty_mx_sum += outwaremx_mx[ll_j].qty
- lb_f = True
- END IF
- NEXT
- ELSE
- FOR ll_j = 1 To it_mxbt_mx
- IF outwaremx_mx[ll_j].printid = ll_printid_child And &
- outwaremx_mx[ll_j].mtrlid = ll_SonMtrlid[ll_k] And &
- outwaremx_mx[ll_j].status = ls_status[ll_k] And &
- outwaremx_mx[ll_j].woodcode = ls_woodcode[ll_k] And &
- outwaremx_mx[ll_j].pcode = ls_pcode[ll_k] THEN
- ld_planqty_mx_sum += outwaremx_mx[ll_j].qty
- lb_f = True
- END IF
- NEXT
- END IF
-
- IF Not lb_f THEN
- arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',没有配套包件明细行,请检查,可能包件库存不足'
- rslt = 0
- GOTO ext
- END IF
-
- IF ld_rqty_mx <> ld_planqty_mx_sum THEN
- arg_msg = '发货明细行:'+String(ll_i)+',编码:'+outwaremx[ll_i].mtrlcode+',与包件明细行配套数量不相符,请检查'
- rslt = 0
- GOTO ext
- END IF
- NEXT
- END IF
- NEXT
- ext:
- RETURN rslt
- end function
- public function integer priceaudit (long arg_scid, long arg_outwareid, boolean arg_ifcommit, ref string arg_msg, string arg_emp);Long rslt = 1,i
- uo_cusprice uo_price
- If uo_option_outware_saleout = -1000 Then
- rslt = 0
- arg_msg = '选项:[147]使用销售出仓单,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If uo_option_checkprice_native = -1000 Then
- rslt = 0
- arg_msg = '选项:[056]销售价按本位币限价,读取初始默认值失败,操作取消!'
- Goto ext
- End If
- If arg_scid < 0 Then
- rslt = 0
- arg_msg = "错误的分部ID"
- 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 priceflag = 1 Then
- rslt = 0
- arg_msg = "单据已经确认"
- Goto ext
- End If
- //yyx20150529调整顺序
- Update u_outware
- Set priceemp = :arg_emp,
- pricedate = getdate(),
- priceflag = 1
- Where u_outware.outwareid = :arg_outwareid
- And priceflag = 0
- And scid = :arg_scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- ElseIf commit_transaction.SQLNRows = 0 Then
- rslt = 0
- arg_msg = "单据正在确认,请稍后查询。"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
- uo_price = Create uo_cusprice
- For i = 1 To it_mxbt
- If outwaremx[i].outtype <> '' Then Continue
-
- If uo_option_checkprice_native = 1 Then
- If uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,&
- outwaremx[i].woodcode,relint_2,outwaremx[i].price,outwaremx[i].uqty,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Else
- If uo_price.uof_check_price (cusid,outwaremx[i].mtrlid,&
- outwaremx[i].mtrlcode,outwaremx[i].status,outwaremx[i].pcode,&
- outwaremx[i].woodcode,relint_2,outwaremx[i].enprice * outwaremx[i].rebate,outwaremx[i].uqty,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- Next
- If uo_option_outware_saleout > 0 Then
- //更新库存已开单数(减)
- If uof_noauditingqty_del(arg_scid,arg_outwareid,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- End If
- If uo_option_outware_saleout = 1 Then
- Int li_ifpack,li_ifunit,li_ifpackpro
- Int li_ifpackcnt,li_ifpackprocnt
- Decimal ld_rate,ld_uqty,ld_rate_buy
- Decimal ld_fprice,ld_uprice
- String ls_uunit,ls_unit_buy,ls_unit
- Long chc,ll_j,ll_i
- Long ll_storageid_arr[],cnt = 0
- li_ifpackcnt = 0
-
- uo_outware uo_out
-
- uo_out = Create uo_outware
- uo_out.commit_transaction = sqlca
- uo_out.if_getid_ture = False
-
- For ll_i = 1 To it_mxbt_mx
- If ll_i = 1 Then
- cnt++
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- Goto _next
- End If
-
- For ll_j = 1 To cnt
- If ll_storageid_arr[ll_j] = outwaremx_mx[ll_i].storageid Then
- Goto _next
- End If
- Next
-
- cnt++
- ll_storageid_arr[cnt] = outwaremx_mx[ll_i].storageid
- _next:
- Next
-
- For ll_i = 1 To cnt
- If uo_out.newbegin(scid,21,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
-
- uo_out.relid = outwareid
- uo_out.outdate = outdate
- uo_out.outrep = outrep
- uo_out.part = outwarecode
- uo_out.dscrp = dscrp
- uo_out.cusname = '包件明细自动出仓'
- uo_out.storageid = ll_storageid_arr[ll_i]
-
- chc = 0
-
- For i = 1 To it_mxbt_mx
- If outwaremx_mx[i].storageid <> ll_storageid_arr[ll_i] Then Continue
- Select ifpack,ifunit,unit,rate_buy,unit_buy,planprice
- Into :li_ifpack,:li_ifunit,:ls_unit,:ld_rate_buy,:ls_unit_buy,:ld_fprice
- From u_mtrldef
- Where mtrlid = :outwaremx_mx[i].mtrlid;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "因网络或其它原因导致查询应发明细操作失败"+"~n"+commit_transaction.SQLErrText
- Goto ext
- End If
-
- chc++
-
- If li_ifunit = 0 Then
- ls_uunit = ls_unit
- ld_rate = 1
- ld_uqty = outwaremx_mx[i].qty
- Else
- If ld_rate_buy = 0 Then
- arg_msg = '明细行:'+String(i)+',资料设为双数量核算,但没有设置默认转换率,请检查'
- rslt = 0
- Goto ext
- End If
- ls_uunit = ls_unit_buy
- ld_rate = ld_rate_buy
- ld_uqty = outwaremx_mx[i].qty /ld_rate_buy
- End If
-
- If uo_out.acceptmx(outwaremx_mx[i].mtrlwareid,&
- outwaremx_mx[i].qty,ld_fprice,1,&
- outwaremx_mx[i].mxdscrp,chc,arg_msg,0,outwaremx_mx[i].printid,0,0,'',outwaremx_mx[i].planqty,outwaremx_mx[i].mxprintid,&
- ls_uunit,ld_uqty,ld_rate,'','',0,0,'',0,0,0,0,'','') = 0 Then
- rslt = 0
- Goto ext
- End If
- Next
-
- If uo_out.Save(False,arg_msg) = 0 Then
- rslt = 0
- Goto ext
- End If
- Next
- End If
- priceflag = 1
- //将相关虚拟库存数设为无效
- For i = 1 To it_mxbt
- Update u_mtrlware_view
- Set inuse = 0
- Where cusid = :cusid
- And mtrlwareid = :outwaremx[i].mtrlwareid
- And inuse = 1 Using commit_transaction;
- 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_mtrlware_view
- Set inuse = 0
- Where cusid = :cusid
- And mtrlwareid = :outwaremx_mx[i].mtrlwareid
- And inuse = 1 Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '更新相关包件明细虚拟库存为无效失败'+'~n'+commit_transaction.SQLErrText
- Goto ext
- 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
- Destroy uo_price
- Destroy uo_out
- Return rslt
- end function
- on uo_outware_sale.create
- call super::create
- end on
- on uo_outware_sale.destroy
- call super::destroy
- end on
- event constructor;call super::constructor;String str_optionvalue,arg_msg
- f_get_sys_option_value('045',str_optionvalue,arg_msg)
- uo_option_m_msttake = Long(str_optionvalue)
- f_get_sys_option_value('052',str_optionvalue,arg_msg)
- uo_option_otheramt_msttake = Long(str_optionvalue)
- f_get_sys_option_value('050',str_optionvalue,arg_msg)
- uo_option_change_otheramt = trim(str_optionvalue)
- f_get_sys_option_value('188',str_optionvalue,arg_msg)
- uo_option_outware_sale_ifmating = Long(str_optionvalue)
- f_get_sys_option_value('332',str_optionvalue,arg_msg)
- uo_option_secaudit_notupdate_hisprice = Long(str_optionvalue)
- end event
|