# `Sp_System_AccountSquareCheck_New` (procedure)

> @author:杨恒林 
		     @date:20210521 封存 
				 @describe: 检验期间内未审核单据：
				 iType = 0 库存单据： 
				     材料 iType2 = 0 或 1  	生产领料,生产退料,采购入库,采购退货,材料调拨,材料报废,来料入库,材料盘点,材料库存调整,
																		存货调整金额,其他入库				 
						 产品 iType2 = 0 或 2  	成品入库,成品报废,送货单,退货单,成品调拨,发外入库,成品盘点 
				 iType = 1 应收单据： 根据应收类型，找到相应单据销售发票 1 送货单 2印刷工单 3销售订单 4销售合同 5销售对账
				 iType = 2 应付单据： 根据应付类弄，找到相应单据 0 采购订单 1 采购入库 2采购对账


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iType` | `int` |
| 2 | IN | `tStartDate` | `datetime` |
| 3 | IN | `tEndDate` | `datetime` |
| 4 | IN | `iType2` | `int` |
| 5 | IN | `sWareHouseGuid` | `varchar(100)` |
| 6 | IN | `sBrId` | `varchar(100)` |
| 7 | IN | `sSuId` | `varchar(100)` |
| 8 | IN | `sLoginId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |
| 10 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 成本核算 / 财务月结 — successor copy of `Sp_System_AccountSquareCheck` (same `iType`/`iType2` matrix for 库存单据 / 应收单据 / 应付单据). Same author/date comment (杨恒林 2021-05-21 封存) — both flavours coexist; the `_New` body is the one referenced by the modernised close path.

**What it does:** Same shape as the base proc — for the requested `iType`/`iType2` slice it scans the matching 业务表 inside `[tStartDate, tEndDate]` for `bCheck=0` rows, collects their `sBillNo` list, and if any are found returns `sCode=-1` with the localised "存在未审核单据" message plus the BillNo list, letting the caller block the close. See `Sp_System_AccountSquareCheck` for the field-level matrix.

**Invocation:** Status: appears orphaned at this snapshot. No `gdsmodule` hook, no `gdsconfigformmaster` binding, no other-routine caller (information_schema query at audit returned empty), no xly-src reference outside the install script `script/标版/30100101/cost/Sp_System_AccountSquareCheck_New.sql`. Kept as a `_New` variant alongside `Sp_System_AccountSquareCheck` and `Sp_System_AccountSquareCheck_material`; verify which body the close flow actually invokes before relying on it.
