# `Sp_Calc_sPit1` (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_sPit1`'`._

## Narrative

**Business context:** Finance opening-balance — work-in-progress (在制品) opening import audit on `accProductDoingMaster`. The check freezes a WIP opening-balance row into the current accounting period (`sConfirmMonth`, `bConfirm=1`) so cost-accounting can roll forward; the procedure refuses a second check if another period's balance is already audited.

**What it does:** Guards on `sGuid`, `SysLocking`, `bInvalid`. Loads `sCostPeriod` and reads `Fun_Sis_GetConstNew(…,'sPit1HaveAccountData')` to refuse audit when a row in a different `sCostPeriod` is already `bCheck=1`. On `iFlag=1` updates `accProductDoingMaster` to `bCheck=1, sStatus=1, sCheckPerson, tCheckDate=NOW(), sConfirmMonth=DATE_FORMAT(NOW(),'%Y%m'), bConfirm=1`. `iFlag=0` clears the flags. Mechanism mirrors `Sp_Calc_sPit2` (which targets `accproductinitmaster` for finished-product opening, not WIP).

**Invocation:** Status: appears orphaned in the live database. No `gdsmodule.sProcName` binding, no `gdsconfigformmaster` reference, no callers in `information_schema.ROUTINES`. xly-src ships an install script (`script/标版/30100101/Sp_Calc_sPit1.sql`) but no Java/XML wiring — the 在制品期初(财务) module exists in scripts only. Candidate for maintainer audit.
