# `Sp_Calc_sCmt` (procedure) > @author:zhucx @date:2021.11.21 封存 @describe: 1.移动端-来料检验-保存自动调用本过程,当系统设定中本单据为自动审核时 - **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(4000)` | | 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_sCmt`'`._ ## Narrative **Business context:** 质量管理 → 质量管理单据 → 材料检验单据 — incoming-materials-inspection check / uncheck on `qlycomematerialstestmaster`. Auditing a 来料检验 (incoming-material inspection) row freezes the inspection result and (per the proc's banner comment) is also auto-invoked from the mobile-side save path when the system setting marks the form as 自动审核. **What it does:** Validates `sGuid` and `SysLocking` (concurrent edit guard). Reads master `sBillNo`, `bInvalid`, `tCreateDate`; refuses if invalid. With `iFlag=1`: refuses if already checked; the (currently commented-out, dated 2023-06-25) `PurPurchaseOrderSlave` back-write block accumulated tested / sample qty totals back onto the purchase-order slave — kept around for rollback but disabled. Then sets master `bCheck=1`. With `iFlag=0`: symmetric uncheck. **Invocation:** Bound to `gdsmodule.sProcName` on: - `材料检验单据` (sId `15827054010002527067474512475000`) — 质量管理 → 质量管理单据 - `库存检验` (sId `101251240115016105078918480`) — 质量管理 → 质量管理单据 - `材料检验(mobile单据)` (sId `12012615914116374731613080`) — 现场 (mobile front-end of the same audit)