uo_invoice.sru 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. $PBExportHeader$uo_invoice.sru
  2. forward
  3. global type uo_invoice from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_invoice from nonvisualobject
  7. end type
  8. global uo_invoice uo_invoice
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long scid = 0 //分部id
  11. PUBLIC PROTECTEDWRITE Long invoiceid //进仓单表自动增量id
  12. PUBLIC PROTECTEDWRITE String invoicecode //单据的唯一编号
  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. Long relid = 0 //关联相关销售单id
  21. string relcode='' //关联相关销售单code
  22. Long storageid = 0 //进仓仓库
  23. DateTime invoicedate //进仓发生时间
  24. String dscrp = '' //备注
  25. Long cusid = 0 //客户id
  26. string cuscode=''
  27. string cusname=''
  28. string currencyname=''
  29. string bankname=''
  30. Transaction commit_transaction //数据commit事务
  31. Boolean if_getid_ture = TRUE
  32. s_invoicemx invoicemx[] //明细结构数组
  33. Long it_mxbt = 0 //明细结构数组末指针
  34. Boolean it_newbegin = FALSE //新建标志
  35. Boolean it_updatebegin = FALSE //修改标志
  36. end variables
  37. forward prototypes
  38. public function integer p_clearmx ()
  39. public function integer p_reset ()
  40. public function integer p_getinfo (long arg_scid, long arg_invoiceid, ref string arg_msg)
  41. public function integer getinfo (long arg_scid, long arg_invoiceid, ref string arg_msg)
  42. public function integer newbegin (long arg_scid, ref string arg_msg)
  43. public function integer updatebegin (long arg_scid, long arg_invoiceid, ref string arg_msg)
  44. public function integer add_dscrp (long arg_scid, long arg_invoiceid, string arg_newdescppart, ref string arg_msg)
  45. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  46. public function integer del (long arg_scid, long arg_invoiceid, ref string arg_msg, boolean arg_ifcommit)
  47. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  48. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  49. public function integer acceptmx (decimal arg_qty, double arg_price, decimal arg_amt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode)
  50. end prototypes
  51. public function integer p_clearmx ();//int p_clearmx()
  52. //清除明细
  53. it_mxbt=0
  54. return 1
  55. end function
  56. public function integer p_reset ();//int p_reset()
  57. //清除对象及其明细
  58. scid=0
  59. invoiceid=0
  60. invoicecode=''
  61. opemp=''
  62. modemp=''
  63. auditingrep=''
  64. flag=0
  65. relid=0
  66. relcode=''
  67. dscrp=''
  68. cusid=0
  69. cuscode=''
  70. cusname=''
  71. currencyname=''
  72. bankname=''
  73. it_newbegin=false
  74. it_updatebegin=false
  75. //清除明细
  76. p_clearmx()
  77. return 1
  78. end function
  79. public function integer p_getinfo (long arg_scid, long arg_invoiceid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  80. //0 失败 1成功
  81. INT rslt=1
  82. IF arg_invoiceid<=0 THEN
  83. rslt=0
  84. arG_MSG="非法发票单唯一码"
  85. goto ext
  86. end if
  87. SELECT u_invoice.invoicecode,
  88. u_invoice.cusid,
  89. u_invoice.cuscode,
  90. u_invoice.cusname,
  91. u_invoice.currencyname,
  92. u_invoice.bankname,
  93. u_invoice.invoicedate,
  94. u_invoice.relid,
  95. u_invoice.relcode,
  96. u_invoice.dscrp,
  97. u_invoice.flag
  98. INTO :invoicecode,
  99. :cusid,
  100. :cuscode,
  101. :cusname,
  102. :currencyname,
  103. :bankname,
  104. :invoicedate,
  105. :relid,
  106. :relcode,
  107. :dscrp,
  108. :flag
  109. FROM u_invoice
  110. WHERE u_invoice.invoiceid = :arg_invoiceid
  111. and scid=:arg_scid
  112. using commit_transaction;
  113. if commit_transaction.sqlcode<>0 then
  114. rslt=0
  115. arG_MSG="查询操作失败(错误发票单唯一码),发票单"+commit_transaction.sqlerrtext
  116. goto ext
  117. end if
  118. invoiceid = arg_invoiceid
  119. scid = arg_scid
  120. ext:
  121. IF rslt=0 THEN p_reset()
  122. return rslt
  123. end function
  124. public function integer getinfo (long arg_scid, long arg_invoiceid, ref string arg_msg);//getinfo(arg_scid,arg_invoiceid,arg_msg)
  125. //0 失败 1成功
  126. int rslt = 1,i = 1,no_mxcheck = 0
  127. if arg_invoiceid <= 0 then
  128. rslt = 0
  129. arg_msg = "非法发票单唯一码"
  130. goto ext
  131. end if
  132. rslt = p_getinfo(arg_scid,arg_invoiceid,arg_msg)
  133. if rslt = 0 then goto ext
  134. //用游标读取明细
  135. declare cur_inwaermx cursor for
  136. select u_invoicemx.printid,
  137. u_invoicemx.mtrlid,
  138. u_invoicemx.mtrlcode,
  139. u_invoicemx.mtrlname,
  140. u_invoicemx.qty,
  141. u_invoicemx.price,
  142. u_invoicemx.dscrp,
  143. u_invoicemx.amt,
  144. u_invoicemx.mtrlmode
  145. from u_invoicemx
  146. where u_invoicemx.invoiceid = :arg_invoiceid and
  147. u_invoicemx.scid = :arg_scid using commit_transaction;
  148. open cur_inwaermx;
  149. fetch cur_inwaermx into :invoicemx[i].printid,
  150. :invoicemx[i].mtrlid,:invoicemx[i].mtrlcode,
  151. :invoicemx[i].mtrlname,:invoicemx[i].qty,
  152. :invoicemx[i].price,
  153. :invoicemx[i].mxdscrp,
  154. :invoicemx[i].amt,
  155. :invoicemx[i].mtrlmode;
  156. do while commit_transaction.sqlcode = 0
  157. i++
  158. fetch cur_inwaermx into :invoicemx[i].printid,
  159. :invoicemx[i].mtrlid,:invoicemx[i].mtrlcode,
  160. :invoicemx[i].mtrlname,:invoicemx[i].qty,
  161. :invoicemx[i].price,
  162. :invoicemx[i].mxdscrp,
  163. :invoicemx[i].amt,
  164. :invoicemx[i].mtrlmode;
  165. loop
  166. close cur_inwaermx;
  167. //检验明细是否读入完整
  168. select count(*) into :no_mxcheck
  169. from u_invoicemx
  170. where u_invoicemx.invoiceid = :arg_invoiceid
  171. and scid = :arg_scid using commit_transaction;
  172. if commit_transaction.sqlcode <> 0 then
  173. rslt = 0
  174. arg_msg = "查询操作失败,发票单明细数量"
  175. goto ext
  176. end if
  177. if i <> (no_mxcheck+1) then
  178. rslt = 0
  179. arg_msg = "查询操作失败,发票单明细"
  180. goto ext
  181. end if
  182. invoiceid = arg_invoiceid
  183. scid = arg_scid
  184. it_mxbt = i - 1
  185. it_newbegin = false
  186. it_updatebegin = false
  187. ext:
  188. if rslt = 0 then p_reset()
  189. return rslt
  190. end function
  191. public function integer newbegin (long arg_scid, ref string arg_msg);//====================================================================
  192. // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
  193. //--------------------------------------------------------------------
  194. // Description: 从置对象,设定业务类型,准备建立新进仓单
  195. //--------------------------------------------------------------------
  196. // Arguments:
  197. // value long arg_scid
  198. // value integer arg_billtype
  199. // reference string arg_msg
  200. //--------------------------------------------------------------------
  201. // Returns: integer
  202. //--------------------------------------------------------------------
  203. // Author: yyx Date: 2003.11.12
  204. //--------------------------------------------------------------------
  205. // Modify History:
  206. //
  207. //====================================================================
  208. int rslt=1
  209. if arg_scid < 0 then
  210. arg_msg = '请选择分部'
  211. rslt = 0
  212. goto ext
  213. end if
  214. p_reset()
  215. scid=arg_scid
  216. it_newbegin=true
  217. it_updatebegin=false
  218. ext:
  219. if rslt=0 then p_reset()
  220. return rslt
  221. end function
  222. public function integer updatebegin (long arg_scid, long arg_invoiceid, ref string arg_msg);//====================================================================
  223. // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
  224. //--------------------------------------------------------------------
  225. // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
  226. //--------------------------------------------------------------------
  227. // Arguments:
  228. // value long arg_scid
  229. // value long arg_inwareid
  230. // value integer arg_billtype
  231. // reference string arg_msg
  232. //--------------------------------------------------------------------
  233. // Returns: integer
  234. //--------------------------------------------------------------------
  235. // Author: yyx Date: 2003.11.12
  236. //--------------------------------------------------------------------
  237. // Modify History:
  238. //
  239. //====================================================================
  240. long rslt=1
  241. if arg_scid < 0 then
  242. arg_msg = '请选择分部'
  243. rslt = 0
  244. goto ext
  245. end if
  246. if arg_invoiceid<=0 then
  247. rslt=0
  248. goto ext
  249. end if
  250. rslt=p_getinfo(arg_scid,arg_invoiceid,arg_msg)
  251. if rslt=0 then goto ext
  252. if flag=1 then
  253. rslt=0
  254. arg_msg='单据已经审核,不可以修改'
  255. goto ext
  256. end if
  257. invoiceid=arg_invoiceid
  258. scid=arg_scid
  259. it_newbegin=false
  260. it_updatebegin=true
  261. p_clearmx() //清除明细
  262. ext:
  263. if rslt=0 then p_reset()
  264. return rslt
  265. end function
  266. public function integer add_dscrp (long arg_scid, long arg_invoiceid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  267. //0 fail 1 success
  268. int rslt=1
  269. arg_newdescppart=trim(arg_newdescppart)
  270. if it_updatebegin or it_newbegin then
  271. rslt=0
  272. arg_msg="编辑状态下不可用"
  273. goto ext
  274. end if
  275. if arg_newdescppart='' then
  276. rslt=0
  277. arg_msg="要添加内容为空,操作取消"
  278. goto ext
  279. end if
  280. rslt=p_getinfo(arg_scid,arg_invoiceid,arg_msg)
  281. if rslt=0 then goto ext
  282. if flag=0 then
  283. rslt=0
  284. arg_msg="非审核状态下不可用"
  285. goto ext
  286. end if
  287. update u_invoice
  288. set dscrp = dscrp+' '+:arg_newdescppart
  289. where u_invoice.invoiceid = :invoiceid
  290. and scid=:scid using commit_transaction;
  291. if commit_transaction.sqlcode<>0 then
  292. rollback ;
  293. rslt=0
  294. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.sqlerrtext
  295. goto ext
  296. end if
  297. commit using commit_transaction;
  298. dscrp = dscrp+' '+arg_newdescppart
  299. ext: return (rslt)
  300. end function
  301. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  302. DateTime server_dt
  303. Long ls_newid
  304. String ls_sccode
  305. IF IsNull(relid) THEN relid = 0
  306. IF IsNull(cusid) THEN cusid = 0
  307. IF IsNull(cuscode) THEN cuscode = ''
  308. if isnull(cusname) then cusname=''
  309. if isnull(currencyname) then currencyname=''
  310. if isnull(bankname) then bankname=''
  311. if isnull(relcode) then relcode=''
  312. IF IsNull(dscrp) THEN dscrp = ''
  313. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  314. rslt = 0
  315. arg_msg = "非编辑状态不可以提交"
  316. GOTO ext
  317. END IF
  318. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  319. //取得系统时间,借用操作员表
  320. IF commit_transaction.SQLCode <> 0 THEN
  321. rslt = 0
  322. arg_msg = "查询操作失败,日期 "
  323. GOTO ext
  324. END IF
  325. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  326. rslt = 0
  327. arg_msg = "没有正确进仓内容"
  328. GOTO ext
  329. END IF
  330. IF f_check_inoutdate(0,invoicedate,FALSE,arG_MSG) = 0 THEN
  331. rslt = 0
  332. GOTO ext
  333. END IF
  334. ////////////////////////////////////////////////开始区分:新建/更新 处理
  335. IF invoiceid = 0 THEN //新建
  336. ls_newid = f_sys_scidentity(scid,"u_invoice","invoiceid",arg_msg,TRUE,id_sqlca)
  337. IF ls_newid <= 0 THEN
  338. rslt = 0
  339. GOTO ext
  340. END IF
  341. //取分部代号
  342. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  343. rslt = 0
  344. GOTO ext
  345. END IF
  346. //取得新单据编号
  347. invoicecode = getid(scid,ls_sccode + 'FP',Date(server_dt),if_getid_ture,commit_transaction)
  348. IF invoicecode = "err" THEN
  349. invoicecode = ''
  350. rslt = 0
  351. arg_msg = "无法获取发票单编号"+"~n"+commit_transaction.SQLErrText
  352. GOTO ext
  353. END IF
  354. INSERT INTO u_invoice (
  355. scid,
  356. invoiceid,
  357. invoicecode,
  358. cusid,
  359. cuscode,
  360. cusname,
  361. currencyname,
  362. bankname,
  363. invoicedate,
  364. relid,
  365. relcode,
  366. dscrp,
  367. opdate,
  368. opemp,
  369. flag)
  370. VALUES (
  371. :scid,
  372. :ls_newid,
  373. :invoicecode,
  374. :cusid,
  375. :cuscode,
  376. :cusname,
  377. :currencyname,
  378. :bankname,
  379. :invoicedate,
  380. :relid,
  381. :relcode,
  382. :dscrp,
  383. :server_dt,
  384. :publ_operator,
  385. :flag) USING commit_transaction ;
  386. IF commit_transaction.SQLCode <> 0 THEN
  387. rslt = 0
  388. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  389. GOTO ext
  390. END IF
  391. //读取新invoiceid
  392. invoiceid = ls_newid
  393. FOR i = 1 TO it_mxbt
  394. INSERT INTO u_invoicemx
  395. (scid,
  396. invoiceid,
  397. mtrlid,
  398. mtrlcode,
  399. mtrlname,
  400. printid,
  401. qty,
  402. price,
  403. amt,
  404. dscrp,
  405. mtrlmode)
  406. VALUES (
  407. :scid,
  408. :ls_newid,
  409. :invoicemx[i].mtrlid,
  410. :invoicemx[i].mtrlcode,
  411. :invoicemx[i].mtrlname,
  412. :invoicemx[i].printid,
  413. :invoicemx[i].qty,
  414. :invoicemx[i].price,
  415. :invoicemx[i].amt,
  416. :invoicemx[i].mxdscrp,
  417. :invoicemx[i].mtrlmode) USING commit_transaction;
  418. IF commit_transaction.SQLCode <> 0 THEN
  419. invoiceid = 0 //还原invoiceid
  420. rslt = 0
  421. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  422. GOTO ext
  423. END IF
  424. NEXT
  425. ELSE //////////////////////////////////////////////////更新
  426. UPDATE u_invoice
  427. SET cusid=:cusid,
  428. cuscode=:cuscode,
  429. cusname=:cusname,
  430. currencyname=:currencyname,
  431. bankname=:bankname,
  432. invoicedate=:invoicedate,
  433. relid=:relid,
  434. relcode=:relcode,
  435. dscrp=:dscrp,
  436. moddate=: server_dt,
  437. modemp=:publ_operator
  438. WHERE u_invoice.invoiceid = :invoiceid
  439. AND u_invoice.scid = :scid
  440. AND flag = 0 USING commit_transaction;
  441. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  442. rslt = 0
  443. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+commit_transaction.SQLErrText
  444. GOTO ext
  445. END IF
  446. //删除原有明细
  447. DELETE FROM u_invoicemx
  448. WHERE u_invoicemx.invoiceid = :invoiceid
  449. AND u_invoicemx.scid = :scid USING commit_transaction;
  450. IF commit_transaction.SQLCode <> 0 THEN
  451. rslt = 0
  452. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  453. GOTO ext
  454. END IF
  455. FOR i = 1 TO it_mxbt
  456. INSERT INTO u_invoicemx
  457. (scid,
  458. invoiceid,
  459. mtrlid,
  460. mtrlcode,
  461. mtrlname,
  462. printid,
  463. qty,
  464. price,
  465. amt,
  466. dscrp,
  467. mtrlmode)
  468. VALUES (
  469. :scid,
  470. :invoiceid,
  471. :invoicemx[i].mtrlid,
  472. :invoicemx[i].mtrlcode,
  473. :invoicemx[i].mtrlname,
  474. :invoicemx[i].printid,
  475. :invoicemx[i].qty,
  476. :invoicemx[i].price,
  477. :invoicemx[i].amt,
  478. :invoicemx[i].mxdscrp,
  479. :invoicemx[i].mtrlmode) USING commit_transaction;
  480. IF commit_transaction.SQLCode <> 0 THEN
  481. rslt = 0
  482. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  483. GOTO ext
  484. END IF
  485. NEXT
  486. end if
  487. it_newbegin = FALSE
  488. it_updatebegin = FALSE
  489. ext:
  490. IF rslt = 0 THEN
  491. ROLLBACK USING commit_transaction;
  492. p_clearmx()
  493. ELSEIF rslt = 1 AND arg_ifcommit THEN
  494. COMMIT USING commit_transaction;
  495. END IF
  496. RETURN rslt
  497. end function
  498. public function integer del (long arg_scid, long arg_invoiceid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
  499. //0 FAIL, 1 SUCCESS
  500. Int rslt = 1
  501. IF arg_invoiceid <= 0 THEN
  502. rslt = 0
  503. arG_MSG = "没有删除对象,操作取消"
  504. GOTO ext
  505. END IF
  506. IF p_getinfo(arg_scid,arg_invoiceid,arG_MSG) = 0 THEN
  507. rslt = 0
  508. GOTO ext
  509. END IF
  510. IF flag = 1 THEN
  511. rslt = 0
  512. arG_MSG = "单据已经审核,不可以删除"
  513. GOTO ext
  514. END IF
  515. DELETE FROM u_invoice
  516. WHERE u_invoice.invoiceid = :arg_invoiceid
  517. AND u_invoice.scid = :arg_scid USING commit_transaction;
  518. IF commit_transaction.SQLCode <> 0 THEN
  519. rslt = 0
  520. arG_MSG = "删除发票单操作失败"+"~n"+commit_transaction.SQLErrText
  521. GOTO ext
  522. END IF
  523. DELETE FROM u_invoicemx
  524. WHERE u_invoicemx.invoiceid = :arg_invoiceid
  525. AND u_invoicemx.scid = :arg_scid USING commit_transaction;
  526. IF commit_transaction.SQLCode <> 0 THEN
  527. rslt = 0
  528. arG_MSG = "删除发票单明细操作失败"+"~n"+commit_transaction.SQLErrText
  529. GOTO ext
  530. END IF
  531. it_newbegin = FALSE
  532. it_updatebegin = FALSE
  533. ext:
  534. IF rslt = 0 THEN
  535. ROLLBACK USING commit_transaction;
  536. p_reset()
  537. ELSEIF rslt = 1 AND arg_ifcommit THEN
  538. COMMIT USING commit_transaction;
  539. END IF
  540. RETURN (rslt)
  541. end function
  542. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  543. IF invoiceid = 0 THEN
  544. rslt = 0
  545. arg_msg = "没有审核对象"
  546. GOTO ext
  547. END IF
  548. IF flag = 1 THEN
  549. rslt = 0
  550. arg_msg = "单据已经审核"
  551. GOTO ext
  552. END IF
  553. UPDATE u_invoice
  554. SET auditingrep = :publ_operator,
  555. auditingdate = getdate(),
  556. flag = 1
  557. WHERE u_invoice.invoiceid = :invoiceid
  558. AND flag = 0
  559. AND scid = :scid USING commit_transaction;
  560. IF commit_transaction.SQLCode <> 0 THEN
  561. rslt = 0
  562. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  563. GOTO ext
  564. ELSEIF commit_transaction.SQLNRows = 0 THEN
  565. rslt = 0
  566. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  567. GOTO ext
  568. END IF
  569. flag = 1
  570. ext:
  571. IF rslt = 0 THEN
  572. ROLLBACK USING commit_transaction;
  573. ELSEIF rslt = 1 AND arg_ifcommit THEN
  574. COMMIT USING commit_transaction;
  575. END IF
  576. RETURN rslt
  577. end function
  578. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1
  579. DateTime null_dt
  580. SetNull(null_dt)
  581. IF invoiceid = 0 THEN
  582. rslt = 0
  583. arg_msg = "没有审核对象"
  584. GOTO ext
  585. END IF
  586. IF flag = 0 THEN
  587. rslt = 0
  588. arg_msg = "单据还未审核"
  589. GOTO ext
  590. END IF
  591. UPDATE u_invoice
  592. SET Auditingrep = '',
  593. Auditingdate = :null_dt,
  594. flag = 0
  595. WHERE u_invoice.invoiceid = :invoiceid
  596. AND flag = 1
  597. AND scid = :scid USING commit_transaction;
  598. IF commit_transaction.SQLCode <> 0 THEN
  599. rslt = 0
  600. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  601. GOTO ext
  602. ELSEIF commit_transaction.SQLNRows = 0 THEN
  603. rslt = 0
  604. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  605. GOTO ext
  606. END IF
  607. flag = 0
  608. ext:
  609. IF rslt = 0 THEN
  610. ROLLBACK USING commit_transaction;
  611. ELSEIF rslt = 1 AND arg_ifcommit THEN
  612. COMMIT USING commit_transaction;
  613. END IF
  614. RETURN rslt
  615. end function
  616. public function integer acceptmx (decimal arg_qty, double arg_price, decimal arg_amt, string arg_mxdscrp, long arg_printid, ref string arg_msg, long arg_mtrlid, string arg_mtrlcode, string arg_mtrlname, string arg_mtrlmode);Long rslt = 1,cnt = 0
  617. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  618. rslt = 0
  619. arg_msg = "非编辑状态不可以使用,操作取消"
  620. GOTO ext
  621. END IF
  622. //清除空值
  623. IF IsNull(arg_qty) THEN arg_qty = 0
  624. IF IsNull(arg_price) THEN arg_price = 0
  625. IF IsNull(arg_printid) THEN arg_printid = 0
  626. IF IsNull(arg_amt) THEN arg_amt = 0
  627. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  628. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  629. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  630. IF IsNull(arg_mtrlname) THEN arg_mtrlname = ''
  631. IF IsNull(arg_mtrlmode) THEN arg_mtrlmode = ''
  632. IF arg_qty = 0 THEN
  633. rslt = 1
  634. GOTO ext
  635. END IF
  636. arg_price = Round(arg_amt/arg_qty,8)
  637. IF arg_price < 0 THEN
  638. rslt = 0
  639. arg_msg = "错误金额或数量,数量与金额的正负方向必须相同,操作取消"
  640. GOTO ext
  641. END IF
  642. //写入内容
  643. it_mxbt++
  644. invoicemx[it_mxbt].mtrlid = arg_mtrlid
  645. invoicemx[it_mxbt].mtrlname = arg_mtrlname
  646. invoicemx[it_mxbt].qty = arg_qty
  647. invoicemx[it_mxbt].amt = Round(arg_amt,2)
  648. invoicemx[it_mxbt].price = arg_price
  649. invoicemx[it_mxbt].mtrlcode = arg_mtrlcode
  650. invoicemx[it_mxbt].mtrlmode = arg_mtrlmode
  651. invoicemx[it_mxbt].mxdscrp = arg_mxdscrp
  652. invoicemx[it_mxbt].printid = arg_printid
  653. ext:
  654. IF rslt = 0 THEN p_clearmx()
  655. RETURN rslt
  656. end function
  657. on uo_invoice.create
  658. call super::create
  659. TriggerEvent( this, "constructor" )
  660. end on
  661. on uo_invoice.destroy
  662. TriggerEvent( this, "destructor" )
  663. call super::destroy
  664. end on