uo_giveback.sru 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. $PBExportHeader$uo_giveback.sru
  2. forward
  3. global type uo_giveback from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_giveback from nonvisualobject
  7. end type
  8. global uo_giveback uo_giveback
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long scid = 0 //分部id
  11. PUBLIC PROTECTEDWRITE Long givebackid //进仓单表自动增量id
  12. PUBLIC PROTECTEDWRITE String givebackcode //单据的唯一编号
  13. PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
  14. PUBLIC PROTECTEDWRITE String opemp //建立操作员
  15. PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动
  16. PUBLIC PROTECTEDWRITE String modemp //修改操作员
  17. PUBLIC PROTECTEDWRITE Int flag = 0 //仓库审核标志
  18. PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间
  19. PUBLIC PROTECTEDWRITE String auditingrep //审核操作员
  20. String relcode = ''
  21. DateTime givebackdate
  22. String dscrp = '' //备注
  23. String assign_emp = '' //经手人
  24. Long cusid = 0 //客户id
  25. DateTime startdate //开始日
  26. DateTime enddate //结束日
  27. Decimal {5} givebackrate = 0 //返利率
  28. Decimal {5} sumamt = 0 //单据总金额
  29. Long banktypeid = 0 //结算方式
  30. Long relint_3 = 0
  31. long moneyid = 0
  32. decimal givebackamt = 0
  33. int uo_option_if_givebackrate
  34. Transaction commit_transaction //数据commit事务
  35. Boolean if_getid_ture = TRUE
  36. s_givebackmx givebackmx[] //明细结构数组
  37. Long it_mxbt = 0 //明细结构数组末指针
  38. Boolean it_newbegin = FALSE //新建标志
  39. Boolean it_updatebegin = FALSE //修改标志
  40. end variables
  41. forward prototypes
  42. public function integer p_clearmx ()
  43. public function integer p_reset ()
  44. public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg)
  45. public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg)
  46. public function integer newbegin (long arg_scid, ref string arg_msg)
  47. public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg)
  48. public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg)
  49. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  50. public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit)
  51. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  52. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  53. public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate)
  54. public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate, string arg_rulsqlstr, string arg_gbratestr)
  55. end prototypes
  56. public function integer p_clearmx ();//int p_clearmx()
  57. //清除明细
  58. it_mxbt=0
  59. sumamt = 0
  60. return 1
  61. end function
  62. public function integer p_reset ();//int p_reset()
  63. //清除对象及其明细
  64. scid = 0
  65. givebackid = 0
  66. givebackcode = ''
  67. opemp = ''
  68. modemp = ''
  69. auditingrep = ''
  70. flag = 0
  71. assign_emp = ''
  72. relcode = ''
  73. dscrp = ''
  74. cusid = 0
  75. givebackrate = 0
  76. sumamt = 0
  77. moneyid = 0
  78. it_newbegin = FALSE
  79. it_updatebegin = FALSE
  80. //清除明细
  81. p_clearmx()
  82. RETURN 1
  83. end function
  84. public function integer p_getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  85. //0 失败 1成功
  86. Int rslt = 1
  87. IF arg_givebackid <= 0 THEN
  88. rslt = 0
  89. arG_MSG = "非法返利单唯一码"
  90. GOTO ext
  91. END IF
  92. SELECT givebackcode,
  93. cusid,
  94. givebackdate,
  95. startdate,
  96. enddate,
  97. givebackrate,
  98. sumamt,
  99. assign_emp,
  100. relcode,
  101. dscrp,
  102. flag,
  103. banktypeid,
  104. relint_3,
  105. moneyid,
  106. givebackamt
  107. INTO :givebackcode,
  108. :cusid,
  109. :givebackdate,
  110. :startdate,
  111. :enddate,
  112. :givebackrate,
  113. :sumamt,
  114. :assign_emp,
  115. :relcode,
  116. :dscrp,
  117. :flag,
  118. :banktypeid,
  119. :relint_3,
  120. :moneyid,
  121. :givebackamt
  122. FROM u_giveback
  123. WHERE u_giveback.givebackid = :arg_givebackid
  124. AND scid = :arg_scid USING commit_transaction;
  125. IF commit_transaction.SQLCode <> 0 THEN
  126. rslt = 0
  127. arG_MSG = "查询操作失败(错误返利单唯一码),返利单"+commit_transaction.SQLErrText
  128. GOTO ext
  129. END IF
  130. givebackid = arg_givebackid
  131. scid = arg_scid
  132. ext:
  133. IF rslt = 0 THEN p_reset()
  134. RETURN rslt
  135. end function
  136. public function integer getinfo (long arg_scid, long arg_givebackid, ref string arg_msg);//getinfo(arg_scid,arg_givebackid,arg_msg)
  137. //0 失败 1成功
  138. Int rslt = 1,i = 1,no_mxcheck = 0
  139. IF arg_givebackid <= 0 THEN
  140. rslt = 0
  141. arg_msg = "非法返利单唯一码"
  142. GOTO ext
  143. END IF
  144. rslt = p_getinfo(arg_scid,arg_givebackid,arg_msg)
  145. IF rslt = 0 THEN GOTO ext
  146. //用游标读取明细
  147. DECLARE cur_inwaermx CURSOR FOR
  148. SELECT givebackdate,
  149. relcode,
  150. printid,
  151. norebateamt,
  152. childsumamt,
  153. mxDscrp,
  154. outwareid,
  155. rulSqlStr,
  156. gbRateStr
  157. FROM u_givebackmx
  158. WHERE u_givebackmx.givebackid = :arg_givebackid AND
  159. u_givebackmx.scid = :arg_scid USING commit_transaction;
  160. OPEN cur_inwaermx;
  161. FETCH cur_inwaermx INTO :givebackmx[i].givebackdate,
  162. :givebackmx[i].relcode,:givebackmx[i].printid,
  163. :givebackmx[i].norebateamt,:givebackmx[i].childsumamt,
  164. :givebackmx[i].mxdscrp,
  165. :givebackmx[i].outwareid,
  166. :givebackmx[i].rulSqlStr,
  167. :givebackmx[i].gbRateStr;
  168. DO WHILE commit_transaction.SQLCode = 0
  169. i++
  170. FETCH cur_inwaermx INTO :givebackmx[i].givebackdate,
  171. :givebackmx[i].relcode,:givebackmx[i].printid,
  172. :givebackmx[i].norebateamt,:givebackmx[i].childsumamt,
  173. :givebackmx[i].mxdscrp,
  174. :givebackmx[i].outwareid,
  175. :givebackmx[i].rulSqlStr,
  176. :givebackmx[i].gbRateStr;
  177. LOOP
  178. CLOSE cur_inwaermx;
  179. //检验明细是否读入完整
  180. SELECT count(*) INTO :no_mxcheck
  181. FROM u_givebackmx
  182. WHERE u_givebackmx.givebackid = :arg_givebackid
  183. AND scid = :arg_scid USING commit_transaction;
  184. IF commit_transaction.SQLCode <> 0 THEN
  185. rslt = 0
  186. arg_msg = "查询操作失败,返利单明细数量"
  187. GOTO ext
  188. END IF
  189. IF i <> (no_mxcheck+1) THEN
  190. rslt = 0
  191. arg_msg = "查询操作失败,返利单明细"
  192. GOTO ext
  193. END IF
  194. givebackid = arg_givebackid
  195. scid = arg_scid
  196. it_mxbt = i - 1
  197. it_newbegin = FALSE
  198. it_updatebegin = FALSE
  199. ext:
  200. IF rslt = 0 THEN p_reset()
  201. RETURN rslt
  202. end function
  203. public function integer newbegin (long arg_scid, ref string arg_msg);//====================================================================
  204. // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
  205. //--------------------------------------------------------------------
  206. // Description: 从置对象,设定业务类型,准备建立新进仓单
  207. //--------------------------------------------------------------------
  208. // Arguments:
  209. // value long arg_scid
  210. // value integer arg_billtype
  211. // reference string arg_msg
  212. //--------------------------------------------------------------------
  213. // Returns: integer
  214. //--------------------------------------------------------------------
  215. // Author: yyx Date: 2003.11.12
  216. //--------------------------------------------------------------------
  217. // Modify History:
  218. //
  219. //====================================================================
  220. int rslt=1
  221. if arg_scid < 0 then
  222. arg_msg = '请选择分部'
  223. rslt = 0
  224. goto ext
  225. end if
  226. p_reset()
  227. scid=arg_scid
  228. it_newbegin=true
  229. it_updatebegin=false
  230. ext:
  231. if rslt=0 then p_reset()
  232. return rslt
  233. end function
  234. public function integer updatebegin (long arg_scid, long arg_givebackid, ref string arg_msg);//====================================================================
  235. // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
  236. //--------------------------------------------------------------------
  237. // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
  238. //--------------------------------------------------------------------
  239. // Arguments:
  240. // value long arg_scid
  241. // value long arg_inwareid
  242. // value integer arg_billtype
  243. // reference string arg_msg
  244. //--------------------------------------------------------------------
  245. // Returns: integer
  246. //--------------------------------------------------------------------
  247. // Author: yyx Date: 2003.11.12
  248. //--------------------------------------------------------------------
  249. // Modify History:
  250. //
  251. //====================================================================
  252. long rslt=1
  253. if arg_scid < 0 then
  254. arg_msg = '请选择分部'
  255. rslt = 0
  256. goto ext
  257. end if
  258. if arg_givebackid<=0 then
  259. rslt=0
  260. goto ext
  261. end if
  262. rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg)
  263. if rslt=0 then goto ext
  264. if flag=1 then
  265. rslt=0
  266. arg_msg='单据已经审核,不可以修改'
  267. goto ext
  268. end if
  269. givebackid=arg_givebackid
  270. scid=arg_scid
  271. it_newbegin=false
  272. it_updatebegin=true
  273. p_clearmx() //清除明细
  274. ext:
  275. if rslt=0 then p_reset()
  276. return rslt
  277. end function
  278. public function integer add_dscrp (long arg_scid, long arg_givebackid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  279. //0 fail 1 success
  280. int rslt=1
  281. arg_newdescppart=trim(arg_newdescppart)
  282. if it_updatebegin or it_newbegin then
  283. rslt=0
  284. arg_msg="编辑状态下不可用"
  285. goto ext
  286. end if
  287. if arg_newdescppart='' then
  288. rslt=0
  289. arg_msg="要添加内容为空,操作取消"
  290. goto ext
  291. end if
  292. rslt=p_getinfo(arg_scid,arg_givebackid,arg_msg)
  293. if rslt=0 then goto ext
  294. if flag=0 then
  295. rslt=0
  296. arg_msg="非审核状态下不可用"
  297. goto ext
  298. end if
  299. update u_giveback
  300. set dscrp = dscrp+' '+:arg_newdescppart
  301. where u_giveback.givebackid = :givebackid
  302. and scid=:scid using commit_transaction;
  303. if commit_transaction.sqlcode<>0 then
  304. rollback ;
  305. rslt=0
  306. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
  307. goto ext
  308. end if
  309. commit using commit_transaction;
  310. dscrp = dscrp+' '+arg_newdescppart
  311. ext: return (rslt)
  312. end function
  313. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  314. DateTime server_dt
  315. Long ls_newid
  316. String ls_sccode
  317. IF uo_option_if_givebackrate = -1000 THEN
  318. rslt = 0
  319. arg_msg = '选项:[097]返利单按返利率返利,读取初始默认值失败,操作取消!'
  320. GOTO ext
  321. END IF
  322. IF IsNull(givebackrate) THEN givebackrate = 0
  323. IF IsNull(cusid) THEN cusid = 0
  324. IF IsNull(assign_emp) THEN assign_emp = ''
  325. IF IsNull(sumamt) THEN sumamt = 0
  326. IF IsNull(relcode) THEN relcode = ''
  327. IF IsNull(dscrp) THEN dscrp = ''
  328. IF uo_option_if_givebackrate = 1 THEN
  329. givebackamt = givebackrate * sumamt
  330. ELSE
  331. givebackrate = 0
  332. sumamt = 0
  333. it_mxbt = 0
  334. END IF
  335. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  336. rslt = 0
  337. arg_msg = "非编辑状态不可以提交"
  338. GOTO ext
  339. END IF
  340. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  341. //取得系统时间,借用操作员表
  342. IF commit_transaction.SQLCode <> 0 THEN
  343. rslt = 0
  344. arg_msg = "查询操作失败,日期 "
  345. GOTO ext
  346. END IF
  347. IF uo_option_if_givebackrate = 1 THEN
  348. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  349. rslt = 0
  350. arg_msg = "没有正确明细内容"
  351. GOTO ext
  352. END IF
  353. END IF
  354. IF f_check_inoutdate(0,givebackdate,FALSE,arg_msg) = 0 THEN
  355. rslt = 0
  356. GOTO ext
  357. END IF
  358. IF banktypeid = 0 THEN
  359. arg_msg = '请选择结算方式'
  360. rslt = 0
  361. GOTO ext
  362. END IF
  363. IF moneyid = 0 THEN
  364. arg_msg = '请选择结算方式'
  365. rslt = 0
  366. GOTO ext
  367. END IF
  368. cnt = 0
  369. SELECT count(*) INTO :cnt
  370. FROM cw_currency
  371. Where moneyid = :moneyid;
  372. IF sqlca.SQLCode <> 0 THEN
  373. arg_msg = '查询币种失败'
  374. rslt = 0
  375. GOTO ext
  376. END IF
  377. IF cnt = 0 THEN
  378. arg_msg = '币种资料不存在'
  379. rslt = 0
  380. GOTO ext
  381. END IF
  382. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  383. IF givebackid = 0 THEN //新建
  384. ls_newid = f_sys_scidentity(scid,"u_giveback","givebackid",arg_msg,TRUE,id_sqlca)
  385. IF ls_newid <= 0 THEN
  386. rslt = 0
  387. GOTO ext
  388. END IF
  389. //取分部代号
  390. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  391. rslt = 0
  392. GOTO ext
  393. END IF
  394. //取得新单据编号
  395. givebackcode = getid(scid,ls_sccode + 'FL',Date(server_dt),if_getid_ture,commit_transaction)
  396. IF givebackcode = "err" THEN
  397. givebackcode = ''
  398. rslt = 0
  399. arg_msg = "无法获取返利单编号"+"~n"+commit_transaction.SQLErrText
  400. GOTO ext
  401. END IF
  402. INSERT INTO u_giveback (
  403. scid,
  404. givebackid,
  405. givebackcode,
  406. cusid,
  407. givebackdate,
  408. startdate,
  409. enddate,
  410. givebackrate,
  411. sumamt,
  412. assign_emp,
  413. relcode,
  414. dscrp,
  415. opdate,
  416. opemp,
  417. flag,
  418. banktypeid,
  419. moneyid,
  420. givebackamt)
  421. VALUES (
  422. :scid,
  423. :ls_newid,
  424. :givebackcode,
  425. :cusid,
  426. :givebackdate,
  427. :startdate,
  428. :enddate,
  429. :givebackrate,
  430. :sumamt,
  431. :assign_emp,
  432. :relcode,
  433. :dscrp,
  434. :server_dt,
  435. :publ_operator,
  436. :flag,
  437. :banktypeid,
  438. :moneyid,
  439. :givebackamt) USING commit_transaction ;
  440. IF commit_transaction.SQLCode <> 0 THEN
  441. rslt = 0
  442. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  443. GOTO ext
  444. END IF
  445. //读取新givebackid
  446. givebackid = ls_newid
  447. FOR i = 1 TO it_mxbt
  448. INSERT INTO u_givebackmx
  449. (scid,
  450. givebackid,
  451. givebackdate,
  452. outwareid,
  453. relcode,
  454. printid,
  455. norebateamt,
  456. childsumamt,
  457. mxDscrp,
  458. rulSqlStr,
  459. gbRateStr)
  460. VALUES (
  461. :scid,
  462. :ls_newid,
  463. :givebackmx[i].givebackdate,
  464. :givebackmx[i].outwareid,
  465. :givebackmx[i].relcode,
  466. :givebackmx[i].printid,
  467. :givebackmx[i].norebateamt,
  468. :givebackmx[i].childsumamt,
  469. :givebackmx[i].mxDscrp,
  470. :givebackmx[i].rulSqlStr,
  471. :givebackmx[i].gbRateStr) USING commit_transaction;
  472. IF commit_transaction.SQLCode <> 0 THEN
  473. givebackid = 0 //还原givebackid
  474. rslt = 0
  475. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  476. GOTO ext
  477. END IF
  478. NEXT
  479. ELSE //////////////////////////////////////////////// //更新
  480. UPDATE u_giveback
  481. SET cusid = :cusid,
  482. givebackdate = :givebackdate,
  483. startdate = :startdate,
  484. enddate = :enddate,
  485. givebackrate = :givebackrate,
  486. sumamt = :sumamt,
  487. assign_emp = :assign_emp,
  488. relcode = :relcode,
  489. dscrp = :dscrp,
  490. moddate = : server_dt,
  491. modemp = :publ_operator,
  492. banktypeid = :banktypeid,
  493. moneyid = :moneyid,
  494. givebackamt = :givebackamt
  495. WHERE u_giveback.givebackid = :givebackid
  496. AND u_giveback.scid = :scid
  497. AND flag = 0 USING commit_transaction;
  498. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  499. rslt = 0
  500. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  501. GOTO ext
  502. END IF
  503. //删除原有明细
  504. DELETE FROM u_givebackmx
  505. WHERE u_givebackmx.givebackid = :givebackid
  506. AND u_givebackmx.scid = :scid USING commit_transaction;
  507. IF commit_transaction.SQLCode <> 0 THEN
  508. rslt = 0
  509. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  510. GOTO ext
  511. END IF
  512. FOR i = 1 TO it_mxbt
  513. INSERT INTO u_givebackmx
  514. (scid,
  515. givebackid,
  516. givebackdate,
  517. outwareid,
  518. relcode,
  519. printid,
  520. norebateamt,
  521. childsumamt,
  522. mxDscrp,
  523. rulSqlStr,
  524. gbRateStr)
  525. VALUES (
  526. :scid,
  527. :givebackid,
  528. :givebackmx[i].givebackdate,
  529. :givebackmx[i].outwareid,
  530. :givebackmx[i].relcode,
  531. :givebackmx[i].printid,
  532. :givebackmx[i].norebateamt,
  533. :givebackmx[i].childsumamt,
  534. :givebackmx[i].mxDscrp,
  535. :givebackmx[i].rulSqlStr,
  536. :givebackmx[i].gbRateStr) USING commit_transaction;
  537. IF commit_transaction.SQLCode <> 0 THEN
  538. rslt = 0
  539. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  540. GOTO ext
  541. END IF
  542. NEXT
  543. END IF
  544. it_newbegin = FALSE
  545. it_updatebegin = FALSE
  546. ext:
  547. IF rslt = 0 THEN
  548. ROLLBACK USING commit_transaction;
  549. p_clearmx()
  550. ELSEIF rslt = 1 AND arg_ifcommit THEN
  551. COMMIT USING commit_transaction;
  552. END IF
  553. RETURN rslt
  554. end function
  555. public function integer del (long arg_scid, long arg_givebackid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
  556. //0 FAIL, 1 SUCCESS
  557. Int rslt = 1
  558. IF arg_givebackid <= 0 THEN
  559. rslt = 0
  560. arG_MSG = "没有删除对象,操作取消"
  561. GOTO ext
  562. END IF
  563. IF p_getinfo(arg_scid,arg_givebackid,arG_MSG) = 0 THEN
  564. rslt = 0
  565. GOTO ext
  566. END IF
  567. IF flag = 1 THEN
  568. rslt = 0
  569. arG_MSG = "单据已经审核,不可以删除"
  570. GOTO ext
  571. END IF
  572. DELETE FROM u_giveback
  573. WHERE u_giveback.givebackid = :arg_givebackid
  574. AND u_giveback.scid = :arg_scid USING commit_transaction;
  575. IF commit_transaction.SQLCode <> 0 THEN
  576. rslt = 0
  577. arG_MSG = "删除返利单操作失败"+"~n"+commit_transaction.SQLErrText
  578. GOTO ext
  579. END IF
  580. DELETE FROM u_givebackmx
  581. WHERE u_givebackmx.givebackid = :arg_givebackid
  582. AND u_givebackmx.scid = :arg_scid USING commit_transaction;
  583. IF commit_transaction.SQLCode <> 0 THEN
  584. rslt = 0
  585. arG_MSG = "删除返利单明细操作失败"+"~n"+commit_transaction.SQLErrText
  586. GOTO ext
  587. END IF
  588. it_newbegin = FALSE
  589. it_updatebegin = FALSE
  590. ext:
  591. IF rslt = 0 THEN
  592. ROLLBACK USING commit_transaction;
  593. p_reset()
  594. ELSEIF rslt = 1 AND arg_ifcommit THEN
  595. COMMIT USING commit_transaction;
  596. END IF
  597. RETURN (rslt)
  598. end function
  599. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0
  600. uo_musttake uo_take
  601. uo_take = CREATE uo_musttake
  602. Decimal ld_takeamt = 0,ld_msttakeamt = 0,ld_mrate
  603. IF givebackid = 0 THEN
  604. rslt = 0
  605. arg_msg = "没有审核对象"
  606. GOTO ext
  607. END IF
  608. IF flag = 1 THEN
  609. rslt = 0
  610. arg_msg = "单据已经审核"
  611. GOTO ext
  612. END IF
  613. SELECT count(*) INTO :cnt
  614. FROM u_user
  615. Where username = :publ_operator USING commit_transaction ;
  616. IF commit_transaction.SQLCode <> 0 THEN
  617. rslt = 0
  618. arg_msg = "查询操作失败,操作员"
  619. GOTO ext
  620. END IF
  621. IF cnt = 0 THEN
  622. rslt = 0
  623. arg_msg = "操作员姓名未登记或已取消"
  624. GOTO ext
  625. END IF
  626. ld_mrate = f_get_mrate(moneyid)
  627. if ld_mrate = 0 then
  628. rslt = 0
  629. arg_msg = '错误的币种汇率'
  630. goto ext
  631. end if
  632. Int li_btype
  633. Long ll_accountsid
  634. SELECT btype,accountsid INTO :li_btype,:ll_accountsid
  635. FROM cw_banktype
  636. Where banktypeid = :banktypeid USING commit_transaction;
  637. IF commit_transaction.SQLCode <> 0 THEN
  638. rslt = 0
  639. arg_msg = '查询结算方式类型失败,'+ commit_transaction.SQLErrText
  640. GOTO ext
  641. END IF
  642. UPDATE u_giveback
  643. SET auditingrep = :publ_operator,
  644. auditingdate = getdate(),
  645. flag = 1
  646. WHERE u_giveback.givebackid = :givebackid
  647. AND flag = 0
  648. AND scid = :scid USING commit_transaction;
  649. IF commit_transaction.SQLCode <> 0 THEN
  650. rslt = 0
  651. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  652. GOTO ext
  653. ELSEIF commit_transaction.SQLNRows = 0 THEN
  654. rslt = 0
  655. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  656. GOTO ext
  657. END IF
  658. String ls_about = '',ls_dscrp = ''
  659. Decimal sum_amt
  660. sum_amt = 0 - Round(givebackamt,2)
  661. IF sum_amt <> 0 THEN
  662. ls_about = givebackcode + "返利款"
  663. ls_dscrp = ls_about
  664. ld_msttakeamt = sum_amt
  665. IF li_btype = 1 THEN
  666. ld_takeamt = ld_msttakeamt
  667. ELSE
  668. ld_takeamt = 0
  669. END IF
  670. Long ll_dft_itemid
  671. SELECT itemid INTO :ll_dft_itemid
  672. FROM u_itemdef
  673. Where dfttype = 6;
  674. IF sqlca.SQLCode <> 0 THEN
  675. arg_msg = '查询默认销售返利资料失败,'+sqlca.sqlerrtext
  676. rslt = 0
  677. GOTO ext
  678. END IF
  679. s_bmsttake s_take
  680. s_take.scid = scid
  681. s_take.cusid = cusid
  682. s_take.takedate = givebackdate
  683. s_take.inrep = assign_emp
  684. s_take.oriamt = ld_msttakeamt
  685. s_take.msttakeamt = ld_msttakeamt
  686. s_take.takeamt = ld_takeamt
  687. s_take.dscrp = ls_about
  688. s_take.billcode = givebackcode
  689. s_take.relcode = relcode
  690. s_take.banktypeid = banktypeid
  691. s_take.opemp = publ_operator
  692. s_take.buildtype = 1
  693. s_take.outwareid = givebackid
  694. s_take.accountsid = ll_accountsid
  695. s_take.itemid = ll_dft_itemid
  696. s_take.moneyid = moneyid
  697. s_take.takeamt_cn = ld_takeamt
  698. s_take.moneyid_cn = moneyid
  699. s_take.mrate = ld_mrate
  700. IF uo_take.add_takerec (s_take,arg_msg,FALSE) = 0 THEN
  701. rslt = 0
  702. GOTO ext
  703. END IF
  704. UPDATE u_giveback
  705. SET relint_3 = :uo_take.ref_takeid
  706. WHERE u_giveback.givebackid = :givebackid
  707. AND scid = :scid
  708. AND flag = 1 USING commit_transaction;
  709. IF commit_transaction.SQLCode <> 0 THEN
  710. arg_msg = '更新返利单相关应收帐ID失败'
  711. rslt = 0
  712. GOTO ext
  713. END IF
  714. END IF
  715. flag = 1
  716. ext:
  717. IF rslt = 0 THEN
  718. ROLLBACK USING commit_transaction;
  719. ELSEIF rslt = 1 AND arg_ifcommit THEN
  720. COMMIT USING commit_transaction;
  721. END IF
  722. RETURN rslt
  723. end function
  724. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0
  725. DateTime null_dt
  726. SetNull(null_dt)
  727. uo_musttake uo_take
  728. uo_take = CREATE uo_musttake
  729. IF givebackid = 0 THEN
  730. rslt = 0
  731. arg_msg = "没有审核对象"
  732. GOTO ext
  733. END IF
  734. IF flag = 0 THEN
  735. rslt = 0
  736. arg_msg = "单据还未审核"
  737. GOTO ext
  738. END IF
  739. SELECT count(*) INTO :cnt
  740. FROM u_user
  741. Where username = :publ_operator USING commit_transaction ;
  742. IF commit_transaction.SQLCode <> 0 THEN
  743. rslt = 0
  744. arg_msg = "查询操作失败,操作员"
  745. GOTO ext
  746. END IF
  747. IF cnt = 0 THEN
  748. rslt = 0
  749. arg_msg = "操作员姓名未登记或已取消"
  750. GOTO ext
  751. END IF
  752. UPDATE u_giveback
  753. SET Auditingrep = '',
  754. Auditingdate = :null_dt,
  755. flag = 0,
  756. relint_3 = 0
  757. WHERE u_giveback.givebackid = :givebackid
  758. AND flag = 1
  759. AND scid = :scid USING commit_transaction;
  760. IF commit_transaction.SQLCode <> 0 THEN
  761. rslt = 0
  762. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  763. GOTO ext
  764. ELSEIF commit_transaction.SQLNRows = 0 THEN
  765. rslt = 0
  766. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  767. GOTO ext
  768. END IF
  769. Decimal sum_amt
  770. sum_amt = 0 - Round(givebackamt,2)
  771. IF sum_amt <> 0 THEN
  772. IF uo_take.del_takerec(scid,1,relint_3,cusid,arg_msg,FALSE) = 0 THEN
  773. rslt = 0
  774. GOTO ext
  775. END IF
  776. END IF
  777. flag = 0
  778. ext:
  779. IF rslt = 0 THEN
  780. ROLLBACK USING commit_transaction;
  781. ELSEIF rslt = 1 AND arg_ifcommit THEN
  782. COMMIT USING commit_transaction;
  783. END IF
  784. RETURN rslt
  785. end function
  786. public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate);Long rslt = 1,cnt = 0
  787. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  788. rslt = 0
  789. arg_msg = "非编辑状态不可以使用,操作取消"
  790. GOTO ext
  791. END IF
  792. //清除空值
  793. IF IsNull(arg_norebateamt) THEN arg_norebateamt = 0
  794. IF IsNull(arg_childsumamt) THEN arg_childsumamt = 0
  795. IF IsNull(arg_printid) THEN arg_printid = 0
  796. IF IsNull(arg_outwareid) THEN arg_outwareid = 0
  797. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  798. IF IsNull(arg_relcode) THEN arg_relcode = ''
  799. if arg_norebateamt<0 then
  800. rslt = 0
  801. arg_msg = "有明细单据金额小于零,操作取消"
  802. GOTO ext
  803. END IF
  804. ////检查相关销售单
  805. //select count(*)
  806. //into :cnt
  807. //FROM u_outware INNER JOIN
  808. // u_outwaremx ON u_outware.scid = u_outwaremx.scid AND
  809. // u_outware.outwareid = u_outwaremx.outwareid
  810. //where u_outware.outwareid=:arg_outwareid and u_outware.scid=:scid
  811. // and u_outwaremx.rebate=1 using commit_transaction;
  812. //IF commit_transaction.SQLCode <> 0 THEN
  813. // rslt = 0
  814. // arG_MSG = "查询操作失败,相关销售单"
  815. // GOTO ext
  816. //END IF
  817. //IF cnt = 0 THEN
  818. // rslt = 0
  819. // arG_MSG = "错误的销售单: "+String(arg_relcode)
  820. // GOTO ext
  821. //END IF
  822. //写入内容
  823. it_mxbt++
  824. sumamt=sumamt+arg_norebateamt
  825. givebackmx[it_mxbt].outwareid = arg_outwareid
  826. givebackmx[it_mxbt].norebateamt = arg_norebateamt
  827. givebackmx[it_mxbt].childsumamt = arg_childsumamt
  828. givebackmx[it_mxbt].relcode = arg_relcode
  829. givebackmx[it_mxbt].givebackdate = arg_givebackdate
  830. givebackmx[it_mxbt].mxdscrp = arg_mxdscrp
  831. givebackmx[it_mxbt].printid = arg_printid
  832. givebackmx[it_mxbt].rulSqlStr = ""
  833. givebackmx[it_mxbt].gbRateStr = ""
  834. ext:
  835. IF rslt = 0 THEN p_clearmx()
  836. RETURN rslt
  837. end function
  838. public function integer acceptmx (decimal arg_norebateamt, decimal arg_childsumamt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_outwareid, string arg_relcode, datetime arg_givebackdate, string arg_rulsqlstr, string arg_gbratestr);
  839. Long rslt = 1,cnt = 0
  840. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  841. rslt = 0
  842. arg_msg = "非编辑状态不可以使用,操作取消"
  843. GOTO ext
  844. END IF
  845. //清除空值
  846. IF IsNull(arg_norebateamt) THEN arg_norebateamt = 0
  847. IF IsNull(arg_childsumamt) THEN arg_childsumamt = 0
  848. IF IsNull(arg_printid) THEN arg_printid = 0
  849. IF IsNull(arg_outwareid) THEN arg_outwareid = 0
  850. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  851. IF IsNull(arg_relcode) THEN arg_relcode = ''
  852. IF IsNull(arg_rulSqlStr) THEN arg_rulSqlStr = ''
  853. IF IsNull(arg_gbRateStr) THEN arg_gbRateStr = ''
  854. if arg_norebateamt<0 then
  855. rslt = 0
  856. arg_msg = "有明细单据金额小于零,操作取消"
  857. GOTO ext
  858. END IF
  859. ////检查相关销售单
  860. //select count(*)
  861. //into :cnt
  862. //FROM u_outware INNER JOIN
  863. // u_outwaremx ON u_outware.scid = u_outwaremx.scid AND
  864. // u_outware.outwareid = u_outwaremx.outwareid
  865. //where u_outware.outwareid=:arg_outwareid and u_outware.scid=:scid
  866. // and u_outwaremx.rebate=1 using commit_transaction;
  867. //IF commit_transaction.SQLCode <> 0 THEN
  868. // rslt = 0
  869. // arG_MSG = "查询操作失败,相关销售单"
  870. // GOTO ext
  871. //END IF
  872. //IF cnt = 0 THEN
  873. // rslt = 0
  874. // arG_MSG = "错误的销售单: "+String(arg_relcode)
  875. // GOTO ext
  876. //END IF
  877. //写入内容
  878. it_mxbt++
  879. sumamt=sumamt+arg_norebateamt
  880. givebackmx[it_mxbt].outwareid = arg_outwareid
  881. givebackmx[it_mxbt].norebateamt = arg_norebateamt
  882. givebackmx[it_mxbt].childsumamt = arg_childsumamt
  883. givebackmx[it_mxbt].relcode = arg_relcode
  884. givebackmx[it_mxbt].givebackdate = arg_givebackdate
  885. givebackmx[it_mxbt].mxdscrp = arg_mxdscrp
  886. givebackmx[it_mxbt].printid = arg_printid
  887. givebackmx[it_mxbt].rulSqlStr = arg_rulSqlStr
  888. givebackmx[it_mxbt].gbRateStr = arg_gbRateStr
  889. ext:
  890. IF rslt = 0 THEN p_clearmx()
  891. RETURN rslt
  892. end function
  893. on uo_giveback.create
  894. call super::create
  895. TriggerEvent( this, "constructor" )
  896. end on
  897. on uo_giveback.destroy
  898. TriggerEvent( this, "destructor" )
  899. call super::destroy
  900. end on
  901. event constructor;String str_optionvalue,arg_msg
  902. f_get_sys_option_value('097',str_optionvalue,arg_msg)
  903. uo_option_if_givebackrate = Long(str_optionvalue)
  904. end event