# `Sp_CheckChild_sPst` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 成品入库 save-time child-product completeness check, called from `Sp_Check_sPst`. Mirror of `Sp_CheckChild_sPdt` for the inbound (rather than QC) side: when a composite product is being booked into stock, every child component must have been delivered before the parent's 入库 can proceed. The proc looks up the child rows in `salsalesorderslave` (via `sFatherSlaveId`) and verifies each child's `dOutProductRejQty` already covers `dProductQty * dCombineCoefficient`.

**What it does:** Reads `pitproductinstoreslave` rows for the master `sParentId=sGuid`, joins `mftworkorderslave` (filtered to `bMain=1`) to discover the order-slave references, and builds a temp table summing `dProductQty` per `sOrderSlaveId`. Joins back to `salsalesorderslave` + `eleproduct` to find any child row whose `dOutProductRejQty < B.dProductQty * A.dCombineCoefficient`; concatenates `"子产品：<name>出库不足,应出库 X 已出库 Y"` lines into `p_sMsg`. Sets `sCode=-8`, `sReturn=p_sMsg`, and `LEAVE TOP` if any short row is found.

**Invocation:** Called by `Sp_Check_sPst` (成品入库单据保存之前数据校验) during the `Sp_Check_sPst` post-save flow, after the QC-qty cap check and before the 余数仓库 overflow logic. No direct UI binding.
