uo_giveback.sru 24 KB

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