# `Sp_financialClosing_BtnEventCheckout_CheckInstoreOutSide` (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 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** Sibling of `Sp_financialClosing_BtnEventCheckout_CheckInstore` for the 外购 (outside-purchased finished-goods) path — "成品外购入库申请控制是否领料 是否报工". Same gating logic: a 外购成品 入库 申请 cannot proceed when its upstream 领料/报工 is incomplete for the current 会计期.

**What it does:** Given a `qlyproducttestmaster.sId=sGuid` for an 外购 product, deletes prior `accchecking` rows keyed on `sBillInStoreId=sGuid` and on the source `sBillNo`, resolves `sWorkOrderSlaveId`, looks up current period start via `sysaccountperiod`, builds `p_pitproductinstoremaster` aggregating 已入库 vs 工单计划 qty per slave, then writes blocking `accchecking` rows when 领料/报工 is incomplete. Body matches `Sp_financialClosing_BtnEventCheckout_CheckInstore` aside from the 外购 path filter.

**Invocation:** Called by `Sp_Calc_sPdt` (the 成品检验单据 audit proc — gdsmodule sIds `15831288240001057224508428921300` / `101251240115016214914428520`) during 审核 of 外购 finished-product QC bills. No direct front-end binding.
