f_cmpl_qty_check.srf 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. $PBExportHeader$f_cmpl_qty_check.srf
  2. global type f_cmpl_qty_check from function_object
  3. end type
  4. forward prototypes
  5. global function boolean f_cmpl_qty_check (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg)
  6. end prototypes
  7. global function boolean f_cmpl_qty_check (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg);Int rslt = 1
  8. datastore ds_cmp
  9. Decimal{5} ls_number
  10. String ls_exp
  11. String ls_rs
  12. Decimal ld_temp
  13. string ls_temp
  14. string ls_mtrlmode
  15. ls_exp = arg_cmpl.formula
  16. IF ls_exp = '' THEN GOTO EXT
  17. ds_cmp = CREATE datastore
  18. ds_cmp.DataObject = "ds_cmp_qty"
  19. ds_cmp.SetTransObject(sqlca)
  20. ds_cmp.Retrieve()
  21. ds_cmp.InsertRow(0)
  22. DO WHILE Pos(ls_exp,'[辅数]') > 0 OR Pos(ls_exp,'[单价]') > 0 OR Pos(ls_exp,'[折扣]') > 0 OR Pos(ls_exp,'[价格表单价]') > 0 OR &
  23. Pos(ls_exp,'[配置]') > 0 OR Pos(ls_exp,'[配置1]') > 0 OR &
  24. Pos(ls_exp,'[配置2]') > 0 OR Pos(ls_exp,'[自定义1]') > 0 OR &
  25. Pos(ls_exp,'[自定义2]') > 0 OR Pos(ls_exp,'[包装数]') > 0
  26. IF Pos(ls_exp,'[规格]') > 0 THEN
  27. ls_exp = Replace(ls_exp,Pos(ls_exp,'[规格]'),len('[规格]'),arg_cmpl.mtrlmode)
  28. END IF
  29. IF Pos(ls_exp,'[辅数]') > 0 THEN
  30. ls_exp = Replace(ls_exp,Pos(ls_exp,'[辅数]'),len('[辅数]'),String(arg_cmpl.addqty,'######0.00####'))
  31. END IF
  32. IF Pos(ls_exp,'[单价]') > 0 THEN
  33. ls_exp = Replace(ls_exp,Pos(ls_exp,'[单价]'),len('[单价]'),String(arg_cmpl.price,'######0.00####'))
  34. END IF
  35. IF Pos(ls_exp,'[价格表单价]') > 0 THEN
  36. ls_exp = Replace(ls_exp,Pos(ls_exp,'[价格表单价]'),len('[价格表单价]'),String(arg_cmpl.cusprice,'######0.00####'))
  37. END IF
  38. IF Pos(ls_exp,'[折扣]') > 0 THEN
  39. ls_exp = Replace(ls_exp,Pos(ls_exp,'[折扣]'),len('[折扣]'),String(arg_cmpl.rebate,'######0.00####'))
  40. END IF
  41. IF Pos(ls_exp,'[包装数]') > 0 THEN
  42. ls_exp = Replace(ls_exp,Pos(ls_exp,'[包装数]'),len('[包装数]'),String(arg_cmpl.packqty,'######0.00####'))
  43. END IF
  44. ls_temp ='[配置1]' // '['+ sys_option_change_woodcode + ']'
  45. IF Pos(ls_exp,ls_temp) > 0 THEN
  46. ld_temp = 0
  47. IF f_cmpl_qty_son(arg_cmpl.woodcode,ld_temp,arg_msg) = 0 THEN
  48. rslt = 0
  49. GOTO ext
  50. END IF
  51. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  52. END IF
  53. ls_temp = '[配置]' // '['+ sys_option_change_status + ']'
  54. IF Pos(ls_exp,ls_temp) > 0 THEN
  55. ld_temp = 0
  56. IF f_cmpl_qty_son(arg_cmpl.status,ld_temp,arg_msg) = 0 THEN
  57. rslt = 0
  58. GOTO ext
  59. END IF
  60. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  61. END IF
  62. ls_temp = '[配置2]' // '['+ sys_option_change_pcode + ']'
  63. IF Pos(ls_exp,ls_temp) > 0 THEN
  64. ld_temp = 0
  65. IF f_cmpl_qty_son(arg_cmpl.pcode,ld_temp,arg_msg) = 0 THEN
  66. rslt = 0
  67. GOTO ext
  68. END IF
  69. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  70. END IF
  71. ls_temp = '[自定义1]' // '['+ sys_option_change_mtrlsectype + ']'
  72. IF Pos(ls_exp,ls_temp) > 0 THEN
  73. ld_temp = 0
  74. IF f_cmpl_qty_son(arg_cmpl.mtrlsectype,ld_temp,arg_msg) = 0 THEN
  75. rslt = 0
  76. GOTO ext
  77. END IF
  78. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  79. END IF
  80. ls_temp = '[自定义2]' // '['+ sys_option_change_zxmtrlmode + ']'
  81. IF Pos(ls_exp,ls_temp) > 0 THEN
  82. ld_temp = 0
  83. IF f_cmpl_qty_son(arg_cmpl.zxmtrlmode,ld_temp,arg_msg) = 0 THEN
  84. rslt = 0
  85. GOTO ext
  86. END IF
  87. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  88. END IF
  89. LOOP
  90. ls_rs = ds_cmp.Modify("cmp.Expression='"+ ls_exp+"'")
  91. IF ls_rs = '' THEN
  92. ds_cmp.AcceptText()
  93. ls_number = ds_cmp.Object.cmp[ds_cmp.GetRow()]
  94. IF arg_cmpl.flag THEN
  95. ls_number = ls_number * Dec(arg_cmpl.addvalue)
  96. ELSE
  97. ls_number = ls_number / Dec(arg_cmpl.addvalue)
  98. END IF
  99. ls_number = Round(ls_number,arg_cmpl.num)
  100. ELSE
  101. arg_msg = '非法格式,不能计算!'+ls_exp
  102. RETURN FALSE
  103. END IF
  104. IF ABS(ls_number - arg_cmpl.oldqty) > 0.01 THEN
  105. RSLT = 0
  106. ELSE
  107. RSLT = 1
  108. END IF
  109. EXT:
  110. IF RSLT = 1 THEN
  111. RETURN TRUE
  112. ELSE
  113. RETURN FALSE
  114. END IF
  115. end function