uo_asset_clear.sru 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. $PBExportHeader$uo_asset_clear.sru
  2. forward
  3. global type uo_asset_clear from nonvisualobject
  4. end type
  5. type s_astclear from structure within uo_asset_clear
  6. end type
  7. end forward
  8. type s_astclear from structure
  9. long assetcardid
  10. long incrdecid
  11. decimal {5} earing
  12. decimal {5} payout
  13. string dscrp
  14. datetime cleardate
  15. end type
  16. global type uo_asset_clear from nonvisualobject
  17. end type
  18. global uo_asset_clear uo_asset_clear
  19. type variables
  20. public protectedwrite long accsetid
  21. public protectedwrite long astclearid
  22. public protectedwrite datetime opdate
  23. public protectedwrite string opemp
  24. datetime billdate//清理日期
  25. string memo//清理原因
  26. string relcode
  27. string dscrp //摘要
  28. string othersubid //对方科目
  29. long credid
  30. private:
  31. s_astclear astclearmx[]
  32. long it_mxbt=0
  33. BOOLEAN IT_NEWBEGIN=FALSE //新建标志
  34. BOOLEAN IT_UPDATEBEGIN=FALSE//修改标志
  35. end variables
  36. forward prototypes
  37. public function integer newbegin ()
  38. public function integer p_reset ()
  39. public function integer getinfo (long arg_astclearid, ref string arg_msg)
  40. public function integer del (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit)
  41. public function integer p_clearmx ()
  42. public function integer save (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit)
  43. public function integer p_getinfo (long arg_astclearid, ref string arg_msg)
  44. public function integer updatebegin (long arg_astclearid, string arg_msg)
  45. public function integer acceptmx (long arg_assetcardid, long arg_incrdecid, decimal arg_earing, decimal arg_payout, ref string arg_msg, string arg_dscrp)
  46. end prototypes
  47. public function integer newbegin ();//newbegin()
  48. //从置对象,准备建立新凭证
  49. //0 fail 1 success
  50. LONG RSLT=1
  51. p_reset()
  52. it_newbegin=TRUE
  53. it_updatebegin=FALSE
  54. IF RSLT=0 THEN p_reset()
  55. return RSLT
  56. end function
  57. public function integer p_reset ();//INT p_RESET()
  58. //清除对象
  59. accsetid = 0
  60. astclearid = 0
  61. dscrp = ''
  62. memo = ''
  63. relcode = ''
  64. othersubid = ''
  65. credid = 0
  66. it_newbegin=FALSE
  67. it_updatebegin=FALSE
  68. p_clearmx()
  69. RETURN 1
  70. end function
  71. public function integer getinfo (long arg_astclearid, ref string arg_msg);//取固定资产清理信息
  72. Int rslt = 1
  73. Long i = 1,no_mxcheck = 0
  74. IF arg_astclearid <= 0 THEN
  75. rslt = 0
  76. arg_msg = '固定资产清理ID错误'
  77. GOTO ext
  78. END IF
  79. rslt = p_getinfo(arg_astclearid,arg_msg)
  80. IF rslt = 0 THEN GOTO ext
  81. DECLARE cur_astclearmx CURSOR FOR
  82. SELECT cw_astclear.assetcardid,
  83. cw_astclear.incrdecid,
  84. cw_astclear.earing,
  85. cw_astclear.payout,
  86. cw_astclear.dscrp,
  87. cw_astclear.cleardate
  88. FROM cw_astclear
  89. WHERE cw_astclear.astclearid = :arg_astclearid
  90. AND cw_astclear.accsetid = :sys_accsetid;
  91. OPEN cur_astclearmx;
  92. FETCH cur_astclearmx INTO :astclearmx[i].assetcardid,:astclearmx[i].incrdecid,
  93. :astclearmx[i].earing,:astclearmx[i].payout,:astclearmx[i].dscrp,:astclearmx[i].cleardate;
  94. DO WHILE sqlca.SQLCode = 0
  95. i++
  96. FETCH cur_astclearmx INTO :astclearmx[i].assetcardid,:astclearmx[i].incrdecid,
  97. :astclearmx[i].earing,:astclearmx[i].payout,:astclearmx[i].dscrp,:astclearmx[i].cleardate;
  98. LOOP
  99. CLOSE cur_astclearmx;
  100. //检验明细是否读入完整
  101. SELECT count(*) INTO :no_mxcheck
  102. FROM cw_astclear
  103. WHERE cw_astclear.astclearid = :arg_astclearid
  104. AND cw_astclear.accsetid = :sys_accsetid;
  105. IF sqlca.SQLCode <> 0 THEN
  106. rslt = 0
  107. arg_msg = "查询操作失败,单据明细数量"
  108. GOTO ext
  109. END IF
  110. IF i <> (no_mxcheck+1) THEN
  111. rslt = 0
  112. arg_msg = "查询操作失败,资产减少单明细"
  113. GOTO ext
  114. END IF
  115. astclearid = arg_astclearid
  116. accsetid = sys_accsetid
  117. it_mxbt = i - 1
  118. it_newbegin = FALSE
  119. it_updatebegin = FALSE
  120. ext:
  121. IF rslt = 0 THEN p_reset()
  122. RETURN rslt
  123. end function
  124. public function integer del (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  125. IF getinfo(arg_astclearid,arg_msg) = 0 THEN
  126. rslt = 0
  127. GOTO ext
  128. END IF
  129. DELETE FROM cw_astclear
  130. WHERE cw_astclear.astclearid = :arg_astclearid
  131. AND cw_astclear.accsetid = :sys_accsetid;
  132. IF sqlca.SQLCode <> 0 THEN
  133. rslt = 0
  134. arg_msg = "删除固定资产清理明细操作失败"+"~n"+sqlca.SQLErrText
  135. GOTO ext
  136. END IF
  137. DELETE FROM cw_astclear_bill
  138. WHERE cw_astclear_bill.astclearid = :arg_astclearid
  139. AND cw_astclear_bill.accsetid = :sys_accsetid;
  140. IF sqlca.SQLCode <> 0 THEN
  141. rslt = 0
  142. arg_msg = "删除固定资产清理操作失败"+"~n"+sqlca.SQLErrText
  143. GOTO ext
  144. END IF
  145. it_newbegin = FALSE
  146. it_updatebegin = FALSE
  147. IF rslt = 0 THEN
  148. ROLLBACK;
  149. p_reset()
  150. ELSEIF rslt = 1 AND arg_ifcommit THEN
  151. COMMIT;
  152. END IF
  153. ext:
  154. RETURN (rslt)
  155. end function
  156. public function integer p_clearmx ();it_mxbt=0
  157. return 1
  158. end function
  159. public function integer save (long arg_astclearid, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0
  160. Long ls_astclearid,i
  161. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  162. rslt = 0
  163. arG_MSG = "非编辑状态不可以提交"
  164. GOTO ext
  165. END IF
  166. IF IsNull(memo) THEN memo = ''
  167. IF IsNull(othersubid) THEN othersubid = ''
  168. IF IsNull(relcode) THEN relcode = ''
  169. IF IsNull(credid) THEN credid = 0
  170. IF billdate < DateTime(1900-01-01,Now()) THEN
  171. rslt = 0
  172. arG_MSG = '不合理减少日期!'
  173. GOTO ext
  174. END IF
  175. IF billdate < DateTime(f_rst_mon_1st(1,sys_curyearmon)) THEN
  176. arG_MSG = '减少日期不能在当前会计期间之前!'
  177. rslt = 0
  178. GOTO ext
  179. END IF
  180. IF billdate > DateTime(f_rst_mon_1st(3,sys_curyearmon)) THEN
  181. arG_MSG = '减少日期不能在当前会计期间之后!'
  182. rslt = 0
  183. GOTO ext
  184. END IF
  185. IF astclearid = 0 THEN //新建
  186. ls_astclearid = arg_astclearid
  187. IF ls_astclearid = 0 THEN
  188. ls_astclearid = f_sys_scidentity(sys_accsetid,"cw_astclear_bill","astclearid",arG_MSG,TRUE,id_sqlca)
  189. IF ls_astclearid <= 0 THEN
  190. rslt = 0
  191. GOTO ext
  192. END IF
  193. END IF
  194. INSERT INTO cw_astclear_bill (
  195. accsetid,
  196. astclearid,
  197. billdate,
  198. relcode,
  199. memo,
  200. dscrp,
  201. othersubid,
  202. credid)
  203. VALUES ( :sys_accsetid,
  204. :ls_astclearid,
  205. :billdate,
  206. :relcode,
  207. :memo,
  208. :dscrp,
  209. :othersubid,
  210. :credid) ;
  211. IF SQLCA.SQLCode <> 0 THEN
  212. rslt = 0
  213. arG_MSG = "因网络或其它原因导致新建固定资产清理操作失败"+"~n"+SQLCA.SQLErrText
  214. GOTO ext
  215. END IF
  216. FOR i = 1 TO it_mxbt
  217. INSERT INTO cw_astclear (
  218. accsetid,
  219. astclearid,
  220. assetcardid,
  221. incrdecid,
  222. earing,
  223. payout,
  224. dscrp,
  225. cleardate)
  226. VALUES ( :sys_accsetid,
  227. :ls_astclearid,
  228. :astclearmx[i].assetcardid,
  229. :astclearmx[i].incrdecid,
  230. :astclearmx[i].earing,
  231. :astclearmx[i].payout,
  232. :astclearmx[i].dscrp,
  233. :astclearmx[i].cleardate) ;
  234. IF SQLCA.SQLCode <> 0 THEN
  235. rslt = 0
  236. arG_MSG = "因网络或其它原因导致新建固定资产清理明细操作失败"+"~n"+SQLCA.SQLErrText
  237. GOTO ext
  238. END IF
  239. NEXT
  240. astclearid = ls_astclearid
  241. ELSE //////////////////////////////////////////////////更新
  242. UPDATE cw_astclear_bill
  243. SET memo = :memo,
  244. billdate = :billdate,
  245. credid = :credid,
  246. dscrp = :dscrp,
  247. relcode = :relcode,
  248. othersubid = :othersubid
  249. WHERE cw_astclear_bill.accsetid = :sys_accsetid
  250. AND cw_astclear_bill.astclearid = :astclearid ;
  251. IF SQLCA.SQLCode <> 0 THEN
  252. rslt = 0
  253. arG_MSG = "因网络或其它原因导致更新固定资产清理操作失败"+"~n"+SQLCA.SQLErrText
  254. GOTO ext
  255. END IF
  256. //删除原有明细
  257. DELETE FROM cw_astclear
  258. WHERE cw_astclear.accsetid = :sys_accsetid
  259. AND cw_astclear.astclearid = :astclearid ;
  260. IF SQLCA.SQLCode <> 0 THEN
  261. rslt = 0
  262. arG_MSG = "删除旧有明细操作失败"+"~n"+SQLCA.SQLErrText
  263. GOTO ext
  264. END IF
  265. FOR i = 1 TO it_mxbt
  266. INSERT INTO cw_astclear (
  267. accsetid,
  268. astclearid,
  269. assetcardid,
  270. incrdecid,
  271. earing,
  272. payout,
  273. dscrp,
  274. cleardate)
  275. VALUES ( :sys_accsetid,
  276. :astclearid,
  277. :astclearmx[i].assetcardid,
  278. :astclearmx[i].incrdecid,
  279. :astclearmx[i].earing,
  280. :astclearmx[i].payout,
  281. :astclearmx[i].dscrp,
  282. :astclearmx[i].cleardate) ;
  283. IF SQLCA.SQLCode <> 0 THEN
  284. rslt = 0
  285. arG_MSG = "因网络或其它原因导致新建固定资产清理明细操作失败"+"~n"+SQLCA.SQLErrText
  286. GOTO ext
  287. END IF
  288. NEXT
  289. END IF
  290. it_newbegin = FALSE
  291. it_updatebegin = FALSE
  292. ext:
  293. IF rslt = 0 THEN
  294. ROLLBACK;
  295. astclearid = 0
  296. ELSEIF rslt = 1 AND arg_ifcommit THEN
  297. COMMIT;
  298. END IF
  299. RETURN(rslt)
  300. end function
  301. public function integer p_getinfo (long arg_astclearid, ref string arg_msg);INT rslt=1
  302. IF arg_astclearid<=0 THEN
  303. rslt=0
  304. arG_MSG="非法资产清理单唯一码"
  305. goto ext
  306. end if
  307. SELECT cw_astclear_bill.billdate,
  308. cw_astclear_bill.relcode,
  309. cw_astclear_bill.dscrp,
  310. cw_astclear_bill.memo,
  311. cw_astclear_bill.credid,
  312. cw_astclear_bill.othersubid
  313. INTO :billdate,
  314. :relcode,
  315. :dscrp,
  316. :memo,
  317. :credid,
  318. :othersubid
  319. FROM cw_astclear_bill
  320. WHERE cw_astclear_bill.astclearid = :arg_astclearid
  321. and cw_astclear_bill.accsetid =:sys_accsetid;
  322. if sqlca.sqlcode<>0 then
  323. rslt=0
  324. arG_MSG="查询操作失败(错误资产清理唯一码),资产清理单"+sqlca.sqlerrtext
  325. goto ext
  326. end if
  327. astclearid = arg_astclearid
  328. accsetid = sys_accsetid
  329. ext:
  330. IF rslt=0 THEN p_reset()
  331. return rslt
  332. end function
  333. public function integer updatebegin (long arg_astclearid, string arg_msg);Int rslt = 1
  334. IF getinfo(arg_astclearid,arg_msg) = 0 THEN
  335. rslt = 0
  336. GOTO ext
  337. END IF
  338. astclearid = arg_astclearid
  339. it_newbegin = FALSE
  340. it_updatebegin = TRUE
  341. p_clearmx() //清除明细
  342. ext:
  343. IF rslt = 0 THEN p_RESET()
  344. RETURN rslt
  345. end function
  346. public function integer acceptmx (long arg_assetcardid, long arg_incrdecid, decimal arg_earing, decimal arg_payout, ref string arg_msg, string arg_dscrp);Int rslt = 1
  347. Long cnt = 0
  348. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  349. rslt = 0
  350. arg_msg = "非编辑状态不可以使用,操作取消"
  351. GOTO ext
  352. END IF
  353. IF IsNull(arg_assetcardid) THEN arg_assetcardid = 0
  354. IF IsNull(arg_incrdecid) THEN arg_incrdecid = 0
  355. IF IsNull(arg_earing) THEN arg_earing = 0
  356. IF IsNull(arg_payout) THEN arg_payout = 0
  357. IF IsNull(arg_dscrp) THEN arg_dscrp = ''
  358. IF arg_assetcardid = 0 THEN
  359. rslt = 0
  360. GOTO ext
  361. END IF
  362. cnt = 0
  363. SELECT count(*) INTO :cnt FROM cw_assetcard
  364. WHERE cw_assetcard.accsetid = :sys_accsetid
  365. AND cw_assetcard.assetcardid = :arg_assetcardid
  366. AND cw_assetcard.clearflag = 0;
  367. IF sqlca.SQLCode = -1 THEN
  368. rslt = 0
  369. arg_msg = '查询固定资产失败'
  370. GOTO ext
  371. END IF
  372. IF cnt = 0 THEN
  373. rslt = 0
  374. arg_msg = '该帐套已经不存存在该固定资产,请检查'
  375. GOTO ext
  376. END IF
  377. IF arg_incrdecid = 0 THEN
  378. rslt = 0
  379. arg_msg = '请选择减少方式!'
  380. GOTO ext
  381. END IF
  382. it_mxbt++
  383. astclearmx[it_mxbt].assetcardid = arg_assetcardid
  384. astclearmx[it_mxbt].incrdecid = arg_incrdecid
  385. astclearmx[it_mxbt].earing = arg_earing
  386. astclearmx[it_mxbt].payout = arg_payout
  387. astclearmx[it_mxbt].dscrp = arg_dscrp
  388. astclearmx[it_mxbt].cleardate = billdate
  389. ext:
  390. RETURN rslt
  391. end function
  392. on uo_asset_clear.create
  393. call super::create
  394. TriggerEvent( this, "constructor" )
  395. end on
  396. on uo_asset_clear.destroy
  397. TriggerEvent( this, "destructor" )
  398. call super::destroy
  399. end on