# `Sp_financialClosing_BtnEventCheckout_CheckInstore` (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_CheckInstore`'`._

## Narrative

**Business context:** Gate on 成品入库 申请 — "control whether 领料 / 报工 is complete before allowing finished-product warehouse entry". Despite living in the `Sp_financialClosing_*` namespace this is a quality-side guard wired into the 成品检验 audit, not the month-close panel.

**What it does:** Given a `qlyproducttestmaster.sId=sGuid`, deletes prior `accchecking` rows keyed on `sBillInStoreId=sGuid` and on the source `sBillNo`. Resolves the underlying `sWorkOrderSlaveId` from the QC master and looks up the current 会计期 start (`sPeriodId=DATE_FORMAT(NOW(),'%Y%m')`). Builds `p_pitproductinstoremaster(sWorkOrderId, sWorkOrderNo, sWorkOrderSlaveId, dProductInQty, dWorkOrderQty, dWorkOrderQtyBl, sFormId, tCreateDate)` aggregating existing 入库 vs work-order plan qty. The downstream block (truncated in this body summary) compares against 领料/报工 completion in `mftproductionreport*` and `mftmaterialdraw*` and writes `accchecking` warnings — returning `sCode=-1` with localized message when 领料/报工 is incomplete.

**Invocation:** Called by `Sp_Calc_sPdt` (the 成品检验单据 audit proc bound to gdsmodule sIds `15831288240001057224508428921300` 成品检验单据 and `101251240115016214914428520` 成品检验(单据)) during 审核 to block downstream 入库 申请 when upstream production hasn't been reported. No direct front-end binding.
