123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008 |
- $PBExportHeader$uo_inware_other.sru
- forward
- global type uo_inware_other from uo_inware
- end type
- end forward
- global type uo_inware_other from uo_inware
- end type
- global uo_inware_other uo_inware_other
- forward prototypes
- public function integer acceptmx (s_inwaremx s_mx, ref string arg_msg)
- public function integer save (boolean arg_ifcommit, ref string arg_msg)
- end prototypes
- public function integer acceptmx (s_inwaremx s_mx, ref string arg_msg);Long rslt = 1,cnt = 0,ls_i
- Decimal ld_planprice,ld_cost,ld_cost_notax,ld_dftsptprice
- Decimal ld_noauditqty,ld_bootqty
- String ls_relcode,ls_unit,ls_saletaskcode
- Int li_iflimitprice
- Dec ld_round = 100
- uo_spt_price uo_sptprice
- uo_sptprice = Create uo_spt_price
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以使用,操作取消"
- GOTO ext
- END IF
- //清除空值
- IF IsNull(s_mx.printid) THEN s_mx.printid = 0
- IF IsNull(s_mx.mtrlid) THEN s_mx.mtrlid = 0
- IF IsNull(s_mx.mtrlcode) THEN s_mx.mtrlcode = ''
- IF IsNull(s_mx.plancode) THEN s_mx.plancode = ''
- IF IsNull(s_mx.status) THEN s_mx.status = ''
- IF IsNull(s_mx.uqty) THEN s_mx.uqty = 0
- IF IsNull(s_mx.addqty) THEN s_mx.addqty = 0
- IF IsNull(s_mx.packqty) THEN s_mx.packqty = 0
- IF IsNull(s_mx.uprice) THEN s_mx.uprice = 0
- IF IsNull(s_mx.rebate) THEN s_mx.rebate = 0
- IF IsNull(s_mx.mxdscrp) THEN s_mx.mxdscrp = ''
- IF IsNull(s_mx.mxdscrp2) THEN s_mx.mxdscrp2 = ''
- IF IsNull(s_mx.mxdscrp3) THEN s_mx.mxdscrp3 = ''
- IF IsNull(s_mx.mxdscrp4) THEN s_mx.mxdscrp4 = ''
- IF IsNull(s_mx.jgprice) THEN s_mx.jgprice = 0
- 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.mxdscrp) THEN s_mx.woodcode = ''
- IF IsNull(s_mx.pcode) THEN s_mx.pcode = ''
- IF IsNull(s_mx.sptid) THEN s_mx.sptid = 0
- IF IsNull(s_mx.mtrlcuscode) THEN s_mx.mtrlcuscode = ''
- IF IsNull(s_mx.unit) THEN s_mx.unit = ''
- IF IsNull(s_mx.rate) THEN s_mx.rate = 1
- IF s_mx.rate = 0 THEN s_mx.rate = 1
- IF IsNull(s_mx.formula) THEN s_mx.formula = ''
- IF IsNull(s_mx.waredscrp) THEN s_mx.waredscrp = ''
- IF mrate = 0 THEN mrate = 1
- IF IsNull(s_mx.tax) THEN s_mx.tax = 0
- IF IsNull(s_mx.buyqty) THEN s_mx.buyqty = 0
- IF IsNull(s_mx.uprice_notax) THEN s_mx.uprice_notax = 0
- IF s_mx.uprice_notax = 0 THEN
- s_mx.uprice_notax = s_mx.uprice / (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_buyqty = 1 And billtype = 1 THEN //采购 , 采购数与进仓数分离
- ELSE //不分离
- s_mx.buyqty = s_mx.uqty
- END IF
- IF s_mx.mtrlid = 0 Or (s_mx.buyqty = 0 And s_mx.uqty = 0 And s_mx.addqty = 0) THEN
- rslt = 1
- GOTO ext
- END IF
- IF acceptmx_chk(s_mx, arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //检查物料id
- SELECT unit,planprice,iflimitprice
- INTO :ls_unit,:ld_planprice,:li_iflimitprice
- FROM u_mtrldef
- Where u_mtrldef.mtrlid = :s_mx.mtrlid Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行,查询物料资料信息失败,编码:"+s_mx.mtrlcode
- GOTO ext
- END IF
- //确实有=1的情况
- //IF ls_unit <> s_mx.unit And s_mx.rate = 1 THEN
- // arg_msg = "第" + String(s_mx.printid) + "行,库存单位与采购单位不同,但转换率为1,请检查!"
- // rslt = 0
- // GOTO ext
- //END IF
- IF ls_unit = s_mx.unit And s_mx.rate <> 1 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,库存单位与采购单位相同,但转换率不为1,请检查!"
- rslt = 0
- GOTO ext
- END IF
- //查询采购限价并检查进仓价
- IF billtype = 1 Or billtype = 4 THEN
- IF li_iflimitprice = 1 THEN
- IF uo_sptprice.uf_check_price_save(thflag,sptid,s_mx.mtrlid,s_mx.mtrlcode,s_mx.unit,s_mx.status,s_mx.woodcode,s_mx.pcode,s_mx.uprice * s_mx.rebate,arg_msg) = 0 THEN
- arg_msg = "第" + String(s_mx.printid) + "行," + arg_msg
- rslt = 0
- GOTO ext
- END IF
- END IF
- END IF
- Int li_if_cus_mtrlware, li_if_plancode, li_inwaretype
- IF sys_option_hide_ware = 0 THEN
- SELECT balctype , if_plancode, inwaretype
- INTO :li_if_cus_mtrlware, :li_if_plancode, :li_inwaretype
- FROM u_storage
- Where storageid = :storageid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,查询仓库是否使用客户库存失败"
- rslt = 0
- GOTO ext
- END IF
- END IF
- //关于客户库存处理,sptid
- Long ll_cusid
- Int li_bhflag
- IF dxflag = 0 THEN
- IF li_if_cus_mtrlware = 1 THEN
- IF billtype = 3 THEN
- //特殊情况 20140104
- //生产进仓单,按订单进仓的产品,如果订单的客户为 备货客户, 进仓时不按客户库存;
- IF s_mx.ifrel > 0 THEN
- IF s_mx.relid = 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的销售订单'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT top 1 cusid INTO :ll_cusid
- FROM u_saletaskmx,u_saletask
- WHERE u_saletaskmx.scid = u_saletask.scid
- AND u_saletaskmx.taskid = u_saletask.taskid
- AND u_saletaskmx.scid = :scid
- AND u_saletaskmx.taskid = :s_mx.relid
- AND u_saletaskmx.printid = :s_mx.relprintid
- AND u_saletaskmx.mtrlid = :s_mx.mtrlid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单客户资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- // s_mx.mtrlid 以后有可能是 下级的生产物料!!!!
-
- IF IsNull(ll_cusid) THEN ll_cusid = 0
-
- IF ll_cusid > 0 THEN
- SELECT bhflag INTO :li_bhflag FROM u_cust WHERE cusid = :ll_cusid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单客户资料失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- li_bhflag = 0
- END IF
- IF IsNull(li_bhflag) THEN li_bhflag = 0
-
- IF li_bhflag = 1 THEN
- s_mx.sptid = 0
- ELSE
- s_mx.sptid = s_mx.sptid
- END IF
- END IF
-
- ELSE
- s_mx.sptid = s_mx.sptid
- END IF
- ELSE
- s_mx.sptid = 0
- END IF
- ELSE
- IF li_if_cus_mtrlware <> 1 THEN
- arg_msg = "仓库没有使用客户库存,不能建立代销单据"
- rslt = 0
- GOTO ext
- END IF
- s_mx.sptid = sptid
- END IF
- CHOOSE CASE billtype
- CASE 1 //采购
- IF s_mx.ifrel > 0 THEN
- IF s_mx.relid = 0 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,请先择相应的订单!"
- rslt = 0
- GOTO ext
- END IF
-
- SELECT taskcode ,uqty - consignedqty,
- CASE when u_buytask.billtype = 1 THEN u_buytaskmx.relcode ELSE '' END
- INTO :ls_relcode,:ld_bootqty,:ls_saletaskcode
- FROM u_buytaskmx,u_buytask
- WHERE u_buytaskmx.taskid = u_buytask.taskid
- AND u_buytaskmx.scid = u_buytask.scid
- AND u_buytaskmx.scid = :scid
- AND u_buytaskmx.taskid = :s_mx.relid
- AND u_buytaskmx.printid = :s_mx.relprintid
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,查询采购订单是否有订购:"+s_mx.mtrlcode+'失败!'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
-
- //查相关销售订单已开单数
- ld_noauditqty = 0
- SELECT sum(uqty) INTO :ld_noauditqty
- FROM u_inwaremx
- WHERE scid = :scid
- AND relid = :s_mx.relid
- AND relprintid = :s_mx.relprintid
- And inwareid <> :inwareid;
- IF sqlca.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,查询"+s_mx.mtrlcode+'相关订单单据已开单数失败!'
- rslt = 0
- GOTO ext
- END IF
- IF IsNull(ld_noauditqty) THEN ld_noauditqty = 0
- ELSE
- s_mx.relid = 0
- s_mx.relprintid = 0
- END IF
- CASE 3 //生产
-
- IF s_mx.ifrel > 0 THEN
- IF s_mx.relid = 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的销售订单'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT top 1 taskcode INTO :ls_relcode
- FROM u_saletaskmx,u_saletask
- WHERE u_saletaskmx.scid = u_saletask.scid
- AND u_saletaskmx.taskid = u_saletask.taskid
- AND u_saletaskmx.scid = :scid
- AND u_saletaskmx.taskid = :s_mx.relid
- AND u_saletaskmx.printid = :s_mx.relprintid
- AND u_saletaskmx.mtrlid = :s_mx.mtrlid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,查询销售订单是否有排产:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- ELSE
- s_mx.relid = 0
- s_mx.relprintid = 0
- END IF
- CASE 4 //外协
- IF s_mx.ifrel > 0 THEN
- IF s_mx.relid = 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,请先择相应的外协订单'
- rslt = 0
- GOTO ext
- END IF
-
- SELECT u_order_wfjg.taskcode,
- CASE when u_order_wfjg.billtype = 1 THEN u_order_wfjgmx.relcode ELSE '' END
- INTO :ls_relcode,:ls_saletaskcode
- FROM u_order_wfjgmx,u_order_wfjg
- WHERE u_order_wfjgmx.scid = u_order_wfjg.scid
- AND u_order_wfjgmx.wfjgid = u_order_wfjg.wfjgid
- AND u_order_wfjgmx.wfjgid = :s_mx.relid
- AND u_order_wfjgmx.printid = :s_mx.relprintid
- AND u_order_wfjgmx.mtrlid = :s_mx.mtrlid
- AND u_order_wfjgmx.status = :s_mx.status
- AND u_order_wfjgmx.woodcode = :s_mx.woodcode
- AND u_order_wfjgmx.pcode = :s_mx.pcode
- Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- arg_msg = "第" + String(s_mx.printid) + '行,查询外协订单是否有加工:'+s_mx.mtrlcode+'失败,'+commit_transaction.SQLErrText
- rslt = 0
- GOTO ext
- END IF
- END IF
- END CHOOSE
- //处理plancode
- storage_plancode_flag = 0
- IF li_if_plancode = 0 THEN //不使用
- s_mx.plancode = ''
- ELSE
- IF thflag <> 1 THEN //退货不处理
- IF li_inwaretype = 1 THEN //无(不变)
- //inwaremx[it_mxbt].plancode = s_mx.plancode
- ELSEIF li_inwaretype = 2 THEN //价格
- s_mx.plancode = String(Round(s_mx.uprice * s_mx.rebate,5))
- ELSEIF li_inwaretype = 3 THEN //订单
- IF ls_relcode <> '' And billtype = 3 THEN
- s_mx.plancode = ls_relcode
- ELSEIF ls_saletaskcode <> '' And (billtype = 1 Or billtype = 4 ) THEN
- s_mx.plancode = ls_saletaskcode
- ELSE
- s_mx.plancode = s_mx.plancode //(不变)
- END IF
- ELSEIF li_inwaretype = 5 THEN //进仓单号
- storage_plancode_flag = 1 //仓库中是否设置了使用 “进仓单号” 作为批号
-
- ELSEIF li_inwaretype = 6 THEN //数值
-
- s_mx.plancode = String(s_mx.uqty,'#,##0.####')
- ELSEIF li_inwaretype = 7 THEN //日期时间顺序
-
- IF s_mx.plancode = '' THEN
- s_mx.plancode = String(Today(), 'yymmddhhmm') + '-' + String(s_mx.printid)
- END IF
- END IF
- END IF //退货不处理
- END IF
- //处理 sptmtrlname
- String ls_sptmtrlname
- IF billtype = 1 THEN
- IF uo_sptprice.uf_getmtrlname(sptid,s_mx.mtrlid,ls_sptmtrlname,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ELSE
- ls_sptmtrlname = ""
- END IF
- //处理价格===============================
- //取默认报价
- IF billtype = 1 THEN
- f_get_defsptprice(sptid,s_mx.mtrlid,s_mx.unit,s_mx.status,s_mx.pcode,s_mx.woodcode,ld_dftsptprice)
- ELSE
- ld_dftsptprice = 0
- END IF
- //不是自动的单价
- IF sysautobuild = False THEN
- IF s_mx.uprice * s_mx.rebate < 0 THEN //检查进仓价
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + '行,' + String(s_mx.mtrlcode)+" 单价错误"
- GOTO ext
- END IF
- END IF
- IF s_mx.tax < 0 THEN
- rslt = 0
- arg_msg = "税率不能为负数"
- GOTO ext
- END IF
- //检查成本价调整单
- Long ll_mtrlwareid
- IF sys_option_hide_ware = 0 THEN
- SELECT mtrlwareid
- INTO :ll_mtrlwareid
- FROM u_mtrlware
- WHERE ( mtrlid = :s_mx.mtrlid ) AND
- ( plancode = :s_mx.plancode ) AND
- ( storageid = :storageid ) AND
- ( scid = :scid ) AND
- ( status = :s_mx.status ) AND
- ( sptid = :s_mx.sptid) AND
- ( dxflag = :dxflag) AND
- ( woodcode = :s_mx.woodcode) AND
- ( pcode = :s_mx.pcode) Using commit_transaction;
- IF commit_transaction.SQLCode = -1 THEN
- arg_msg = "第" + String(s_mx.printid) + "行,查询库存信息失败!"
- rslt = 0
- GOTO ext
- END IF
-
- IF IsNull(ll_mtrlwareid) THEN ll_mtrlwareid = 0
- IF ll_mtrlwareid > 0 THEN
- IF Not (billtype = 8 And sptname = '成本价调整单审核自动生成') THEN
- 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 = :ll_mtrlwareid AND
- u_updatecost.scid = :scid Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行,查询成本价调整单操作失败"
- GOTO ext
- END IF
- IF cnt > 0 THEN
- rslt = 0
- arg_msg = "第" + String(s_mx.printid) + "行," + s_mx.mtrlcode + "已开成本价调整单,请先审核"
- GOTO ext
- END IF
- END IF
-
- //出仓的, 查询成本价
-
- ELSE
-
- END IF
- END IF
- //s_mx.price = Round(s_mx.enprice * mrate * s_mx.rebate,10) //进仓实价, 本位币,库存单位
- s_mx.qty = Round(s_mx.uqty * s_mx.rate, sys_option_unit_dec) //库存单位,进仓数量
- //写入内容
- it_mxbt++
- inwaremx[it_mxbt].mtrlwareid = ll_mtrlwareid
- inwaremx[it_mxbt].printid = s_mx.printid
- inwaremx[it_mxbt].mtrlid = s_mx.mtrlid
- inwaremx[it_mxbt].mtrlcode = s_mx.mtrlcode
- inwaremx[it_mxbt].unit = s_mx.unit
- inwaremx[it_mxbt].rate = s_mx.rate
- inwaremx[it_mxbt].noauditqty = ld_noauditqty
- inwaremx[it_mxbt].bootqty = ld_bootqty
- inwaremx[it_mxbt].addqty = s_mx.addqty
- inwaremx[it_mxbt].uqty = s_mx.uqty
- inwaremx[it_mxbt].qty = s_mx.qty
- inwaremx[it_mxbt].buyqty = s_mx.buyqty
- inwaremx[it_mxbt].packqty = s_mx.packqty
- inwaremx[it_mxbt].uprice = s_mx.uprice //进仓价, 原币, 进仓单位
- IF s_mx.buyqty <> 0 THEN
- inwaremx[it_mxbt].fprice = Round((s_mx.uprice * s_mx.buyqty) /(Round(s_mx.buyqty * s_mx.rate,sys_option_unit_dec)) * mrate ,10) //进仓价, 本位币, 库存单位
- ELSE
- inwaremx[it_mxbt].fprice = Round(s_mx.uprice * s_mx.rate * mrate,10)
- END IF
- inwaremx[it_mxbt].price = Round(inwaremx[it_mxbt].fprice * s_mx.rebate,10) //进仓实价, 本位币,库存单位
- inwaremx[it_mxbt].rebate = s_mx.rebate
- inwaremx[it_mxbt].tax = s_mx.tax
- IF billtype = 1 THEN
- ld_round = 10.0 ^ (2 - sys_option_inware_buy_amt_round)
- IF sys_option_inware_buy_amt_round = 5 THEN ld_round = 1000
- END IF
- inwaremx[it_mxbt].uamt = Round(s_mx.buyqty * s_mx.uprice * s_mx.rebate * ld_round, 0) / ld_round //原币,实价含税金额
- inwaremx[it_mxbt].uamt_tax = Round((s_mx.buyqty * s_mx.uprice * s_mx.rebate) * s_mx.tax / (1 + s_mx.tax) * ld_round, 0) / ld_round //原币, 税金
- inwaremx[it_mxbt].bsamt = Round(s_mx.buyqty * s_mx.uprice * s_mx.rebate * mrate * ld_round, 0) / ld_round //本位币, 实价含税金额
- inwaremx[it_mxbt].bsamt_tax = Round((s_mx.buyqty * s_mx.uprice * s_mx.rebate * mrate) * s_mx.tax / (1 + s_mx.tax) * ld_round, 0) / ld_round //本位币, 税金
- inwaremx[it_mxbt].planprice = ld_planprice
- inwaremx[it_mxbt].jgprice = s_mx.jgprice
- inwaremx[it_mxbt].mxdscrp = s_mx.mxdscrp
- inwaremx[it_mxbt].mxdscrp2 = s_mx.mxdscrp2
- inwaremx[it_mxbt].mxdscrp3 = s_mx.mxdscrp3
- inwaremx[it_mxbt].mxdscrp4 = s_mx.mxdscrp4
- inwaremx[it_mxbt].dxflag = dxflag
- inwaremx[it_mxbt].relid = s_mx.relid
- inwaremx[it_mxbt].relprintid = s_mx.relprintid
- inwaremx[it_mxbt].ifrel = s_mx.ifrel
- inwaremx[it_mxbt].status = s_mx.status
- inwaremx[it_mxbt].woodcode = s_mx.woodcode
- inwaremx[it_mxbt].pcode = s_mx.pcode
- inwaremx[it_mxbt].relcode = ls_relcode
- inwaremx[it_mxbt].mtrlcuscode = s_mx.mtrlcuscode
- inwaremx[it_mxbt].dftsptprice = ld_dftsptprice
- inwaremx[it_mxbt].formula = s_mx.formula
- inwaremx[it_mxbt].waredscrp = s_mx.waredscrp
- inwaremx[it_mxbt].inworkdate = s_mx.inworkdate
- inwaremx[it_mxbt].plancode = s_mx.plancode
- inwaremx[it_mxbt].sptid = s_mx.sptid
- inwaremx[it_mxbt].sptmtrlname = ls_sptmtrlname //供应商别名
- inwaremx[it_mxbt].uprice_notax = s_mx.uprice_notax //不含税单价
- //IF sys_option_buyth_wareamt = 0 THEN
- //
- If (billtype = 1 And thflag = 1 And sys_option_buyth_wareamt = 0 ) &
- Or (s_mx.uqty < 0 And billtype <> 3 And billtype <> 1) THEN //采购退货单 或者 非采购/生产进仓
- SELECT cost,cost_notax
- INTO :ld_cost,:ld_cost_notax
- FROM u_mtrlware
- WHERE scid = :scid
- AND mtrlid = :s_mx.mtrlid
- AND storageid = :storageid
- AND status = :s_mx.status
- AND plancode = :s_mx.plancode
- AND woodcode = :s_mx.woodcode
- AND pcode = :s_mx.pcode
- AND dxflag = :dxflag
- And sptid = :s_mx.sptid;
- IF sqlca.SQLCode <> 0 Or IsNull(ld_cost) THEN ld_cost = 0
-
- inwaremx[it_mxbt].cost = ld_cost
- inwaremx[it_mxbt].cost_notax = ld_cost_notax
- ELSE
- inwaremx[it_mxbt].cost = inwaremx[it_mxbt].fprice * s_mx.rebate
- inwaremx[it_mxbt].cost_notax = inwaremx[it_mxbt].fprice * s_mx.rebate
- END IF
- inwaremx[it_mxbt].costamt = Round(inwaremx[it_mxbt].cost * inwaremx[it_mxbt].qty, 2) //成本金额,库存单位
- ext:
- Destroy uo_sptprice
- IF rslt = 0 THEN
- p_clearmx()
- arg_msg = billname + ',' + arg_msg
- END IF
- 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
- IF IsNull(relid) THEN relid = 0
- IF IsNull(storageid) THEN storageid = 0
- IF IsNull(inrep) THEN inrep = ''
- IF IsNull(dscrp) THEN dscrp = ''
- IF IsNull(part) THEN part = ''
- IF IsNull(sptid) THEN sptid = 0
- IF IsNull(sptname) THEN sptname = ''
- IF IsNull(dxflag) THEN dxflag = 0
- IF IsNull(thflag) THEN thflag = 0
- IF IsNull(relint_1) THEN relint_1 = 0
- IF IsNull(relint_2) THEN relint_2 = 0
- IF IsNull(relint_3) THEN relint_3 = 0
- IF IsNull(relint_4) THEN relint_4 = 0
- IF IsNull(relint_5) THEN relint_5 = 0
- IF IsNull(relstr_1) THEN relstr_1 = ''
- IF IsNull(relstr_2) THEN relstr_2 = ''
- IF IsNull(relstr_3) THEN relstr_3 = ''
- IF IsNull(mrate) THEN mrate = 0
- IF mrate = 0 THEN mrate = 1
- IF it_newbegin = False And it_updatebegin = False THEN
- rslt = 0
- arg_msg = "非编辑状态不可以提交"
- GOTO ext
- END IF
- SELECT Top 1 getdate() Into :server_dt From u_user Using commit_transaction ;
- //取得系统时间,借用操作员表
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "查询操作失败,日期 "
- GOTO ext
- END IF
- IF save_chk(arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //查找进仓原因,记录staticid
- select staticid into :staticid
- from u_static
- where reason = :sptname
- and inoutflag = 1;
- IF SQLCA.SQLCODE <>0 THEN
- staticid = 0
- END IF
- IF ISNULL(staticid) THEN staticid = 0
- ////////////////////////////////////////////// //开始区分:新建/更新 处理
- IF inwareid = 0 THEN //新建
- ls_newid = f_sys_scidentity(scid,"u_inware","inwareid",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
- inwarecode = getid(scid,ls_sccode + 'CG',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- inwarecode = getid(scid,ls_sccode + 'CT',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 3
- inwarecode = getid(scid,ls_sccode + 'CP',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 4
- IF thflag = 0 THEN
- inwarecode = getid(scid,ls_sccode + 'WN',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- inwarecode = getid(scid,ls_sccode + 'WH',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 8
- inwarecode = getid(scid,ls_sccode + 'JC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 9
- inwarecode = getid(scid,ls_sccode + 'PY',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 12
- inwarecode = getid(scid,ls_sccode + 'IC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 15
- inwarecode = getid(scid,ls_sccode + 'DC',Date(server_dt),if_getid_ture,commit_transaction)
- CASE 20
- IF thflag = 0 THEN
- inwarecode = getid(scid,ls_sccode + 'RI',Date(server_dt),if_getid_ture,commit_transaction)
- ELSE
- inwarecode = getid(scid,ls_sccode + 'RT',Date(server_dt),if_getid_ture,commit_transaction)
- END IF
- CASE 22
- inwarecode = getid(scid,ls_sccode + 'TI',Date(server_dt),if_getid_ture,commit_transaction)
- END CHOOSE
-
- IF inwarecode = "err" THEN
- inwarecode = ''
- rslt = 0
- arg_msg = "无法获取进仓单编号"+"~n"
- GOTO ext
- END IF
-
- INSERT INTO u_inware (
- scid,
- inwareid,
- inwarecode,
- billtype,
- relid,
- storageid,
- indate,
- inrep,
- part,
- dscrp,
- sptid,
- sptname,
- thflag,
- dxflag,
- otheramt,
- opdate,
- opemp,
- relint_1,
- relint_2,
- relint_3,
- relstr_1,
- relstr_2,
- relstr_3,
- mrate,
- relint_4,
- relint_5,
- staticid)
- VALUES (
- :scid,
- :ls_newid,
- :inwarecode,
- :billtype,
- :relid,
- :storageid,
- :indate,
- :inrep,
- :part,
- :dscrp,
- :sptid,
- :sptname,
- :thflag,
- :dxflag,
- :otheramt,
- :server_dt,
- :publ_operator,
- :relint_1,
- :relint_2,
- :relint_3,
- :relstr_1,
- :relstr_2,
- :relstr_3,
- :mrate,
- :relint_4,
- :relint_5,
- :staticid) Using commit_transaction ;
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inware') > 0 THEN
- arg_msg = '插入单据资料失败,关键字ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inware') > 0 THEN
- arg_msg = '插入单据资料失败,单据编号重复'
- ELSE
- arg_msg = '插入单据资料失败,'+commit_transaction.SQLErrText
- END IF
- //arg_msg = "插入操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- //读取新inwareid
- inwareid = ls_newid
-
- ELSE //////////////////////////////////////////////// //更新
- UPDATE u_inware
- SET billtype = :billtype,
- relid = :relid,
- storageid = :storageid,
- indate = :indate,
- inrep = :inrep,
- part = :part,
- dscrp = :dscrp,
- sptid = :sptid,
- sptname = :sptname,
- thflag = :thflag,
- dxflag = :dxflag,
- otheramt = :otheramt,
- moddate = :server_dt,
- modemp = :publ_operator,
- relint_1 = :relint_1,
- relint_2 = :relint_2,
- relint_3 = :relint_3,
- relstr_1 = :relstr_1,
- relstr_2 = :relstr_2,
- relstr_3 = :relstr_3,
- mrate = :mrate,
- relint_4 = :relint_4,
- relint_5 = :relint_5,
- staticid = :staticid
- WHERE u_inware.inwareid = :inwareid
- AND u_inware.scid = :scid
- Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 Or commit_transaction.SQLNRows <= 0 THEN
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inware') > 0 THEN
- arg_msg = '更新单据资料失败,关键字ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inware') > 0 THEN
- arg_msg = '更新单据资料失败,单据编号重复'
- ELSE
- arg_msg = '更新单据资料失败,'+commit_transaction.SQLErrText
- END IF
-
-
- arg_msg = "更新单据操作失败"+"~n"+commit_transaction.SQLErrText
- GOTO ext
- END IF
-
- IF billtype > 1 Or billtype = 1 And flag = 0 THEN
-
-
- //删除原有明细
- DELETE FROM u_inwaremx
- WHERE u_inwaremx.inwareid = :inwareid
- And u_inwaremx.scid = :scid Using commit_transaction;
-
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "删除旧有单据明细操作失败"+"~n"
- GOTO ext
- END IF
-
- ELSE
-
- END IF
- END IF
- IF billtype > 1 Or billtype = 1 And flag = 0 THEN
- FOR i = 1 To it_mxbt
- IF storage_plancode_flag = 1 THEN //仓库中是否设置了使用 “进仓单号” 作为批号
- inwaremx[i].plancode = inwarecode
- END IF
- INSERT INTO u_inwaremx
- (scid,
- inwareid,
- printid,
- mtrlid,
- plancode,
- status,
- qty,
- addqty,
- packqty,
- fprice,
- rebate,
- price,
- planprice,
- mxdscrp,
- mxdscrp2,
- mxdscrp3,
- mxdscrp4,
- jgprice,
- relid,
- relprintid,
- ifrel,
- woodcode,
- relcode,
- pcode,
- sptid_cusid,
- cost,
- cost_notax,
- sptmtrlname,
- unit,
- rate,
- uprice,
- uqty,
- bootqty,
- noauditqty,
- mtrlcuscode,
- dftsptprice,
- formula,
- waredscrp,
- inworkdate,
- tax,
- buyqty,
- uamt,
- uamt_tax,
- bsamt,
- bsamt_tax,
- costamt,
- uprice_notax)
- VALUES (
- :scid,
- :inwareid,
- :inwaremx[i].printid,
- :inwaremx[i].mtrlid,
- :inwaremx[i].plancode,
- :inwaremx[i].status,
- :inwaremx[i].qty,
- :inwaremx[i].addqty,
- :inwaremx[i].packqty,
- :inwaremx[i].fprice,
- :inwaremx[i].rebate,
- :inwaremx[i].price,
- :inwaremx[i].planprice,
- :inwaremx[i].mxdscrp,
- :inwaremx[i].mxdscrp2,
- :inwaremx[i].mxdscrp3,
- :inwaremx[i].mxdscrp4,
- :inwaremx[i].jgprice,
- :inwaremx[i].relid,
- :inwaremx[i].relprintid,
- :inwaremx[i].ifrel,
- :inwaremx[i].woodcode,
- :inwaremx[i].relcode,
- :inwaremx[i].pcode,
- :inwaremx[i].sptid,
- :inwaremx[i].cost,
- :inwaremx[i].cost_notax,
- :inwaremx[i].sptmtrlname,
- :inwaremx[i].unit,
- :inwaremx[i].rate,
- :inwaremx[i].uprice,
- :inwaremx[i].uqty,
- :inwaremx[i].bootqty,
- :inwaremx[i].noauditqty,
- :inwaremx[i].mtrlcuscode,
- :inwaremx[i].dftsptprice,
- :inwaremx[i].formula,
- :inwaremx[i].waredscrp,
- :inwaremx[i].inworkdate,
- :inwaremx[i].tax,
- :inwaremx[i].buyqty,
- :inwaremx[i].uamt,
- :inwaremx[i].uamt_tax,
- :inwaremx[i].bsamt,
- :inwaremx[i].bsamt_tax,
- :inwaremx[i].costamt,
- :inwaremx[i].uprice_notax) Using commit_transaction;
- IF commit_transaction.SQLCode <> 0 THEN
- IF it_newbegin THEN inwareid = 0
- rslt = 0
-
- IF Pos(Lower(commit_transaction.SQLErrText),'PK_u_inwaremx') > 0 THEN
- arg_msg = '插入单据明细内容失败,关键字ID重复'
- ELSEIF Pos(Lower(commit_transaction.SQLErrText),'IX_u_inwaremx') > 0 THEN
- arg_msg = '插入单据明细内容失败,三个属性字段重复'
- ELSE
- arg_msg = '插入单据明细内容失败,'+commit_transaction.SQLErrText
- END IF
- GOTO ext
- END IF
- NEXT
-
- ELSE
- FOR i = 1 To it_mxbt
- UPDATE u_inWAREmx
- SET uprice = :inWAREmx[i].uprice,
- mxdscrp = :inwaremx[I].mxdscrp,
- mxdscrp2 = :inwaremx[I].mxdscrp2,
- mxdscrp3 = :inwaremx[I].mxdscrp3,
- mxdscrp4 = :inwaremx[I].mxdscrp4,
- fprice = :inwaremx[I].fprice,
- rebate = :inwaremx[I].rebate,
- price = :inwaremx[I].price,
- tax = :inwaremx[i].tax,
- uamt = :inwaremx[i].uamt,
- uamt_tax = :inwaremx[i].uamt_tax,
- bsamt = :inwaremx[i].bsamt,
- bsamt_tax = :inwaremx[i].bsamt_tax,
- uprice_notax =:inwaremx[i].uprice_notax
- WHERE ( scid = :scid AND
- inWAREid = :inwareid AND
- printid = :inwaremx[i].printid);
- IF commit_transaction.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = "更新明细价格、备注操作失败"+"~n"
- 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
- on uo_inware_other.create
- call super::create
- end on
- on uo_inware_other.destroy
- call super::destroy
- end on
|