# `Sp_Calc_sPdt` (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(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_sPdt`'`._ ## Narrative **Business context:** 质量管理 → 质量管理单据 → 成品检验单据 — finished-goods inspection audit (审核/反审核) on `QlyProductTestMaster`. Also serves the variants 发货检验单据 (delivery-inspection) and 成品检验(mobile单据) under the 功能操作 mobile branch. **What it does:** Guards on `bInvalid`/`bCheck` and `SysLocking`, reads `SysSystemSettings.CkxProductInSotrecheck` to decide whether to run `Sp_financialClosing_BtnEventCheckout_CheckInstore` and `Sp_CheckChild_sPdt` (cross-checking the upstream stock-in master/process for the inspection batch). On `iFlag=1` flips `bCheck=1, sStatus=1, sCheckPerson, tCheckDate` on `QlyProductTestMaster`, propagates `tCheckedDate` into `eleproductstock`, and — when `iTestResult` flags a rejection — adjusts `opsoutsideprocessslave.dCheckQty`/`dRetuAuxiliaryQty` (returning quantity to the outsourced-process upstream); when `iLastInStock=1` writes `sLossMemo, sLossPerson` back to `mftworkorderslave`. `iFlag=0` runs `Sp_Bill_Used` to refuse uncheck if downstream rows exist, then symmetrically clears the flags. **Invocation:** Bound to `gdsmodule.sProcName` on 成品检验单据 (sId `15831288240001057224508428921300`), 成品检验(单据) and 成品检验(mobile单据) under 功能操作, plus 发货检验单据 — all dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the audit/un-audit button. `script/标版/30100101/Sp_Calc_sPdt.sql` is the install script.