123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- $PBExportHeader$uo_cmplcost.sru
- forward
- global type uo_cmplcost from nonvisualobject
- end type
- end forward
- global type uo_cmplcost from nonvisualobject
- end type
- global uo_cmplcost uo_cmplcost
- type variables
- long deep = 0
- boolean ifcmpl_1 = false
- end variables
- forward prototypes
- public function integer uof_get_wageprice (long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, ref decimal arg_wageprice, ref string arg_msg)
- public function integer uof_get_cost (long arg_scid, long arg_mtrlid, string arg_mtrlcode, string arg_pfcode, decimal arg_qty, long arg_lp, ref decimal arg_price, ref decimal arg_mprice, ref decimal arg_outcost, ref decimal arg_wageprice, ref string arg_msg)
- public function integer uof_get_f_price (long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, ref decimal arg_f_price, ref string arg_msg)
- end prototypes
- public function integer uof_get_wageprice (long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, ref decimal arg_wageprice, ref string arg_msg);int rslt = 1
- decimal ld_wageprice
- SELECT sum(workprice * u_sc_workprice.workqty) INTO :ld_wageprice
- FROM u_sc_workprice
- WHERE ifownpro = 0
- AND mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode = -1 THEN
- arg_msg = '查询物料:'+arg_mtrlcode+'本厂工价失败'
- rslt = 0
- GOTO ext
- END IF
- IF IsNull(ld_wageprice) THEN ld_wageprice = 0
- arg_wageprice = ld_wageprice * arg_qty
- ext:
- return rslt
- end function
- public function integer uof_get_cost (long arg_scid, long arg_mtrlid, string arg_mtrlcode, string arg_pfcode, decimal arg_qty, long arg_lp, ref decimal arg_price, ref decimal arg_mprice, ref decimal arg_outcost, ref decimal arg_wageprice, ref string arg_msg);Int rslt = 1
- Decimal Sonscale,SonLoss,SonDECLosS
- Long SonMtrlid,count = 0,ls_i
- String mtrlcode, mtrlname
- s_pfmx ls_s_pfmx[]
- Decimal ld_price,ld_qty,ld_outcost,ld_wageprice
- Decimal ld_planprice
- Int li_mtrlorigin
- Long ll_scid
- deep++
- IF deep > 10000 THEN //防止死递归
- arg_msg = '物料:'+arg_mtrlcode+'死循环'
- rslt = 0
- GOTO ext
- END IF
- DECLARE pf_cur CURSOR FOR
- SELECT u_PrdPF.Sonscale,
- u_PrdPF.SonLoss,
- u_PrdPF.SonDECLosS,
- u_PrdPF.SonMtrlid,
- u_mtrldef.mtrlcode,
- :arg_pfcode
- FROM u_PrdPF,
- u_mtrldef
- WHERE ( u_PrdPF.SonMtrlid = u_mtrldef.mtrlid ) AND
- ( u_PrdPF.mtrlid = :arg_mtrlid ) AND
- ( u_PrdPF.pfcode = :arg_pfcode );
-
- OPEN pf_cur;
- count = 1
- FETCH pf_cur INTO :ls_s_pfmx[count].Sonscale,:ls_s_pfmx[count].SonLoss,&
- :ls_s_pfmx[count].SonDECLosS,:ls_s_pfmx[count].SonMtrlid,&
- :ls_s_pfmx[count].mtrlcode,:ls_s_pfmx[count].sonpfcode;
-
- DO WHILE sqlca.SQLCode = 0
- count++
- FETCH pf_cur INTO :ls_s_pfmx[count].Sonscale,:ls_s_pfmx[count].SonLoss,&
- :ls_s_pfmx[count].SonDECLosS,:ls_s_pfmx[count].SonMtrlid,&
- :ls_s_pfmx[count].mtrlcode,:ls_s_pfmx[count].sonpfcode;
- LOOP
- count = count - 1
- CLOSE pf_cur;
- //***查询最新采购价
- IF arg_lp > 1 OR ifcmpl_1 THEN
-
- SELECT mtrlorigin, planprice
- INTO :li_mtrlorigin, :ld_planprice
- FROM u_mtrldef
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode <> 0 THEN
- MessageBox(publ_operator,'查询:'+arg_mtrlcode+'来源失败')
- rslt = 0
- GOTO ext
- END IF
-
- CHOOSE CASE li_mtrlorigin
- CASE 2,3
- SELECT price INTO :ld_price
- FROM v_maxprice_sptprice
- Where mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode = -1 THEN
- arg_msg = '查询物料:'+arg_mtrlcode+'最新采购价或最新外加工单价失败'
- rslt = 0
- GOTO ext
- END IF
-
- IF IsNull(ld_price) THEN ld_price = 0
-
- IF li_mtrlorigin = 3 THEN
- arg_mprice = arg_mprice + ld_price * arg_qty
- END IF
-
- IF li_mtrlorigin = 2 AND count = 0 THEN
- arg_price = arg_price + ld_price * arg_qty
- rslt = 1
- GOTO ext
- END IF
-
- CASE 0
- IF arg_scid <> ll_scid THEN
- arg_price = arg_price + ld_planprice * arg_qty
- rslt = 1
- GOTO ext
- ELSE
- //计算分摊费用
- IF uof_get_f_price(arg_mtrlid,arg_mtrlcode,arg_qty,ld_outcost,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
-
- arg_outcost = arg_outcost + ld_outcost
-
-
- //计算人工
- IF uof_get_wageprice(arg_mtrlid,arg_mtrlcode,arg_qty,ld_wageprice,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_wageprice = arg_wageprice + ld_wageprice
- END IF
- END CHOOSE
- END IF
-
- FOR ls_i = 1 TO count
- ld_qty = round(arg_qty * (ls_s_pfmx[ls_i].Sonscale / (1 - ls_s_pfmx[ls_i].SonLoss) + ls_s_pfmx[ls_i].SonDECLosS),sys_option_produce_dec)
- IF uof_get_cost(arg_scid,ls_s_pfmx[ls_i].SonMtrlid,ls_s_pfmx[ls_i].mtrlcode,ls_s_pfmx[ls_i].sonpfcode,ld_qty,arg_lp+1,arg_price,arg_mprice,arg_outcost,arg_wageprice,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- NEXT
- ext:
- RETURN rslt
- end function
- public function integer uof_get_f_price (long arg_mtrlid, string arg_mtrlcode, decimal arg_qty, ref decimal arg_f_price, ref string arg_msg);Int rslt = 1
- Decimal ld_f_rice
- SELECT isnull(sum(u_mtrl_cost.cost),0) INTO :ld_f_rice
- FROM u_mtrl_cost
- Where u_mtrl_cost.mtrlid = :arg_mtrlid;
- IF sqlca.SQLCode = -1 THEN
- // arg_msg = '查询:'+arg_mtrlcode+'分摊费用成本失败,'+sqlca.sqlerrtext
- // rslt = 0
- // GOTO ext
- ld_f_rice = 0
- END IF
- IF IsNull(arg_f_price) THEN arg_f_price = 0
- arg_f_price = ld_f_rice * arg_qty
- //ext:
- RETURN rslt
- end function
- on uo_cmplcost.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on uo_cmplcost.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
|