uo_cusamt.sru 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  1. $PBExportHeader$uo_cusamt.sru
  2. forward
  3. global type uo_cusamt from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_cusamt from nonvisualobject
  7. end type
  8. global uo_cusamt uo_cusamt
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long cusmonid //自动增量id
  11. PUBLIC PROTECTEDWRITE String cusmoncode //罚款单的唯一编号
  12. PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
  13. PUBLIC PROTECTEDWRITE String opemp //建立人
  14. PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动
  15. PUBLIC PROTECTEDWRITE String modemp //修改人
  16. PUBLIC PROTECTEDWRITE Int flag = 0 //审核标志
  17. PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间
  18. PUBLIC PROTECTEDWRITE String auditingrep //审核操作员
  19. PUBLIC PROTECTEDWRITE Int confirmflag = 0 //确认标志
  20. PUBLIC PROTECTEDWRITE DateTime confirmdate //确认时间
  21. PUBLIC PROTECTEDWRITE String confirmemp //确认人
  22. PUBLIC PROTECTEDWRITE Int secflag = 0 //审核标志
  23. PUBLIC PROTECTEDWRITE DateTime secdate //审核时间
  24. PUBLIC PROTECTEDWRITE String secemp //审核操作员
  25. Long banktypeid
  26. Long scid
  27. Long cusid
  28. Long accountid
  29. DateTime cusdate
  30. Decimal cusamt
  31. String dscrp
  32. Int billtype
  33. Long itemid
  34. Long refrapid
  35. Long reldateint
  36. String cusrep
  37. Long moneyid
  38. Decimal mrate
  39. DateTime viewdate
  40. string relcode
  41. string fpcode
  42. Int cwauditingflag = 0 //总账审核标记
  43. DateTime cwauditingdate //总账审核时间
  44. String cwauditingrep //总账审核操作员
  45. PRIVATE:
  46. Boolean it_newbegin = FALSE //新建标志
  47. Boolean it_updatebegin = FALSE//修改标志
  48. end variables
  49. forward prototypes
  50. public function integer p_reset ()
  51. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  52. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg)
  53. public function integer newbegin (long arg_scid, ref string arg_msg)
  54. public function integer del (long arg_scid, long arg_billid, ref string arg_msg)
  55. public function integer auditing (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  56. public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  57. public function integer confirm (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  58. public function integer cconfirm (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  59. public function integer add_dscrp (long arg_cusmonid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit)
  60. public function integer secauditing (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  61. public function integer c_secauditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  62. public function integer uof_update_cust (long arg_billid, long arg_cusid, ref string arg_msg, boolean arg_ifcommit)
  63. public function integer getinfo (long arg_billid, ref string arg_msg)
  64. public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  65. public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg)
  66. end prototypes
  67. public function integer p_reset ();//INT p_RESET()
  68. //清除对象及其明细
  69. banktypeid = 0
  70. cusmonid = 0
  71. cusmoncode = ''
  72. opemp = ''
  73. auditingrep = ''
  74. flag = 0
  75. cusid = 0
  76. cusamt = 0
  77. dscrp = ''
  78. itemid = 0
  79. billtype = 0
  80. cusrep = ''
  81. moneyid = 0
  82. accountid = 0
  83. scid = 0
  84. it_newbegin = FALSE
  85. it_updatebegin = FALSE
  86. RETURN 1
  87. end function
  88. public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0,i
  89. DateTime server_dt
  90. Long ls_newid
  91. String ls_sccode
  92. Long ll_moneyid_account
  93. IF IsNull(cusid) THEN cusid = 0
  94. IF IsNull(accountid) THEN accountid = 0
  95. IF IsNull(dscrp) THEN dscrp = ''
  96. IF IsNull(cusamt) THEN cusamt = 0
  97. IF IsNull(scid) THEN scid = 0
  98. IF IsNull(billtype) THEN billtype = 0
  99. IF IsNull(itemid) THEN itemid = 0
  100. IF IsNull(cusrep) THEN cusrep = ''
  101. IF IsNull(moneyid) THEN moneyid = 0
  102. IF IsNull(mrate) THEN mrate = 0
  103. IF IsNull(relcode) THEN relcode = ''
  104. IF IsNull(fpcode) THEN fpcode = ''
  105. IF accountid = 0 THEN
  106. arg_msg = '请选择帐号'
  107. rslt = 0
  108. GOTO ext
  109. END IF
  110. SELECT moneyid INTO :ll_moneyid_account
  111. FROM u_accounts
  112. Where accountsid = :accountid;
  113. IF sqlca.SQLCode <> 0 THEN
  114. arg_msg = '查询帐号币种失败,'+sqlca.SQLErrText
  115. rslt = 0
  116. GOTO ext
  117. END IF
  118. IF IsNull(ll_moneyid_account) THEN ll_moneyid_account = 0
  119. IF ll_moneyid_account = 0 THEN
  120. arg_msg = '帐号币种未指定,请检查'
  121. rslt = 0
  122. GOTO ext
  123. END IF
  124. IF billtype = 0 THEN
  125. if sys_option_msttake_takeamt_secaudit = 0 then //
  126. IF cusid = 0 THEN
  127. arg_msg = '请先选择客户'
  128. rslt = 0
  129. GOTO ext
  130. END IF
  131. SELECT count(*) INTO :cnt
  132. FROM u_cust
  133. Where cusid = :cusid;
  134. IF sqlca.SQLCode <> 0 THEN
  135. arg_msg = '查询客户资料失败'
  136. rslt = 0
  137. GOTO ext
  138. END IF
  139. IF cnt > 1 THEN
  140. arg_msg = '客户资料重复'
  141. rslt = 0
  142. GOTO ext
  143. END IF
  144. END IF
  145. ELSE
  146. IF cusid = 0 THEN
  147. arg_msg = '请先选择供应商'
  148. rslt = 0
  149. GOTO ext
  150. END IF
  151. SELECT count(*) INTO :cnt
  152. FROM u_spt
  153. Where sptid = :cusid;
  154. IF sqlca.SQLCode <> 0 THEN
  155. arg_msg = '查询供应商资料失败'
  156. rslt = 0
  157. GOTO ext
  158. END IF
  159. IF cnt > 1 THEN
  160. arg_msg = '供应商资料重复'
  161. rslt = 0
  162. GOTO ext
  163. END IF
  164. END IF
  165. IF moneyid = 0 THEN
  166. arg_msg = '请选择币种'
  167. rslt = 0
  168. GOTO ext
  169. END IF
  170. IF mrate <= 0 THEN
  171. arg_msg = '请输入币种汇率'
  172. rslt = 0
  173. GOTO ext
  174. END IF
  175. IF moneyid <> ll_moneyid_account AND mrate = 1 THEN
  176. arg_msg = '收款币种与帐号币种不相同,汇率不能设为1'
  177. rslt = 0
  178. GOTO ext
  179. END IF
  180. IF moneyid = ll_moneyid_account AND mrate <> 1 THEN
  181. arg_msg = '收款币种与帐号币种相同,汇率要设为1'
  182. rslt = 0
  183. GOTO ext
  184. END IF
  185. IF f_check_inoutdate(0,cusdate,False,arg_msg) = 0 THEN
  186. rslt = 0
  187. arg_msg = "该单据超出指定日期范围(单据限制录入天数)"
  188. GOTO ext
  189. END IF
  190. cnt = 0
  191. SELECT count(*) INTO :cnt
  192. FROM u_itemdef
  193. Where itemid = :itemid;
  194. IF sqlca.SQLCode <> 0 THEN
  195. arg_msg = '查询项目资料失败,'+sqlca.SQLErrText
  196. rslt = 0
  197. GOTO ext
  198. END IF
  199. IF cnt <> 1 THEN
  200. arg_msg = '项目资料不存在或重复'
  201. rslt = 0
  202. GOTO ext
  203. END IF
  204. ///20100426
  205. Long ll_itemflag
  206. SELECT itemflag
  207. INTO :ll_itemflag
  208. FROM u_itemdef
  209. Where itemid = :itemid;
  210. IF sqlca.SQLCode <> 0 THEN
  211. arg_msg = '查询项目资料核算方向失败,'+sqlca.SQLErrText
  212. rslt = 0
  213. GOTO ext
  214. END IF
  215. IF billtype = 0 AND ll_itemflag = -1 THEN
  216. arg_msg = '客户收款单,不能选择核算支出方向的收支项目'
  217. rslt = 0
  218. GOTO ext
  219. END IF
  220. IF billtype = 1 AND ll_itemflag = 1 THEN
  221. arg_msg = '供应商付款单,不能选择核算收入方向的收支项目'
  222. rslt = 0
  223. GOTO ext
  224. END IF
  225. IF banktypeid = 0 THEN
  226. arg_msg = '没有结算方式'
  227. rslt = 0
  228. GOTO ext
  229. END IF
  230. IF cusamt = 0 THEN
  231. arg_msg = '请输入正确的金额'
  232. rslt = 0
  233. GOTO ext
  234. END IF
  235. SELECT Top 1 getdate() INTO :server_dt FROM u_user;
  236. IF sqlca.SQLCode <> 0 THEN
  237. rslt = 0
  238. arg_msg = "查询操作失败,日期 "
  239. GOTO ext
  240. END IF
  241. IF Year(Date(cusdate)) < 2000 OR IsNull(cusdate) THEN
  242. rslt = 0
  243. arg_msg = "时间不合理"
  244. GOTO ext
  245. END IF
  246. ////////////////////////////////////////////////开始区分:新建/更新 处理
  247. IF cusmonid = 0 THEN //新建
  248. ls_newid = f_sys_scidentity(0,"u_cusamt","cusmonid",arg_msg,TRUE,sqlca)
  249. IF ls_newid <= 0 THEN
  250. rslt = 0
  251. GOTO ext
  252. END IF
  253. //取分部代号
  254. IF f_get_sccode(0,sqlca,ls_sccode,arg_msg) = 0 THEN
  255. rslt = 0
  256. GOTO ext
  257. END IF
  258. IF billtype = 0 THEN//客户收款单
  259. cusmoncode = getid(0,ls_sccode + "SK",Date(server_dt),TRUE,sqlca) //取得新单据编号
  260. ELSE//供应商付款单
  261. cusmoncode = getid(0,ls_sccode + "FK",Date(server_dt),TRUE,sqlca) //取得新单据编号
  262. END IF
  263. IF cusmoncode = "err" THEN
  264. cusmoncode = ''
  265. rslt = 0
  266. arg_msg = "无法获取单据编号"
  267. GOTO ext
  268. END IF
  269. INSERT INTO u_cusamt (
  270. scid,
  271. cusmonid,
  272. cusmoncode,
  273. cusdate,
  274. cusid,
  275. cusamt,
  276. dscrp,
  277. opdate,
  278. opemp,
  279. accountid,
  280. banktypeid,
  281. billtype,
  282. itemid,
  283. cusrep,
  284. moneyid,
  285. mrate,
  286. viewdate,
  287. relcode,
  288. fpcode)
  289. VALUES (
  290. :scid,
  291. :ls_newid,
  292. :cusmoncode,
  293. :cusdate,
  294. :cusid,
  295. :cusamt,
  296. :dscrp,
  297. getdate(),
  298. :publ_operator,
  299. :accountid,
  300. :banktypeid,
  301. :billtype,
  302. :itemid,
  303. :cusrep,
  304. :moneyid,
  305. :mrate,
  306. :viewdate,
  307. :relcode,
  308. :fpcode);
  309. IF sqlca.SQLCode <> 0 THEN
  310. rslt = 0
  311. IF Pos(Lower(sqlca.SQLErrText),'PK_u_cusamt') > 0 THEN
  312. arg_msg = '插入操作失败,关键字单据ID重复'
  313. ELSE
  314. arg_msg = "插入操作失败"+"~n"+sqlca.SQLErrText
  315. END IF
  316. GOTO ext
  317. END IF
  318. cusmonid = ls_newid
  319. ELSE //////////////////////////////////////////////////更新
  320. UPDATE u_cusamt
  321. SET cusdate = :cusdate,
  322. cusid = :cusid,
  323. cusamt = :cusamt,
  324. dscrp = :dscrp,
  325. moddate = getdate(),
  326. modemp = :publ_operator,
  327. cusmoncode = :cusmoncode,
  328. scid = :scid,
  329. accountid = :accountid,
  330. banktypeid = :banktypeid,
  331. itemid = :itemid,
  332. cusrep = :cusrep,
  333. moneyid = :moneyid,
  334. mrate = :mrate,
  335. viewdate = :viewdate,
  336. relcode = :relcode,
  337. fpcode = :fpcode
  338. Where cusmonid = :cusmonid;
  339. IF sqlca.SQLCode <> 0 OR sqlca.SQLNRows <= 0 THEN
  340. rslt = 0
  341. arg_msg = "更新单据操作失败"+"~n"+sqlca.SQLErrText
  342. GOTO ext
  343. END IF
  344. END IF
  345. it_newbegin = FALSE
  346. it_updatebegin = FALSE
  347. ext:
  348. IF rslt = 0 THEN
  349. ROLLBACK;
  350. ELSEIF rslt = 1 AND arg_ifcommit THEN
  351. COMMIT;
  352. END IF
  353. Return(rslt)
  354. end function
  355. public function integer updatebegin (long arg_scid, long arg_billid, ref string arg_msg);//====================================================================
  356. // Function: updatebegin(arg_billid,arg_msg)
  357. //--------------------------------------------------------------------
  358. // Description:
  359. //--------------------------------------------------------------------
  360. // Arguments:
  361. // value long arg_billid
  362. // reference string arg_msg
  363. //--------------------------------------------------------------------
  364. // Returns: integer
  365. //--------------------------------------------------------------------
  366. // Author: yyx Date: 2003.11.21
  367. //--------------------------------------------------------------------
  368. // Modify History:
  369. //
  370. //====================================================================
  371. int rslt = 1
  372. if arg_billid <= 0 then
  373. cusmonid = 0
  374. arg_msg = '错误的单据ID'
  375. goto ext
  376. end if
  377. select
  378. u_cusamt.cusmonid,
  379. u_cusamt.cusmoncode,
  380. u_cusamt.cusid,
  381. u_cusamt.cusamt,
  382. u_cusamt.dscrp ,
  383. u_cusamt.cusdate,
  384. u_cusamt.scid,
  385. u_cusamt.accountid,
  386. u_cusamt.flag
  387. into
  388. :cusmonid,
  389. :cusmoncode,
  390. :cusid,
  391. :cusamt,
  392. :dscrp,
  393. :cusdate,
  394. :scid,
  395. :accountid,
  396. :flag
  397. from u_cusamt
  398. where cusmonid = :arg_billid;
  399. if sqlca.sqlcode <> 0 then
  400. rslt = 0
  401. arg_msg = '查询数据操作失败,单据'+sqlca.sqlerrtext
  402. goto ext
  403. end if
  404. if flag = 1 then
  405. rslt = 0
  406. arg_msg = '单据已经审核,不可以修改'
  407. goto ext
  408. end if
  409. cusmonid = arg_billid
  410. scid = arg_scid
  411. it_newbegin = false
  412. it_updatebegin = true
  413. ext:
  414. if rslt = 0 then p_reset()
  415. return rslt
  416. end function
  417. public function integer newbegin (long arg_scid, ref string arg_msg);int rslt = 1
  418. if arg_scid < 0 then
  419. arg_msg = '请选择分部'
  420. rslt = 0
  421. goto ext
  422. end if
  423. p_reset()
  424. scid=arg_scid
  425. it_newbegin=TRUE
  426. it_updatebegin=FALSE
  427. ext:
  428. if rslt = 0 then p_reset()
  429. return rslt
  430. end function
  431. public function integer del (long arg_scid, long arg_billid, ref string arg_msg);//====================================================================
  432. // Function: del(arg_billid,arg_msg)
  433. //--------------------------------------------------------------------
  434. // Description:
  435. //--------------------------------------------------------------------
  436. // Arguments:
  437. // value long arg_billid
  438. // reference string arg_msg
  439. //--------------------------------------------------------------------
  440. // Returns: integer
  441. //--------------------------------------------------------------------
  442. // Author: yyx Date: 2003.11.21
  443. //--------------------------------------------------------------------
  444. // Modify History:
  445. //
  446. //====================================================================
  447. Int rslt = 1
  448. IF arg_billid <= 0 THEN
  449. rslt = 0
  450. arg_msg = "没有删除对象,操作取消"
  451. GOTO ext
  452. END IF
  453. IF it_newbegin Or it_updatebegin THEN
  454. rslt = 0
  455. arg_msg = "编辑状态下不可以执行,操作取消"
  456. GOTO ext
  457. END IF
  458. SELECT u_cusamt.flag
  459. INTO :flag
  460. FROM u_cusamt
  461. Where u_cusamt.cusmonid = :arg_billid;
  462. IF sqlca.SQLCode <> 0 THEN
  463. rslt = 0
  464. arg_msg = '查询收款单操作失败'
  465. GOTO ext
  466. END IF
  467. IF flag = 1 THEN
  468. rslt = 0
  469. arg_msg = "单据已经审核,不可以删除"
  470. GOTO ext
  471. END IF
  472. DELETE FROM u_cusamt
  473. Where u_cusamt.cusmonid = :arg_billid ;
  474. IF sqlca.SQLCode <> 0 THEN
  475. rslt = 0
  476. arg_msg = "删除单据操作失败"+"~n"+sqlca.SQLErrText
  477. GOTO ext
  478. END IF
  479. it_newbegin = False
  480. it_updatebegin = False
  481. ext:
  482. IF rslt = 0 THEN
  483. ROLLBACK;
  484. p_reset()
  485. ELSE
  486. COMMIT;
  487. END IF
  488. Return (rslt)
  489. end function
  490. public function integer auditing (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);
  491. Long cnt = 0
  492. Long i
  493. Int rslt = 1
  494. Long ref_rapid
  495. Long ref_dateint
  496. String ls_code, ls_name, ls_custype
  497. String ls_dscrp
  498. Long ll_moneyid_account
  499. uo_musttake uo_take
  500. uo_mustpay uo_pay
  501. uo_take = Create uo_musttake
  502. uo_pay = Create uo_mustpay
  503. uo_iteminput uo_item
  504. uo_item = Create uo_iteminput
  505. IF getinfo(arg_billid,arg_msg) = 0 THEN
  506. rslt = 0
  507. GOTO ext
  508. END IF
  509. IF flag = 1 THEN
  510. rslt = 0
  511. arg_msg = '单据已经审核,不可以再审核'
  512. GOTO ext
  513. END IF
  514. IF billtype = 0 And sys_option_msttake_takeamt_secaudit = 0 THEN
  515. UPDATE u_cusamt
  516. SET audopemp = :publ_operator,
  517. audopdate = getdate(),
  518. flag = 1,
  519. secemp = :publ_operator,
  520. secdate = getdate(),
  521. secflag = 1
  522. WHERE u_cusamt.cusmonid = :arg_billid
  523. And flag = 0;
  524. ELSE
  525. UPDATE u_cusamt
  526. SET audopemp = :publ_operator,
  527. audopdate = getdate(),
  528. flag = 1
  529. WHERE u_cusamt.cusmonid = :arg_billid
  530. And flag = 0;
  531. END IF
  532. IF sqlca.SQLCode <> 0 THEN
  533. rslt = 0
  534. arg_msg = "因网络或其它原因导致审核单据操作失败,"+"~n"+sqlca.SQLErrText
  535. GOTO ext
  536. ELSEIF sqlca.SQLNRows = 0 THEN
  537. rslt = 0
  538. arg_msg = "单据正在审核,请稍后查询,"+"~n"+sqlca.SQLErrText
  539. GOTO ext
  540. END IF
  541. DateTime ld_viewdate
  542. //SetNull(ld_viewdate)
  543. Int li_item_dfttype,li_itemflag
  544. Decimal ld_takeamt
  545. IF billtype = 0 THEN //客户收款单
  546. IF cusid > 0 THEN
  547. SELECT cuscode, name, custype INTO :ls_code, :ls_name, :ls_custype
  548. FROM u_cust
  549. Where cusid = :cusid;
  550. IF sqlca.SQLCode <> 0 THEN
  551. arg_msg = '查询客户名称失败,可能客户资料不存在'
  552. rslt = 0
  553. GOTO ext
  554. END IF
  555. ELSE
  556. ls_code = ''
  557. ls_name = ''
  558. END IF
  559. ls_dscrp = dscrp
  560. if trim(fpcode) <> '' then
  561. ls_dscrp = ls_dscrp + ' 发票号:'+fpcode
  562. end if
  563. s_bmsttake s_take
  564. s_take.scid = scid
  565. s_take.cusid = cusid
  566. s_take.takedate = cusdate
  567. s_take.inrep = cusrep
  568. s_take.oriamt = 0 - cusamt
  569. s_take.msttakeamt = 0
  570. s_take.takeamt_cn = cusamt
  571. s_take.takeamt = cusamt * mrate
  572. s_take.dscrp = ls_dscrp
  573. s_take.billcode = cusmoncode
  574. s_take.banktypeid = banktypeid
  575. s_take.buildtype = 4
  576. s_take.opemp = arg_opemp
  577. s_take.outwareid = 0
  578. s_take.salebillid = 0
  579. s_take.viewdate = viewdate
  580. s_take.accountsid = accountid
  581. s_take.itemid = itemid
  582. s_take.moneyid = moneyid
  583. s_take.moneyid_cn = ll_moneyid_account
  584. s_take.relcode = relcode
  585. IF sys_option_msttake_takeamt_secaudit = 0 THEN //两审一起进行,生成应收,出纳
  586. IF cusid = 0 THEN
  587. arg_msg = '查询客户名称失败,可能客户资料不存在'
  588. rslt = 0
  589. GOTO ext
  590. END IF
  591. //
  592. SELECT moneyid INTO :ll_moneyid_account
  593. FROM u_accounts
  594. Where accountsid = :accountid;
  595. IF sqlca.SQLCode <> 0 THEN
  596. arg_msg = '查询帐号币种资料失败,'+sqlca.SQLErrText
  597. rslt = 0
  598. GOTO ext
  599. END IF
  600. IF IsNull(ll_moneyid_account) THEN ll_moneyid_account = 0
  601. IF ll_moneyid_account = 0 THEN
  602. arg_msg = '帐号币种未指定,请检查'
  603. rslt = 0
  604. GOTO ext
  605. END IF
  606. IF uo_take.add_takerec(s_take,arg_msg,False) = 0 THEN
  607. rslt = 0
  608. GOTO ext
  609. END IF
  610. ref_rapid = uo_take.ref_takeid
  611. IF ref_rapid = 0 THEN
  612. arg_msg = '错误的应收应付帐ID!'
  613. rslt = 0
  614. GOTO ext
  615. END IF
  616. UPDATE u_cusamt
  617. SET refrapid = :ref_rapid
  618. WHERE cusmonid = :arg_billid
  619. And flag = 1;
  620. IF sqlca.SQLCode <> 0 THEN
  621. arg_msg = '更新单据资料失败,'+sqlca.SQLErrText
  622. rslt = 0
  623. GOTO ext
  624. END IF
  625. ELSE //IF sys_option_msttake_takeamt_secaudit = 0 THEN //初审出纳; 终审应收
  626. IF ls_code <> '' THEN
  627. ls_dscrp = ls_code+ ' ' + ls_name + ' ' + ls_custype + ' '+dscrp
  628. if trim(fpcode) <> '' then
  629. ls_dscrp = ls_dscrp + ' 发票号:'+fpcode
  630. end if
  631. END IF
  632. SELECT dfttype,itemflag
  633. INTO :li_item_dfttype,:li_itemflag
  634. FROM u_itemdef
  635. Where u_itemdef.itemid = :s_take.itemid;
  636. IF sqlca.SQLCode <> 0 THEN
  637. arg_msg = '查询当前收支项目核算类型和核算方向失败!'
  638. rslt = 0
  639. GOTO ext
  640. END IF
  641. CHOOSE CASE li_item_dfttype
  642. CASE 1,3,4
  643. ld_takeamt = s_take.takeamt * li_itemflag
  644. CASE ELSE
  645. ld_takeamt = s_take.takeamt
  646. END CHOOSE
  647. IF sys_option_cusamt_dftdate = 0 THEN
  648. ld_viewdate = s_take.takedate
  649. ELSE
  650. ld_viewdate = s_take.viewdate
  651. END IF
  652. s_iteminput s_input
  653. s_input.itemid = s_take.itemid
  654. s_input.dateint = 0
  655. s_input.outdate = ld_viewdate
  656. s_input.dscrp = ls_dscrp
  657. s_input.outamt = ld_takeamt
  658. s_input.accountsid = s_take.accountsid
  659. s_input.banktypeid = s_take.banktypeid
  660. s_input.billcode = s_take.billcode
  661. s_input.relcode = s_take.relcode
  662. s_input.buildtype = 1
  663. s_input.opemp = publ_operator
  664. s_input.relrep = ''
  665. s_input.scid = s_take.scid
  666. s_input.moneyid = s_take.moneyid
  667. IF uo_item.add_iteminput(s_input,arg_msg,False) = 0 THEN
  668. arg_msg = '增加收支明细帐失败!~n' + arg_msg
  669. rslt = 0
  670. GOTO ext
  671. END IF
  672. ref_dateint = uo_item.ref_dateint
  673. IF ref_dateint = 0 THEN
  674. arg_msg = '增加收支出纳明细帐失败!'
  675. rslt = 0
  676. GOTO ext
  677. END IF
  678. UPDATE u_cusamt
  679. SET reldateint = :ref_dateint
  680. WHERE cusmonid = :arg_billid
  681. And flag = 1;
  682. IF sqlca.SQLCode <> 0 THEN
  683. arg_msg = '更新单据收支帐ID资料失败,'+sqlca.SQLErrText
  684. rslt = 0
  685. GOTO ext
  686. END IF
  687. END IF
  688. ELSE //供应商付款单
  689. SELECT sptcode, name INTO :ls_code,:ls_name
  690. FROM u_spt
  691. Where sptid = :cusid;
  692. IF sqlca.SQLCode <> 0 THEN
  693. arg_msg = '查询供应商名称失败,可能供应商资料不存在'
  694. rslt = 0
  695. GOTO ext
  696. END IF
  697. //ls_dscrp = dscrp
  698. // if ls_code <> '' then
  699. // ls_dscrp = ls_code + ' '+ls_name + ' '+dscrp
  700. // else
  701. ls_dscrp = dscrp
  702. // end if
  703. // DateTime null_plandate
  704. // SetNull(null_plandate)
  705. if trim(fpcode) <> '' then
  706. ls_dscrp = ls_dscrp + ' 发票号:'+fpcode
  707. end if
  708. s_bmstpay s_pay
  709. s_pay.scid = scid
  710. s_pay.sptid = cusid
  711. s_pay.paydate = cusdate
  712. s_pay.inrep = cusrep
  713. s_pay.oriamt = 0 - cusamt
  714. s_pay.mstpayamt = 0
  715. s_pay.payamt = cusamt * mrate
  716. s_pay.dscrp = ls_dscrp
  717. s_pay.billcode = cusmoncode
  718. s_pay.banktypeid = banktypeid
  719. s_pay.buildtype = 4
  720. s_pay.opemp = arg_opemp
  721. s_pay.inwareid = 0
  722. s_pay.buybillid = 0
  723. s_pay.accountsid = accountid
  724. s_pay.itemid = itemid
  725. s_pay.moneyid = moneyid
  726. s_pay.relcode = relcode
  727. s_pay.viewdate = viewdate
  728. IF uo_pay.add_payrec(s_pay,arg_msg,False) = 0 THEN
  729. rslt = 0
  730. GOTO ext
  731. END IF
  732. ref_rapid = uo_pay.ref_payid
  733. IF ref_rapid = 0 THEN
  734. arg_msg = '错误的应收应付帐ID!'
  735. rslt = 0
  736. GOTO ext
  737. END IF
  738. UPDATE u_cusamt
  739. SET refrapid = :ref_rapid
  740. WHERE cusmonid = :arg_billid
  741. And flag = 1;
  742. IF sqlca.SQLCode <> 0 THEN
  743. arg_msg = '更新单据资料失败,'+sqlca.SQLErrText
  744. rslt = 0
  745. GOTO ext
  746. END IF
  747. END IF
  748. flag = 1
  749. ext:
  750. IF rslt = 0 THEN
  751. ROLLBACK;
  752. ELSEIF rslt = 1 And arg_ifcommit THEN
  753. COMMIT;
  754. END IF
  755. Destroy uo_take
  756. Destroy uo_pay
  757. Destroy uo_item
  758. RETURN rslt
  759. end function
  760. public function integer c_auditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);Long cnt = 0
  761. Long i
  762. Int rslt = 1
  763. Long ref_rapid
  764. DateTime null_dt
  765. SetNull(null_dt)
  766. uo_musttake uo_take
  767. uo_mustpay uo_pay
  768. uo_take = CREATE uo_musttake
  769. uo_pay = CREATE uo_mustpay
  770. uo_iteminput uo_item
  771. uo_item = CREATE uo_iteminput
  772. IF getinfo(arg_billid,arg_msg) = 0 THEN
  773. rslt = 0
  774. GOTO ext
  775. END IF
  776. IF cwauditingflag = 1 THEN
  777. rslt = 0
  778. arG_MSG = "该单据已经总账审核,不能撤审"
  779. GOTO ext
  780. END IF
  781. IF flag = 0 THEN
  782. rslt = 0
  783. arg_msg = '单据未审核,不可以再撤审'
  784. GOTO ext
  785. END IF
  786. IF billtype = 0 AND sys_option_msttake_takeamt_secaudit = 0 THEN
  787. UPDATE u_cusamt
  788. SET audopemp = '',
  789. audopdate = :null_dt,
  790. flag = 0,
  791. secemp = '',
  792. secdate = :null_dt,
  793. secflag = 0
  794. WHERE cusmonid = :arg_billid
  795. AND flag = 1;
  796. //AND secflag = 1; //为了兼容之前的单 111130 lhd
  797. ELSE
  798. UPDATE u_cusamt
  799. SET audopemp = '',
  800. audopdate = :null_dt,
  801. flag = 0
  802. WHERE u_cusamt.cusmonid = :arg_billid
  803. AND flag = 1
  804. AND secflag = 0;
  805. END IF
  806. IF sqlca.SQLCode <> 0 THEN
  807. rslt = 0
  808. arg_msg = "撤审单据操作失败"+"~n"+sqlca.SQLErrText
  809. GOTO ext
  810. ELSEIF sqlca.SQLNRows = 0 THEN
  811. rslt = 0
  812. arg_msg = "单据正在撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  813. GOTO ext
  814. END IF
  815. IF billtype = 0 THEN //客户收款
  816. IF sys_option_msttake_takeamt_secaudit = 0 THEN
  817. IF uo_take.del_takerec(scid,1,refrapid,cusid,arg_msg,FALSE) = 0 THEN
  818. rslt = 0
  819. GOTO ext
  820. END IF
  821. ELSE //IF sys_option_msttake_takeamt_secaudit = 0 THEN
  822. IF secflag = 1 THEN
  823. arg_msg = '客户收款单已终审,不能操作'
  824. rslt = 0
  825. GOTO ext
  826. END IF
  827. IF uo_item.del_iteminput(itemid,reldateint,1,arg_msg,FALSE) = 0 THEN
  828. arg_msg = '删除收支明细帐失败!~n' + arg_msg
  829. rslt = 0
  830. GOTO ext
  831. END IF
  832. END IF
  833. ELSE //供应商付款
  834. IF secflag = 1 THEN
  835. arg_msg = '供应商付款已终审,不能操作'
  836. rslt = 0
  837. GOTO ext
  838. END IF
  839. IF uo_pay.del_payrec(scid,1,refrapid,cusid,arg_msg,FALSE) = 0 THEN
  840. rslt = 0
  841. GOTO ext
  842. END IF
  843. END IF
  844. flag = 0
  845. ext:
  846. IF rslt = 0 THEN
  847. ROLLBACK;
  848. ELSEIF rslt = 1 AND arg_ifcommit THEN
  849. COMMIT;
  850. END IF
  851. DESTROY uo_take
  852. DESTROY uo_pay
  853. DESTROY uo_item
  854. RETURN rslt
  855. end function
  856. public function integer confirm (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Long cnt = 0
  857. Int rslt = 1
  858. IF getinfo(arg_billid,arg_msg) = 0 THEN
  859. rslt = 0
  860. GOTO ext
  861. END IF
  862. IF flag = 0 THEN
  863. rslt = 0
  864. arg_msg = '单据未审核,不可以确认'
  865. GOTO ext
  866. END IF
  867. IF confirmflag = 1 THEN
  868. rslt = 0
  869. arg_msg = '单据已确认,不可以确认'
  870. GOTO ext
  871. END IF
  872. UPDATE u_cusamt
  873. SET confirmemp = :publ_operator,
  874. confirmdate = getdate(),
  875. confirmflag = 1
  876. WHERE u_cusamt.cusmonid = :arg_billid
  877. AND confirmflag = 0;
  878. IF sqlca.SQLCode <> 0 THEN
  879. rslt = 0
  880. arg_msg = "因网络或其它原因导致确认单据操作失败,"+"~n"+sqlca.SQLErrText
  881. GOTO ext
  882. ELSEIF sqlca.SQLNRows = 0 THEN
  883. rslt = 0
  884. arg_msg = "单据正在确认,请稍后查询,"+"~n"+sqlca.SQLErrText
  885. GOTO ext
  886. END IF
  887. confirmflag = 1
  888. ext:
  889. IF rslt = 0 THEN
  890. ROLLBACK;
  891. ELSEIF rslt = 1 AND arg_ifcommit THEN
  892. COMMIT;
  893. END IF
  894. RETURN rslt
  895. end function
  896. public function integer cconfirm (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Long cnt = 0
  897. Int rslt = 1
  898. datetime null_dt
  899. setnull(null_dt)
  900. IF getinfo(arg_billid,arg_msg) = 0 THEN
  901. rslt = 0
  902. GOTO ext
  903. END IF
  904. IF confirmflag = 0 THEN
  905. rslt = 0
  906. arg_msg = '单据未确认,不可以反确认'
  907. GOTO ext
  908. END IF
  909. UPDATE u_cusamt
  910. SET confirmemp = '',
  911. confirmdate = :null_dt,
  912. confirmflag = 0
  913. WHERE u_cusamt.cusmonid = :arg_billid
  914. AND confirmflag = 1;
  915. IF sqlca.SQLCode <> 0 THEN
  916. rslt = 0
  917. arg_msg = "因网络或其它原因导致反确认单据操作失败,"+"~n"+sqlca.SQLErrText
  918. GOTO ext
  919. ELSEIF sqlca.SQLNRows = 0 THEN
  920. rslt = 0
  921. arg_msg = "单据正在反确认,请稍后查询,"+"~n"+sqlca.SQLErrText
  922. GOTO ext
  923. END IF
  924. confirmflag = 0
  925. ext:
  926. IF rslt = 0 THEN
  927. ROLLBACK;
  928. ELSEIF rslt = 1 AND arg_ifcommit THEN
  929. COMMIT;
  930. END IF
  931. RETURN rslt
  932. end function
  933. public function integer add_dscrp (long arg_cusmonid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);//add_dscrp(string arg_newdescppart)
  934. //0 fail 1 SUCCESS
  935. Int rslt = 1
  936. arg_newdescppart = Trim(arg_newdescppart)
  937. IF it_updatebegin OR it_newbegin THEN
  938. rslt = 0
  939. arG_MSG = "编辑状态下不可用"
  940. GOTO ext
  941. END IF
  942. IF getinfo(arg_cusmonid,arG_MSG) = 0 THEN
  943. rslt = 0
  944. GOTO ext
  945. END IF
  946. IF flag = 0 THEN
  947. rslt = 0
  948. arG_MSG = "非审核状态下不可用"
  949. GOTO ext
  950. END IF
  951. UPDATE u_cusamt
  952. SET DSCRP = ltrim(rtrim(DSCRP))+' '+:arg_newdescppart
  953. Where u_cusamt.cusmonid = :arg_cusmonid;
  954. IF SQLCA.SQLCode <> 0 THEN
  955. rslt = 0
  956. arG_MSG = "因网络或其它原因导致添加单据备注操作失败"+"~n"+SQLCA.SQLErrText
  957. GOTO ext
  958. END IF
  959. DSCRP = DSCRP+' '+arg_newdescppart
  960. ext:
  961. IF rslt = 0 THEN
  962. ROLLBACK;
  963. ELSEIF rslt = 1 AND arg_ifcommit THEN
  964. COMMIT;
  965. END IF
  966. Return (rslt)
  967. end function
  968. public function integer secauditing (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);
  969. Int rslt = 1
  970. uo_musttake uo_take
  971. uo_take = Create uo_musttake
  972. If getinfo(arg_billid,arg_msg) = 0 Then
  973. rslt = 0
  974. Goto ext
  975. End If
  976. If flag = 0 Then
  977. rslt = 0
  978. arg_msg = '单据未初审,不可以终审'
  979. Goto ext
  980. End If
  981. If secflag = 1 Then
  982. rslt = 0
  983. arg_msg = '单据已经审核,不可以再审核'
  984. Goto ext
  985. End If
  986. Update u_cusamt
  987. Set secemp = :publ_operator,
  988. secdate = getdate(),
  989. secflag = 1
  990. Where u_cusamt.cusmonid = :arg_billid
  991. And flag = 1
  992. And secflag = 0 ;
  993. If sqlca.SQLCode <> 0 Then
  994. rslt = 0
  995. arg_msg = "因网络或其它原因导致最终审核单据操作失败,"+"~n"+sqlca.SQLErrText
  996. Goto ext
  997. ElseIf sqlca.SQLNRows = 0 Then
  998. rslt = 0
  999. arg_msg = "单据正在审核,请稍后查询,"+"~n"+sqlca.SQLErrText
  1000. Goto ext
  1001. End If
  1002. If billtype = 0 Then
  1003. If sys_option_msttake_takeamt_secaudit = 1 Then
  1004. String ls_dscrp,ls_code,ls_name,ls_custype
  1005. DateTime ld_viewdate
  1006. Long ll_moneyid_account
  1007. Long ref_rapid,ll_rapmoneyid
  1008. Select cuscode, name,custype Into :ls_code,:ls_name, :ls_custype
  1009. From u_cust
  1010. Where cusid = :cusid;
  1011. If sqlca.SQLCode <> 0 Then
  1012. arg_msg = '查询客户名称失败,可能客户资料不存在'
  1013. rslt = 0
  1014. Goto ext
  1015. End If
  1016. If ls_code <> '' Then
  1017. ls_dscrp = ls_code+ ' ' + ls_name + ' ' + ls_custype + ' '+dscrp
  1018. If Trim(fpcode) <> '' Then
  1019. ls_dscrp = ls_dscrp + ' 发票号:'+fpcode
  1020. End If
  1021. Else
  1022. ls_dscrp = dscrp
  1023. End If
  1024. Update u_iteminput
  1025. Set dscrp = :ls_dscrp
  1026. Where dateint = :reldateint;
  1027. If sqlca.SQLCode <> 0 Then
  1028. arg_msg = '更新摘要失败,'+sqlca.SQLErrText
  1029. rslt = 0
  1030. Goto ext
  1031. End If
  1032. Select rapmoneyid Into :ll_rapmoneyid
  1033. From u_iteminput
  1034. Where dateint = :reldateint;
  1035. If sqlca.SQLCode <> 0 Then
  1036. arg_msg = '查找出纳账ID失败,'+sqlca.SQLErrText
  1037. rslt = 0
  1038. Goto ext
  1039. End If
  1040. Update u_rap_money
  1041. Set dscrp = :ls_dscrp
  1042. Where rapmoneyid = :ll_rapmoneyid;
  1043. If sqlca.SQLCode <> 0 Then
  1044. arg_msg = '更新出纳账摘要失败,'+sqlca.SQLErrText
  1045. rslt = 0
  1046. Goto ext
  1047. End If
  1048. s_bmsttake s_take
  1049. s_take.scid = scid
  1050. s_take.cusid = cusid
  1051. s_take.takedate = cusdate
  1052. s_take.inrep = cusrep
  1053. s_take.oriamt = 0 - Round(cusamt,sys_saleamt_round)
  1054. s_take.msttakeamt = 0
  1055. // s_take.takeamt_cn = round(cusamt,sys_saleamt_round)
  1056. s_take.takeamt = Round(cusamt ,sys_saleamt_round) //* mrate
  1057. s_take.dscrp = ls_dscrp
  1058. s_take.billcode = cusmoncode
  1059. s_take.banktypeid = banktypeid
  1060. s_take.buildtype = 4
  1061. s_take.opemp = arg_opemp
  1062. s_take.outwareid = 0
  1063. s_take.salebillid = 0
  1064. s_take.viewdate = ld_viewdate
  1065. s_take.accountsid = accountid
  1066. s_take.itemid = itemid
  1067. s_take.moneyid = moneyid
  1068. // s_take.moneyid_cn = ll_moneyid_account
  1069. s_take.relcode = relcode
  1070. Select moneyid Into :ll_moneyid_account
  1071. From u_accounts
  1072. Where accountsid = :accountid;
  1073. If sqlca.SQLCode <> 0 Then
  1074. arg_msg = '查询帐号币种资料失败,'+sqlca.SQLErrText
  1075. rslt = 0
  1076. Goto ext
  1077. End If
  1078. If IsNull(ll_moneyid_account) Then ll_moneyid_account = 0
  1079. If ll_moneyid_account = 0 Then
  1080. arg_msg = '帐号币种未指定,请检查'
  1081. rslt = 0
  1082. Goto ext
  1083. End If
  1084. If uo_take.add_takerec(s_take,arg_msg,False) = 0 Then
  1085. rslt = 0
  1086. Goto ext
  1087. End If
  1088. ref_rapid = uo_take.ref_takeid
  1089. If ref_rapid = 0 Then
  1090. arg_msg = '错误的应收应付帐ID!'
  1091. rslt = 0
  1092. Goto ext
  1093. End If
  1094. Update u_cusamt
  1095. Set refrapid = :ref_rapid
  1096. Where cusmonid = :arg_billid
  1097. And flag = 1
  1098. And secflag = 1;
  1099. If sqlca.SQLCode <> 0 Then
  1100. arg_msg = '更新单据资料失败,'+sqlca.SQLErrText
  1101. rslt = 0
  1102. Goto ext
  1103. End If
  1104. End If
  1105. End If
  1106. flag = 1
  1107. secflag = 1
  1108. ext:
  1109. If rslt = 0 Then
  1110. Rollback;
  1111. ElseIf rslt = 1 And arg_ifcommit Then
  1112. Commit;
  1113. End If
  1114. Destroy uo_take
  1115. Return rslt
  1116. end function
  1117. public function integer c_secauditing (long arg_billid, ref string arg_msg, boolean arg_ifcommit);
  1118. Int rslt = 1
  1119. DateTime null_dt
  1120. SetNull(null_dt)
  1121. uo_musttake uo_take
  1122. uo_take = Create uo_musttake
  1123. IF getinfo(arg_billid,arg_msg) = 0 THEN
  1124. rslt = 0
  1125. GOTO ext
  1126. END IF
  1127. IF cwauditingflag = 1 THEN
  1128. rslt = 0
  1129. arG_MSG = "该单据已经总账审核,不能撤审"
  1130. GOTO ext
  1131. END IF
  1132. IF secflag = 0 THEN
  1133. rslt = 0
  1134. arg_msg = '单据未审核,不可以再撤审'
  1135. GOTO ext
  1136. END IF
  1137. UPDATE u_cusamt
  1138. SET secemp = '',
  1139. secdate = :null_dt,
  1140. secflag = 0
  1141. WHERE u_cusamt.cusmonid = :arg_billid
  1142. And secflag = 1 And flag = 1;
  1143. IF sqlca.SQLCode <> 0 THEN
  1144. rslt = 0
  1145. arg_msg = "因网络或其它原因导致撤审单据操作失败"+"~n"+sqlca.SQLErrText
  1146. GOTO ext
  1147. ELSEIF sqlca.SQLNRows = 0 THEN
  1148. rslt = 0
  1149. arg_msg = "单据正在撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  1150. GOTO ext
  1151. END IF
  1152. IF billtype = 0 THEN
  1153. IF sys_option_msttake_takeamt_secaudit = 1 THEN
  1154. IF uo_take.del_takerec(scid,1,refrapid,cusid,arg_msg,False) = 0 THEN
  1155. rslt = 0
  1156. GOTO ext
  1157. END IF
  1158. END IF
  1159. END IF
  1160. flag = 1
  1161. secflag = 0
  1162. ext:
  1163. IF rslt = 0 THEN
  1164. ROLLBACK;
  1165. ELSEIF rslt = 1 And arg_ifcommit THEN
  1166. COMMIT;
  1167. END IF
  1168. Destroy uo_take
  1169. RETURN rslt
  1170. end function
  1171. public function integer uof_update_cust (long arg_billid, long arg_cusid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1172. IF getinfo(arg_billid,arg_msg) = 0 THEN
  1173. rslt = 0
  1174. GOTO ext
  1175. END IF
  1176. IF flag = 0 THEN
  1177. rslt = 0
  1178. arg_msg = '单据未初审,不可以操作'
  1179. GOTO ext
  1180. END IF
  1181. IF secflag = 1 THEN
  1182. rslt = 0
  1183. arg_msg = '单据已终审,不可以再操作'
  1184. GOTO ext
  1185. END IF
  1186. IF billtype <> 0 THEN
  1187. arg_msg = '不是客户收款单,不能操作'
  1188. rslt = 0
  1189. GOTO ext
  1190. END IF
  1191. UPDATE u_cusamt
  1192. SET cusid = :arg_cusid
  1193. WHERE u_cusamt.cusmonid = :arg_billid
  1194. AND flag = 1
  1195. AND secflag = 0;
  1196. IF sqlca.SQLCode <> 0 THEN
  1197. rslt = 0
  1198. arg_msg = "因网络或其它原因导致单据客户资料操作失败,"+"~n"+sqlca.SQLErrText
  1199. GOTO ext
  1200. ELSEIF sqlca.SQLNRows = 0 THEN
  1201. rslt = 0
  1202. arg_msg = "单据正在更新单据客户资料,请稍后查询,"+"~n"+sqlca.SQLErrText
  1203. GOTO ext
  1204. END IF
  1205. cusid = arg_cusid
  1206. ext:
  1207. IF rslt = 0 THEN
  1208. ROLLBACK;
  1209. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1210. COMMIT;
  1211. END IF
  1212. RETURN rslt
  1213. end function
  1214. public function integer getinfo (long arg_billid, ref string arg_msg);Int rslt = 1
  1215. IF arg_billid <= 0 THEN
  1216. rslt = 0
  1217. arg_msg = '错误的单据id'
  1218. GOTO ext
  1219. END IF
  1220. SELECT u_cusamt.scid,
  1221. u_cusamt.cusid,
  1222. u_cusamt.banktypeid,
  1223. u_cusamt.accountid,
  1224. u_cusamt.cusdate,
  1225. u_cusamt.cusamt,
  1226. u_cusamt.dscrp,
  1227. u_cusamt.flag,
  1228. u_cusamt.cusmoncode,
  1229. u_cusamt.billtype,
  1230. u_cusamt.refrapid,
  1231. u_cusamt.itemid,
  1232. u_cusamt.cusrep,
  1233. u_cusamt.moneyid,
  1234. u_cusamt.mrate,
  1235. u_cusamt.confirmflag,
  1236. u_cusamt.relcode,
  1237. u_cusamt.secflag,
  1238. u_cusamt.secemp,
  1239. u_cusamt.secdate,
  1240. reldateint,
  1241. viewdate,
  1242. u_cusamt.fpcode,
  1243. u_cusamt.cwauditingflag,
  1244. u_cusamt.cwauditingrep,
  1245. u_cusamt.cwauditingdate
  1246. INTO :scid,
  1247. :cusid,
  1248. :banktypeid,
  1249. :accountid,
  1250. :cusdate,
  1251. :cusamt,
  1252. :dscrp,
  1253. :flag,
  1254. :cusmoncode,
  1255. :billtype,
  1256. :refrapid,
  1257. :itemid,
  1258. :cusrep,
  1259. :moneyid,
  1260. :mrate,
  1261. :confirmflag,
  1262. :relcode,
  1263. :secflag,
  1264. :secemp,
  1265. :secdate,
  1266. :reldateint,
  1267. :viewdate,
  1268. :fpcode,
  1269. :cwauditingflag,
  1270. :cwauditingrep,
  1271. :cwauditingdate
  1272. FROM u_cusamt
  1273. Where u_cusamt.cusmonid = :arg_billid;
  1274. IF sqlca.SQLCode <> 0 THEN
  1275. rslt = 0
  1276. arg_msg = '查询数据操作失败,收据'+sqlca.SQLErrText
  1277. GOTO ext
  1278. END IF
  1279. cusmonid = arg_billid
  1280. ext:
  1281. IF rslt = 0 THEN p_reset()
  1282. RETURN rslt
  1283. end function
  1284. public function integer audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  1285. Int rslt = 1,cnt = 0
  1286. IF arg_billid = 0 THEN
  1287. rslt = 0
  1288. arg_msg = "没有审核对象"
  1289. GOTO ext
  1290. END IF
  1291. IF getinfo(arg_billid,arg_msg) = 0 THEN
  1292. rslt = 0
  1293. GOTO ext
  1294. END IF
  1295. IF secflag = 0 THEN
  1296. rslt = 0
  1297. arg_msg = "单据没有终审"
  1298. GOTO ext
  1299. END IF
  1300. IF cwauditingflag = 1 THEN
  1301. rslt = 0
  1302. arg_msg = "单据已经总账审核"
  1303. GOTO ext
  1304. END IF
  1305. UPDATE u_cusamt
  1306. SET cwauditingflag = 1,
  1307. cwauditingdate = getdate(),
  1308. cwauditingrep = :publ_operator
  1309. WHERE ( u_cusamt.cusmonid = :arg_billid ) AND
  1310. ( u_cusamt.scid = :arg_scid) Using sqlca;
  1311. IF sqlca.SQLCode <> 0 THEN
  1312. rslt = 0
  1313. arg_msg = "因网络或其它原因导致总账审核操作失败"+"~n"+sqlca.SQLErrText
  1314. ROLLBACK Using sqlca;
  1315. GOTO ext
  1316. END IF
  1317. ext:
  1318. IF arg_ifcommit And rslt = 1 THEN
  1319. COMMIT Using sqlca;
  1320. END IF
  1321. Return (rslt)
  1322. end function
  1323. public function integer c_audit_subject (long arg_scid, long arg_billid, boolean arg_ifcommit, ref string arg_msg);
  1324. Int rslt = 1,cnt = 0
  1325. IF arg_billid = 0 THEN
  1326. rslt = 0
  1327. arg_msg = "没有审核对象"
  1328. GOTO ext
  1329. END IF
  1330. IF getinfo(arg_billid,arg_msg) = 0 THEN
  1331. rslt = 0
  1332. GOTO ext
  1333. END IF
  1334. IF cwauditingflag = 0 THEN
  1335. rslt = 0
  1336. arg_msg = "单据没有总账审核"
  1337. GOTO ext
  1338. END IF
  1339. UPDATE u_cusamt
  1340. SET cwauditingflag = 0,
  1341. cwauditingdate =null,
  1342. cwauditingrep = ''
  1343. WHERE ( u_cusamt.cusmonid = :arg_billid ) AND
  1344. ( u_cusamt.scid = :arg_scid) Using sqlca;
  1345. IF sqlca.SQLCode <> 0 THEN
  1346. rslt = 0
  1347. arg_msg = "因网络或其它原因导致总账撤审操作失败"+"~n"+sqlca.SQLErrText
  1348. ROLLBACK Using sqlca;
  1349. GOTO ext
  1350. END IF
  1351. ext:
  1352. IF arg_ifcommit And rslt = 1 THEN
  1353. COMMIT Using sqlca;
  1354. END IF
  1355. Return (rslt)
  1356. end function
  1357. on uo_cusamt.create
  1358. call super::create
  1359. TriggerEvent( this, "constructor" )
  1360. end on
  1361. on uo_cusamt.destroy
  1362. TriggerEvent( this, "destructor" )
  1363. call super::destroy
  1364. end on