f_cmpl_qty.srf 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. $PBExportHeader$f_cmpl_qty.srf
  2. global type f_cmpl_qty from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_cmpl_qty (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg)
  6. end prototypes
  7. global function integer f_cmpl_qty (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 Pos(ls_exp,'[配置2]') > 0 OR &
  24. Pos(ls_exp,'[自定义1]') > 0 OR Pos(ls_exp,'[自定义2]') > 0 OR Pos(ls_exp,'[包装数]') > 0 OR &
  25. Pos(ls_exp,'[明细备注]') > 0 OR Pos(ls_exp,'[明细备注2]') > 0 or Pos(ls_exp,'[明细备注3]') > 0 OR Pos(ls_exp,'[明细备注4]') > 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. ls_temp = '[明细备注]' // '['+ sys_option_change_zxmtrlmode + ']'
  90. IF Pos(ls_exp,ls_temp) > 0 THEN
  91. ld_temp = 0
  92. IF f_cmpl_qty_son(arg_cmpl.mxdscrp,ld_temp,arg_msg) = 0 THEN
  93. rslt = 0
  94. GOTO ext
  95. END IF
  96. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  97. END IF
  98. ls_temp = '[明细备注2]' // '['+ sys_option_change_zxmtrlmode + ']'
  99. IF Pos(ls_exp,ls_temp) > 0 THEN
  100. ld_temp = 0
  101. IF f_cmpl_qty_son(arg_cmpl.mxdscrp2,ld_temp,arg_msg) = 0 THEN
  102. rslt = 0
  103. GOTO ext
  104. END IF
  105. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  106. END IF
  107. ls_temp = '[明细备注3]' // '['+ sys_option_change_zxmtrlmode + ']'
  108. IF Pos(ls_exp,ls_temp) > 0 THEN
  109. ld_temp = 0
  110. IF f_cmpl_qty_son(arg_cmpl.mxdscrp3,ld_temp,arg_msg) = 0 THEN
  111. rslt = 0
  112. GOTO ext
  113. END IF
  114. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  115. END IF
  116. ls_temp = '[明细备注4]' // '['+ sys_option_change_zxmtrlmode + ']'
  117. IF Pos(ls_exp,ls_temp) > 0 THEN
  118. ld_temp = 0
  119. IF f_cmpl_qty_son(arg_cmpl.mxdscrp4,ld_temp,arg_msg) = 0 THEN
  120. rslt = 0
  121. GOTO ext
  122. END IF
  123. ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
  124. END IF
  125. LOOP
  126. ls_rs = ds_cmp.Modify("cmp.Expression='"+ ls_exp+"'")
  127. IF ls_rs = '' THEN
  128. ds_cmp.AcceptText()
  129. ls_number = ds_cmp.Object.cmp[ds_cmp.GetRow()]
  130. IF arg_cmpl.flag THEN
  131. ls_number = ls_number * Dec(arg_cmpl.addvalue)
  132. ELSE
  133. ls_number = ls_number / Dec(arg_cmpl.addvalue)
  134. END IF
  135. ls_number = Round(ls_number,arg_cmpl.num)
  136. ELSE
  137. arg_msg = '非法格式,不能计算!'+ls_exp
  138. rslt = 0
  139. GOTO ext
  140. END IF
  141. arg_qty = ls_number
  142. ext:
  143. RETURN rslt
  144. end function