123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- $PBExportHeader$f_cmpl_qty_check.srf
- global type f_cmpl_qty_check from function_object
- end type
- forward prototypes
- global function boolean f_cmpl_qty_check (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg)
- end prototypes
- global function boolean f_cmpl_qty_check (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg);Int rslt = 1
- datastore ds_cmp
- Decimal{5} ls_number
- String ls_exp
- String ls_rs
- Decimal ld_temp
- string ls_temp
- string ls_mtrlmode
- ls_exp = arg_cmpl.formula
- IF ls_exp = '' THEN GOTO EXT
- ds_cmp = CREATE datastore
- ds_cmp.DataObject = "ds_cmp_qty"
- ds_cmp.SetTransObject(sqlca)
- ds_cmp.Retrieve()
- ds_cmp.InsertRow(0)
- DO WHILE Pos(ls_exp,'[辅数]') > 0 OR Pos(ls_exp,'[单价]') > 0 OR Pos(ls_exp,'[折扣]') > 0 OR Pos(ls_exp,'[价格表单价]') > 0 OR &
- Pos(ls_exp,'[配置]') > 0 OR Pos(ls_exp,'[配置1]') > 0 OR &
- Pos(ls_exp,'[配置2]') > 0 OR Pos(ls_exp,'[自定义1]') > 0 OR &
- Pos(ls_exp,'[自定义2]') > 0 OR Pos(ls_exp,'[包装数]') > 0
- IF Pos(ls_exp,'[规格]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[规格]'),len('[规格]'),arg_cmpl.mtrlmode)
- END IF
- IF Pos(ls_exp,'[辅数]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[辅数]'),len('[辅数]'),String(arg_cmpl.addqty,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[单价]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[单价]'),len('[单价]'),String(arg_cmpl.price,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[价格表单价]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[价格表单价]'),len('[价格表单价]'),String(arg_cmpl.cusprice,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[折扣]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[折扣]'),len('[折扣]'),String(arg_cmpl.rebate,'######0.00####'))
- END IF
-
- IF Pos(ls_exp,'[包装数]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[包装数]'),len('[包装数]'),String(arg_cmpl.packqty,'######0.00####'))
- END IF
-
- ls_temp ='[配置1]' // '['+ sys_option_change_woodcode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.woodcode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[配置]' // '['+ sys_option_change_status + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.status,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[配置2]' // '['+ sys_option_change_pcode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.pcode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[自定义1]' // '['+ sys_option_change_mtrlsectype + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mtrlsectype,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[自定义2]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.zxmtrlmode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
- LOOP
-
- ls_rs = ds_cmp.Modify("cmp.Expression='"+ ls_exp+"'")
- IF ls_rs = '' THEN
- ds_cmp.AcceptText()
- ls_number = ds_cmp.Object.cmp[ds_cmp.GetRow()]
-
- IF arg_cmpl.flag THEN
- ls_number = ls_number * Dec(arg_cmpl.addvalue)
- ELSE
- ls_number = ls_number / Dec(arg_cmpl.addvalue)
- END IF
-
- ls_number = Round(ls_number,arg_cmpl.num)
-
- ELSE
- arg_msg = '非法格式,不能计算!'+ls_exp
- RETURN FALSE
- END IF
- IF ABS(ls_number - arg_cmpl.oldqty) > 0.01 THEN
- RSLT = 0
- ELSE
- RSLT = 1
- END IF
- EXT:
- IF RSLT = 1 THEN
- RETURN TRUE
- ELSE
- RETURN FALSE
- END IF
- end function
|