1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483 |
- $PBExportHeader$uo_outware.sru
- forward
- global type uo_outware from nonvisualobject
- end type
- end forward
- global type uo_outware from nonvisualobject
- end type
- global uo_outware uo_outware
- type variables
- PUBLIC PROTECTEDWRITE Long scid = 0 //分部id
- PUBLIC PROTECTEDWRITE Long outwareid //出仓单表自动增量id
- PUBLIC PROTECTEDWRITE String outwarecode //单据的唯一编号
- PUBLIC PROTECTEDWRITE Int billtype = 0 //业务类型
- PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
- PUBLIC PROTECTEDWRITE String opemp //建立操作员
- PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动
- PUBLIC PROTECTEDWRITE String modemp //修改操作员
- PUBLIC PROTECTEDWRITE Int balcflag = 0 //仓库结存标志
- PUBLIC PROTECTEDWRITE Int flag = 0 //仓库审核标志
- PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间
- PUBLIC PROTECTEDWRITE String auditingrep //审核操作员
- PUBLIC PROTECTEDWRITE Int secflag = 0 //财务审核标志
- PUBLIC PROTECTEDWRITE DateTime secauditingdate //二审核时间
- PUBLIC PROTECTEDWRITE String secauditingrep //二审核操作员
- PUBLIC PROTECTEDWRITE Decimal sum_amt = 0 //单据总金额(本位币)
- PUBLIC PROTECTEDWRITE Decimal sum_amt_en = 0 //单据总金额(原币)
- PUBLIC PROTECTEDWRITE Decimal sum_enamt = 0 //单据总金额(原币)
- PUBLIC PROTECTEDWRITE Decimal sum_enamt_tax = 0 //税金(原币)
- PUBLIC PROTECTEDWRITE Decimal sum_bsamt = 0 //单据总金额(本位币)
- PUBLIC PROTECTEDWRITE Decimal sum_bsamt_tax = 0 //税金(本位币)
- PUBLIC PROTECTEDWRITE Int priceflag = 0 //确认标志
- PUBLIC PROTECTEDWRITE DateTime pricedate //确认时间
- PUBLIC PROTECTEDWRITE String priceemp //确认操作员
- PUBLIC PROTECTEDWRITE Int secpflag = 0 //确认标志
- PUBLIC PROTECTEDWRITE DateTime secpdate //确认时间
- PUBLIC PROTECTEDWRITE String secpemp //确认操作员
- //仓库信息
- PUBLIC PROTECTEDWRITE int if_cus_mtrlware
- Long relid = 0 //关联id
- Long storageid = 0 //出仓仓库
- DateTime outdate //出仓发生时间
- String outrep = '' //经手人
- String part = '' //相关号码
- String dscrp = '' //备注
- String dscrp2 = '' //备注
- String dscrp3 = '' //备注
- Long cusid = 0 //客户id
- String cusname = '' //客户名称(不记帐模式使用)
- Int thflag = 0 //退货标记
- string billname
- String relstr_1
- String relstr_2
- String relstr_3
- long relint_1
- long relint_2
- long relint_3
- decimal otheramt=0
- decimal deposit=0
- decimal mrate
- string rel_address
- string rel_tele
- string rel_tele1
- string rel_fax
- string rel_rep
- dec totalamt = 0
- dec getamt = 0
- int lsflag = 0
- string transcode
- string carcode
- string paytype
- int typeid
- Long staticid
- datetime viewdate //预收款时间
- Int cwauditingflag = 0 //总账审核标记
- DateTime cwauditingdate //总账审核时间
- String cwauditingrep //总账审核操作员
- Boolean sysautobuild = FALSE //自动操作标记
- Boolean if_getid_ture = TRUE
- Transaction commit_transaction //数据commit事务
- s_outwaremx outwaremx[] //明细结构数组
- Long it_mxbt = 0 //明细结构数组末指针
- Boolean it_newbegin = FALSE //新建标志
- Boolean it_updatebegin = FALSE //修改标志
- end variables
- forward prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg)
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg)
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
- public function integer p_clearmx ()
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
- public function integer p_reset ()
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_relprintid, long arg_relid2, long arg_olmtrlid, long arg_packqty, integer arg_outtype, string arg_unit, decimal arg_rate, string arg_mtrlcuscode, string arg_formula)
- public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg)
- public function integer uf_chk_updatecost (ref string arg_msg)
- public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg)
- public function integer auditing_chk (ref string arg_msg)
- public function integer auditing_end (ref string arg_msg)
- public function integer c_auditing_chk (ref string arg_msg)
- public function integer c_auditing_end (ref string arg_msg)
- public function integer save_end (ref string arg_msg)
- public function integer save_chk (ref string arg_msg)
- public subroutine uf_get_billname (integer arg_billtype)
- public function integer uf_w_cmp_fifo_cb_bill (long ll_scid, long ll_mtrlwareid, boolean arg_ifcommit, ref string arg_msg)
- public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
- public function integer p_update_cost (ref s_outwaremx arg_s_mx, ref decimal arg_ref_costamt, ref decimal arg_ref_costamt_notax, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_update_cost_fifo (ref s_outwaremx arg_s_mx, ref decimal arg_ref_costamt, ref decimal arg_ref_costamt_notax, ref string arg_msg, boolean arg_ifcommit)
- public function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_addqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, ref string arg_msg, decimal arg_costamt_notax)
- end prototypes
- public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);//====================================================================
- // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
- //--------------------------------------------------------------------
- // Description: 从置对象,设定业务类型,准备建立新出仓单
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_scid
- // value integer arg_billtype
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Int rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF Not(arg_billtype = 1 Or arg_billtype = 2 Or arg_billtype = 3 Or arg_billtype = 4 Or arg_billtype = 8 Or arg_billtype = 9 Or arg_billtype = 10 Or arg_billtype = 12 Or arg_billtype = 15) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'1-销售[记帐模式],'
- arg_msg = arg_msg+'2-销售[不记帐模式],'
- arg_msg = arg_msg+'3-领料出仓,'
- arg_msg = arg_msg+'4-外协发出仓,'
- arg_msg = arg_msg+'8-其他出仓,'
- arg_msg = arg_msg+'9-盘亏出仓,'
- arg_msg = arg_msg+'10-工具出仓,'
- arg_msg = arg_msg+'12-调拨出仓'
- arg_msg = arg_msg+'15-拆装出仓'
- GOTO ext
- END IF
- uf_get_billname(arg_billtype)
- //CHOOSE CASE arg_billtype
- // CASE 1
- // billname = '销售单'
- // CASE 2
- // billname = '销售单'
- // CASE 3
- // billname = '领料出仓单'
- // CASE 4
- // billname = '外协发出仓'
- // CASE 8
- // billname = '其他进仓单'
- // CASE 9
- // billname = '盘亏出仓单'
- // CASE 10 //人事
- // billname = '工具出仓单'
- // CASE 12
- // billname = '调拨出仓单'
- // CASE 15
- // billname = '拆装出仓单'
- //END CHOOSE
- p_reset()
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = True
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
- DateTime server_dt
- Long ls_newid
- String ls_sccode,ls_typebillcode
- Long ll_typeid
- String ls_outwarecode
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- IF IsNull(relid) THEN relid = 0
- IF IsNull(storageid) THEN storageid = 0
- IF IsNull(outrep) THEN outrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(dscrp2) THEN dscrp2 = ''
- IF IsNull(dscrp3) THEN dscrp3 = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(cusid) THEN cusid = 0
- IF IsNull(cusname) THEN cusname = ''
- IF IsNull(thflag) THEN thflag = 0
- IF IsNull(otheramt) THEN otheramt = 0
- IF IsNull(deposit) THEN deposit = 0
- IF IsNull(relstr_1) THEN relstr_1 = ''
- IF IsNull(relstr_2) THEN relstr_2 = ''
- IF IsNull(relstr_3) THEN relstr_3 = ''
- IF IsNull(relint_1) THEN relint_1 = 0
- IF IsNull(relint_2) THEN relint_2 = 0
- IF IsNull(relint_3) THEN relint_3 = 0
- IF IsNull(mrate) THEN mrate = 0
- IF IsNull(rel_address) THEN rel_address = ''
- IF IsNull(rel_tele) THEN rel_tele = ''
- IF IsNull(rel_tele1) THEN rel_tele1 = ''
- IF IsNull(rel_fax) THEN rel_fax = ''
- IF IsNull(rel_rep) THEN rel_rep = ''
- IF IsNull(totalamt) THEN totalamt = 0
- IF IsNull(getamt) THEN getamt = 0
- IF IsNull(lsflag) THEN lsflag = 0
- IF IsNull(transcode) THEN transcode = ''
- IF IsNull(carcode) THEN carcode = ''
- IF IsNull(paytype) THEN paytype = ''
- IF IsNull(typeid) THEN typeid = 0
- //查找出仓原因,记录staticid
- IF billtype = 8 then
- select staticid into :staticid
- from u_static
- where reason = :cusname
- and inoutflag = 0;
- IF ISNULL(staticid) THEN staticid = 0
- END IF
- IF billtype = 1 THEN //and thflag = 0
- IF sys_option_outware_type = 1 THEN
- IF typeid = 0 THEN
- arg_msg = '请先选择订单分类'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT billcode INTO :ls_typebillcode
- FROM u_outwaretype
- Where typeid = :typeid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询销售发货单分类属性失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF ls_typebillcode = '' THEN
- arg_msg = '销售发货单分类未设置对应单据抬头,请检查'
- rslt = 0
- GOTO ext
- END IF
- ELSE
- typeid = 0
- END IF
- END IF
- // //未注册限制
- //IF sys_if_register = 0 THEN
- // Long ll_bill_count
- // SELECT count(*)
- // INTO :ll_bill_count
- // From u_outware;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "查询操作失败,单据数量 "
- // GOTO ext
- // END IF
- //
- // IF ll_bill_count > 100 THEN
- // rslt = 0
- // arg_msg = "未注册版本,出仓单只能保存100张! "
- // GOTO ext
- // END IF
- //END IF
- //
- //
- SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- //
- //IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- // rslt = 0
- // arg_msg = "没有正确出仓内容"
- // GOTO ext
- //END IF
- //
- //cnt = 0
- ////检查仓库
- //SELECT balctype INTO :if_cus_mtrlware
- // FROM u_storage
- // Where storageid = :storageid Using commit_transaction;
- //IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询仓库是否使用客户库存失败'
- // rslt = 0
- // GOTO ext
- //END IF
- //
- //IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
- // rslt = 0
- // arg_msg = "缺少出仓发生时间或不合理"
- // GOTO ext
- //END IF
- //
- ////====================================================================
- //// Script - save ( boolean arg_ifcommit, ref string arg_msg )
- //// Reason:
- ////--------------------------------------------------------------------
- //// Modified By: yyx Date: 2004.01.02
- ////--------------------------------------------------------------------
- //IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(outdate,'yyyy-mm-dd'))) > sys_option_input_days THEN
- // rslt = 0
- // arg_msg = '出仓日期错误,日期不能超前系统日期'
- // GOTO ext
- //END IF
- //
- //IF DaysAfter(Date(String(outdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN
- // rslt = 0
- // arg_msg = '出仓日期错误,日期不能落后系统日期'
- // GOTO ext
- //END IF
- //
- //IF f_check_inoutdate(storageid,outdate,True,arg_msg) = 0 THEN
- // rslt = 0
- // GOTO ext
- //END IF
- ////====================================================================
- //
- //IF billtype = 1 THEN
- // SELECT name INTO :cusname
- // FROM u_cust
- // Where cusid = :cusid Using commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "查询操作失败,客户资料"
- // GOTO ext
- // END IF
- //
- // IF relint_1 = 0 THEN
- // arg_msg = '请选择结算方式'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // cnt = 0
- // SELECT count(*) INTO :cnt
- // FROM cw_currency
- // Where moneyid = :relint_2;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询币种失败'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF cnt = 0 THEN
- // arg_msg = '币种资料不存在'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF mrate = 0 THEN
- // arg_msg = '币种汇率错误'
- // rslt = 0
- // GOTO ext
- // END IF
- //ELSEIF billtype = 3 THEN
- // IF relid = 0 THEN
- // arg_msg = '请选择领料工作中心'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- //ELSEIF billtype = 4 THEN
- // SELECT name INTO :cusname
- // FROM u_spt
- // Where sptid = :cusid Using commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "查询操作失败,加工商资料"
- // GOTO ext
- // END IF
- //ELSEIF billtype = 8 THEN
- // IF Trim(cusname) = '' Or IsNull(cusname) THEN
- // rslt = 0
- // arg_msg = "请输入出仓原因!"
- // GOTO ext
- // END IF
- //ELSEIF billtype = 9 THEN
- // IF Trim(cusname) = '' Or IsNull(cusname) THEN
- // cusname = "盘亏"
- // END IF
- //END IF
- IF save_chk(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF outwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_outware","outwareid",arg_msg,if_getid_ture,commit_transaction)
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取分部代号
- IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- //取得新单据编号
- CHOOSE CASE billtype
- CASE 1,2
- IF thflag = 0 THEN
- IF sys_option_outware_type = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'XS',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid_outware(scid,ls_sccode + ls_typebillcode,Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- ELSE
-
- IF sys_option_outware_type = 0 THEN
- outwarecode = getid(scid,ls_sccode + 'XT',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- outwarecode = getid_outware(scid,ls_sccode + ls_typebillcode,Date(server_dt),if_getid_ture,commit_transaction)
- END IF
-
- END IF
- CASE 3
- outwarecode = getid(scid,ls_sccode + 'LL',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 4
- outwarecode = getid(scid,ls_sccode + 'KL',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 8
- outwarecode = getid(scid,ls_sccode + 'CC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 9
- outwarecode = getid(scid,ls_sccode + 'PQ',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 10
- outwarecode = getid(scid,ls_sccode + 'KF',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 12
- outwarecode = getid(scid,ls_sccode + 'OC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 15
- outwarecode = getid(scid,ls_sccode + 'DI',Date(server_dt),if_getid_ture,commit_transaction)
- END CHOOSE
-
- IF outwarecode = "err" THEN
- outwarecode = ''
- rslt = 0
- arg_msg = "无法获取出仓单编号"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
-
- INSERT INTO u_outware (
- scid,
- outwareid,
- outwarecode,
- billtype,
- relid,
- storageid,
- outdate,
- outrep,
- part,
- dscrp,
- dscrp2,
- dscrp3,
- cusid,
- cusname,
- thflag,
- opdate,
- opemp,
- relstr_1,
- relstr_2,
- relstr_3,
- relint_1,
- relint_2,
- relint_3,
- otheramt,
- rel_address,
- rel_tele,
- rel_tele1,
- rel_fax,
- rel_rep,
- mrate,
- totalamt,
- getamt,
- lsflag,
- deposit,
- transcode,
- carcode,
- paytype,
- typeid,
- staticid,
- viewdate)
- VALUES (
- :scid,
- :ls_newid,
- :outwarecode,
- :billtype,
- :relid,
- :storageid,
- :outdate,
- :outrep,
- :part,
- :dscrp,
- :dscrp2,
- :dscrp3,
- :cusid,
- :cusname,
- :thflag,
- :server_dt,
- :publ_operator,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :relint_1,
- :relint_2,
- :relint_3,
- :otheramt,
- :rel_address,
- :rel_tele,
- :rel_tele1,
- :rel_fax,
- :rel_rep,
- :mrate,
- :totalamt,
- :getamt,
- :lsflag,
- :deposit,
- :transcode,
- :carcode,
- :paytype,
- :typeid,
- :staticid,
- :viewdate) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '插入单据资料失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新outwareid
- outwareid = ls_newid
- ELSE //////////////////////////////////////////////// //更新
- IF billtype = 1 And sys_option_autowaste = 1 THEN
- uo_outware_waste uo_waste
- uo_waste = Create uo_outware_waste
- uo_waste.commit_transaction = commit_transaction
- IF uo_waste.insertwaste(1,scid,outwareid,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- Destroy uo_waste
- END IF
-
- // SELECT typeid,outwarecode INTO :ll_typeid,:ls_outwarecode
- // FROM u_outware
- // WHERE outwareid = :outwareid
- // And scid = :scid Using commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询销售发货单分类属性失败,'+commit_transaction.SQLErrText
- // rslt = 0
- // GOTO ext
- // END IF
-
- // IF sys_option_outware_type = 1 THEN
- // IF ll_typeid <> typeid THEN
- // SELECT billcode INTO :ls_typebillcode
- // FROM u_outwaretype
- // Where typeid = :typeid Using commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询销售发货单分类属性失败,'+commit_transaction.SQLErrText
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF ls_typebillcode = '' THEN
- // arg_msg = '发货单分类未设置对应单据抬头,请检查'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // //取分部代号
- // IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // outwarecode = getid_outware(scid,ls_sccode + ls_typebillcode,Date(server_dt),if_getid_ture,commit_transaction)
- // IF outwarecode = "err" THEN
- // outwarecode = ''
- // rslt = 0
- // arg_msg = "无法获取销售订单分类编号"+"~n"+sqlca.SQLErrText
- // GOTO ext
- // END IF
- //
- // ls_outwarecode = outwarecode
- // END IF
- // ELSE
- // outwarecode = getid(scid,ls_sccode + 'XS',Date(server_dt),if_getid_ture,commit_transaction)
- // IF outwarecode = "err" THEN
- // outwarecode = ''
- // rslt = 0
- // arg_msg = "无法获取销售订单分类编号"+"~n"+sqlca.SQLErrText
- // GOTO ext
- // END IF
- // ls_outwarecode = outwarecode
- // END IF
-
-
- IF billtype > 1 Or (billtype = 1 And flag = 0 And priceflag = 0) THEN
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- dscrp2 = :dscrp2,
- dscrp3 = :dscrp3,
- cusid = :cusid,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- relint_3 = :relint_3,
- otheramt = :otheramt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_tele1 = :rel_tele1,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- totalamt = :totalamt,
- getamt = :getamt,
- lsflag = :lsflag,
- deposit = :deposit,
- transcode = :transcode,
- carcode = :carcode,
- paytype = :paytype,
- typeid = :typeid,
- staticid = :staticid,
- viewdate = :viewdate
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "更新单据信息操作失败(1)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //删除原有明细
- DELETE FROM u_outwaremx
- WHERE u_outwaremx.outwareid = :outwareid
- And u_outwaremx.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- ELSEIF billtype > 1 Or (billtype = 1 And flag = 0 And priceflag = 1) THEN //确认后修改 单据信息
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- dscrp2 = :dscrp2,
- dscrp3 = :dscrp3,
- cusid = :cusid,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- otheramt = :otheramt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_tele1 = :rel_tele1,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- deposit = :deposit,
- transcode = :transcode,
- carcode = :carcode,
- paytype = :paytype,
- staticid = :staticid
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- AND flag = 0
- AND secflag = 0
- And priceflag = 1 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新单据操作失败(2)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- ELSE // 仓审后修改 财务信息
- UPDATE u_outware
- SET billtype = :billtype,
- relid = :relid,
- outdate = :outdate,
- outrep = :outrep,
- part = :part,
- dscrp = :dscrp,
- dscrp2 = :dscrp2,
- dscrp3 = :dscrp3,
- cusname = :cusname,
- thflag = :thflag,
- moddate = :server_dt,
- modemp = :publ_operator,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- otheramt = :otheramt,
- rel_address = :rel_address,
- rel_tele = :rel_tele,
- rel_tele1 = :rel_tele1,
- rel_fax = :rel_fax,
- rel_rep = :rel_rep,
- mrate = :mrate,
- totalamt = :totalamt,
- getamt = :getamt,
- lsflag = :lsflag,
- deposit = :deposit,
- transcode = :transcode,
- carcode = :carcode,
- paytype = :paytype,
- staticid = :staticid,
- viewdate = :viewdate
- WHERE u_outware.outwareid = :outwareid
- AND u_outware.scid = :scid
- AND flag = 1
- And secflag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
- arg_msg = "更新单据操作失败(2)"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
-
- END IF
- END IF
- //处理明细
- IF billtype > 1 Or (billtype = 1 And flag = 0 And priceflag = 0) THEN
- FOR i = 1 To it_mxbt
- INSERT INTO u_outwaremx
- (scid,
- outwareid,
- mtrlwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- addqty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- sptid,
- dxflag,
- costamt,
- ifrel,
- relid,
- relprintid,
- relid2,
- packqty,
- olmtrlid,
- woodcode,
- relcode,
- pcode,
- enprice,
- newpriceamt,
- outtype,
- dftsaleprice,
- cost,
- unit,
- rate,
- uqty,
- ware_enprice,
- ware_fprice,
- ware_price,
- mtrlcuscode,
- formula,
- mxdscrp2,
- ware_amt,
- tax,
- enamt,
- enamt_tax,
- bsamt,
- bsamt_tax,
- saleqty,
- net_weight,
- gross_weight,
- cubage,
- mxdscrp3,
- mxdscrp4,
- enprice_notax,
- priceformula,
- cost_notax,
- costamt_notax,
- otherprice)
- VALUES (
- :scid,
- :outwareid,
- :outwaremx[i].mtrlwareid,
- :outwaremx[i].printid,
- :outwaremx[i].mtrlid,
- :outwaremx[i].plancode,
- :outwaremx[i].status,
- :outwaremx[i].qty,
- :outwaremx[i].addqty,
- :outwaremx[i].fprice,
- :outwaremx[i].rebate,
- :outwaremx[i].price,
- :outwaremx[i].planprice,
- :outwaremx[i].mxdscrp,
- :outwaremx[i].sptid,
- :outwaremx[i].dxflag,
- :outwaremx[i].costamt,
- :outwaremx[i].ifrel,
- :outwaremx[i].relid,
- :outwaremx[i].relprintid,
- :outwaremx[i].relid2,
- :outwaremx[i].packqty,
- :outwaremx[i].olmtrlid,
- :outwaremx[i].woodcode,
- :outwaremx[i].relcode,
- :outwaremx[i].pcode,
- :outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,
- :outwaremx[i].outtype,
- :outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,
- :outwaremx[i].unit,
- :outwaremx[i].rate,
- :outwaremx[i].uqty,
- :outwaremx[i].ware_enprice,
- :outwaremx[i].ware_fprice,
- :outwaremx[i].ware_price,
- :outwaremx[i].mtrlcuscode,
- :outwaremx[i].formula,
- :outwaremx[i].mxdscrp2,
- :outwaremx[i].ware_amt,
- :outwaremx[i].tax,
- :outwaremx[i].enamt,
- :outwaremx[i].enamt_tax,
- :outwaremx[i].bsamt,
- :outwaremx[i].bsamt_tax,
- :outwaremx[i].saleqty,
- :outwaremx[i].net_weight,
- :outwaremx[i].gross_weight,
- :outwaremx[i].cubage,
- :outwaremx[i].mxdscrp3,
- :outwaremx[i].mxdscrp4,
- :outwaremx[i].enprice_notax,
- :outwaremx[i].priceformula,
- :outwaremx[i].cost_notax,
- :outwaremx[i].costamt_notax,
- :outwaremx[i].otherprice) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- IF it_newbegin THEN outwareid = 0 //重置id
- rslt = 0
- arg_msg = '插入单据明细内容失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- ELSEIF billtype > 1 Or (billtype = 1 And flag = 0 And priceflag = 1) THEN //确认后修改
- FOR i = 1 To it_mxbt
- UPDATE u_outWAREmx
- SET
- mxdscrp = :outwaremx[I].mxdscrp,
- fprice = :outwaremx[I].fprice,
- rebate = :outwaremx[I].rebate,
- enprice = :outwaremx[I].enprice,
- packqty = :outwaremx[I].packqty,
- outtype = :outwaremx[I].outtype,
- qty = :outwaremx[I].qty,
- uqty = :outwaremx[I].uqty,
- saleqty = :outwaremx[I].saleqty,
- price = :outwaremx[i].price,
- ware_price = :outWAREmx[i].ware_price,
- ware_fprice = :outWAREmx[i].ware_fprice,
- ware_enprice = :outWAREmx[i].ware_enprice,
- formula = :outwaremx[i].formula,
- mxdscrp2 = :outwaremx[I].mxdscrp2,
- ware_amt = :outwaremx[i].ware_amt,
- tax = :outwaremx[i].tax,
- enamt = :outwaremx[i].enamt,
- enamt_tax = :outwaremx[i].enamt_tax,
- bsamt = :outwaremx[i].bsamt,
- bsamt_tax = :outwaremx[i].bsamt_tax,
- net_weight = :outwaremx[i].net_weight,
- gross_weight = :outwaremx[i].gross_weight,
- cubage = :outwaremx[i].cubage,
- mxdscrp3 = :outwaremx[i].mxdscrp3,
- mxdscrp4 = :outwaremx[i].mxdscrp4,
- enprice_notax = :outwaremx[i].enprice_notax,
- priceformula = :outwaremx[i].priceformula,
- otherprice = :outwaremx[i].otherprice
- WHERE ( scid = :scid AND
- outWAREid = :outwareid AND
- printid = :outwaremx[i].printid);
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致更新明细价格操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
-
- ELSE //仓审后修改, 或销售数量
- FOR i = 1 To it_mxbt
- UPDATE u_outWAREmx
- SET price = :outWAREmx[i].price,
- mxdscrp = :outwaremx[I].mxdscrp,
- mxdscrp2 = :outwaremx[I].mxdscrp2,
- saleqty = :outwaremx[I].saleqty,
- fprice = :outwaremx[I].fprice,
- rebate = :outwaremx[I].rebate,
- enprice = :outwaremx[I].enprice,
- ware_price = :outWAREmx[i].ware_price,
- ware_fprice = :outWAREmx[i].ware_fprice,
- ware_enprice = :outWAREmx[i].ware_enprice,
- ware_amt = :outwaremx[i].ware_amt,
- formula = :outwaremx[i].formula,
- tax = :outwaremx[i].tax,
- enamt = :outwaremx[i].enamt,
- enamt_tax = :outwaremx[i].enamt_tax,
- bsamt = :outwaremx[i].bsamt,
- bsamt_tax = :outwaremx[i].bsamt_tax,
- net_weight = :outwaremx[i].net_weight,
- gross_weight = :outwaremx[i].gross_weight,
- cubage = :outwaremx[i].cubage,
- mxdscrp3 = :outwaremx[i].mxdscrp3,
- mxdscrp4 = :outwaremx[i].mxdscrp4,
- enprice_notax = :outwaremx[i].enprice_notax,
- priceformula = :outwaremx[i].priceformula,
- otherprice = :outwaremx[i].otherprice
- WHERE ( scid = :scid AND
- outWAREid = :outwareid AND
- printid = :outwaremx[i].printid)
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新单据明细价格失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- NEXT
- END IF
- IF save_end(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- it_newbegin = False
- it_updatebegin = False
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- p_clearmx()
- arg_msg = billname + ',' + arg_msg
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
- Dec new_noallocqty = 0
- Long ls_newid
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin Or it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arg_msg = "单据已经审核"
- GOTO ext
- END IF
- IF auditing_chk(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- 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"
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在审核,请稍后查询。"+"~n"
- GOTO ext
- END IF
- Long li_if_fifo = 0
- SELECT if_fifo
- INTO :li_if_fifo
- FROM u_storage
- Where storageid = :storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "查询仓库存货核算方法错误!"
- rslt = 0
- GOTO ext
- END IF
- IF sys_option_hide_ware = 0 THEN
- FOR i = 1 To it_mxbt
-
- Decimal ld_ref_costamt,ld_ref_costamt_notax
-
- Long li_mtrlwaremxid = 0
-
-
-
- IF li_if_fifo = 0 THEN //移动平均法
- IF p_update_cost(outwaremx[i],ld_ref_costamt,ld_ref_costamt_notax,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF p_update_cost_fifo(outwaremx[i],ld_ref_costamt,ld_ref_costamt_notax,arg_msg,False) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
-
- END IF
-
-
- Decimal dec_fifo_inprice,dec_fifo_inprice_notax
-
- //dec_fifo_inprice = outwaremx[i].enprice * outwaremx[i].rebate
- //负数出仓 取库存cost作为入仓成本单价
- dec_fifo_inprice = 0
- SELECT cost,cost_notax Into :dec_fifo_inprice,:dec_fifo_inprice_notax From u_mtrlware Where scid = :scid And mtrlwareid = :outwaremx[i].mtrlwareid;
- IF dec_fifo_inprice > 0 THEN
- ELSE
- dec_fifo_inprice = 0
- END IF
- IF dec_fifo_inprice_notax > 0 THEN
- ELSE
- dec_fifo_inprice_notax = 0
- END IF
-
-
-
- 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].addqty, ld_ref_costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,ld_ref_costamt_notax) = 0 THEN
- arg_msg = "行:"+String(i)+","+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
-
- //先进先出法 ,加入进仓批 u_mtrlware_inmx star
-
-
-
-
-
-
-
- IF li_if_fifo = 1 And outwaremx[i].qty < 0 THEN //负数 使用先进先出
- IF f_add_mtrlware_inmx(scid, outwaremx[i].mtrlwareid,outwareid,outwaremx[i].printid,outwarecode,outdate,outwaremx[i].qty,dec_fifo_inprice,dec_fifo_inprice_notax,1,False,commit_transaction,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF f_trigger_fifo_procedure(scid,outwaremx[i].mtrlwareid,outdate,1,outwareid,li_mtrlwaremxid,False,commit_transaction,arg_msg) = 0 THEN //负数等于进仓
-
- rslt = 0
- GOTO ext
- END IF
-
- //重算结存表
- IF f_cmp_fifo_warebalc(scid,outwaremx[i].mtrlwareid,False,commit_transaction,arg_msg) = 0 THEN
-
- rslt = 0
- GOTO ext
- END IF
-
- END IF
-
- IF li_if_fifo = 1 And outwaremx[i].qty > 0 THEN //正数
- IF f_trigger_fifo_procedure(scid,outwaremx[i].mtrlwareid,outdate,2,outwareid,li_mtrlwaremxid,False,commit_transaction,arg_msg) = 0 THEN
-
- rslt = 0
- GOTO ext
- END IF
-
- //重算结存表
- IF f_cmp_fifo_warebalc(scid,outwaremx[i].mtrlwareid,False,commit_transaction,arg_msg) = 0 THEN
-
- rslt = 0
- GOTO ext
- END IF
-
- END IF
-
-
-
-
-
- //先进先出法 ,加入进仓批 u_mtrlware_inmx end
-
-
-
-
- NEXT
-
- //检查是否正确生成进仓批
- IF li_if_fifo = 1 THEN
- FOR i = 1 To it_mxbt
-
- IF f_check_mtrlware_inmx(scid, outwaremx[i].mtrlwareid,commit_transaction,arg_msg) = 0 THEN
-
- IF uf_w_cmp_fifo_cb_bill(scid,outwaremx[i].mtrlwareid,False,arg_msg) = 0 THEN //尝试修复
- rslt = 0
- arg_msg = '第' + String(i) + '行 ' + arg_msg
- GOTO ext
- ELSE
- IF f_check_mtrlware_inmx(scid, outwaremx[i].mtrlwareid,commit_transaction,arg_msg) = 0 THEN //再检查一次
- rslt = 0
- arg_msg = '第' + String(i) + '行 ' + arg_msg
- GOTO ext
- END IF
-
- END IF
-
-
-
-
-
-
-
- END IF
-
- NEXT
- END IF
-
-
- END IF
- IF auditing_end(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- flag = 1
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- IF billname <> "" THEN
- arg_msg = billname + ',' + arg_msg
- END IF
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);//====================================================================
- // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
- //--------------------------------------------------------------------
- // Description: 从置对象,设定业务类型与关联ID,准备更新出仓单
- //--------------------------------------------------------------------
- // Arguments:
- // value long arg_scid
- // value long arg_inwareid
- // value integer arg_billtype
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.12
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1
- IF arg_scid < 0 THEN
- arg_msg = '请选择分部'
- rslt = 0
- GOTO ext
- END IF
- IF arg_outwareid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF Not(arg_billtype = 1 Or arg_billtype = 2 Or arg_billtype = 3 Or arg_billtype = 4 Or arg_billtype = 8 Or arg_billtype = 9 Or arg_billtype = 10 Or arg_billtype = 12) THEN
- rslt = 0
- arg_msg = '此单据类型必须为:'
- arg_msg = arg_msg+'1-销售[记帐模式],'
- arg_msg = arg_msg+'2-销售[不记帐模式],'
- arg_msg = arg_msg+'3-领料出仓,'
- arg_msg = arg_msg+'4-外加工出仓,'
- arg_msg = arg_msg+'8-其他出仓,'
- arg_msg = arg_msg+'9-盘亏出仓,'
- arg_msg = arg_msg+'10-工具出仓,'
- arg_msg = arg_msg+'12-调拨出仓'
- GOTO ext
- END IF
- uf_get_billname(arg_billtype)
- //CHOOSE CASE arg_billtype
- // CASE 1
- // billname = '销售单'
- // CASE 2
- // billname = '销售单'
- // CASE 3
- // billname = '领料出仓单'
- // CASE 4
- // billname = '外协发出仓'
- // CASE 8
- // billname = '其他进仓单'
- // CASE 9
- // billname = '盘亏出仓单'
- // CASE 10
- // billname = '工具出仓单'
- // CASE 12
- // billname = '调拨出仓单'
- // CASE 15
- // billname = '拆装出仓单'
- //END CHOOSE
- IF arg_billtype = 12 THEN
- rslt = 0
- arg_msg = '单据类型:12-调拨出仓>>不能修改'
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF arg_billtype = 1 THEN
- // IF priceflag = 1 and flag = 0 And secflag = 0 THEN
- // rslt = 0
- // arg_msg = '单据已确认未仓库,不可以修改'
- // GOTO ext
- // END IF
- IF flag = 1 And secflag = 1 THEN
- rslt = 0
- arg_msg = '单据已经过仓库及财务审核,不可以修改'
- GOTO ext
- END IF
- ELSE
- IF flag = 1 THEN
- rslt = 0
- arg_msg = '单据已经审核,不可以修改'
- GOTO ext
- END IF
- END IF
- outwareid = arg_outwareid
- billtype = arg_billtype
- scid = arg_scid
- it_newbegin = False
- it_updatebegin = True
- p_clearmx() //清除明细
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1,i = 1,no_mxcheck = 0
- sum_amt = 0
- sum_amt_en = 0
- sum_enamt = 0
- sum_enamt_tax = 0
- sum_bsamt = 0
- sum_bsamt_tax = 0
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arg_msg = "非法出仓单唯一码"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- //用游标读取明细
- DECLARE cur_inwaermx CURSOR FOR
- SELECT u_outwaremx.printid,
- u_outwaremx.mtrlid,
- u_outwaremx.plancode,
- u_outwaremx.status,
- u_outwaremx.qty,
- u_outwaremx.addqty,
- u_outwaremx.fprice,
- u_outwaremx.rebate,
- u_outwaremx.price,
- u_outwaremx.planprice,
- u_outwaremx.mxdscrp,
- u_mtrldef.mtrlcode,
- u_outwaremx.sptid,
- u_outwaremx.dxflag,
- u_outwaremx.mtrlwareid,
- u_outwaremx.storageid,
- u_outwaremx.costamt,
- u_outwaremx.ifrel,
- u_outwaremx.relid,
- u_outwaremx.relprintid,
- u_outwaremx.relid2,
- u_outwaremx.olmtrlid,
- u_outwaremx.packqty,
- u_outwaremx.woodcode,
- u_outwaremx.pcode,
- u_outwaremx.enprice,
- u_outwaremx.newpriceamt,
- u_outwaremx.outtype,
- u_outwaremx.dftsaleprice,
- u_outwaremx.cost,
- u_outwaremx.unit,
- u_outwaremx.rate,
- u_outwaremx.uqty,
- u_outwaremx.ware_enprice,
- u_outwaremx.ware_fprice,
- u_outwaremx.ware_price,
- u_outwaremx.mtrlcuscode,
- u_outwaremx.mxdscrp2,
- u_outwaremx.tax,
- u_outwaremx.enamt,
- u_outwaremx.enamt_tax,
- u_outwaremx.bsamt,
- u_outwaremx.bsamt_tax,
- u_outwaremx.saleqty,
- u_outwaremx.enprice_notax,
- u_outwaremx.costamt_notax,
- u_outwaremx.otherprice
- FROM u_outwaremx,u_mtrldef,u_outware
- WHERE u_outware.outwareid = :arg_outwareid AND
- u_outwaremx.mtrlid = u_mtrldef.mtrlid AND
- u_outware.scid = :arg_scid AND
- u_outware.outwareid = u_outwaremx.outwareid AND
- u_outware.scid = u_outwaremx.scid USING commit_transaction;
-
- OPEN cur_inwaermx;
- FETCH cur_inwaermx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].addqty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,:outwaremx[i].planprice,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].sptid,:outwaremx[i].dxflag,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,:outwaremx[i].relprintid,
- :outwaremx[i].relid2,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,:outwaremx[i].unit,:outwaremx[i].rate,
- :outwaremx[i].uqty,:outwaremx[i].ware_enprice,:outwaremx[i].ware_fprice,
- :outwaremx[i].ware_price,:outwaremx[i].mtrlcuscode,:outwaremx[i].mxdscrp2,
- :outwaremx[i].tax,:outwaremx[i].enamt,:outwaremx[i].enamt_tax,:outwaremx[i].bsamt,:outwaremx[i].bsamt_tax,
- :outwaremx[i].saleqty,:outwaremx[i].enprice_notax,:outwaremx[i].costamt_notax,:outwaremx[i].otherprice;
- DO WHILE commit_transaction.SQLCode = 0
- // //淘汰
- // sum_enamt += round(outwaremx[i].uqty * outwaremx[i].enprice * outwaremx[i].rebate,2)//计算单据原币总金额
- // sum_amt = sum_amt + round(outwaremx[i].uqty * outwaremx[i].enprice * outwaremx[i].rebate * mrate,2) //计算单据本位币总金额
- //新增的,以此为标准
- sum_enamt += outwaremx[i].enamt//计算单据原币总金额
- sum_enamt_tax += outwaremx[i].enamt_tax//计算单据原币总税金
- sum_bsamt += outwaremx[i].bsamt//计算单据本位币总金额
- sum_bsamt_tax += outwaremx[i].bsamt_tax//计算单据本位币总税金
-
-
- i++
- FETCH cur_inwaermx INTO :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
- :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].addqty,:outwaremx[i].fprice,
- :outwaremx[i].rebate,:outwaremx[i].price,:outwaremx[i].planprice,
- :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
- :outwaremx[i].sptid,:outwaremx[i].dxflag,
- :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
- :outwaremx[i].costamt,:outwaremx[i].ifrel,
- :outwaremx[i].relid,:outwaremx[i].relprintid,
- :outwaremx[i].relid2,:outwaremx[i].olmtrlid,:outwaremx[i].packqty,
- :outwaremx[i].woodcode,:outwaremx[i].pcode,:outwaremx[i].enprice,
- :outwaremx[i].newpriceamt,:outwaremx[i].outtype,:outwaremx[i].dftsaleprice,
- :outwaremx[i].cost,:outwaremx[i].unit,:outwaremx[i].rate,
- :outwaremx[i].uqty,:outwaremx[i].ware_enprice,:outwaremx[i].ware_fprice,
- :outwaremx[i].ware_price,:outwaremx[i].mtrlcuscode,:outwaremx[i].mxdscrp2,
- :outwaremx[i].tax,:outwaremx[i].enamt,:outwaremx[i].enamt_tax,:outwaremx[i].bsamt,:outwaremx[i].bsamt_tax,
- :outwaremx[i].saleqty,:outwaremx[i].enprice_notax,:outwaremx[i].costamt_notax,:outwaremx[i].otherprice;
- LOOP
- CLOSE cur_inwaermx;
- //检验明细是否读入完整
- SELECT count(*) INTO :no_mxcheck
- FROM u_outwaremx
- WHERE u_outwaremx.outwareid = :arg_outwareid
- AND scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细数量"
- GOTO ext
- END IF
- IF i <> (no_mxcheck+1) THEN
- rslt = 0
- arg_msg = "查询操作失败,出仓单明细"
- GOTO ext
- END IF
- outwareid = arg_outwareid
- scid = arg_scid
- it_mxbt = i - 1
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- p_reset()
- arg_msg = billname + ',' + arg_msg
- end if
- RETURN rslt
- end function
- public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
- //0 FAIL, 1 SUCCESS
- Int rslt = 1
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arG_MSG = "没有删除对象,操作取消"
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_outwareid,arG_MSG) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF flag = 1 THEN
- rslt = 0
- arG_MSG = "单据已经审核,不可以删除"
- GOTO ext
- END IF
- IF billtype = 1 THEN
- IF priceflag = 1 THEN
- rslt = 0
- arG_MSG = "单据已经确认,不可以删除"
- GOTO ext
- END IF
-
- IF sys_option_autowaste = 1 THEN
- uo_outware_waste uo_waste
- uo_waste = CREATE uo_outware_waste
- uo_waste.commit_transaction = commit_transaction
- IF uo_waste.insertwaste(0,arg_scid,arg_outwareid,arG_MSG,FALSE) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- DESTROY uo_waste
- END IF
- END IF
- DELETE FROM u_outware
- WHERE u_outware.outwareid = :arg_outwareid
- AND u_outware.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除出仓单操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- DELETE FROM u_outwaremx
- WHERE u_outwaremx.outwareid = :arg_outwareid
- AND u_outwaremx.scid = :arg_scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "删除出仓单明细操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- it_newbegin = FALSE
- it_updatebegin = FALSE
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- p_reset()
- arG_MSG = billname + ',' + arG_MSG
- ELSEIF rslt = 1 AND arg_ifcommit THEN
- COMMIT USING commit_transaction;
- END IF
- Return (rslt)
- end function
- public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
- //0 fail 1 success
- Int rslt = 1
- arg_newdescppart = Trim(arg_newdescppart)
- IF it_updatebegin OR it_newbegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可用"
- GOTO ext
- END IF
- IF arg_newdescppart = '' THEN
- rslt = 0
- arg_msg = "要添加内容为空,操作取消"
- GOTO ext
- END IF
- rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
- IF rslt = 0 THEN GOTO ext
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "非审核状态下不可用"
- GOTO ext
- END IF
- UPDATE u_outware
- SET dscrp = dscrp+' '+:arg_newdescppart
- WHERE u_outware.outwareid = :outwareid
- AND scid = :scid USING commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "添加单据备注操作失败"+"~n"
- GOTO ext
- END IF
- dscrp = dscrp+' '+arg_newdescppart
- ext:
- IF rslt = 0 THEN
- ROLLBACK USING commit_transaction;
- arg_msg = billname + ',' + arg_msg
- else
- COMMIT USING commit_transaction;
- END IF
- Return (rslt)
- end function
- public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);//====================================================================
- // Function: c_auditing(arg_ifcommit,arg_msg)
- //--------------------------------------------------------------------
- // Description:
- //--------------------------------------------------------------------
- // Arguments:
- // value boolean arg_ifcommit
- // reference string arg_msg
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2003.11.19
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1,cnt = 0,i
- Long ls_newid
- DateTime null_dt
- SetNull(null_dt)
- IF outwareid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF it_newbegin Or it_updatebegin THEN
- rslt = 0
- arg_msg = "编辑状态下不可以执行审核"
- GOTO ext
- END IF
- IF cwauditingflag = 1 THEN
- rslt = 0
- arG_MSG = "该单据已经总账审核,不能进行财务撤审"
- GOTO ext
- END IF
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据还未审核"
- GOTO ext
- END IF
- IF balcflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经结存,不能撤审"
- GOTO ext
- END IF
- IF c_auditing_chk(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- 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"
- GOTO ext
- ELSEIF commit_transaction.SQLNRows = 0 THEN
- rslt = 0
- arg_msg = "单据正在撤审,请稍后查询。"+"~n"
- GOTO ext
- END IF
- Long li_if_fifo = 0
- SELECT if_fifo
- INTO :li_if_fifo
- FROM u_storage
- Where storageid = :storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "查询仓库存货核算方法错误!"
- rslt = 0
- GOTO ext
- END IF
- IF sys_option_hide_ware = 0 THEN
- //撤审限制,迟于本出仓单审核时间的成本价调整单审核后本出仓单不能撤审
- IF uf_chk_updatecost(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- FOR i = 1 To it_mxbt
- 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].addqty,0 - outwaremx[i].costamt,&
- outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
- outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,0 - outwaremx[i].costamt_notax) = 0 THEN
- arg_msg = "行:"+String(i)+","+arg_msg
- rslt = 0
- GOTO ext
- END IF
-
-
- //先进先出法 ,删除进仓批 u_mtrlware_inmx star
-
- Long li_mtrlwaremxid = 0
-
-
-
-
-
-
- IF li_if_fifo = 1 And outwaremx[i].qty < 0 THEN //负数 使用先进先出
- li_mtrlwaremxid = 0
- SELECT top 1 mtrlwaremxid INTO :li_mtrlwaremxid FROM u_mtrlware_inmx
- WHERE scid = :scid AND
- inwareid = :outwareid AND
- printid = :outwaremx[i].printid AND
- if_outware = 1
- Using commit_transaction;
-
-
-
- IF f_del_mtrlware_inmx(li_mtrlwaremxid,False,commit_transaction,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- IF f_trigger_fifo_procedure(scid,outwaremx[i].mtrlwareid,outdate,1,outwareid,li_mtrlwaremxid,False,commit_transaction,arg_msg) = 0 THEN //负数等于进仓
-
- rslt = 0
- GOTO ext
- END IF
-
- //重算结存表
- IF f_cmp_fifo_warebalc(scid,outwaremx[i].mtrlwareid,False,commit_transaction,arg_msg) = 0 THEN
-
- rslt = 0
- GOTO ext
- END IF
-
- END IF
-
-
- IF li_if_fifo = 1 And outwaremx[i].qty > 0 THEN //正数
- li_mtrlwaremxid = 0
- IF f_trigger_fifo_procedure(scid,outwaremx[i].mtrlwareid,outdate,2,outwareid,li_mtrlwaremxid,False,commit_transaction,arg_msg) = 0 THEN //正数
-
- rslt = 0
- GOTO ext
- END IF
-
- //重算结存表
- IF f_cmp_fifo_warebalc(scid,outwaremx[i].mtrlwareid,False,commit_transaction,arg_msg) = 0 THEN
-
- rslt = 0
- GOTO ext
- END IF
-
- END IF
-
-
-
-
- //先进先出法 ,删除进仓批 u_mtrlware_inmx end
-
-
- NEXT
-
-
- //检查是否正确生成进仓批
- IF li_if_fifo = 1 THEN
- FOR i = 1 To it_mxbt
- IF f_check_mtrlware_inmx(scid, outwaremx[i].mtrlwareid,commit_transaction,arg_msg) = 0 THEN
-
- IF uf_w_cmp_fifo_cb_bill(scid,outwaremx[i].mtrlwareid,False,arg_msg) = 0 THEN //尝试修复
- rslt = 0
- arg_msg = '第' + String(i) + '行 ' + arg_msg
- GOTO ext
- ELSE
- IF f_check_mtrlware_inmx(scid, outwaremx[i].mtrlwareid,commit_transaction,arg_msg) = 0 THEN //再检查一次
- rslt = 0
- arg_msg = '第' + String(i) + '行 ' + arg_msg
- GOTO ext
- END IF
-
- END IF
- END IF
- NEXT
- END IF
-
-
-
-
-
- END IF
- IF c_auditing_end(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- flag = 0
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- IF billname <> "" THEN
- arg_msg = billname + ',' + arg_msg
- END IF
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_clearmx ();//int p_clearmx()
- //清除明细
- it_mxbt=0
- return 1
- end function
- public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
- //0 失败 1成功
- Int rslt = 1
- IF arg_outwareid <= 0 THEN
- rslt = 0
- arG_MSG = "非法出仓单唯一码"
- GOTO ext
- END IF
- SELECT u_outware.outwarecode,
- u_outware.billtype,
- u_outware.relid,
- u_outware.storageid,
- u_outware.outdate,
- u_outware.outrep,
- u_outware.part,
- u_outware.cusid,
- u_outware.cusname,
- u_outware.dscrp,
- u_outware.thflag,
- u_outware.flag,
- u_outware.secflag,
- u_outware.balcflag,
- u_outware.relstr_1,
- u_outware.relstr_2,
- u_outware.relstr_3,
- u_outware.relint_1,
- u_outware.relint_2,
- u_outware.relint_3,
- u_outware.priceflag,
- u_outware.otheramt,
- u_outware.rel_address,
- u_outware.rel_tele,
- u_outware.rel_fax,
- u_outware.rel_rep,
- u_outware.mrate,
- u_outware.Auditingdate,
- u_outware.secpflag,
- u_outware.secpdate,
- u_outware.secpemp,
- u_outware.cwauditingflag,
- u_outware.cwauditingrep,
- u_outware.cwauditingdate,
- u_outware.viewdate
-
-
-
- INTO :outwarecode,
- :billtype,
- :relid,
- :storageid,
- :outdate,
- :outrep,
- :part,
- :cusid,
- :cusname,
- :dscrp,
- :thflag,
- :flag,
- :secflag,
- :balcflag,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :relint_1,
- :relint_2,
- :relint_3,
- :priceflag,
- :otheramt,
- :rel_address,
- :rel_tele,
- :rel_fax,
- :rel_rep,
- :mrate,
- :Auditingdate,
- :secpflag,
- :secpdate,
- :secpemp,
- :cwauditingflag,
- :cwauditingrep,
- :cwauditingdate,
- :viewdate
-
-
- FROM u_outware
- WHERE u_outware.outwareid = :arg_outwareid
- AND scid = :arg_scid
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arG_MSG = "查询操作失败(错误出仓单唯一码),出仓单"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- outwareid = arg_outwareid
- scid = arg_scid
- uf_get_billname(billtype)
- ext:
- IF rslt = 0 THEN p_reset()
- RETURN rslt
- end function
- public function integer p_reset ();//int p_reset()
- //清除对象及其明细
- scid = 0
- outwareid = 0
- outwarecode = ''
- billtype = 0
- opemp = ''
- modemp = ''
- auditingrep = ''
- secauditingrep = ''
- flag = 0
- secflag = 0
- relid = 0
- storageid = 0
- outrep = ''
- part = ''
- dscrp = ''
- dscrp2 = ''
- dscrp3 = ''
- cusid = 0
- cusname = ''
- thflag = 0
- otheramt = 0
- rel_address = ''
- rel_tele = ''
- rel_tele1 = ''
- rel_fax = ''
- rel_rep= ''
- totalamt = 0
- getamt = 0
- lsflag = 0
- transcode = ''
- carcode = ''
- paytype = ''
- priceflag=0
- secpflag=0
- it_newbegin = FALSE
- it_updatebegin = FALSE
- //清除明细
- p_clearmx()
- RETURN 1
- end function
- public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_addqty, decimal arg_fprice, decimal arg_rebate, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_relprintid, long arg_relid2, long arg_olmtrlid, long arg_packqty, integer arg_outtype, string arg_unit, decimal arg_rate, string arg_mtrlcuscode, string arg_formula);
- s_outwaremx s_mx
- s_mx.mtrlwareid = arg_mtrlwareid
- s_mx.qty = arg_qty
- s_mx.addqty = arg_addqty
- s_mx.fprice = arg_fprice
- s_mx.rebate = arg_rebate
- s_mx.mxdscrp = arg_mxdscrp
- s_mx.printid = arg_printid
- s_mx.ifrel = arg_ifrel
- s_mx.relid = arg_relid
- s_mx.relprintid = arg_relprintid
- s_mx.relid2 = arg_relid2
- s_mx.olmtrlid = arg_olmtrlid
- s_mx.packqty = arg_packqty
- s_mx.outtype = arg_outtype
- s_mx.unit = arg_unit
- s_mx.rate = arg_rate
- s_mx.mtrlcuscode = arg_mtrlcuscode
- s_mx.formula = arg_formula
- return acceptmx(s_mx, arg_msg)
- //Long rslt = 1,cnt = 0,LS_i
- //Long i_mtrlid,i_storageid,i_sptid
- //Int i_dxflag,li_mtrlkind
- //String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode,i_mtrlname
- //Decimal i_planprice,ld_dftsaleprice
- //Double i_cost,i_newprice
- //Decimal i_notauditqty,i_allouseqty,i_noallocaddqty
- //String ls_relcode
- //
- //
- //IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
- // rslt = 0
- // arg_msg = "非编辑状态不可以使用,操作取消"
- // GOTO ext
- //END IF
- //
- ////清除空值
- //IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
- //IF IsNull(arg_printid) THEN arg_printid = 0
- //IF IsNull(arg_qty) THEN arg_qty = 0
- //IF IsNull(arg_addqty) THEN arg_addqty = 0
- //IF IsNull(arg_fprice) THEN arg_fprice = 0
- //IF IsNull(arg_rebate) THEN arg_rebate = 0
- //IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
- //IF IsNull(arg_ifrel) THEN arg_ifrel = 0
- //IF IsNull(arg_relid) THEN arg_relid = 0
- //IF IsNull(arg_relprintid) THEN arg_relprintid = 0
- //IF IsNull(arg_relid2) THEN arg_relid2 = 0
- //IF IsNull(arg_olmtrlid) THEN arg_olmtrlid = 0
- //IF IsNull(arg_packqty) THEN arg_packqty = 0
- //IF IsNull(arg_outtype) THEN arg_outtype = 0
- //IF IsNull(arg_rate) OR arg_rate = 0 THEN arg_rate = 1
- //IF IsNull(arg_unit) THEN arg_unit = ''
- //IF IsNull(arg_mtrlcuscode) THEN arg_mtrlcuscode = ''
- //IF IsNull(arg_formula) THEN arg_formula = ''
- //
- //
- //arg_qty = Round(arg_qty,5)
- //arg_addqty = Round(arg_addqty,5)
- //
- //// 如果出仓数量为 0,或物料编号为空,则不作任何处理
- //IF arg_mtrlwareid = 0 Or (arg_qty = 0 AND arg_addqty = 0) THEN
- // rslt = 1
- // GOTO ext
- //END IF
- //
- ////检查物料库存ID
- //SELECT u_mtrlware.mtrlid,
- // u_mtrlware.storageid,
- // u_mtrlware.plancode,
- // u_mtrlware.status,
- // u_mtrlware.cost,
- // u_mtrldef.planprice,
- // u_mtrldef.mtrlcode,
- // u_mtrldef.mtrlname,
- // u_mtrlware.sptid,
- // u_mtrlware.dxflag,
- // u_mtrlware.woodcode,
- // u_mtrlware.pcode,
- // isnull(uv_mtrlware_noauditingqty.noauditingqty,0),
- // u_mtrlware.noallocqty,
- // u_mtrlware.noallocaddqty
- // INTO :i_mtrlid,
- // :i_storageid,
- // :i_plancode,
- // :i_status,
- // :i_cost,
- // :i_planprice,
- // :i_mtrlcode,
- // :i_mtrlname,
- // :i_sptid,
- // :i_dxflag,
- // :i_woodcode,
- // :i_pcode,
- // :i_notauditqty,
- // :i_allouseqty,
- // :i_noallocaddqty
- // FROM u_mtrlware left OUTER join uv_mtrlware_noauditingqty
- // on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid)
- // AND ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid),u_mtrldef
- // WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
- // AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- // And ( u_mtrlware.scid = :scid ) USING commit_transaction;
- //
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "第" + String(arg_printid) + "行,查询操作失败,库存信息错误"
- // GOTO ext
- //END IF
- //
- ////检查成本价调整单
- //cnt = 0
- //SELECT count(*)
- // INTO :cnt
- // FROM u_updatecost,u_updatecostmx
- // WHERE u_updatecost.wareid = u_updatecostmx.wareid AND
- // u_updatecost.flag = 0 AND
- // u_updatecostmx.mtrlwareid = :arg_mtrlwareid AND
- // u_updatecost.scid = :scid USING commit_transaction;
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "第" + String(arg_printid) + "行,编码["+i_mtrlcode+"]查询成本价调整单操作失败"
- // GOTO ext
- //END IF
- //IF cnt > 0 THEN
- // rslt = 0
- // arg_msg = "第" + String(arg_printid) + "行,编码["+i_mtrlcode+"]已开成本价调整单,请先审核"
- // GOTO ext
- //END IF
- //
- //
- //IF IsNull(ld_dftsaleprice) THEN ld_dftsaleprice = 0
- //IF IsNull(i_cost) THEN i_cost = 0
- //IF IsNull(i_plancode) THEN i_plancode = ''
- //IF IsNull(i_status) THEN i_status = ''
- //IF IsNull(i_mtrlid) THEN i_mtrlid = 0
- //IF IsNull(i_storageid) THEN i_storageid = 0
- //IF IsNull(i_planprice) THEN i_planprice = 0
- //IF IsNull(i_sptid) THEN i_sptid = 0
- //IF IsNull(i_dxflag) THEN i_dxflag = 0
- //IF IsNull(i_woodcode) THEN i_woodcode = ''
- //IF IsNull(i_pcode) THEN i_pcode = ''
- //
- //IF sys_option_addqty = 1 AND i_noallocaddqty <> 0 THEN //辅数限制
- // IF arg_addqty = 0 AND billtype <> 9 THEN
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,出仓时必须录入辅数。'
- // GOTO ext
- // END IF
- //
- // If (i_noallocaddqty = arg_addqty) And (i_allouseqty <> arg_qty) THEN
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存辅数全部出仓时,库存数量应全部出仓.'
- // GOTO ext
- // END IF
- //
- // If (i_allouseqty = arg_qty) And (i_noallocaddqty <> arg_addqty) THEN
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存数量全部出仓时,库存辅数应全部出仓.'
- // GOTO ext
- // END IF
- //END IF
- //
- //IF billtype = 1 THEN
- // Int li_if_cus_mtrlware
- // SELECT balctype INTO :li_if_cus_mtrlware
- // FROM u_storage
- // Where storageid = :storageid USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询仓库是否使用客户库存失败'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF li_if_cus_mtrlware = 1 THEN
- // IF cusid <> i_sptid THEN
- // rslt = 0
- // arg_msg = "查询操作失败,明细纪录对应的库存不是该客户的库存!"
- // GOTO ext
- // END IF
- // END IF
- //END IF
- //
- //IF billtype = 1 THEN
- // f_get_defsaleprice(cusid,i_mtrlid,arg_unit,i_status,i_pcode,i_woodcode,relint_2,ld_dftsaleprice)
- //ELSE
- // ld_dftsaleprice = 0
- // mrate = 1
- //END IF
- //
- //decimal ld_mx_qty
- ////*****检查大于未开数不可以开单
- //IF flag = 0 THEN
- // Decimal ol_mtrl_qty = 0
- // Int ls_noallocflag
- //
- // SELECT noallocflag INTO :ls_noallocflag
- // FROM u_storage
- // Where storageid = :storageid;
- // IF sqlca.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = '查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
- // GOTO ext
- // END IF
- //
- // IF ls_noallocflag = 1 THEN
- //
- // IF it_updatebegin THEN
- // SELECT sum(u_outwaremx.qty)
- // INTO :ol_mtrl_qty
- // FROM u_outwaremx
- // WHERE u_outwaremx.outwareid = :outwareid
- // AND u_outwaremx.mtrlwareid = :arg_mtrlwareid
- // AND scid = :scid;
- // IF sqlca.SQLCode = -1 THEN
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,查询原开单数量失败'
- // GOTO ext
- // END IF
- // END IF
- //
- // FOR LS_i = 1 TO it_mxbt
- // IF arg_mtrlwareid = outwaremx[LS_i].mtrlwareid THEN
- // ld_mx_qty = ld_mx_qty + outwaremx[LS_i].qty
- // END IF
- // NEXT
- //
- // ld_mx_qty = ld_mx_qty + arg_qty
- //
- // //盘亏单不检查
- // IF billtype <> 9 THEN
- // IF ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,' + String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
- // GOTO ext
- // END IF
- // END IF
- // END IF
- //END IF
- //
- ////***********************************************
- //
- //
- //IF arg_fprice * arg_rebate < 0 THEN //检查出仓价
- // rslt = 0
- // arg_msg = '第' + String(arg_printid) + '行,' + String(i_mtrlcode)+" 单价错误"
- // GOTO ext
- //END IF
- //
- //CHOOSE CASE billtype
- // CASE 1
- // IF arg_ifrel > 0 THEN
- // IF flag = 0 THEN
- // Decimal lde_mx_qty,lde_noconqty,lde_notauditqty
- //
- // IF arg_relid = 0 THEN
- // arg_msg = '第' + String(arg_printid) + '行,请先择相应的订单'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // SELECT top 1 taskcode,saleqty - consignedqty INTO :ls_relcode,:lde_noconqty
- // FROM u_saletaskmx,u_saletask
- // WHERE u_saletaskmx.mtrlid = :i_mtrlid
- // AND u_saletaskmx.taskid = :arg_relid
- // AND u_saletaskmx.printid = :arg_relprintid
- // AND u_saletaskmx.scid = :scid
- // AND u_saletaskmx.scid = u_saletask.scid
- // AND u_saletaskmx.status = :i_status
- // AND u_saletaskmx.woodcode = :i_woodcode
- // AND u_saletaskmx.pcode = :i_pcode
- // AND u_saletaskmx.unit = :arg_unit
- // AND u_saletaskmx.mtrlcuscode = :arg_mtrlcuscode
- // AND u_saletaskmx.taskid = u_saletask.taskid
- // USING commit_transaction;
- //
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '第' + String(arg_printid) + '行,查询销售订单是否有订购编码:'+i_mtrlcode+'失败'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- //
- // lde_mx_qty = 0
- // FOR LS_i = 1 TO it_mxbt
- // IF i_mtrlid = outwaremx[LS_i].mtrlid AND &
- // arg_relid = outwaremx[LS_i].relid AND &
- // arg_relprintid = outwaremx[LS_i].relprintid AND &
- // i_status = outwaremx[LS_i].status AND &
- // i_woodcode = outwaremx[LS_i].woodcode AND &
- // i_pcode = outwaremx[LS_i].pcode AND &
- // i_plancode = outwaremx[LS_i].plancode THEN
- // lde_mx_qty = lde_mx_qty + outwaremx[LS_i].qty
- // END IF
- // NEXT
- //
- // lde_mx_qty = lde_mx_qty + arg_qty
- // //查询相关订单已开发货单未审核数量
- // SELECT isnull(sum(qty),0) INTO :lde_notauditqty
- // FROM u_outwaremx,u_outware
- // WHERE u_outwaremx.relid = :arg_relid
- // AND u_outwaremx.relprintid = :arg_relprintid
- // AND u_outwaremx.mtrlid = :i_mtrlid
- // AND u_outwaremx.status = :i_status
- // AND u_outwaremx.woodcode = :i_woodcode
- // AND u_outwaremx.pcode = :i_pcode
- // AND u_outware.flag = 0
- // AND u_outwaremx.outwareid = u_outware.outwareid
- // AND u_outwaremx.scid = u_outware.scid
- // AND u_outware.outwareid <> :outwareid
- // USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '查询销售订单:'+ls_relcode+'产品:'+i_mtrlcode+'已开发货单未审核数量失败'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // IF lde_notauditqty + lde_mx_qty > lde_noconqty THEN
- // arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // END IF
- // END IF
- // CASE 3
- // IF arg_ifrel = 1 THEN
- // IF arg_relid = 0 THEN
- // arg_msg = '第' + String(arg_printid) + '行,请先择相应的订单'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // SELECT taskcode INTO :ls_relcode
- // FROM u_saletask Where taskid = :arg_relid
- // USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '第' + String(arg_printid) + '行,查询销售订单号失败!'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // if arg_relid2 > 0 then //检查订单运算
- // SELECT count(*)
- // INTO :cnt
- // FROM u_saleRqMtrl_scll
- // WHERE scid = :scid
- // and taskid = :arg_relid
- // and printid = :arg_relprintid
- // and rqmtrlid = :arg_relid2
- // USING commit_transaction;
- // IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '第' + String(arg_printid) + '行,查询销售订单信息失败!'
- // rslt = 0
- // GOTO ext
- // END IF
- //
- // if cnt <> 1 then
- // arg_msg = '第' + String(arg_printid) + '行,物料销售订单运算结果不存在或重复!'
- // rslt = 0
- // GOTO ext
- // end if
- // END IF
- // END IF
- //
- //END CHOOSE
- //
- //
- ////**取最新价
- //SELECT price
- // INTO :i_newprice
- // FROM v_maxprice_sptprice
- // Where mtrlid = :i_mtrlid;
- //IF sqlca.SQLCode <> 0 OR IsNull(i_newprice) THEN i_newprice = 0
- //
- //
- ////写入内容
- //it_mxbt++
- //outwaremx[it_mxbt].dftsaleprice = ld_dftsaleprice
- //
- //outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
- //outwaremx[it_mxbt].mtrlid = i_mtrlid
- //outwaremx[it_mxbt].status = i_status
- //outwaremx[it_mxbt].uqty = arg_qty
- //outwaremx[it_mxbt].addqty = arg_addqty
- //outwaremx[it_mxbt].storageid = i_storageid
- //outwaremx[it_mxbt].cost = i_cost
- //outwaremx[it_mxbt].costamt = Round(i_cost * arg_qty,2)
- //outwaremx[it_mxbt].newpriceamt = Round(i_newprice * arg_qty,2)
- //outwaremx[it_mxbt].plancode = i_plancode
- //outwaremx[it_mxbt].planprice = i_planprice
- //outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- //outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
- //outwaremx[it_mxbt].printid = arg_printid
- //outwaremx[it_mxbt].outtype = arg_outtype
- //outwaremx[it_mxbt].mtrlcuscode = arg_mtrlcuscode
- //
- //outwaremx[it_mxbt].enprice = arg_fprice
- //outwaremx[it_mxbt].rebate = arg_rebate
- //outwaremx[it_mxbt].fprice = Round(arg_fprice * mrate,10)
- //outwaremx[it_mxbt].price = Round(arg_fprice * mrate * arg_rebate,10)
- //
- //outwaremx[it_mxbt].sptid = i_sptid
- //outwaremx[it_mxbt].dxflag = i_dxflag
- //
- //outwaremx[it_mxbt].ifrel = arg_ifrel
- //outwaremx[it_mxbt].relid = arg_relid
- //outwaremx[it_mxbt].relprintid = arg_relprintid
- //outwaremx[it_mxbt].relid2 = arg_relid2
- //
- //outwaremx[it_mxbt].olmtrlid = arg_olmtrlid
- //outwaremx[it_mxbt].packqty = arg_packqty
- //outwaremx[it_mxbt].woodcode = i_woodcode
- //outwaremx[it_mxbt].pcode = i_pcode
- //outwaremx[it_mxbt].relcode = ls_relcode
- //outwaremx[it_mxbt].formula = arg_formula
- //
- //outwaremx[it_mxbt].unit = arg_unit
- //outwaremx[it_mxbt].rate = arg_rate
- //outwaremx[it_mxbt].qty = Round(arg_qty * arg_rate,5)
- //
- //IF arg_qty <> 0 THEN
- // outwaremx[it_mxbt].ware_enprice = Round((arg_fprice * arg_qty)/Round(arg_qty * arg_rate ,5),10)
- // outwaremx[it_mxbt].ware_fprice = Round((arg_fprice * arg_qty)/Round(arg_qty * arg_rate ,5),10) * mrate
- // outwaremx[it_mxbt].ware_price = Round((arg_fprice * arg_qty)/Round(arg_qty * arg_rate ,5),10) * mrate * arg_rebate
- //ELSE
- // outwaremx[it_mxbt].ware_enprice = arg_fprice
- // outwaremx[it_mxbt].ware_fprice = Round(arg_fprice * mrate,10)
- // outwaremx[it_mxbt].ware_price = Round(arg_fprice * mrate * arg_rebate,10)
- //END IF
- //
- //ext:
- //IF rslt = 0 THEN
- // p_clearmx()
- // arg_msg = billname + ',' + arg_msg
- //END IF
- //RETURN rslt
- end function
- public function integer acceptmx (s_outwaremx s_mx, ref string arg_msg);/*
- s_mx.mtrlwareid = dw_child.Object.u_outwaremx_mtrlwareid[i]
- s_mx.uqty = dw_child.Object.u_outwaremx_qty[i]
- s_mx.addqty = dw_child.Object.u_outwaremx_addqty[i]
- s_mx.enprice = dw_child.Object.u_outwaremx_fprice[i]
- s_mx.rebate = 1
- s_mx.mxdscrp = dw_child.Object.u_outwaremx_mxdscrp[i]
- s_mx.printid = dw_child.Object.printid[i]
- s_mx.ifrel = 0
- s_mx.relid = 0
- s_mx.relprintid = 0
- s_mx.relid2 = 0
- s_mx.olmtrlid = 0
- s_mx.packqty = 0
- s_mx.outtype = 0
- s_mx.unit = dw_child.Object.u_mtrldef_unit[i]
- s_mx.rate = 1
- s_mx.mtrlcuscode = ''
- s_mx.formula = dw_child.Object.u_outwaremx_formula[i]
- */
- Long rslt = 1,cnt = 0,ll_i
- Long i_mtrlid,i_storageid,i_sptid
- Int i_dxflag,li_mtrlkind
- String i_plancode,i_mtrlcode,i_status,i_woodcode,i_pcode,i_mtrlname
- Decimal i_planprice,ld_dftsaleprice, lde_lmsaleprice
- Double i_cost,i_newprice
- Decimal i_notauditqty,i_allouseqty,i_noallocaddqty
- String ls_relcode
- Decimal lde_packqty
- Decimal lde_upsalerate
- Decimal lde_upsaleqty
- Decimal lde_upscllrate
- Decimal lde_upscllqty
- Decimal lde_cost_notax
- If it_newbegin = False And it_updatebegin = False Then
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- Goto ext
- End If
- //清除空值
- s_mx.uqty = s_mx.qty //历史原因,数组传入的是s_mx.qty
- s_mx.enprice = s_mx.fprice //同上
- If IsNull(s_mx.mtrlwareid) Then s_mx.mtrlwareid = 0
- If IsNull(s_mx.printid) Then s_mx.printid = 0
- If IsNull(s_mx.uqty) Then s_mx.uqty = 0
- If IsNull(s_mx.saleqty) Then s_mx.saleqty = 0
- If IsNull(s_mx.addqty) Then s_mx.addqty = 0
- If IsNull(s_mx.enprice) Then s_mx.enprice = 0
- If IsNull(s_mx.tax) Then s_mx.tax = 0
- If IsNull(s_mx.rebate) Then s_mx.rebate = 0
- If IsNull(s_mx.rate) Or s_mx.rate = 0 Then s_mx.rate = 1
- If IsNull(s_mx.unit) Then s_mx.unit = ''
- If IsNull(s_mx.mxdscrp) Then s_mx.mxdscrp = ''
- If IsNull(s_mx.ifrel) Then s_mx.ifrel = 0
- If IsNull(s_mx.relid) Then s_mx.relid = 0
- If IsNull(s_mx.relprintid) Then s_mx.relprintid = 0
- If IsNull(s_mx.relid2) Then s_mx.relid2 = 0
- If IsNull(s_mx.olmtrlid) Then s_mx.olmtrlid = 0
- If IsNull(s_mx.packqty) Then s_mx.packqty = 0
- If IsNull(s_mx.outtype) Then s_mx.outtype = 0
- If IsNull(s_mx.mtrlcuscode) Then s_mx.mtrlcuscode = ''
- If IsNull(s_mx.formula) Then s_mx.formula = ''
- If IsNull(s_mx.mxdscrp2) Then s_mx.mxdscrp2 = ''
- If IsNull(s_mx.net_weight) Then s_mx.net_weight = 0
- If IsNull(s_mx.gross_weight) Then s_mx.gross_weight = 0
- If IsNull(s_mx.cubage) Then s_mx.cubage = 0
- If IsNull(s_mx.mxdscrp3) Then s_mx.mxdscrp3 = ''
- If IsNull(s_mx.mxdscrp4) Then s_mx.mxdscrp4 = ''
- If IsNull(s_mx.priceformula) Then s_mx.priceformula = ''
- If IsNull(s_mx.enamt_tax) Then s_mx.enamt_tax = 0 //税金
- If IsNull(s_mx.enprice_notax) Then s_mx.enprice_notax = 0 //不含税单价
- If IsNull(s_mx.otherprice) Then s_mx.otherprice = 0
- If IsNull(s_mx.status) Then s_mx.status = ''
- If IsNull(s_mx.woodcode) Then s_mx.woodcode = ''
- If IsNull(s_mx.pcode) Then s_mx.pcode = ''
- If s_mx.enprice_notax = 0 Then
- s_mx.enprice_notax = s_mx.enprice / (1 + s_mx.tax)
- End If
- s_mx.uqty = Round(s_mx.uqty,5)
- s_mx.addqty = Round(s_mx.addqty,5)
- If sys_option_outware_if_saleqty = 1 And billtype = 1 Then //销售 , 销售数与出仓数分离
- Else //不分离
- s_mx.saleqty = s_mx.uqty
- End If
- // 如果出仓数量为 0,或物料编号为空,则不作任何处理
- If s_mx.mtrlwareid = 0 Or (s_mx.addqty = 0 And s_mx.uqty = 0 And s_mx.addqty = 0) Then
- rslt = 1
- Goto ext
- End If
- //检查成本价调整单
- cnt = 0
- Select count(*)
- Into :cnt
- From u_updatecost,u_updatecostmx
- Where u_updatecost.wareid = u_updatecostmx.wareid And
- u_updatecost.flag = 0 And
- u_updatecostmx.mtrlwareid = :s_mx.mtrlwareid And
- u_updatecost.scid = :scid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行,编码["+i_mtrlcode+"]查询成本价调整单操作失败"
- Goto ext
- End If
- If cnt > 0 Then
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行,编码["+i_mtrlcode+"]已开成本价调整单,请先审核"
- Goto ext
- End If
- //检查物料库存ID
- Select u_mtrlware.mtrlid,
- u_mtrlware.storageid,
- u_mtrlware.plancode,
- u_mtrlware.status,
- u_mtrlware.cost,
- u_mtrldef.planprice,
- u_mtrldef.lmsaleprice,
- u_mtrldef.mtrlcode,
- u_mtrldef.mtrlname,
- u_mtrldef.packqty,
- u_mtrlware.sptid,
- u_mtrlware.dxflag,
- u_mtrlware.woodcode,
- u_mtrlware.pcode,
- isnull(uv_mtrlware_noauditingqty.noauditingqty,0),
- u_mtrlware.noallocqty,
- u_mtrlware.noallocaddqty,
- u_mtrldef.upsalerate,
- u_mtrldef.upsaleqty,
- u_mtrldef.upscllrate,
- u_mtrldef.upscllqty,
- u_mtrlware.cost_notax
- Into :i_mtrlid,
- :i_storageid,
- :i_plancode,
- :i_status,
- :i_cost,
- :i_planprice,
- :lde_lmsaleprice,
- :i_mtrlcode,
- :i_mtrlname,
- :lde_packqty,
- :i_sptid,
- :i_dxflag,
- :i_woodcode,
- :i_pcode,
- :i_notauditqty,
- :i_allouseqty,
- :i_noallocaddqty,
- :lde_upsalerate,
- :lde_upsaleqty,
- :lde_upscllrate,
- :lde_upscllqty,
- :lde_cost_notax
- From u_mtrlware left Outer join uv_mtrlware_noauditingqty
- on ( u_mtrlware.mtrlwareid = uv_mtrlware_noauditingqty.mtrlwareid)
- And ( u_mtrlware.scid = uv_mtrlware_noauditingqty.scid) Inner JOIN
- u_mtrldef ON ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
- Where ( u_mtrlware.scid = :scid )
- And ( u_mtrlware.mtrlwareid = :s_mx.mtrlwareid )
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行,查询操作失败,库存信息错误"
- Goto ext
- End If
- //IF IsNull(ld_dftsaleprice) THEN ld_dftsaleprice = 0
- If IsNull(i_cost) Then i_cost = 0
- If IsNull(i_mtrlid) Then i_mtrlid = 0
- If IsNull(i_plancode) Then i_plancode = ''
- If IsNull(i_status) Then i_status = ''
- If IsNull(i_woodcode) Then i_woodcode = ''
- If IsNull(i_pcode) Then i_pcode = ''
- If IsNull(i_storageid) Then i_storageid = 0
- If IsNull(i_planprice) Then i_planprice = 0
- If IsNull(i_sptid) Then i_sptid = 0
- If IsNull(i_dxflag) Then i_dxflag = 0
- If IsNull(lde_cost_notax) Then lde_cost_notax = 0
- /////////////////检查辅数//////////////////// //
- If sys_option_addqty = 1 And i_noallocaddqty <> 0 Then //辅数限制
- If s_mx.addqty = 0 And billtype <> 9 Then
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,出仓时必须录入辅数。'
- Goto ext
- End If
-
- If (i_noallocaddqty = s_mx.addqty) And (i_allouseqty <> s_mx.uqty) Then
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存辅数全部出仓时,库存数量应全部出仓.'
- Goto ext
- End If
-
- If (i_allouseqty = s_mx.uqty) And (i_noallocaddqty <> s_mx.addqty) Then
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,['+i_mtrlcode+' '+i_mtrlname+']在库存中使用了辅数,当库存数量全部出仓时,库存辅数应全部出仓.'
- Goto ext
- End If
- End If
- If sys_option_hide_ware = 0 Then
- If billtype = 1 Then
-
- Int li_if_cus_mtrlware
- Select balctype Into :li_if_cus_mtrlware
- From u_storage
- Where storageid = :storageid Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询仓库是否使用客户库存失败'
- rslt = 0
- Goto ext
- End If
-
-
- If li_if_cus_mtrlware = 1 Then
- If thflag = 0 And sys_option_outware_ifpublware = 0 Then //发货时, 系统选项是否可用公共库存, 否则必须是客户库存
- If cusid <> i_sptid Then
- rslt = 0
- arg_msg = "明细纪录对应的库存不是该客户的库存!"
- Goto ext
- End If
- Else //退货时,可退会该客户库存,也可以退货非客户库存; 但不能退给其他客户库存
- If cusid <> i_sptid And i_sptid <> 0 Then
- rslt = 0
- arg_msg = "明细纪录对应的库存不是该客户或无客户的库存!"
- Goto ext
- End If
- End If
- End If
-
-
- End If
-
-
-
- //数量相关的检查
- //*****检查大于未开数不可以开单
- If billtype <> 9 Then //盘亏单不检查
- If flag = 0 Then
-
- Decimal ld_mx_qty //本单当前累计数量
- Decimal ol_mtrl_qty = 0 //本单保存前开单数量
- Int ls_noallocflag
-
- If s_mx.uqty > 0 Then
- Select noallocflag Into :ls_noallocflag
- From u_storage
- Where storageid = :storageid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
- Goto ext
- End If
-
- If ls_noallocflag = 1 Then
-
- If it_updatebegin Then //修改
- Select sum(u_outwaremx.qty)
- Into :ol_mtrl_qty
- From u_outwaremx
- Where u_outwaremx.outwareid = :outwareid
- And u_outwaremx.mtrlwareid = :s_mx.mtrlwareid
- And scid = :scid;
- If sqlca.SQLCode <> 0 Then
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,查询原开单数量失败'
- Goto ext
- End If
- If IsNull(ol_mtrl_qty) Then ol_mtrl_qty = 0
- End If //IF it_updatebegin THEN //修改
-
- For ll_i = 1 To it_mxbt
- If s_mx.mtrlwareid = outwaremx[ll_i].mtrlwareid Then
- ld_mx_qty = ld_mx_qty + outwaremx[ll_i].qty
- End If
- Next
-
- If s_mx.rate = 1 Then
- ld_mx_qty = ld_mx_qty + s_mx.uqty
- Else
- ld_mx_qty = ld_mx_qty + Round(s_mx.uqty * s_mx.rate,sys_option_unit_dec_sale) //s_mx.qty
- End If
-
- If ld_mx_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) Then
- // IF ld_mx_qty > ( i_allouseqty + ol_mtrl_qty ) THEN
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,' + String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
- Goto ext
- End If
- End If //IF ls_noallocflag = 1 THEN
- End If //IF s_mx.uqty > 0 THEN
- End If
- End If
- End If
- //***********************************************
- //检查来源单据
- Choose Case billtype
- Case 1
- If s_mx.ifrel > 0 Then
- If flag = 0 Then
- Decimal lde_mx_qty,lde_usaleqty, lde_consignedqty,lde_notauditqty, lde_usaleqty_tol
-
- If s_mx.relid = 0 Then
- arg_msg = '第' + String(s_mx.printid) + '行,请先择相应的订单'
- rslt = 0
- Goto ext
- End If
-
- //查询订单
- Select top 1 taskcode,usaleqty, consignedqty
- Into :ls_relcode,:lde_usaleqty, :lde_consignedqty
- From u_saletaskmx,u_saletask
- Where u_saletaskmx.taskid = :s_mx.relid
- And u_saletaskmx.printid = :s_mx.relprintid
- And u_saletaskmx.scid = :scid
- And u_saletaskmx.scid = u_saletask.scid
- And u_saletaskmx.taskid = u_saletask.taskid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第' + String(s_mx.printid) + '行,查询销售订单是否有订购编码:'+i_mtrlcode+'失败'
- rslt = 0
- Goto ext
- End If
-
- //查询相关订单已开发货单未审核数量
- Select isnull(sum(uqty),0) Into :lde_notauditqty
- From u_outwaremx,u_outware
- Where u_outwaremx.relid = :s_mx.relid
- And u_outwaremx.relprintid = :s_mx.relprintid
- And u_outware.flag = 0
- And u_outwaremx.outwareid = u_outware.outwareid
- And u_outwaremx.scid = u_outware.scid
- And u_outware.outwareid <> :outwareid
- And u_outware.billtype = 1
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '查询销售订单:'+ls_relcode+'产品:'+i_mtrlcode+'已开发货单未审核数量失败'
- rslt = 0
- Goto ext
- End If
-
-
- lde_mx_qty = 0
- For ll_i = 1 To it_mxbt
- If i_mtrlid = outwaremx[ll_i].mtrlid And &
- s_mx.relid = outwaremx[ll_i].relid And &
- s_mx.relprintid = outwaremx[ll_i].relprintid And &
- i_status = outwaremx[ll_i].status And &
- i_woodcode = outwaremx[ll_i].woodcode And &
- i_pcode = outwaremx[ll_i].pcode And &
- (i_plancode = outwaremx[ll_i].plancode or sys_option_saletask_chuange_plancode = 1 )And &
- s_mx.mtrlcuscode = outwaremx[ll_i].mtrlcuscode Then
- lde_mx_qty = lde_mx_qty + outwaremx[ll_i].uqty
- End If
- Next
-
- lde_mx_qty += s_mx.uqty
-
- lde_usaleqty_tol = lde_usaleqty * (1 + lde_upsalerate) + lde_upsaleqty //增加可超比例
- If lde_usaleqty_tol < lde_consignedqty + lde_notauditqty + lde_mx_qty Then
- arg_msg = '订单:'+ls_relcode+' 产品:'+i_mtrlcode+'未发货数:'+String(lde_usaleqty - lde_consignedqty ,'#,##0.##########')
- If lde_usaleqty_tol - lde_usaleqty <> 0 Then
- arg_msg += ',可超数:'+String(lde_usaleqty_tol - lde_usaleqty,'#,##0.##########') + ',总可发数:'+String(lde_usaleqty_tol - lde_consignedqty ,'#,##0.##########')
- End If
- If lde_notauditqty <> 0 Then
- arg_msg += ',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')
- End If
- arg_msg += ',不能再开单:'+String(lde_mx_qty,'#,##0.##########')
- rslt = 0
- Goto ext
- End If
-
- End If
- End If
- Case 3
- If s_mx.ifrel = 1 Then
- If s_mx.relid = 0 Then
- arg_msg = '第' + String(s_mx.printid) + '行,请先择相应的订单'
- rslt = 0
- Goto ext
- End If
-
- Select taskcode Into :ls_relcode
- From u_saletask Where taskid = :s_mx.relid
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第' + String(s_mx.printid) + '行,查询销售订单号失败!'
- rslt = 0
- Goto ext
- End If
-
- If s_mx.relid2 > 0 Then //检查订单运算
- Select count(*)
- Into :cnt
- From u_saleRqMtrl_scll
- Where scid = :scid
- And taskid = :s_mx.relid
- And printid = :s_mx.relprintid
- And rqmtrlid = :s_mx.relid2
- Using commit_transaction;
- If commit_transaction.SQLCode <> 0 Then
- arg_msg = '第' + String(s_mx.printid) + '行,查询销售订单信息失败!'
- rslt = 0
- Goto ext
- End If
-
- If cnt <> 1 Then
- arg_msg = '第' + String(s_mx.printid) + '行,物料销售订单运算结果不存在或重复!'
- rslt = 0
- Goto ext
- End If
- End If
- End If
-
- End Choose
- //价格相关的检查
- If billtype = 1 Then
- f_get_defsaleprice(cusid,i_mtrlid,s_mx.unit,i_status,i_pcode,i_woodcode,relint_2,ld_dftsaleprice,s_mx.qty)
- If Not sys_power_issuper And f_power_ind(1399) Then
- If ld_dftsaleprice > 0 And ld_dftsaleprice > s_mx.enprice Then
- rslt = 0
- arg_msg = '用户权限限制, 第' + String(s_mx.printid) + '行,' + String(i_mtrlcode)+" 单价不能低于客户价格表单价,请检查"
- Goto ext
- End If
- End If
-
- //不能低于设定售价
- If Not sys_power_issuper And f_power_ind(1778) Then
- If lde_lmsaleprice > 0 And lde_lmsaleprice > s_mx.enprice Then
- rslt = 0
- arg_msg = '用户权限限制, 第' + String(s_mx.printid) + '行,' + String(i_mtrlcode)+" 单价不能低于设定售价,请检查"
- Goto ext
- End If
- End If
-
- //不能低于库存成本价
- If Not sys_power_issuper And f_power_ind(1600) Then
- If i_cost > 0 And i_cost > s_mx.enprice Then
- rslt = 0
- arg_msg = '用户权限限制, 第' + String(s_mx.printid) + '行,' + String(i_mtrlcode)+" 单价不能低于库存成本价,请检查"
- Goto ext
- End If
- End If
-
- Else
- ld_dftsaleprice = 0
- mrate = 1
- End If
- If s_mx.tax < 0 Then
- rslt = 0
- arg_msg = "税率不能为负数"
- Goto ext
- End If
- If s_mx.enprice * s_mx.rebate < 0 Then //检查出仓价
- rslt = 0
- arg_msg = '第' + String(s_mx.printid) + '行,' + String(i_mtrlcode)+" 单价错误"
- Goto ext
- End If
- //**取最新价
- Select price
- Into :i_newprice
- From v_maxprice_sptprice
- Where mtrlid = :i_mtrlid;
- If sqlca.SQLCode <> 0 Or IsNull(i_newprice) Then i_newprice = 0
- s_mx.price = Round(s_mx.enprice * mrate * s_mx.rebate,10) //本位币, 出仓单位, 实价
- If s_mx.rate = 1 Then
- s_mx.qty = s_mx.uqty
- Else
- s_mx.qty = Round(s_mx.uqty * s_mx.rate,sys_option_unit_dec_sale) //库存单位,出仓数量
- End If
- //写入内容
- it_mxbt++
- outwaremx[it_mxbt].printid = s_mx.printid
- outwaremx[it_mxbt].mtrlwareid = s_mx.mtrlwareid
- outwaremx[it_mxbt].storageid = i_storageid
- outwaremx[it_mxbt].mtrlid = i_mtrlid
- if sys_option_hide_ware = 1 then
- outwaremx[it_mxbt].status = s_mx.status
- outwaremx[it_mxbt].woodcode = s_mx.woodcode
- outwaremx[it_mxbt].pcode = s_mx.pcode
- else
- outwaremx[it_mxbt].status = i_status
- outwaremx[it_mxbt].woodcode = i_woodcode
- outwaremx[it_mxbt].pcode = i_pcode
- end if
- outwaremx[it_mxbt].plancode = i_plancode
- outwaremx[it_mxbt].sptid = i_sptid
- outwaremx[it_mxbt].dxflag = i_dxflag
- outwaremx[it_mxbt].mtrlcode = i_mtrlcode
- outwaremx[it_mxbt].mtrlcuscode = s_mx.mtrlcuscode
- outwaremx[it_mxbt].saleqty = s_mx.saleqty //销售数
- outwaremx[it_mxbt].uqty = s_mx.uqty //出仓数, 出仓单位
- outwaremx[it_mxbt].addqty = s_mx.addqty
- outwaremx[it_mxbt].unit = s_mx.unit
- outwaremx[it_mxbt].rate = s_mx.rate
- outwaremx[it_mxbt].qty = s_mx.qty //库存单位,出仓数量
- outwaremx[it_mxbt].enprice = s_mx.enprice //原币, 出仓单位, 单价, 含税
- outwaremx[it_mxbt].fprice = Round(s_mx.enprice * mrate,10) //本位币 , 出仓单位, 单价, 含税
- outwaremx[it_mxbt].price = s_mx.price //本位币, 出仓单位, 实价, 含税
- outwaremx[it_mxbt].rebate = s_mx.rebate //折扣
- outwaremx[it_mxbt].tax = s_mx.tax //税率
- outwaremx[it_mxbt].enamt = Round(s_mx.saleqty * s_mx.enprice * s_mx.rebate, 2) //原币, 实价含税金额
- If s_mx.enamt_tax = 0 Then
- outwaremx[it_mxbt].enamt_tax = Round((s_mx.saleqty * s_mx.enprice * s_mx.rebate) * s_mx.tax / (1 + s_mx.tax), 2) //原币, 税金
- Else
- outwaremx[it_mxbt].enamt_tax = s_mx.enamt_tax
- End If
- outwaremx[it_mxbt].bsamt = Round(s_mx.saleqty * outwaremx[it_mxbt].fprice * s_mx.rebate, 2) //本位币, 实价含税金额
- outwaremx[it_mxbt].bsamt_tax = Round((s_mx.saleqty * outwaremx[it_mxbt].fprice * s_mx.rebate) * s_mx.tax / (1 + s_mx.tax), 2) //本位币, 税金
- If billtype = 1 Then
- Choose Case sys_option_outware_sale_amt_round
- Case 0 //分
- outwaremx[it_mxbt].enamt = Round(outwaremx[it_mxbt].enamt, 2)
- outwaremx[it_mxbt].enamt_tax = Round(outwaremx[it_mxbt].enamt_tax, 2)
- outwaremx[it_mxbt].bsamt = Round(outwaremx[it_mxbt].bsamt, 2)
- outwaremx[it_mxbt].bsamt_tax = Round(outwaremx[it_mxbt].bsamt_tax, 2)
- Case 1
- outwaremx[it_mxbt].enamt = Round(outwaremx[it_mxbt].enamt, 1)
- outwaremx[it_mxbt].enamt_tax = Round(outwaremx[it_mxbt].enamt_tax, 1)
- outwaremx[it_mxbt].bsamt = Round(outwaremx[it_mxbt].bsamt, 1)
- outwaremx[it_mxbt].bsamt_tax = Round(outwaremx[it_mxbt].bsamt_tax, 1)
- Case 2
- outwaremx[it_mxbt].enamt = Round(outwaremx[it_mxbt].enamt, 0)
- outwaremx[it_mxbt].enamt_tax = Round(outwaremx[it_mxbt].enamt_tax, 0)
- outwaremx[it_mxbt].bsamt = Round(outwaremx[it_mxbt].bsamt, 0)
- outwaremx[it_mxbt].bsamt_tax = Round(outwaremx[it_mxbt].bsamt_tax, 0)
- Case 3
- outwaremx[it_mxbt].enamt = Round(outwaremx[it_mxbt].enamt / 10, 0) * 10
- outwaremx[it_mxbt].enamt_tax = Round(outwaremx[it_mxbt].enamt_tax / 10, 0) * 10
- outwaremx[it_mxbt].bsamt = Round(outwaremx[it_mxbt].bsamt / 10, 0) * 10
- outwaremx[it_mxbt].bsamt_tax = Round(outwaremx[it_mxbt].bsamt_tax / 10, 0) * 10
- Case 4
- outwaremx[it_mxbt].enamt = Round(outwaremx[it_mxbt].enamt / 100, 0) * 100
- outwaremx[it_mxbt].enamt_tax = Round(outwaremx[it_mxbt].enamt_tax / 100, 0) * 100
- outwaremx[it_mxbt].bsamt = Round(outwaremx[it_mxbt].bsamt / 100, 0) * 100
- outwaremx[it_mxbt].bsamt_tax = Round(outwaremx[it_mxbt].bsamt_tax / 100, 0) * 100
- End Choose
- End If
- If s_mx.saleqty <> 0 Then
- outwaremx[it_mxbt].ware_enprice = Round((s_mx.enprice * s_mx.saleqty)/Round(s_mx.saleqty * s_mx.rate ,5),10) //原币,库存单位,单价
- outwaremx[it_mxbt].ware_fprice = Round((s_mx.enprice * s_mx.saleqty)/Round(s_mx.saleqty * s_mx.rate ,5),10) * mrate //本位币,库存单位,单价
- outwaremx[it_mxbt].ware_price = Round((s_mx.enprice * s_mx.saleqty)/Round(s_mx.saleqty * s_mx.rate ,5),10) * mrate * s_mx.rebate //本位币,库存单位,实价
- Else
- outwaremx[it_mxbt].ware_enprice = s_mx.enprice
- outwaremx[it_mxbt].ware_fprice = Round(s_mx.enprice * mrate,10)
- outwaremx[it_mxbt].ware_price = Round(s_mx.enprice * mrate * s_mx.rebate,10)
- End If
- outwaremx[it_mxbt].ware_amt = outwaremx[it_mxbt].bsamt //本位币,实价金额 //无用的
- outwaremx[it_mxbt].cost = i_cost
- outwaremx[it_mxbt].cost_notax = lde_cost_notax
- outwaremx[it_mxbt].costamt = Round(i_cost * s_mx.qty, 2)
- outwaremx[it_mxbt].costamt_notax = Round(lde_cost_notax * s_mx.qty, 2)
- outwaremx[it_mxbt].newpriceamt = Round(i_newprice * s_mx.qty, 2 )
- outwaremx[it_mxbt].dftsaleprice = ld_dftsaleprice
- outwaremx[it_mxbt].planprice = i_planprice
- outwaremx[it_mxbt].ifrel = s_mx.ifrel
- outwaremx[it_mxbt].relid = s_mx.relid
- outwaremx[it_mxbt].relprintid = s_mx.relprintid
- outwaremx[it_mxbt].relid2 = s_mx.relid2
- outwaremx[it_mxbt].relcode = ls_relcode
- outwaremx[it_mxbt].olmtrlid = s_mx.olmtrlid
- outwaremx[it_mxbt].packqty = s_mx.packqty
- outwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
- outwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2
- outwaremx[it_mxbt].outtype = s_mx.outtype
- outwaremx[it_mxbt].formula = s_mx.formula
- outwaremx[it_mxbt].net_weight = s_mx.net_weight
- outwaremx[it_mxbt].gross_weight = s_mx.gross_weight
- outwaremx[it_mxbt].cubage = s_mx.cubage
- outwaremx[it_mxbt].mxdscrp3 = s_mx.mxdscrp3
- outwaremx[it_mxbt].mxdscrp4 = s_mx.mxdscrp4
- outwaremx[it_mxbt].enprice_notax = s_mx.enprice_notax //不含税单价
- outwaremx[it_mxbt].priceformula = s_mx.priceformula
- outwaremx[it_mxbt].otherprice = s_mx.otherprice
- ext:
- If rslt = 0 Then
- p_clearmx()
- arg_msg = billname + ',' + arg_msg
- End If
- Return rslt
- end function
- public function integer uf_chk_updatecost (ref string arg_msg);//撤审限制,迟于本出仓单审核时间的成本价调整单审核后本出仓单不能撤审
- //否则单价会出现错误;
- int rslt = 1
- Long i, ll_count
- FOR i = 1 TO it_mxbt
- ll_count = 0
- SELECT count(*)
- INTO :ll_count
- FROM u_updatecostmx,
- u_updatecost
- WHERE ( u_updatecostmx.scid = u_updatecost.scid ) AND
- ( u_updatecost.wareid = u_updatecostmx.wareid) AND
- ( u_updatecost.flag = 1 ) AND
- ( u_updatecostmx.mtrlwareid = :outwaremx[i].mtrlwareid) AND
- ( u_updatecostmx.scid = :scid) and
- ( u_updatecost.Auditingdate > :Auditingdate ) USING commit_transaction;
- IF sqlca.SQLCode = 0 THEN
- IF ll_count > 0 THEN
- rslt = 0
- arg_msg = '第'+ string(i) +'行,' + outwaremx[i].mtrlcode + "已调整成本价,不能撤审,涉及成本价调整单数量:" + string(ll_count)
- GOTO ext
- END IF
- ELSE
- rslt = 0
- arg_msg = '第'+ string(i) +'行,' + outwaremx[i].mtrlcode + "查询成本价调整单失败"
- GOTO ext
- END IF
- NEXT
- ext:
- return rslt
- end function
- public function integer uof_check_warepdb_audit (long arg_storageid, ref string arg_msg);//如果有盘点表未审核 , 则不能审核通过
- Int rslt = 1
- Long cnt
- SELECT count(*)
- INTO :cnt
- FROM u_warepdb
- WHERE storageid = :arg_storageid
- And flag = 0 Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询仓库是否有盘点表未审核失败,'+commit_transaction.SQLErrText
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = '仓库有盘点表未审核,不能仓审或仓撤单据,请检查'
- GOTO ext
- END IF
- ext:
- RETURN rslt
- end function
- public function integer auditing_chk (ref string arg_msg);//uo_outware_sale 重写
- //uo_outware_scll 重写
- long rslt = 1
- IF sys_option_hide_ware = 0 THEN
- IF billtype <> 9 And &
- Not (billtype = 3 And Pos(dscrp,'盘点表审核盘亏自动生成生产领料单') > 0) THEN
- IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF Not sysautobuild THEN
- IF dscrp = '盘点表审核自动生成盘亏单' &
- or dscrp = '盘点表审核盘亏自动生成生产领料单' THEN
- arg_msg = '系统自动生成的单据不能手动审核'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- ext:
- return rslt
- end function
- public function integer auditing_end (ref string arg_msg);long rslt = 1
- return rslt
- end function
- public function integer c_auditing_chk (ref string arg_msg);//uo_outware_sale 重写
- long rslt = 1
- IF sys_option_hide_ware = 0 THEN
- IF billtype <> 9 And &
- Not (billtype = 3 And Pos(dscrp,'盘点表审核盘亏自动生成生产领料单') > 0) THEN
- IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- IF Not sysautobuild THEN
- IF dscrp = '盘点表审核自动生成盘亏单' &
- or dscrp = '盘点表审核盘亏自动生成生产领料单' THEN
- arg_msg = '系统自动生成的单据不能手动撤审'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- ext:
- return rslt
- end function
- public function integer c_auditing_end (ref string arg_msg);long rslt = 1
- return rslt
- end function
- public function integer save_end (ref string arg_msg);long rslt = 1
- return rslt
- end function
- public function integer save_chk (ref string arg_msg);
- long rslt = 1
- long cnt
- //未注册限制
- IF sys_if_register = 0 THEN
- Long ll_bill_count
- SELECT count(*)
- INTO :ll_bill_count
- From u_outware;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,单据数量 "
- GOTO ext
- END IF
-
- IF ll_bill_count > 100 THEN //我
- rslt = 0
- arg_msg = "未注册版本,出仓单只能保存100张! "
- GOTO ext
- END IF
- END IF
- //SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- ////取得系统时间,借用操作员表
- //IF commit_transaction.SQLCode <> 0 THEN
- // rslt = 0
- // arg_msg = "查询操作失败,日期 "
- // GOTO ext
- //END IF
- IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
- rslt = 0
- arg_msg = "没有正确出仓内容"
- GOTO ext
- END IF
- //cnt = 0
- //检查仓库
- SELECT balctype INTO :if_cus_mtrlware
- FROM u_storage
- Where storageid = :storageid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询仓库是否使用客户库存失败'
- rslt = 0
- GOTO ext
- END IF
-
- //IF Year(Date(outdate)) < 2000 Or IsNull(outdate) THEN
- // rslt = 0
- // arg_msg = "缺少出仓发生时间或不合理"
- // GOTO ext
- //END IF
- //====================================================================
- //// Script - save ( boolean arg_ifcommit, ref string arg_msg )
- //// Reason:
- ////--------------------------------------------------------------------
- //// Modified By: yyx Date: 2004.01.02
- ////--------------------------------------------------------------------
- //IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(outdate,'yyyy-mm-dd'))) > sys_option_input_days THEN
- // rslt = 0
- // arg_msg = '出仓日期错误,日期不能超前系统日期'
- // GOTO ext
- //END IF
- //
- //IF DaysAfter(Date(String(outdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN
- // rslt = 0
- // arg_msg = '出仓日期错误,日期不能落后系统日期'
- // GOTO ext
- //END IF
- IF not (billtype = 1 and flag = 1 and secflag = 0) THEN
- IF f_check_inoutdate(storageid,outdate,True,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- end if
- //====================================================================
- IF billtype = 1 THEN
- SELECT name INTO :cusname
- FROM u_cust
- Where cusid = :cusid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,客户资料"
- GOTO ext
- END IF
-
- IF relint_1 = 0 THEN
- arg_msg = '请选择结算方式'
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- SELECT count(*) INTO :cnt
- FROM cw_currency
- Where moneyid = :relint_2;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询币种失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF cnt = 0 THEN
- arg_msg = '币种资料不存在'
- rslt = 0
- GOTO ext
- END IF
-
- IF mrate = 0 THEN
- arg_msg = '币种汇率错误'
- rslt = 0
- GOTO ext
- END IF
-
- IF mrate = 0 THEN
- arg_msg = '币种汇率错误'
- rslt = 0
- GOTO ext
- END IF
-
- cnt = 0
- select COUNT(*) into :cnt //检查未结清的发货单
- from u_outware inner join u_cust
- on u_outware.cusid=u_cust.cusid LEFT OUTER JOIN u_Bmsttake
- ON u_outware.relint_3=u_Bmsttake.takeid
- where u_cust.cusid=:cusid and isnull(u_Bmsttake.finishflag,0)=0
- and u_outware.outdate<Dateadd(day,(0 - u_cust.bmstday),GETDATE()) ;
- IF cnt > 0 and sys_option_sale_outware_bmstday=1 THEN //系统选项
- arg_msg = '收款周期前有未结清的销售发货单'
- rslt = 0
- GOTO ext
- END IF
-
- ELSEIF billtype = 3 THEN
- IF relid = 0 THEN
- arg_msg = '请选择领料工作中心'
- rslt = 0
- GOTO ext
- END IF
-
- ELSEIF billtype = 4 THEN
- SELECT name INTO :cusname
- FROM u_spt
- Where sptid = :cusid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,加工商资料"
- GOTO ext
- END IF
- ELSEIF billtype = 8 THEN
- IF Trim(cusname) = '' Or IsNull(cusname) THEN
- rslt = 0
- arg_msg = "请输入出仓原因!"
- GOTO ext
- END IF
- ELSEIF billtype = 9 THEN
- IF Trim(cusname) = '' Or IsNull(cusname) THEN
- cusname = "盘亏"
- END IF
- END IF
- ext:
- return rslt
- end function
- public subroutine uf_get_billname (integer arg_billtype);CHOOSE CASE arg_billtype
- CASE 1
- billname = '销售单'
- CASE 2
- billname = '销售单'
- CASE 3
- billname = '领料出仓单'
- CASE 4
- billname = '外协发出仓'
- CASE 8
- billname = '其他进仓单'
- CASE 9
- billname = '盘亏出仓单'
- CASE 10 //人事
- billname = '工具出仓单'
- CASE 12
- billname = '调拨出仓单'
- CASE 15
- billname = '拆装出仓单'
- END CHOOSE
- end subroutine
- public function integer uf_w_cmp_fifo_cb_bill (long ll_scid, long ll_mtrlwareid, boolean arg_ifcommit, ref string arg_msg);//
- Long rslt = 1
- Long contractcnt,i
- datastore ds
- //ll_row = dw_1.GetRow()
- //IF ll_row <= 0 THEN RETURN
- //
- //
- //
- //ll_scid = dw_1.Object.u_mtrlware_scid[ll_row]
- //ll_mtrlwareid = dw_1.Object.u_mtrlware_mtrlwareid[ll_row]
- //
- //IF ll_mtrlwareid <= 0 THEN RETURN
- ds = Create datastore
- ds.DataObject = "ddds_cs_cmp_xjxc"
- ds.SetTransObject(commit_transaction)
- contractcnt = ds.Retrieve(ll_scid,ll_mtrlwareid)
- //MessageBox('',String(contractcnt))
- DELETE u_mtrlware_inmx Where scid = :ll_scid And mtrlwareid = :ll_mtrlwareid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除库存进仓批失败"
- GOTO ext
- END IF
- Long ll_inwareid,ll_printid
- DateTime dt_indate
- String ls_inwarecode
- Decimal dec_inqty
- Decimal dec_inprice,dec_inprice_notax
- FOR i = 1 To contractcnt
- ll_inwareid = 0
- ll_printid = 0
- ls_inwarecode = ''
- dec_inqty = 0
- dec_inprice = 0
-
- ll_inwareid = ds.Object.inwareid[i]
- ll_printid = ds.Object.printid[i]
- dt_indate = ds.Object.inwaredate[i]
- ls_inwarecode = ds.Object.inwarecode[i]
- dec_inqty = ds.Object.inqty[i]
- dec_inprice = ds.Object.inprice[i]
- dec_inprice_notax = ds.Object.inprice_notax[i]
-
- IF f_add_mtrlware_inmx(ll_scid,ll_mtrlwareid,ll_inwareid,ll_printid,ls_inwarecode,dt_indate,dec_inqty,dec_inprice,dec_inprice_notax,0,False,commit_transaction,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- IF f_cmp_fifo_cb_mtrlware(ll_scid,ll_mtrlwareid,False,commit_transaction,arg_msg) = 0 THEN
- rslt = 0
-
- END IF
- ext:
- //IF rslt = 0 THEN
- // ROLLBACK Using commit_transaction;
- //
- //
- //ELSEIF rslt = 1 And arg_ifcommit THEN
- // COMMIT Using commit_transaction;
- //END IF
- RETURN rslt
- end function
- public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
- Int rslt = 1,cnt = 0
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF billtype = 1 THEN
- IF secflag = 0 THEN
- rslt = 0
- arg_msg = "单据没有财审"
- GOTO ext
- END IF
- ELSE
-
- IF flag = 0 THEN
- rslt = 0
- arg_msg = "单据没有仓审"
- GOTO ext
- END IF
- END IF
- IF cwauditingflag = 1 THEN
- rslt = 0
- arg_msg = "单据已经总账审核"
- GOTO ext
- END IF
- UPDATE u_outware
- SET cwauditingflag = 1,
- cwauditingdate = getdate(),
- cwauditingrep = :publ_operator
- WHERE ( u_outware.outwareid = :arg_billid ) AND
- ( u_outware.scid = :arg_scid) Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致总账审核操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK Using commit_transaction;
- GOTO ext
- END IF
- ext:
- IF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- Return (rslt)
- end function
- public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
- Int rslt = 1,cnt = 0
- IF arg_billid = 0 THEN
- rslt = 0
- arg_msg = "没有审核对象"
- GOTO ext
- END IF
- IF p_getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- IF cwauditingflag = 0 THEN
- rslt = 0
- arg_msg = "单据没有总账审核"
- GOTO ext
- END IF
- UPDATE u_outware
- SET cwauditingflag = 0,
- cwauditingdate =null,
- cwauditingrep = ''
- WHERE ( u_outware.outwareid = :arg_billid ) AND
- ( u_outware.scid = :arg_scid) Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "因网络或其它原因导致总账撤审操作失败"+"~n"+commit_transaction.SQLErrText
- ROLLBACK Using commit_transaction;
- GOTO ext
- END IF
- ext:
- IF arg_ifcommit And rslt = 1 THEN
- COMMIT Using commit_transaction;
- END IF
- Return (rslt)
- end function
- public function integer p_update_cost (ref s_outwaremx arg_s_mx, ref decimal arg_ref_costamt, ref decimal arg_ref_costamt_notax, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_cost, lde_wareamt,lde_noallocqty
- Int li_mtrlorigin
- Dec lde_newprice
- Decimal ld_cost_notax, lde_wareamt_notax
- SELECT cost, wareamt, noallocqty,cost_notax,wareamt_notax INTO :ld_cost, :lde_wareamt,:lde_noallocqty,:ld_cost_notax,:lde_wareamt_notax
- FROM u_mtrlware
- WHERE scid = :scid
- AND storageid = :storageid
- AND mtrlwareid = :arg_s_mx.mtrlwareid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_s_mx.mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- arg_ref_costamt = Round(ld_cost * arg_s_mx.qty ,2)
- arg_ref_costamt_notax = Round(ld_cost_notax * arg_s_mx.qty ,2)
- IF thflag = 0 THEN
- //修正全部出仓时库存金额还有小数
- //修正部分出仓时库存金额小于本次出仓金额
- IF lde_noallocqty = arg_s_mx.qty or arg_ref_costamt > lde_wareamt THEN
- //IF lde_noallocqty = arg_s_mx.qty THEN
- arg_ref_costamt = lde_wareamt
- IF arg_s_mx.qty <> 0 THEN
- ld_cost = Round(lde_wareamt / arg_s_mx.qty,sys_option_cost_dec)
- END IF
- ELSE
- ld_cost = Round(ld_cost,sys_option_cost_dec)
- END IF
- //修正不含税成本价
- IF lde_noallocqty = arg_s_mx.qty or arg_ref_costamt_notax > lde_wareamt_notax THEN
- arg_ref_costamt_notax = lde_wareamt_notax
- IF arg_s_mx.qty <> 0 THEN
- ld_cost_notax = Round(lde_wareamt_notax / arg_s_mx.qty,sys_option_cost_dec)
- END IF
- ELSE
- ld_cost_notax = Round(ld_cost_notax,sys_option_cost_dec)
- END IF
- END IF
- //如果系负数出仓(即进仓),成本价为0时,自制/外协取计划价; 采购取最新采购价;
- //继续为0时,权限判断是否能审
- IF arg_s_mx.qty < 0 THEN
- IF ld_cost = 0 THEN
- SELECT mtrlorigin
- INTO :li_mtrlorigin
- FROM u_mtrldef
- WHERE mtrlid = :arg_s_mx.mtrlid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_s_mx.mtrlcode+'信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF li_mtrlorigin = 2 THEN
- SELECT price
- INTO :lde_newprice
- FROM v_maxprice_sptprice_dftunit
- WHERE mtrlid = :arg_s_mx.mtrlid
- AND status = :arg_s_mx.status
- AND woodcode = :arg_s_mx.woodcode
- AND pcode = :arg_s_mx.pcode
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- lde_newprice = 0
- END IF
- IF IsNull(lde_newprice) THEN lde_newprice = 0
- ELSE
- lde_newprice = f_get_planprice(arg_s_mx.mtrlid, arg_s_mx.status,arg_s_mx.woodcode,arg_s_mx.pcode,True)
- END IF
-
- IF lde_newprice > 0 THEN
- ld_cost = lde_newprice
- arg_ref_costamt = Round(ld_cost * arg_s_mx.qty ,2)
- ELSE
- IF Not sys_power_issuper And f_power_ind(1635) THEN
- arg_msg = '用户特殊权限[限制出仓单负数开单时成本价为0不能审核]限制,不能操作'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- arg_s_mx.costamt = arg_ref_costamt
- arg_s_mx.cost = ld_cost
- arg_s_mx.costamt_notax = arg_ref_costamt_notax
- arg_s_mx.cost_notax = ld_cost_notax
- IF billtype = 1 Or billtype = 2 THEN
- UPDATE u_outwaremx
- SET costamt = :arg_ref_costamt,
- cost = :ld_cost,
- costamt_notax = :arg_ref_costamt_notax,
- cost_notax = :ld_cost_notax
- WHERE scid = :scid
- AND outwareid = :outwareid
- AND printid = :arg_s_mx.printid
- Using commit_transaction;
-
- ELSE
- arg_s_mx.ware_price = ld_cost
- arg_s_mx.ware_fprice = ld_cost / arg_s_mx.rebate
- arg_s_mx.ware_enprice = ld_cost / arg_s_mx.rebate / mrate
- arg_s_mx.price = arg_s_mx.ware_price * arg_s_mx.rate
- arg_s_mx.fprice = arg_s_mx.ware_fprice * arg_s_mx.rate
- arg_s_mx.enprice = arg_s_mx.ware_enprice * arg_s_mx.rate
-
- arg_s_mx.enamt = round(arg_s_mx.uqty * arg_s_mx.enprice * (1 + arg_s_mx.tax) * arg_s_mx.rebate, 2)
- //arg_s_mx.enamt_tax = arg_s_mx.ware_enprice * arg_s_mx.rate //非销售, 0
- arg_s_mx.bsamt = round(arg_s_mx.uqty * arg_s_mx.price * (1 + arg_s_mx.tax) * arg_s_mx.rebate, 2)
- //arg_s_mx.bsamt_tax = arg_s_mx.ware_enprice * arg_s_mx.rate
- UPDATE u_outwaremx
- SET costamt = :arg_ref_costamt,
- cost = :ld_cost,
- costamt_notax = :arg_ref_costamt_notax,
- cost_notax = :ld_cost_notax,
- fprice = :ld_cost,
- enprice = :ld_cost,
- price = :ld_cost,
- ware_fprice = :ld_cost,
- ware_enprice = :ld_cost,
- ware_price = :ld_cost,
- enamt = :arg_s_mx.enamt,
- bsamt = :arg_s_mx.bsamt
- WHERE scid = :scid
- AND outwareid = :outwareid
- AND printid = :arg_s_mx.printid
- Using commit_transaction;
- END IF
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '更新'+arg_s_mx.mtrlcode+'出仓成本价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_update_cost_fifo (ref s_outwaremx arg_s_mx, ref decimal arg_ref_costamt, ref decimal arg_ref_costamt_notax, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
- Decimal ld_cost, lde_wareamt,lde_noallocqty
- Int li_mtrlorigin
- Dec lde_newprice
- Decimal ld_cost_notax, lde_wareamt_notax
- SELECT cost, wareamt, noallocqty,cost_notax,wareamt_notax INTO :ld_cost, :lde_wareamt,:lde_noallocqty,:ld_cost_notax,:lde_wareamt_notax
- FROM u_mtrlware
- WHERE scid = :scid
- AND storageid = :storageid
- AND mtrlwareid = :arg_s_mx.mtrlwareid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_s_mx.mtrlcode+'库存成本价失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- arg_ref_costamt = Round(ld_cost * arg_s_mx.qty ,2)
- arg_ref_costamt_notax = Round(ld_cost_notax * arg_s_mx.qty ,2)
- IF thflag = 0 THEN
- //修正全部出仓时库存金额还有小数
- //修正部分出仓时库存金额小于本次出仓金额
- IF lde_noallocqty = arg_s_mx.qty or arg_ref_costamt > lde_wareamt THEN
- //IF lde_noallocqty = arg_s_mx.qty THEN
- arg_ref_costamt = lde_wareamt
- IF arg_s_mx.qty <> 0 THEN
- ld_cost = Round(lde_wareamt / arg_s_mx.qty,sys_option_cost_dec)
- END IF
- ELSE
- ld_cost = Round(ld_cost,sys_option_cost_dec)
- END IF
- //修正不含税成本价
- IF lde_noallocqty = arg_s_mx.qty or arg_ref_costamt_notax > lde_wareamt_notax THEN
- arg_ref_costamt_notax = lde_wareamt_notax
- IF arg_s_mx.qty <> 0 THEN
- ld_cost_notax = Round(lde_wareamt_notax / arg_s_mx.qty,sys_option_cost_dec)
- END IF
- ELSE
- ld_cost_notax = Round(ld_cost_notax,sys_option_cost_dec)
- END IF
- END IF
- //如果系负数出仓(即进仓),成本价为0时,自制/外协取计划价; 采购取最新采购价;
- //继续为0时,权限判断是否能审
- IF arg_s_mx.qty < 0 THEN
- IF ld_cost = 0 THEN
- SELECT mtrlorigin
- INTO :li_mtrlorigin
- FROM u_mtrldef
- WHERE mtrlid = :arg_s_mx.mtrlid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = '查询'+arg_s_mx.mtrlcode+'信息失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- IF li_mtrlorigin = 2 THEN
- SELECT price
- INTO :lde_newprice
- FROM v_maxprice_sptprice_dftunit
- WHERE mtrlid = :arg_s_mx.mtrlid
- AND status = :arg_s_mx.status
- AND woodcode = :arg_s_mx.woodcode
- AND pcode = :arg_s_mx.pcode
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- lde_newprice = 0
- END IF
- IF IsNull(lde_newprice) THEN lde_newprice = 0
- ELSE
- lde_newprice = f_get_planprice(arg_s_mx.mtrlid, arg_s_mx.status,arg_s_mx.woodcode,arg_s_mx.pcode,True)
- END IF
-
- IF lde_newprice > 0 THEN
- ld_cost = lde_newprice
- arg_ref_costamt = Round(ld_cost * arg_s_mx.qty ,2)
- ELSE
- IF Not sys_power_issuper And f_power_ind(1635) THEN
- arg_msg = '用户特殊权限[限制出仓单负数开单时成本价为0不能审核]限制,不能操作'
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- END IF
- arg_s_mx.costamt = arg_ref_costamt
- arg_s_mx.cost = ld_cost
- arg_s_mx.costamt_notax = arg_ref_costamt_notax
- arg_s_mx.cost_notax = ld_cost_notax
- IF billtype = 1 Or billtype = 2 THEN
- // UPDATE u_outwaremx
- // SET costamt = :arg_ref_costamt,
- // cost = :ld_cost,
- // costamt_notax = :arg_ref_costamt_notax,
- // cost_notax = :ld_cost_notax
- // WHERE scid = :scid
- // AND outwareid = :outwareid
- // AND printid = :arg_s_mx.printid
- // Using commit_transaction;
-
- ELSE
- arg_s_mx.ware_price = ld_cost
- arg_s_mx.ware_fprice = ld_cost / arg_s_mx.rebate
- arg_s_mx.ware_enprice = ld_cost / arg_s_mx.rebate / mrate
- arg_s_mx.price = arg_s_mx.ware_price * arg_s_mx.rate
- arg_s_mx.fprice = arg_s_mx.ware_fprice * arg_s_mx.rate
- arg_s_mx.enprice = arg_s_mx.ware_enprice * arg_s_mx.rate
-
- arg_s_mx.enamt = round(arg_s_mx.uqty * arg_s_mx.enprice * (1 + arg_s_mx.tax) * arg_s_mx.rebate, 2)
- //arg_s_mx.enamt_tax = arg_s_mx.ware_enprice * arg_s_mx.rate //非销售, 0
- arg_s_mx.bsamt = round(arg_s_mx.uqty * arg_s_mx.price * (1 + arg_s_mx.tax) * arg_s_mx.rebate, 2)
- //arg_s_mx.bsamt_tax = arg_s_mx.ware_enprice * arg_s_mx.rate
- // UPDATE u_outwaremx
- // SET costamt = :arg_ref_costamt,
- // cost = :ld_cost,
- // fprice = :ld_cost,
- // enprice = :ld_cost,
- // price = :ld_cost,
- // ware_fprice = :ld_cost,
- // ware_enprice = :ld_cost,
- // ware_price = :ld_cost,
- // enamt = :arg_s_mx.enamt,
- // bsamt = :arg_s_mx.bsamt
- // WHERE scid = :scid
- // AND outwareid = :outwareid
- // AND printid = :arg_s_mx.printid
- // Using commit_transaction;
- END IF
- //
- //IF commit_transaction.SQLCode <> 0 THEN
- // arg_msg = '更新'+arg_s_mx.mtrlcode+'出仓成本价失败,'+commit_transaction.SQLErrText
- // rslt = 0
- // GOTO ext
- //END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK Using commit_transaction;
- ELSEIF rslt = 1 And arg_ifcommit THEN
- COMMIT Using commit_transaction;
- END IF
- RETURN rslt
- end function
- public function integer p_update_mtrlware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, long arg_storageid, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_addqty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, integer arg_dxflag, string arg_woodcode, string arg_pcode, ref string arg_msg, decimal arg_costamt_notax);Int rslt = 1
- Long ls_newid
- Decimal ld_cost,ld_cost_notax
- Decimal arg_qty_temp
- Decimal arg_addqty_temp
- Decimal arg_costamt_temp
- Decimal ld_cost_temp
- //sys_option_noallocaddqty仓审进出仓辅数 0-考虑辅数 1-不考虑辅数 20190107
- IF sys_option_noallocaddqty <>0 then
- arg_addqty = 0
- END IF
- IF billtype = 12 Or billtype = 15 THEN
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- noallocaddqty = noallocaddqty - :arg_addqty ,
- wareamt = wareamt - :arg_costamt,
- wareamt_notax = wareamt_notax - :arg_costamt_notax,
- cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:sys_option_cost_dec) END,
- cost_notax = case noallocqty - :arg_qty when 0 then cost_notax else round((wareamt_notax - :arg_costamt_notax)/(noallocqty - :arg_qty),:sys_option_cost_dec) END
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :scid ) Using commit_transaction ;
-
- ELSE
- UPDATE u_mtrlware
- SET noallocqty = noallocqty - :arg_qty ,
- noallocaddqty = noallocaddqty - :arg_addqty ,
- wareamt = wareamt - :arg_costamt,
- wareamt_notax = wareamt_notax - :arg_costamt_notax,
- cost = case noallocqty - :arg_qty when 0 then cost else round((wareamt - :arg_costamt)/(noallocqty - :arg_qty),:sys_option_cost_dec) END ,
- cost_notax = case noallocqty - :arg_qty when 0 then cost_notax else round((wareamt_notax - :arg_costamt_notax)/(noallocqty - :arg_qty),:sys_option_cost_dec) END,
- outdate = getdate()
- WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- ( scid = :scid ) Using commit_transaction ;
- END IF
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
-
- Long ll_count
- SELECT count(*)
- INTO :ll_count
- FROM u_mtrlware
- Where ( mtrlwareid = :arg_mtrlwareid ) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "编码["+arg_mtrlcode+"]查询库存信息操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF ll_count = 0 And arg_qty < 0 And arg_mtrlwareid > 0 THEN
- ls_newid = arg_mtrlwareid
-
- arg_qty_temp = Abs(arg_qty)
- arg_addqty_temp = Abs(arg_addqty)
- arg_costamt_temp = Abs(arg_costamt)
- ELSE
- ls_newid = f_sys_scidentity(scid,"u_mtrlware","mtrlwareid",arg_msg,False,commit_transaction)
-
- IF ls_newid <= 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- arg_qty_temp = arg_qty
- arg_addqty_temp = arg_addqty
- arg_costamt_temp = arg_costamt
- END IF
-
- ld_cost = Abs(Round(arg_costamt/arg_qty,sys_option_cost_dec))
- ld_cost_notax = Abs(Round(arg_costamt_notax /arg_qty,sys_option_cost_dec))
-
- INSERT INTO u_mtrlware
- (scid,
- mtrlwareid,
- mtrlid,
- storageid,
- plancode,
- status,
- noallocqty,
- noallocaddqty,
- allocqty,
- wareamt,
- planprice,
- sptid,
- dxflag,
- woodcode,
- pcode,
- cost,
- cost_notax)
- VALUES (
- :scid,
- :ls_newid,
- :arg_mtrlid,
- :arg_storageid,
- :arg_plancode,
- :arg_status,
- :arg_qty_temp,
- :arg_addqty_temp,
- 0,
- :arg_costamt_temp,
- :arg_planprice,
- :arg_sptid,
- :arg_dxflag,
- :arg_woodcode,
- :arg_pcode,
- :ld_cost,
- :ld_cost_notax) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "编码["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- END IF
- ELSE
- String or_err_part = 'create rule'
- rslt = 0
- IF Pos(Lower(commit_transaction.SQLErrText),"noallocqty") > 0 THEN
- arg_msg = "编码["+arg_mtrlcode+"]同仓库内同批号没有足够的库存支持冲减" + '需求数 ' + String(Round(arg_qty,2))
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),"noallocaddqty") > 0 THEN
- arg_msg = "编码["+arg_mtrlcode+"]同仓库内同批号没有足够的库存辅数支持冲减"
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),"cost") > 0 THEN
- arg_msg = "编码["+arg_mtrlcode+"]库存金额不足够支持冲减"
- ELSE
- arg_msg = "编码["+arg_mtrlcode+"]库存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- //Int sys_option_check_mtrware_amt= 0 // 282 限制仓库库存表的库存金额不能为负数
- //IF sys_option_check_mtrware_amt = 1 THEN
- // Decimal dec_wareamt
- // dec_wareamt = 0
- // SELECT wareamt
- // INTO :dec_wareamt
- // FROM u_mtrlware
- // WHERE ( mtrlwareid = :arg_mtrlwareid ) AND
- // ( scid = :scid ) Using commit_transaction ;
- //
- //
- // IF dec_wareamt < 0 THEN
- // rslt = 0
- // arg_msg = "编码["+arg_mtrlcode+"] 系统选项282限制库存金额不能为负数!"+"~n"+commit_transaction.SQLErrText
- // GOTO ext
- // END IF
- //
- //
- //END IF
- //-----------------------------------更新结存
- Decimal ld_pypkqty,ld_pypkaddqty
- Decimal ld_saleoutqty,ld_saleoutamt,ld_saleoutaddqty
- Decimal ld_saleoutqty_th,ld_saleoutamt_th,ld_saleoutaddqty_th
- Decimal ld_cpoutqty,ld_cpoutamt,ld_cpoutaddqty
- Decimal ld_jgoutqty,ld_jgoutamt,ld_jgoutaddqty
- Decimal ld_dioutqty,ld_dioutamt,ld_dioutaddqty
- Decimal ld_mvoutqty,ld_mvoutamt,ld_mvoutaddqty
- Decimal ld_otoutqty,ld_otoutamt,ld_otoutaddqty
- Decimal ld_pkoutqty,ld_pkoutamt,ld_pkoutaddqty
- Decimal ld_saleoutamt_th_notax,ld_saleoutamt_notax
- Decimal ld_cpoutamt_notax,ld_jgoutamt_notax,ld_otoutamt_notax
- Decimal ld_pkoutamt_notax,ld_mvoutamt_notax,ld_dioutamt_notax
- CHOOSE CASE billtype
- CASE 1
- IF thflag = 1 THEN
- ld_saleoutqty_th = Abs(arg_qty)
- ld_saleoutaddqty_th = Abs(arg_addqty)
- ld_saleoutamt_th = Abs(arg_costamt)
- ld_saleoutamt_th_notax = Abs(arg_costamt_notax)
- ld_saleoutqty = 0
- ld_saleoutaddqty = 0
- ld_saleoutamt = 0
- ld_saleoutamt_notax = 0
- ELSE
- ld_saleoutqty = arg_qty
- ld_saleoutaddqty = arg_addqty
- ld_saleoutamt = arg_costamt
- ld_saleoutamt_notax = arg_costamt_notax
- END IF
- CASE 3
- ld_cpoutqty = arg_qty
- ld_cpoutaddqty = arg_addqty
- ld_cpoutamt = arg_costamt
- ld_cpoutamt_notax = arg_costamt_notax
- CASE 4
- ld_jgoutqty = arg_qty
- ld_jgoutaddqty = arg_addqty
- ld_jgoutamt = arg_costamt
- ld_jgoutamt_notax = arg_costamt_notax
- CASE 8
- ld_otoutqty = arg_qty
- ld_otoutaddqty = arg_addqty
- ld_otoutamt = arg_costamt
- ld_otoutamt_notax = arg_costamt_notax
- CASE 9
- ld_pkoutqty = arg_qty
- ld_pkoutaddqty = arg_addqty
- ld_pkoutamt = arg_costamt
- ld_pkoutamt_notax = arg_costamt_notax
- ld_pypkqty = arg_qty
- CASE 12
- ld_mvoutqty = arg_qty
- ld_mvoutaddqty = arg_addqty
- ld_mvoutamt = arg_costamt
- ld_mvoutamt_notax = arg_costamt_notax
- CASE 15
- ld_dioutqty = arg_qty
- ld_dioutaddqty = arg_addqty
- ld_dioutamt = arg_costamt
- ld_dioutamt_notax = arg_costamt_notax
- END CHOOSE
- UPDATE u_warebalc
-
- SET desqty = desqty + :arg_qty ,
- desaddqty = desaddqty + :arg_addqty ,
- desamt = desamt + :arg_costamt,
- desamt_notax = desamt_notax + :arg_costamt_notax,
-
- balcqty = balcqty - :arg_qty,
- balcaddqty = balcaddqty - :arg_addqty,
- balcamt = balcamt - :arg_costamt,
- balcamt_notax = balcamt_notax - :arg_costamt_notax,
-
- pypk = pypk - :ld_pypkqty,
- pypkaddqty = pypkaddqty - :ld_pypkaddqty,
-
- saleoutqty = saleoutqty + :ld_saleoutqty,
- saleoutaddqty = saleoutaddqty + :ld_saleoutaddqty,
- saleoutamt = saleoutamt + :ld_saleoutamt,
- saleoutamt_notax = saleoutamt_notax + :ld_saleoutamt_notax,
-
- saleoutqty_th = saleoutqty_th+:ld_saleoutqty_th,
- saleoutaddqty_th = saleoutaddqty_th + :ld_saleoutaddqty_th,
- saleoutamt_th = saleoutamt_th+ :ld_saleoutamt_th,
- saleoutamt_th_notax = saleoutamt_th_notax + :ld_saleoutamt_th_notax,
-
- cpoutqty = cpoutqty + :ld_cpoutqty,
- cpoutaddqty = cpoutaddqty + :ld_cpoutaddqty,
- cpoutamt = cpoutamt + :ld_cpoutamt,
- cpoutamt_notax = cpoutamt_notax + :ld_cpoutamt_notax,
-
- jgoutqty = jgoutqty + :ld_jgoutqty,
- jgoutaddqty = jgoutaddqty + :ld_jgoutaddqty,
- jgoutamt = jgoutamt + :ld_jgoutamt,
- jgoutamt_notax = jgoutamt_notax + :ld_jgoutamt_notax,
-
- otoutqty = otoutqty + :ld_otoutqty,
- otoutaddqty = otoutaddqty + :ld_otoutaddqty,
- otoutamt = otoutamt + :ld_otoutamt,
- otoutamt_notax = otoutamt_notax + :ld_otoutamt_notax,
-
- mvoutqty = mvoutqty + :ld_mvoutqty,
- mvoutaddqty = mvoutaddqty + :ld_mvoutaddqty,
- mvoutamt = mvoutamt + :ld_mvoutamt,
- mvoutamt_notax = mvoutamt_notax + :ld_mvoutamt_notax,
-
- dioutqty = dioutqty + :ld_dioutqty,
- dioutaddqty = dioutaddqty + :ld_dioutaddqty,
- dioutamt = dioutamt + :ld_dioutamt,
- dioutamt_notax = dioutamt_notax + :ld_dioutamt_notax,
-
- pkoutqty = pkoutqty + :ld_pkoutqty,
- pkoutaddqty = pkoutaddqty + :ld_pkoutaddqty,
- pkoutamt = pkoutamt + :ld_pkoutamt,
- pkoutamt_notax = pkoutamt_notax + :ld_pkoutamt_notax
-
-
- WHERE (scid = :scid) AND
- ( balcdateint = 0 ) AND
- ( mtrlid = :arg_mtrlid ) AND
- ( storageid = :arg_storageid ) AND
- ( status = :arg_status ) AND
- ( woodcode = :arg_woodcode) AND
- ( pcode = :arg_pcode) AND
- (sptid_cusid = :arg_sptid) Using commit_transaction ;
- IF commit_transaction.SQLCode = 0 THEN
- IF commit_transaction.SQLNRows = 0 THEN
- INSERT INTO u_warebalc
- ( balcdateint,
- sptid_cusid,
- mtrlid,
- storageid,
- bgqty,
- bgamt,
- incqty,
- incaddqty,
- incamt,
- desqty,
- desaddqty,
- desamt,
- balcqty,
- balcaddqty,
- balcamt,
- pypk,
- pypkaddqty,
- status,
- woodcode,
- pcode,
- scid ,
- saleoutqty,
- saleoutaddqty,
- saleoutamt,
- cpoutqty,
- cpoutaddqty,
- cpoutamt,
- jgoutqty,
- jgoutaddqty,
- jgoutamt,
- dioutqty,
- dioutaddqty,
- dioutamt,
- mvoutqty,
- mvoutaddqty,
- mvoutamt,
- otoutqty,
- otoutaddqty,
- otoutamt,
- pkoutqty,
- pkoutaddqty,
- pkoutamt,
- saleoutqty_th,
- saleoutaddqty_th,
- saleoutamt_th,
- desamt_notax,
- balcamt_notax,
- saleoutamt_notax,
- saleoutamt_th_notax,
- cpoutamt_notax,
- jgoutamt_notax,
- otoutamt_notax,
- mvoutamt_notax,
- dioutamt_notax,
- pkoutamt_notax)
- VALUES (
- 0,
- :arg_sptid,
- :arg_mtrlid,
- :arg_storageid,
- 0,
- 0,
- 0,
- 0,
- 0,
- :arg_qty,
- :arg_addqty,
- :arg_costamt,
- 0 - :arg_qty,
- 0 - :arg_addqty,
- 0 - :arg_costamt,
- 0 - :ld_pypkqty,
- 0 - :ld_pypkaddqty,
- :arg_status,
- :arg_woodcode,
- :arg_pcode,
- :scid,
- :ld_saleoutqty,
- :ld_saleoutaddqty,
- :ld_saleoutamt,
- :ld_cpoutqty,
- :ld_cpoutaddqty,
- :ld_cpoutamt,
- :ld_jgoutqty,
- :ld_jgoutaddqty,
- :ld_jgoutamt,
- :ld_dioutqty,
- :ld_dioutaddqty,
- :ld_dioutamt,
- :ld_mvoutqty,
- :ld_mvoutaddqty,
- :ld_mvoutamt,
- :ld_otoutqty,
- :ld_otoutaddqty,
- :ld_otoutamt,
- :ld_pkoutqty,
- :ld_pkoutaddqty,
- :ld_pkoutamt,
- :ld_saleoutqty_th,
- :ld_saleoutaddqty_th,
- :ld_saleoutamt_th,
- :arg_costamt_notax,
- :arg_costamt_notax,
- :ld_saleoutamt_notax,
- :ld_saleoutamt_th_notax,
- :ld_cpoutamt_notax,
- :ld_jgoutamt_notax,
- :ld_otoutamt_notax,
- :ld_mvoutamt_notax,
- :ld_dioutamt_notax,
- :ld_pkoutamt_notax) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "编码["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
- END IF
- ELSE
- rslt = 0
-
- or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
- IF commit_transaction.SQLCode = 513 Or Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
- arg_msg = "编码["+arg_mtrlcode+"]同仓库内同批号没有足够的结存支持冲减"
- ELSE
- arg_msg = "编码["+arg_mtrlcode+"]结存更新操作失败"+"~n"+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- ext:
- IF rslt = 0 THEN
- ROLLBACK;
- END IF
- RETURN rslt
- end function
- on uo_outware.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_outware.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|