Sp_Check_sUdf.md 2.53 KB

Sp_Check_sUdf (procedure)

凭证单据校验

  • Type: PROCEDURE
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sTableName varchar(100)
2 IN sGuid varchar(100)
3 IN sFormGuid varchar(100)
4 IN sLoginId varchar(100)
5 IN sBrId varchar(100)
6 IN sSuId varchar(100)
7 IN iFlag int
8 OUT sCode int
9 OUT sReturn varchar(4000)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpCheck_sUdf'._

Narrative

Business context: 财务凭证单据 (accounting voucher) post-save validator on udfvouchermaster/udfvoucherslave. Enforces three accounting rules — (1) 费用类科目 (sAccountNo 6601/6602) entries must have both 部门 (sFflex5) and 费用科目代码 (sFflex9) set, (2) total debit (dDebitMoney) must equal total credit (dCreditMoney) per voucher, (3) the assistant-accounting expense code (sFflex9) must contain the row's sAccountNo — then post-processes the voucher (fills 部门第三方编号, derives sVoucherType/iVoucherYear/iVoucherMonth/iEntryNumber, assigns the next sVoucherNo).

What it does: Sets sCode=1. Aborts (without LEAVE — the proc continues so multiple errors can accumulate the same sReturn) with sExpenseNeedDepartAndCode on expense rows missing dept/code, with sDebitBp on unbalanced totals, with sFzhsNoInThis on mismatched assistant accounts. Joins udfvoucherslave to sissubject to refresh sFflex5 from the dept's sThirdNo. Defaults empty sVoucherType to '记'. Updates iVoucherMonth/iVoucherYear from tVoucherDate. Refreshes iEntryNumber to the actual slave row count. Calls SP_Sis_GetMaxNo('udfVoucherMaster', ..., '15928127560001382627511178461700', ..., '{"tVoucherDate":"<now>"}', ...) to fetch the next sequence number and applies it to empty sVoucherNo, also stamping tVoucherDate=NOW().

Invocation: Status: appears orphaned. No gdsmodule.sSaveProName/sSaveProNameBefore hook on 财务凭证单据 (sId 15928127560001382627511178461700) or any other 凭证 module in the current DB snapshot, no form-master binding, no other-routine caller, no xly-src reference. Candidate for maintainer audit on whether the 凭证 save path bypasses validators or wires this differently (the SP_Sis_GetMaxNo call inside hard-codes the form sId so the proc is clearly intended for that module).