# `Sp_Check_sCmt` (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 PROCEDURE `Sp_Check_sCmt`'`._

## Narrative

**Business context:** 品质管理 → 材料检验 (`mitmaterialscheckmaster/slave`) — post-save validator and price/tax/qty back-calculator on the 材料检验单据 form family (incoming-material QC). Used by `材料检验单据` (`15827054010002527067474512475000`), `库存检验` (`101251240115016105078918480`), and `材料检验(mobile单据)` (`12012615914116373127639240`).

**What it does:** Reads `NetMoney`/`NetPrice` precision from `SysSystemSettings`. Cursors every just-saved slave row, joins the upstream source (`purpurchasearriveslave` / `mitmaterialsstoreslave`), pulls `sComputeId`/`sReComputeId` for the line's compute formula, and re-derives `dMaterialsMoney/dMaterialsQty/dAuxiliaryQty/dMaterialsNoTaxMoney/dMaterialsTaxMoney` using `sistax.dRate` (forward or reverse calc depending on `bInverse`). Updates the rows so totals are consistent post-save; falls through with `sCode=1` on success.

**Invocation:** Bound to `gdsmodule.sSaveProName` on `材料检验单据` (`15827054010002527067474512475000`), `库存检验` (`101251240115016105078918480`), and `材料检验(mobile单据)` (`12012615914116373127639240`) — all under 品质管理 → 材料检验. Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sCmt`. xly-src ships `script/标版/30100101/Sp_Check_sCmt.sql` as the install body.
