# `Sp_Calc_sUdf` (procedure)

> 会计凭证


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

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

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Calc_sUdf`'`._

## Narrative

**Business context:** 业财一体化 → 单据 → 财务凭证单据 — audit/un-audit handler for the accounting voucher (`udfvouchermaster` / `udfvoucherslave`). Auditing posts the voucher into the closed period for GL reporting; unaudit reverses it.

**What it does:** Validates `sGuid`. With `iFlag=1`, refuses when the master is already `bCheck=1`; then guards expense-category voucher lines (`sAccountNo` `6601` / `6602`) — refuses when any slave row is missing `sFflex5` (部门) or `sFflex9` (费用科目代码), returning the localised "费用类凭证需填写部门和费用科目代码" message via `Fun_Sis_GetConstNew`. On success `Update udfvouchermaster SET bCheck=1, sStatus='1'`. With `iFlag=0` symmetric un-audit on the same master.

**Invocation:** Bound to `gdsmodule.sProcName` on 财务凭证单据 (sId `15928127560001382627511178461700`) — 业财一体化 → 单据. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(sFormGuid, ...)` on the 审核/反审核 button. xly-src ships `script/标版/30100101/Sp_Calc_sUdf.sql` (install) and `script/标版/optimize/Sp_Calc_sUdf.sql` (patch). Sibling: `Sp_Calc_sUdft` for the voucher-template variant.
